:root {
  --ink: #1d2330; --muted: #6b7280; --paper: #fbfaf7; --line: #e4e0d8;
  --menu-w: 230px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: #11151d; }
body { display: grid; grid-template-rows: auto 1fr; grid-template-columns: minmax(0, 1fr); overflow: hidden; }
#app > * { min-width: 0; }
button, select { font: inherit; color: var(--ink); }

/* ---------- górny pasek ---------- */
#top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding: 9px 16px; background: var(--paper); border-bottom: 1px solid var(--line); z-index: 6; }
.brand { letter-spacing: .02em; white-space: nowrap; }
.brand small { color: var(--muted); margin-left: 6px; }
.brand a { color: inherit; text-decoration: none; }
.brand a:hover { text-decoration: underline; }
.group { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.group span { color: var(--muted); }
.group label { display: flex; align-items: center; gap: 6px; }
.group select { padding: 5px 6px; border: 1px solid var(--line); border-radius: 7px; background: #fff; font-size: 13px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 6px 10px; cursor: pointer; font-size: 13px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--ink); color: #fff; }
.seg button.auto-pick { background: #efe9dc; font-weight: 700; box-shadow: inset 0 -3px 0 #d4a017; }   /* scenariusz dobrany przez „Auto” (D51) */
.actions { display: flex; gap: 6px; }
.actions button, .actions a { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 13px; }
.actions a { color: inherit; text-decoration: none; white-space: nowrap; line-height: normal; }   /* link do komunikatu o budynku (D55) */
.actions button.on { background: var(--ink); color: #fff; }
.stamp { margin-left: auto; font-size: 11px; font-weight: 700; color: #a33; border: 1.5px solid #a33; padding: 3px 8px; border-radius: 4px; transform: rotate(-2deg); }

/* ---------- układ ---------- */
#app { position: relative; display: grid; grid-template-columns: var(--menu-w) 1fr; min-height: 0; }
#menu { background: var(--paper); border-right: 1px solid var(--line); padding: 12px; overflow: auto; z-index: 5; }
#menu h3 { font-size: 11px; letter-spacing: .12em; color: var(--muted); margin: 6px 0 8px; }
#menu h3 small { letter-spacing: 0; font-weight: 400; }
#map { list-style: none; margin: 0 0 16px; padding: 0; }
#map li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
#map li:hover { background: #f0ede6; }
#map li.on { background: var(--ink); color: #fff; }
#map li .sw { width: 10px; height: 10px; border-radius: 2px; flex: none; background: #c9c4ba; }
#map li .dec { margin-left: auto; font-weight: 700; }
#map li.spire { cursor: default; color: var(--muted); font-size: 12px; }
#map li.spire:hover { background: none; }
.tick { display: flex; gap: 6px; }
.tick select { flex: 1; min-width: 0; font-size: 13px; padding: 6px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.tick button { border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; font-size: 15px; }
.dispute { font-size: 12px; margin-top: 6px; color: #8a5a00; min-height: 1.2em; }
/* spółka na górze menu, wyróżniona (D51) */
#menu .sheet-ticker { background: #f3efe6; border: 1px solid #dfd8c8; border-radius: 10px; padding: 10px; margin-bottom: 12px; }
#menu .sheet-ticker h3 { color: var(--ink); margin-top: 0; }
#ticker { font-weight: 600; }
.scen-why { font-size: 12px; line-height: 1.4; margin-top: 6px; color: var(--ink); }
.hint { font-size: 12px; color: var(--muted); line-height: 1.45; margin-top: 14px; }

/* ---------- scena ---------- */
#stage { position: relative; min-width: 0; overflow: hidden; transition: background 1.2s; }
#scene { display: block; width: 100%; height: 100%; touch-action: none; }
#stage.sky-rano    { background: linear-gradient(#ffd6b0 0%, #ffe9d2 40%, #dfeaf4 100%); }
#stage.sky-dzien   { background: linear-gradient(#bfe0ff 0%, #e7f1fa 55%, #f4eee4 100%); }
#stage.sky-wieczor { background: linear-gradient(#3b2f6b 0%, #c4577a 45%, #f3a86b 100%); }
#stage.sky-noc     { background: linear-gradient(#060a14 0%, #121a30 60%, #1f2740 100%); }
#stage.storm       { background: linear-gradient(#4f5b6c 0%, #7d8898 50%, #a9b1bb 100%); }
#stage.storm.sky-noc { background: linear-gradient(#05070d 0%, #151b28 60%, #222a3a 100%); }
#flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 2; }
#overlay { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
#tags { position: absolute; inset: 0; pointer-events: none; z-index: 2; opacity: 0; transition: opacity .3s; }
#tags.on { opacity: 1; }
#tags.on .tag { pointer-events: auto; }
.tag { position: absolute; transform: translate(-100%, -50%); display: flex; align-items: center; gap: 6px; padding: 4px 9px 4px 7px; border: 0; border-radius: 999px; background: rgba(255,255,255,.93); color: #1d2330; font-family: inherit; font-weight: 600; font-size: 12px; line-height: 1.1; white-space: nowrap; box-shadow: 0 1px 6px rgba(0,0,0,.2); cursor: pointer; }
.tag:hover { background: #fff; box-shadow: 0 1px 10px rgba(0,0,0,.3); }
.tag i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.tag b { font-size: 11px; }
.bubble { position: absolute; width: max-content; max-width: 240px; padding: 7px 9px; background: #fff; border-radius: 10px; font-size: 12px; line-height: 1.35; box-shadow: 0 2px 10px rgba(0,0,0,.25); transform: translate(-50%, calc(-100% - 10px)); animation: fade .25s ease-out; }
.bubble::after { content: ""; position: absolute; left: calc(50% + var(--tail, 0px)); bottom: -6px; margin-left: -6px; border: 6px solid transparent; border-bottom: 0; border-top-color: #fff; }
.bubble b { display: block; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
#zoom { position: absolute; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 6px; z-index: 4; }
#zoom button { width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); font-size: 18px; cursor: pointer; }
#toast { position: absolute; left: 50%; top: 54px; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 13px; padding: 7px 12px; border-radius: 8px; opacity: 0; transition: opacity .3s; z-index: 6; pointer-events: none; }
#toast.on { opacity: 1; }
/* belka u góry sceny (D51): spółka, losowanie i wyjaśnienie nastroju; tylko desktop */
#stage-bar { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 4; display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: rgba(251, 250, 247, .94); border: 1px solid var(--line); border-radius: 999px; box-shadow: 0 2px 12px rgba(0,0,0,.18); font-size: 12.5px; white-space: nowrap; max-width: calc(100% - 28px); overflow: hidden; }
#stage-bar .sb-label, #stage-bar .sb-sep { color: var(--muted); flex: none; }
#stage-ticker { font-weight: 700; padding: 3px 6px; border-radius: 6px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 12.5px; flex: none; max-width: 210px; }
#stage-dice { padding: 3px 8px; border-radius: 6px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 600; font-size: 12.5px; flex: none; }
#stage-why { min-width: 0; overflow: hidden; text-overflow: ellipsis; }   /* długi opis ucina się wielokropkiem, pełny w podpowiedzi */

#chat { position: absolute; right: 64px; bottom: 14px; width: 340px; max-height: 62%; overflow: auto; background: var(--paper); border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.35); z-index: 5; display: none; }
#chat.on { display: block; }
#chat header { position: sticky; top: 0; background: var(--paper); z-index: 1; display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 13px; }
#chat header .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
#chat header button { margin-left: auto; border: 0; background: none; font-size: 18px; cursor: pointer; }
#chat .more { display: block; padding: 10px 12px 12px; font-size: 13px; font-weight: 700; color: #1d4ed8; text-decoration: none; }
#chat .fake { padding: 0 12px 10px; font-size: 11px; color: #a33; }
@keyframes pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

#loading { position: absolute; inset: 0; display: grid; place-items: center; color: #e6e9f0; font-size: 14px; z-index: 10; background: #11151d; }
.mobile-only { display: none !important; }

/* ---------- telefon ---------- */
@media (max-width: 820px) {
  .desktop-only, #g-env, .stamp, #btn-share { display: none !important; }
  .mobile-only { display: inline-block !important; }
  #top { gap: 8px; padding: 8px 10px; }
  .actions { gap: 4px; }
  #lnk-about { min-width: 28px; padding: 6px 8px; text-align: center; font-weight: 700; }   /* na telefonie sam „?”, żeby pasek został w dwóch rzędach (D55) */
  .brand { flex: 1; }
  #g-scen { order: 3; width: 100%; }
  #g-scen > span { display: none; }
  #g-scen .seg { width: 100%; }
  #g-scen .seg button { flex: 1; }
  #top.opts-open #g-env { order: 4; width: 100%; flex-wrap: wrap; }
  .bubble { max-width: 160px; font-size: 11px; padding: 6px 7px; }
  #top.opts-open #g-env, #top.opts-open #btn-share { display: flex !important; }
  .brand small { display: none; }
  .seg button { padding: 6px 7px; font-size: 12px; }
  #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  #stage { grid-row: 1; }
  #menu { grid-row: 2; border-right: 0; border-top: 1px solid var(--line); padding: 8px 10px; max-height: 55vh; }
  #menu .sheet-map { display: none; }
  #menu.map-open .sheet-map { display: block; }
  #menu h3 { margin: 2px 0 6px; }
  #btn-map { width: 100%; margin-top: 8px; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px; }
  #chat { left: 8px; right: 8px; width: auto; bottom: 8px; max-height: 42%; }
  #zoom { bottom: auto; top: 10px; right: 10px; }
  #zoom button { width: 34px; height: 34px; }
}
