:root {
  --bg: #10151d;
  --panel: #1a222d;
  --panel-2: #222c39;
  --line: #2a3542;
  --text: #f4f6f8;
  --muted: #a7b1bc;
  --accent: #ff7a2f;
  --accent-ink: #1d0f06;
  --error: #ff5a5f;
  --ok: #3ddc84;
  --blue: #4d8dff;
  --grey: #8a96a3;
  --amber: #f5b94a;
  --head: 'Unbounded', system-ui, sans-serif;
  --body: 'Golos Text', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.45 var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { display: block; }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}
.screen { display: flex; flex-direction: column; flex: 1; min-height: 0; }

/* ---------- buttons ---------- */
.btn {
  min-height: 52px;
  padding: 0 18px;
  border: 0;
  border-radius: 16px;
  font: 700 15px/1.1 var(--head);
  letter-spacing: 0.01em;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:active { filter: brightness(0.92); }
.btn-ghost { background: transparent; color: var(--text); border: 1.5px solid #3a4552; }
.btn-wide { width: 100%; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.btn-col { display: grid; gap: 10px; margin-top: 16px; }

/* ---------- home, tickets, lists ---------- */
#screen-home, #screen-tickets, #screen-list { padding: calc(24px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom)); gap: 14px; }
.start-head { display: grid; gap: 10px; }
.logo { width: 52px; height: 52px; color: var(--accent); }
.logo svg { width: 100%; height: 100%; }
.start-head h1 { margin: 0; font: 700 30px/1.15 var(--head); }
.lead { margin: 0; color: var(--muted); font-size: 16px; }
.modes { display: grid; gap: 10px; margin-top: 6px; }
.mode {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  width: 100%; min-height: 76px; padding: 12px 14px 12px 12px; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
}
.mode:active:not(:disabled) { transform: scale(0.99); background: var(--panel-2); }
.mode:disabled { cursor: default; opacity: 0.7; }
.mode-ic { width: 44px; height: 44px; border-radius: 14px; background: #2a2219; color: var(--accent); display: grid; place-items: center; }
.mode-ic svg { width: 24px; height: 24px; }
.mode-body { display: grid; gap: 3px; min-width: 0; }
.mode-body b { font: 600 16px/1.2 var(--head); }
.mode-sub { color: var(--muted); font-size: 13.5px; line-height: 1.35; }
.mode-meta { color: var(--muted); font: 600 12px/1.2 var(--body); text-align: right; max-width: 76px; }
.mode-meta.count { min-width: 28px; height: 28px; padding: 0 8px; border-radius: 14px; background: var(--error); color: #fff; display: grid; place-items: center; font: 700 13px/1 var(--head); }
.mode-meta:empty { display: none; }
.mode.soon .mode-ic { background: #222a35; color: var(--grey); }
.mode.soon b { color: #c9d0d7; }
.mode.soon .mode-meta { padding: 4px 8px; border-radius: 8px; background: #26313e; color: var(--amber); }

/* 3D crossroads first: a picture tile that starts the game in one tap */
.hero3d {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "img img" "body cta";
  align-items: center; gap: 0; width: 100%; min-height: 0; padding: 0; overflow: hidden; text-align: left;
  border: 1px solid #3a2a1c; border-radius: 22px; background: var(--panel); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.hero3d .hero-img { grid-area: img; display: block; width: 100%; height: auto; aspect-ratio: 700 / 405; object-fit: cover; background: #0f141b; }
.hero-tag { position: absolute; top: 12px; left: 12px; padding: 4px 9px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font: 700 13px/1 var(--head); }
.hero-body { grid-area: body; display: grid; gap: 4px; min-width: 0; padding: 12px 8px 14px 14px; }
.hero-body b { font: 700 20px/1.15 var(--head); }
.hero-sub { color: var(--muted); font-size: 13.5px; line-height: 1.35; }
.hero-cta {
  grid-area: cta; margin-right: 14px; display: inline-flex; align-items: center; gap: 6px; padding: 12px 16px; border-radius: 14px;
  background: var(--accent); color: var(--accent-ink); font: 700 15px/1 var(--head); white-space: nowrap;
}
.hero-cta::after { content: '▶'; font-size: 11px; }
.hero3d:active:not(:disabled) { transform: scale(0.99); }
.hero3d:disabled { opacity: 0.85; }
.hero3d:disabled .hero-cta { background: #3a3f48; color: #c9d0d7; }
.hero3d:disabled .hero-cta::after { content: none; }
.hero-all { justify-self: start; margin: -4px 0 0; padding: 6px 2px; background: none; border: 0; color: var(--accent); font: 600 14px/1.2 var(--body); }
@media (max-width: 380px) { .hero-body b { font-size: 19px; } .hero-sub { font-size: 13px; } .hero-cta { padding: 10px 13px; } }

.sub-head { display: flex; align-items: center; gap: 6px; margin: -6px 0 0 -10px; }
.sub-head h1 { margin: 0; font: 700 24px/1.2 var(--head); min-width: 0; }
.back-btn { flex: 0 0 auto; width: 44px; height: 44px; border: 0; background: none; color: var(--text); display: grid; place-items: center; border-radius: 12px; }
.back-btn svg { width: 24px; height: 24px; }
.sub-lead { margin: 0; color: var(--muted); font-size: 14px; }

.tgrid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 420px) { .tgrid { gap: 10px; } }
.tile {
  width: 100%; aspect-ratio: 1 / 1.08; padding: 8px 6px 8px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--panel); display: grid; grid-template-rows: 1fr auto auto; justify-items: center; align-items: center; gap: 4px;
}
.tile:active { background: var(--panel-2); }
.tile-num { font: 700 19px/1 var(--head); }
.tile-n { min-height: 11px; font: 600 11px/1 var(--body); color: var(--muted); white-space: nowrap; }
.tile-n.solved { color: var(--ok); }
.tile-bar { display: flex; width: 100%; height: 5px; border-radius: 3px; overflow: hidden; background: #141a22; }
.tile-bar i { display: block; height: 100%; }
.tile-bar .ok { background: var(--ok); }
.tile-bar .bad { background: var(--error); }
.tile-bar .todo { background: #3a4552; }
.tile.soon { background: transparent; border-style: dashed; }
.tile.soon .tile-num { color: #5d6875; }
.tile.soon .tile-n { color: #5d6875; }
.tile.done { border-color: rgba(61, 220, 132, 0.55); }
.tlegend { margin: 0; color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tlegend i { display: inline-block; width: 14px; height: 5px; border-radius: 3px; margin-left: 6px; }
.tlegend i:first-child { margin-left: 0; }
.tlegend .ok { background: var(--ok); } .tlegend .bad { background: var(--error); } .tlegend .todo { background: #3a4552; }

.list-title { margin: 8px 0 0; font: 600 14px/1.3 var(--head); color: var(--muted); }
.list-empty { margin: 8px 0 0; padding: 16px; border-radius: 16px; background: var(--panel); color: var(--muted); }
.qlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.qitem {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 12px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px;
}
button.qitem { width: 100%; font: inherit; color: inherit; text-align: left; cursor: pointer; }
button.qitem:active { transform: scale(0.99); }
button.qitem:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.qitem.error { grid-template-columns: 1fr; color: var(--error); }
.qthumb { width: 112px; height: auto; aspect-ratio: 604 / 225; border-radius: 8px; display: block; background: #0c1016; }
.qthumb-none { display: grid; place-items: center; color: #5d6875; font: 600 13px/1 var(--head); }
.qmeta { display: grid; gap: 3px; min-width: 0; }
.qlabel { font: 600 12px/1.2 var(--head); color: var(--accent); }
.qtext { font-size: 14px; line-height: 1.35; }
.list-more { width: 100%; min-height: 48px; border: 1px dashed #3a4552; border-radius: 14px; background: none; color: var(--muted); }
/* the start button stays on screen under a long list (400+ crossroads, all the mistakes) */
.list-go { position: sticky; bottom: 0; margin: 0 -16px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(rgba(16, 21, 29, 0), var(--bg) 16px); }
.list-go:has(#btn-start[hidden]) { display: none; }
.disclaimer { margin-top: auto; padding-top: 14px; color: #7f8a96; font-size: 12px; line-height: 1.4; }

/* ---------- HUD ---------- */
#screen-game { flex: 0 0 auto; height: 100vh; height: 100dvh; overflow: hidden; }
.hud { padding: calc(10px + env(safe-area-inset-top)) 16px 10px; flex: 0 0 auto; }
.hud-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
/* QA 07.10: «Билет 28 · вопрос 13» was cut to «Билет 28 · воп…» on 360–390 px phones -> compact streak chip + fluid size */
.hud-title { min-width: 0; font: 600 clamp(13px, 4.1vw, 15px)/1.2 var(--head); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-right { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
@media (max-width: 340px) { .hud-right { gap: 6px; } .heart { width: 17px; height: 17px; } }
.hearts { display: flex; gap: 3px; }
.heart { width: 20px; height: 20px; color: var(--error); }
.heart.lost { color: #2f3946; }
.heart svg { width: 100%; height: 100%; }
.streak {
  display: inline-flex; align-items: center; gap: 4px;
  height: 28px; padding: 0 10px 0 7px; border-radius: 14px;
  background: var(--panel); color: var(--text); font: 600 13px/1 var(--body);
}
.streak svg { width: 16px; height: 16px; color: var(--accent); }
/* sound on/off (src/sound.js) at the end of the progress row: the first HUD row has no room left on 360 px
   («Билет 28 · вопрос 13» + hearts + streak). 20 px icon, no extra row height, 44 px touch target. */
.hud-row2 { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.hud-row2 .progress { flex: 1 1 auto; margin-top: 0; }
.snd-btn { position: relative; flex: 0 0 auto; width: 22px; height: 20px; margin: -7px 0; padding: 0; border: 0; background: none; color: var(--muted); display: grid; place-items: center; }
.snd-btn svg { width: 20px; height: 20px; }
.snd-btn::after { content: ''; position: absolute; inset: -12px -11px; }
.snd-btn .snd-off, .snd-btn[aria-pressed='false'] .snd-on { display: none; }
.snd-btn[aria-pressed='false'] .snd-off { display: block; }
/* back (a run -> its list, the exam -> «Прервать?») at the start of the progress row, the same 44 px target */
.hud-back { position: relative; flex: 0 0 auto; width: 22px; height: 20px; margin: -7px 0 -7px -3px; padding: 0; border: 0; background: none; color: var(--muted); display: grid; place-items: center; }
.hud-back svg { width: 20px; height: 20px; }
.hud-back::after { content: ''; position: absolute; inset: -12px -11px; }
.timer {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px 0 8px; border-radius: 14px;
  background: var(--panel); color: var(--text); font: 600 14px/1 var(--head); font-variant-numeric: tabular-nums;
}
.timer svg { width: 16px; height: 16px; color: var(--accent); }
.timer.low { background: #3a1d20; color: #ffb3b5; }
.timer.low svg { color: var(--error); }
#screen-game[data-mode='exam'] .streak, #screen-game[data-mode='exam'] .hearts { display: none; }
.progress { display: flex; gap: 4px; margin-top: 10px; }
.progress i { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.progress i.ok { background: var(--ok); }
.progress i.bad { background: var(--error); }
.progress i.cur { background: var(--text); }
.progress i.done { background: #8fa0b2; }
.progress.dense { gap: 3px; }
.progress i.x { border-radius: 1px; }

/* ---------- stage ---------- */
/* QA 07.10: on short screens (360×740, any phone browser with its toolbars) the 3rd/4th answer of 21/14 and 28/13
   fell below the fold. The scene now gives up height first: ~400 px stay for the HUD and the answers. */
.stage {
  position: relative;
  flex: 0 0 auto;
  height: clamp(240px, 52vh, 600px);
  height: clamp(200px, min(52dvh, 100dvh - 400px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)), 600px);
  background: #cfe7f1;
  overflow: hidden;
  touch-action: manipulation;
}
.shake { position: absolute; inset: 0; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.cockpit { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; transition: opacity 0.5s; }
.dash {
  position: absolute; left: 0; right: 0; bottom: 0; height: 44px;
  background: linear-gradient(#1c222b, #13171d);
  border-top: 1px solid #2c343f;
  display: flex; justify-content: center; align-items: center; gap: 12px;
  transition: opacity 0.5s, transform 0.5s;
}
.arr { width: 34px; height: 20px; color: #39424e; }
.arr svg { width: 100%; height: 100%; }
/* shorter scene on short screens (see .stage): a slimmer dash keeps a bit more of the hood in view */
@media (max-height: 760px) { .dash { height: 36px; } .arr { width: 30px; height: 18px; } }
.stage[data-blink='left-on'] .arr-l,
.stage[data-blink='right-on'] .arr-r { color: var(--ok); filter: drop-shadow(0 0 6px rgba(61, 220, 132, 0.7)); }
.stage[data-mode='top'] .cockpit { opacity: 0; }
.stage[data-mode='top'] .dash { opacity: 0; transform: translateY(100%); }

.flash {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 45%, rgba(255, 90, 95, 0.25), rgba(255, 90, 95, 0.7));
}
.flash.on { animation: flash 0.75s ease-out; }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }
.shake.on { animation: shake 0.45s linear; }
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-7px, 3px); }
  30% { transform: translate(6px, -4px); }
  45% { transform: translate(-5px, -2px); }
  60% { transform: translate(4px, 3px); }
  75% { transform: translate(-2px, 1px); }
}

/* projected markers */
.marks { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.mark { position: absolute; left: 0; top: 0; width: 0; height: 0; transition: opacity 0.35s; will-change: transform; }
.mark.hidden { opacity: 0; }
.mark .mk { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); display: grid; place-items: center; }
.badge .mk {
  width: 28px; height: 28px; border-radius: 50%;
  font: 700 13px/1 var(--head); color: #fff;
  border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.badge-you .mk { background: var(--accent); }
.badge-with .mk { background: var(--blue); }
.badge-other .mk { background: var(--grey); }
.burst .mk { width: 56px; height: 56px; animation: pop 0.4s ease-out; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.3)); }
.burst .mk svg { width: 100%; height: 100%; }
.burst-stall .mk { width: 40px; height: 40px; border-radius: 50%; background: var(--amber); color: #2a1d05; padding: 8px; }
.horn .mk {
  width: 42px; height: 42px; border-radius: 50%;
  background: #fff; color: #10151d; padding: 9px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  animation: pulse 0.9s ease-in-out infinite;
}
.horn .mk svg { width: 100%; height: 100%; }
.mark.horn-you { left: 50%; top: auto; bottom: 34%; transform: none !important; }
/* «А» / «Б» over a participant the answers name (scene actor "label", engine.addLabels): a dark letter on a white
   disc, like the letters next to the trams on the ticket picture; smaller than the horn, no colour of the rank badges */
.who .mk {
  width: 28px; height: 28px; border-radius: 50%;
  background: #fff; color: #10151d; border: 2px solid #10151d;
  font: 700 14px/1 var(--head); padding-top: 1px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.mark.off { opacity: 0; }
@keyframes pop { 0% { transform: translate(-50%, -50%) scale(0.2); } 70% { transform: translate(-50%, -50%) scale(1.15); } 100% { transform: translate(-50%, -50%) scale(1); } }
@keyframes pulse { 0%, 100% { transform: translate(-50%, -50%) scale(1); } 50% { transform: translate(-50%, -50%) scale(1.12); } }

.chip-btn { position: absolute; min-height: 48px; padding: 0; border: 0; background: none; display: flex; align-items: center; }
.chip-btn .pill {
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 13px 0 10px; border-radius: 18px;
  background: rgba(16, 21, 29, 0.8); color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.14);
  font: 600 13px/1 var(--body);
  backdrop-filter: blur(6px);
}
.chip-btn .pill svg { width: 17px; height: 17px; }
@media (max-width: 370px) { .chip-btn .pill { gap: 5px; padding: 0 10px 0 8px; font-size: 12.5px; } }
.ticket-btn { top: 8px; left: 14px; }
/* bottom-LEFT: our own rank badge sits at the bottom just right of the centre (we always come from below, in the right
   lane); at 360 px the pill on the right covered it (28/13 «2»). The lower-left quarter is a city block in every scene. */
.replay-btn { left: 12px; bottom: 6px; }
/* QA 07.10: over the top view the long chip covered rank badges near the top edge (21/14 «1», 28/13 car «1»):
   after an answer it shrinks to an icon (still a 48 px target). */
#screen-game[data-phase='result'] .ticket-btn { min-width: 48px; }
#screen-game[data-phase='result'] .ticket-btn .lbl { display: none; }
#screen-game[data-phase='result'] .ticket-btn .pill { width: 36px; padding: 0; justify-content: center; }
/* tap-to-speed-up: hint on the first answers, then «×3» while fast (engine.js setChip) */
.speed-chip { position: absolute; top: 14px; right: 14px; pointer-events: none; transition: opacity 0.3s; }
.speed-chip[hidden] { display: block; opacity: 0; }
.speed-chip .pill {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px 0 9px; border-radius: 15px;
  background: rgba(16, 21, 29, 0.78); color: #fff; font: 600 12.5px/1 var(--body); border: 1px solid rgba(255, 255, 255, 0.14);
}
.speed-chip .pill svg { width: 15px; height: 15px; color: var(--accent); }
.speed-chip[data-state='fast'] .pill { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.speed-chip[data-state='fast'] .pill svg { color: currentColor; }
.stage-msg {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 12px;
  padding: 16px; text-align: center; background: var(--bg); color: var(--muted); font-size: 14px;
}
.fallback-img { width: 100%; height: auto; aspect-ratio: 604 / 225; border-radius: 10px; }

/* a card (question without a 3D scene): no stage, the panel gets the whole screen under the HUD */
#screen-game[data-kind='card'] .stage { display: none; }

/* ---------- panel ---------- */
.panel {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
}
.q-text { margin: 0 0 12px; font: 600 17px/1.35 var(--body); }
.answers { display: grid; gap: 8px; }
.answer {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 52px; padding: 10px 14px;
  text-align: left; background: var(--panel); color: var(--text);
  border: 1.5px solid var(--line); border-radius: 14px;
  font: 400 15.5px/1.35 var(--body);
  transition: border-color 0.2s, opacity 0.2s, background 0.2s;
}
.answer:active { background: var(--panel-2); }
.answer .num {
  flex: 0 0 26px; height: 26px; border-radius: 50%;
  background: #2a3542; color: var(--muted);
  display: grid; place-items: center; font: 700 12px/1 var(--head);
}
.answer.chosen { border-color: var(--accent); background: #24262a; }
.answer.chosen .num { background: var(--accent); color: var(--accent-ink); }
.answer:disabled { cursor: default; }
.answer:disabled:not(.chosen) { opacity: 0.5; }

.card { background: var(--panel); border-radius: 18px; padding: 16px; animation: up 0.35s ease-out; }
@keyframes up { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 7px; border-radius: 8px;
  font: 700 11px/1 var(--head); letter-spacing: 0.06em; text-transform: uppercase;
}
.tag svg { width: 15px; height: 15px; }
.tag-crash { background: var(--error); color: #fff; }
.tag-stall { background: var(--amber); color: #2a1d05; }
.tag-ok { background: var(--ok); color: #06210f; }
.card h2 { margin: 12px 0 8px; font: 600 18px/1.3 var(--head); }
.card-ok h2 { color: var(--ok); }
/* outcome texts are whole sentences (up to 6 lines in the display face on 360 px): the text face reads easier */
.card-bad h2 { font: 600 18px/1.38 var(--body); }
.expl { margin: 0; color: #d3d9df; font-size: 15px; line-height: 1.5; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip-pdd { padding: 5px 10px; border-radius: 8px; background: #26313e; color: #ffb48a; font: 600 12px/1.2 var(--body); }
.legend { margin: 12px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.legend-warn { color: var(--error); font-weight: 600; }
#screen-game .stage { transition: height 0.35s ease; }
#screen-game[data-phase='result'] .stage { height: clamp(220px, 44vh, 520px); height: clamp(220px, 44dvh, 520px); }
.panel:has(.result-actions) { padding-bottom: 0; }
.result-actions {
  position: sticky; bottom: 0; margin: 12px -16px 0; padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(rgba(16, 21, 29, 0), var(--bg) 18px);
}
@media (prefers-reduced-motion: reduce) { #screen-game .stage { transition: none; } }

/* ---------- finish ---------- */
#screen-finish { padding: 40px 16px calc(24px + env(safe-area-inset-bottom)); }
.finish { display: grid; gap: 18px; }
.finish h1 { margin: 0; font: 700 28px/1.2 var(--head); }
.fin-score { display: grid; gap: 4px; background: var(--panel); border-radius: 18px; padding: 18px; }
.fin-score b { font: 700 40px/1.1 var(--head); color: var(--accent); }
.fin-score span { color: var(--muted); }
.fin-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fin-stat { background: var(--panel); border-radius: 16px; padding: 14px; display: grid; gap: 8px; }
.fin-stat b { font: 700 22px/1 var(--head); }
.fin-label { color: var(--muted); font-size: 13px; }
.fin-note { margin: 0; color: #d3d9df; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 10;
  background: rgba(6, 9, 13, 0.82);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-card { width: 100%; max-width: 480px; background: var(--panel); border-radius: 18px; padding: 10px 12px 14px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font: 600 14px/1.2 var(--head); padding-left: 4px; }
.icon-btn { width: 48px; height: 48px; border: 0; background: none; color: var(--text); display: grid; place-items: center; }
.icon-btn svg { width: 22px; height: 22px; }
#modal-img { display: block; width: 100%; height: auto; aspect-ratio: 604 / 225; border-radius: 10px; background: #0c1016; }
.modal-note { margin: 10px 4px 0; color: var(--muted); font-size: 13px; }

/* ---------- cards ---------- */
.qcard { display: grid; gap: 0; }
.qpic { position: relative; display: block; width: 100%; max-width: 604px; margin: 0 0 12px; padding: 0; border: 0; background: #0c1016; border-radius: 12px; overflow: hidden; }
.qimg { display: block; width: 100%; height: auto; aspect-ratio: 604 / 225; }
.qpic-zoom {
  position: absolute; right: 8px; bottom: 8px; width: 32px; height: 32px; border-radius: 50%;
  background: rgba(16, 21, 29, 0.78); color: #fff; display: grid; place-items: center; border: 1px solid rgba(255, 255, 255, 0.16);
}
.qpic-zoom svg { width: 18px; height: 18px; }
.qcard .card { margin-top: 14px; }
.qcard .card-ok .expl { margin-top: 12px; }
.answer.right { border-color: var(--ok); background: #15291f; opacity: 1 !important; }
.answer.right .num { background: var(--ok); color: #06210f; }
.answer.wrong { border-color: var(--error); background: #2d181b; }
.answer.wrong .num { background: var(--error); color: #fff; }
.right-line { margin: -2px 0 10px; color: #d3d9df; font-size: 15px; }
.right-line b { color: var(--ok); font-weight: 600; }
.chip-ref { padding: 5px 10px; border-radius: 8px; background: #1f2d40; color: #9cc2ff; font: 600 12px/1.2 var(--body); }
.note2026 {
  display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: start;
  margin-top: 12px; padding: 10px 12px; border-radius: 12px;
  background: #2e2513; border: 1px solid #5b4718; color: #f3dfb4;
}
.note2026 p { margin: 0; font-size: 14px; line-height: 1.45; }
.note2026 b { color: var(--amber); }
.note-ic { color: var(--amber); padding-top: 1px; }
.note-ic svg { width: 20px; height: 20px; }
.card-extra h2 { color: var(--amber); }

/* ---------- exam result ---------- */
#screen-exam { padding: calc(28px + env(safe-area-inset-top)) 16px 0; }
.verdict { display: grid; grid-template-columns: 52px 1fr; gap: 14px; align-items: center; padding: 16px; border-radius: 18px; background: var(--panel); }
.verdict h1 { margin: 0; font: 700 28px/1.15 var(--head); }
.verdict p { margin: 4px 0 0; color: #d3d9df; }
.verdict-ic { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; }
.verdict-ic svg { width: 28px; height: 28px; }
.verdict.pass .verdict-ic { background: var(--ok); color: #06210f; }
.verdict.pass h1 { color: var(--ok); }
.verdict.fail .verdict-ic { background: var(--error); color: #fff; }
.verdict.fail h1 { color: var(--error); }
.fin-stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.review-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.review { background: var(--panel); border-radius: 18px; padding: 14px; display: grid; gap: 8px; }
.review .q-text { margin: 0; font-size: 16px; }
.review .qpic { margin: 0; }
.review .expl { font-size: 14.5px; }
.review .chips { margin-top: 0; }
.review .note2026 { margin-top: 0; }
.ans-line { margin: 0; font-size: 14.5px; color: var(--muted); }
.ans-line b { font-weight: 600; }
.ans-bad b { color: #ff9a9d; }
.ans-ok b { color: var(--ok); }
.why { margin: 0; color: var(--text); font-weight: 600; }
.btn-3d { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; justify-self: start; font-size: 14px; }
.btn-3d svg { width: 16px; height: 16px; color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.exam-actions { position: sticky; bottom: 0; margin: 16px -16px 0; padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(rgba(16, 21, 29, 0), var(--bg) 18px); }

/* ---------- zoom (card picture) ---------- */
.zoom { position: fixed; inset: 0; z-index: 12; background: #06090d; display: flex; flex-direction: column; justify-content: center; }
.zoom-bar { position: absolute; top: env(safe-area-inset-top); left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 4px 16px; font: 600 14px/1.2 var(--head); }
.zoom-scroll { overflow: auto; -webkit-overflow-scrolling: touch; padding: 0 16px; overscroll-behavior: contain; }
/* twice the size of the card picture on a phone (wider than the screen: drag it), whole on a wide screen */
#zoom-img { display: block; height: min(calc(100dvh - 150px), calc((100vw - 32px) * 0.745), 560px); width: auto; aspect-ratio: 604 / 225; max-width: none; margin: 0 auto; border-radius: 10px; background: #0c1016; }
.zoom-note { margin: 12px 16px 0; color: var(--muted); font-size: 13px; text-align: center; }

/* ---------- bottom sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 11; background: rgba(6, 9, 13, 0.7); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 480px; background: var(--panel); border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); animation: sheet 0.25s ease-out;
}
@keyframes sheet { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet .modal-head { font-size: 17px; padding-left: 0; }
.sheet-body { display: grid; gap: 8px; padding: 0 0 14px; }
.sheet-body p { margin: 0; color: #d3d9df; }
.sheet-big { font: 600 17px/1.35 var(--body); color: var(--text) !important; }
.sheet-stats { display: flex; gap: 14px; font-weight: 600; }
.st-ok { color: var(--ok); } .st-bad { color: #ff9a9d; }
.rules { margin: 0; padding-left: 18px; display: grid; gap: 6px; color: #d3d9df; font-size: 14.5px; }
.sheet-actions .btn-row { margin-top: 0; }

/* ---------- landscape phones ----------
   QA 07.10: in 844×390 / 740×360 the answers sat under a 60–90 px panel and «Дальше / Ещё раз» were cut off.
   Scene on the left, question and answers on the right, both full height. */
@media (orientation: landscape) and (max-height: 540px) {
  #app { max-width: 1000px; }
  #screen-game {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(280px, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }
  #screen-game .hud { grid-column: 1 / -1; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  #screen-game .stage,
  #screen-game[data-phase='result'] .stage { grid-column: 1; grid-row: 2; height: auto; min-height: 0; transition: none; }
  #screen-game .panel { grid-column: 2; grid-row: 2; padding-right: max(16px, env(safe-area-inset-right)); }
  #screen-game[data-kind='card'] .panel { grid-column: 1 / -1; padding-left: max(16px, env(safe-area-inset-left)); }
  .qcard:not(.qcard-text) { grid-template-columns: minmax(0, 1fr) minmax(280px, 1fr); column-gap: 18px; align-items: start; }
  .qcard:not(.qcard-text) .qpic { grid-column: 1; grid-row: 1 / span 3; position: sticky; top: 0; margin: 0; }
  .qcard:not(.qcard-text) > :not(.qpic) { grid-column: 2; }
  .qcard.qcard-text { max-width: 640px; margin: 0 auto; }
  #screen-home, #screen-tickets, #screen-list { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .tgrid { grid-template-columns: repeat(8, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .shake.on { animation: none; }
  .horn .mk { animation: none; }
  .burst .mk { animation: none; }
  .card { animation: none; }
  .sheet { animation: none; }
}
