:root {
  --bg: #0f1117; --panel: #171a22; --border: #2a2f3a; --text: #e8e8e8; --muted: #9aa3b2;
  --ok: #5fd36b; --warn: #ffd23f; --bad: #e23b2e; --accent: #4a8fe0;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: ui-monospace, Menlo, Consolas, monospace; }
.hidden { display: none !important; }

#app { display: flex; height: 100vh; }
#stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 12px; min-width: 0; }
#game { position: relative; container-type: inline-size; background: #000; }
#scene-canvas { display: block; image-rendering: pixelated; image-rendering: crisp-edges; width: 100%; height: 100%; }
#hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
#hint-text { white-space: pre-line; }
#btn-panel { background: #2a2f3a; color: var(--text); border: 1px solid #555; border-radius: 4px; padding: 3px 8px; font-family: inherit; font-size: 12px; cursor: pointer; margin-right: 8px; }
#btn-panel.on { border-color: var(--warn); color: #ffe9a3; }
#panel h2 { margin: 4px 0 2px; font-size: 14px; }
#panel .diff-count { color: var(--muted); margin: 0 0 8px; }
#panel .diff-count.changed { color: var(--warn); }

/* HUD přes plátno; velikosti písma v cqw, aby se škálovalo s plátnem */
#hud { position: absolute; inset: 0; pointer-events: none; font-size: 1.9cqw; line-height: 1.25; text-shadow: 0 1px 0 #000; }
.hud-box { position: absolute; background: rgba(10, 12, 18, 0.72); border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 0.6cqw; padding: 0.9cqw 1.1cqw; }
#hud-car { left: 1cqw; top: 1cqw; width: 25cqw; }
#hud-storm { left: 50%; top: 1cqw; width: 30cqw; transform: translateX(-50%); }
#hud-data { right: 1cqw; top: 1cqw; width: 26cqw; pointer-events: auto; }
#hud-data .row.measure { flex-wrap: wrap; }
#hud-data .muted { color: var(--muted); }
.row { display: flex; justify-content: space-between; gap: 1cqw; }
.row.small { font-size: 1.5cqw; color: var(--muted); margin-top: 0.4cqw; }
.row.warn { color: #ffe9a3; }
.bar { display: grid; grid-template-columns: 11cqw 1fr; align-items: center; gap: 0.8cqw; margin: 0.3cqw 0; }
.bar b { font-weight: 600; }
.bar i { display: block; height: 1.4cqw; background: #2a2f3a; border: 1px solid #000; }
.bar i span { display: block; height: 100%; width: 100%; background: var(--ok); }
.bar.mid i span { background: var(--warn); }
.bar.low i span { background: var(--bad); }
#timeline { display: block; width: 100%; height: 5.5cqw; margin-top: 1.4cqw; background: #1a1d26; border: 1px solid #000; image-rendering: pixelated; }
.pips { color: #8dffb0; letter-spacing: 0.1cqw; }
#measure-pips { flex-basis: 100%; text-align: right; font-size: 1.6cqw; white-space: nowrap; }
#hud-keys { position: absolute; left: 0; right: 0; bottom: 0.4cqw; display: flex; gap: 0.5cqw; justify-content: center; flex-wrap: nowrap; padding: 0 1cqw; }
.key { background: rgba(10, 12, 18, 0.78); border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 0.5cqw; padding: 0.3cqw 0.6cqw; font-size: 1.25cqw; white-space: nowrap; }
.key kbd { display: inline-block; background: #e9e9e9; color: #111; border-radius: 0.3cqw; padding: 0 0.4cqw; font-weight: 700; margin-right: 0.4cqw; }
.key.on { border-color: var(--ok); color: #c9ffd0; }
.key.busy { border-color: var(--accent); color: #cfe3ff; }
.key.warn { border-color: var(--warn); color: #ffe9a3; }
.key.danger { border-color: var(--bad); color: #ffc9c3; }
.key.off { opacity: 0.55; }

#results { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.6); font-size: 2cqw; }
#results-card { background: var(--panel); border: 1px solid var(--border); border-radius: 1cqw; padding: 2cqw 3cqw; min-width: 50cqw; }
#results-card h2 { margin: 0 0 1cqw; font-size: 3cqw; }
#results-card pre { margin: 0 0 1.5cqw; font-size: 1.9cqw; white-space: pre-wrap; }
#results-card .buttons { display: flex; gap: 1cqw; }
#results-card button, #panel button { background: #2a2f3a; color: var(--text); border: 1px solid #555; border-radius: 4px; padding: 6px 10px; font-family: inherit; cursor: pointer; }
#results-card button:hover, #panel button:hover { background: #3a4052; }
#pause-text, #end-text { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); background: rgba(10, 12, 18, 0.85); border: 1px solid var(--warn); color: var(--warn); border-radius: 0.6cqw; padding: 1cqw 2cqw; font-size: 3cqw; pointer-events: none; }
#hud-flash { position: absolute; left: 50%; top: 21cqw; transform: translateX(-50%); background: rgba(10, 12, 18, 0.8); border: 1px solid var(--warn); color: #ffe9a3; border-radius: 0.6cqw; padding: 0.6cqw 1.6cqw; font-size: 2.2cqw; pointer-events: none; white-space: nowrap; }
#debug-text { position: absolute; left: 1cqw; bottom: 9cqw; font-size: 1.6cqw; color: var(--muted); white-space: pre; pointer-events: none; }

/* ladicí panel */
#panel { width: 340px; flex: none; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--border); padding: 10px 12px; font-size: 12px; }
#panel h3 { margin: 10px 0 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
#panel .slider { display: grid; grid-template-columns: 1fr 3.5em; gap: 6px; align-items: center; margin: 2px 0; }
#panel .slider label { display: flex; justify-content: space-between; gap: 6px; }
#panel .slider input[type=range] { width: 100%; }
#panel .slider output { text-align: right; color: var(--warn); }
#panel select, #panel input[type=number], #panel textarea { width: 100%; background: #0f1117; color: var(--text); border: 1px solid #444; border-radius: 4px; padding: 4px; font-family: inherit; font-size: 12px; }
#panel textarea { height: 90px; }
#panel .buttons { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
#panel .mods label { display: inline-block; margin-right: 8px; }
#panel pre { background: #0f1117; border: 1px solid #333; padding: 6px; font-size: 11px; white-space: pre-wrap; margin: 0; }

/* obrazovky: části jedné stránky v rámu 16:9 (#game), přepínané třídou .active */
.screen { position: absolute; inset: 0; display: none; overflow: hidden; }
.screen.active { display: block; }
.screen.ui { background: #14161c; font-size: 1.9cqw; line-height: 1.3; }
.screen.ui .note { color: var(--muted); font-size: 1.6cqw; margin: 0.6cqw 0; }
.screen.ui .warn2 { color: var(--warn); margin: 0.8cqw 0; }
.screen.ui .warn2.danger { color: #ff8a7a; }
.screen.ui .row { margin: 0.35cqw 0; }
.screen.ui .row span:last-child { color: #cfe3ff; text-align: right; }
.screen.ui .row.gold span { color: var(--warn); }
.screen.ui .row.strong span { font-weight: 700; color: var(--text); }
.screen.ui .row.good span:last-child { color: var(--ok); }
.screen.ui .row.bad span:last-child { color: #ff8a7a; }
.screen.ui .row.warn span:last-child { color: #ffe9a3; }
.topbar { position: absolute; left: 0; right: 0; top: 0; height: 6.5cqw; display: flex; align-items: center; justify-content: space-between; gap: 2cqw; padding: 0 1.6cqw; background: #1f232c; border-bottom: 1px solid #333; }
.topbar b { color: var(--warn); }
.btn { background: #2a2f3a; color: var(--text); border: 1px solid #666; border-radius: 0.5cqw; padding: 0.7cqw 1.4cqw; font: inherit; cursor: pointer; }
.btn:hover:not(:disabled) { background: #3a4052; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: #2f5a3a; border-color: var(--ok); color: #d8ffe0; }
.btn.primary:hover:not(:disabled) { background: #3a6e48; }
.btn.small { padding: 0.3cqw 1cqw; font-size: 1.6cqw; }
.btn.big { font-size: 2.6cqw; padding: 1cqw 3cqw; }
#end-text { top: 40%; color: #fff; border-color: #fff; }

/* úvod */
.intro { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2cqw; background: radial-gradient(ellipse at 70% 30%, #34405a 0%, #14161c 70%); }
.intro h1 { margin: 0; font-size: 6cqw; letter-spacing: 0.1em; }
.intro-sub { margin: 0; color: var(--warn); font-size: 2.6cqw; }
.intro-save { color: var(--muted); margin: 1cqw 0; }
.intro-buttons, .intro-small { display: flex; gap: 1.2cqw; }
.intro-small .btn { font-size: 1.6cqw; }
.intro-status { color: var(--warn); min-height: 2cqw; margin: 0; }

/* mapa */
.map-area { position: absolute; left: 0; top: 6.5cqw; width: 62%; bottom: 0; background: #0f1a24; }
.map-area svg { width: 100%; height: calc(100% - 3cqw); display: block; font-family: ui-monospace, Menlo, Consolas, monospace; }
.map-area .marker { cursor: pointer; }
.map-area .marker:hover circle:nth-of-type(1) { stroke-width: 2; }
.map-note { position: absolute; left: 1.5cqw; bottom: 0.6cqw; margin: 0; color: #9ab; font-size: 1.5cqw; }
.card { position: absolute; right: 0; top: 6.5cqw; width: 38%; bottom: 0; background: #1b1f28; border-left: 1px solid #333; padding: 1.4cqw; overflow-y: auto; }
.card h4 { margin: 0 0 0.6cqw; font-size: 1.9cqw; color: #fff; }
.card .btn { display: block; width: 100%; margin-top: 0.8cqw; }

/* vyúčtování */
.results-card { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 66cqw; max-height: 53cqw; overflow-y: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 1cqw; padding: 1.4cqw 2.4cqw; font-size: 1.6cqw; }
.results-card h2 { margin: 0 0 0.3cqw; font-size: 2.6cqw; }
.screen.ui .results-card .row { margin: 0.15cqw 0; }
.screen.ui .results-card .note, .screen.ui .results-card .warn2 { margin: 0.4cqw 0; font-size: 1.5cqw; }
.results-card .phrase { font-style: italic; color: #cfe3ff; margin: 0.6cqw 0; }
.screen.ui .results-card .row.sub span:first-child { padding-left: 2cqw; color: var(--muted); }
.screen.ui .results-card .row.sub.bad span:first-child { color: #ff8a7a; }
.results-card .row-note { color: var(--muted); font-size: 1.25cqw; font-weight: 400; }
.results-card .buttons { display: flex; gap: 1cqw; }

/* garáž */
.garage-left { position: absolute; left: 0; top: 6.5cqw; width: 44%; bottom: 0; padding: 1.4cqw; }
/* garáž: záložky a galerie aut */
.topbar .tabs { display: flex; gap: 0.6cqw; }
.topbar .tab.active { border-color: var(--warn); color: #ffe9a3; background: #3a3420; }
.car-list { position: absolute; left: 0; right: 0; top: 6.5cqw; bottom: 0; overflow-y: auto; padding: 0.8cqw 1.4cqw; }
.car-list .msg { color: var(--warn); margin: 0 0 0.4cqw; }
.car-strip { display: grid; grid-template-columns: 13cqw 1fr 21cqw; gap: 1.2cqw; align-items: center; background: #1b1f28; border: 1px solid #333; border-radius: 0.6cqw; padding: 0.5cqw 1cqw; margin: 0.6cqw 0; }
.car-strip.active { border-color: var(--warn); background: #26231a; }
.car-strip.owned { border-color: #4e7a5c; }
.car-strip.next { border-color: var(--ok); border-style: dashed; }
.car-strip.locked { opacity: 0.55; }
.car-strip.locked .strip-view { filter: grayscale(0.8); }
.strip-view { width: 13cqw; height: auto; image-rendering: pixelated; image-rendering: crisp-edges; background: #2b3040; border-radius: 0.4cqw; }
.strip-info { display: grid; gap: 0.2cqw; min-width: 0; }
.strip-info small { color: #aaa; font-size: 1.4cqw; }
.strip-info .strip-trait { color: #cfe3ff; }
.strip-status { display: grid; gap: 0.3cqw; justify-items: end; text-align: right; }
.strip-status small { color: #aaa; font-size: 1.4cqw; }
.strip-status .gold { color: var(--warn); }
.car-view { display: block; width: 100%; height: auto; image-rendering: pixelated; image-rendering: crisp-edges; background: linear-gradient(#1a1d26 79%, #2b3040 79%); border: 1px solid #333; border-radius: 0.5cqw; }
.car-name { margin: 0.8cqw 0 0; }
.garage-left .btn { margin-top: 1cqw; width: 100%; }
.garage-right { position: absolute; right: 0; top: 6.5cqw; width: 56%; bottom: 0; background: #1b1f28; border-left: 1px solid #333; padding: 1.2cqw 1.4cqw; overflow-y: auto; }
.up { display: grid; grid-template-columns: 12.5cqw 5.5cqw 1fr 9cqw; gap: 0.8cqw; align-items: center; margin: 0.5cqw 0; }
.up small { color: #aaa; font-size: 1.45cqw; }
.up .btn { width: 100%; color: var(--warn); }
.garage-right .pips i { display: inline-block; width: 1.5cqw; height: 1.1cqw; background: #2a2f3a; border: 1px solid #000; margin-right: 0.2cqw; }
.garage-right .pips i.on { background: var(--ok); }
.garage-right .pips i.nx { background: #3a4a3a; border-color: var(--ok); }
.newcar { margin-top: 1.4cqw; display: grid; gap: 0.4cqw; }
.newcar small { color: #aaa; font-size: 1.45cqw; }
.garage-right .msg { color: var(--warn); min-height: 2cqw; margin: 0.6cqw 0 0; }
