/* ═══════════════════════════════════════════════════════════════════════════
   גז! — bright, saturated, cartoon-fast. Pixar Cars, never sci-fi (#p602).
   Everything animates with transform + opacity only.
   ═══════════════════════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'Heebo';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('assets/fonts/heebo-hebrew.woff2') format('woff2');
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
@font-face {
  font-family: 'Heebo';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('assets/fonts/heebo-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Heebo';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('assets/fonts/heebo-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
    U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0,
    U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --sky-hi: #56C7F5;
  --sky-lo: #B7EEFF;
  --sun: #FFD23F;
  --flame: #FF6B1A;
  --flame-dk: #D24405;
  --grape: #7B2FF7;
  --grape-dk: #5312B8;
  --go: #22C55E;
  --go-dk: #11813C;
  --grass: #56CC55;
  --grass-dk: #2F9C3D;
  --asphalt: #47506B;
  --asphalt-dk: #333B52;
  --ink: #171C2B;
  --paper: #FFFFFF;
  --shadow: 0 6px 0 rgba(0, 0, 0, .22);

  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px;

  --radius: 22px;
  --tap: 56px; /* comfortably past the 44px minimum — these are 8-year-old thumbs */
  --ease-pop: cubic-bezier(.2, 1.35, .5, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: 'Heebo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--sky-lo);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  text-rendering: optimizeLegibility;
}

button { font: inherit; color: inherit; }

/* ── Screens ─────────────────────────────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: max(var(--s4), env(safe-area-inset-top)) var(--s4)
           max(var(--s4), env(safe-area-inset-bottom));
  overflow: hidden;
  animation: screen-in .26s var(--ease-pop) both;
}
.screen[hidden] { display: none; }

@keyframes screen-in {
  from { opacity: 0; transform: scale(.985); }
  to   { opacity: 1; transform: none; }
}

/* ── The world behind every non-race screen ──────────────────────────────── */
.scene { position: absolute; inset: 0; z-index: 0; background: linear-gradient(180deg, var(--sky-hi) 0%, var(--sky-lo) 62%); }
.scene--dim::after { content: ''; position: absolute; inset: 0; background: rgba(23, 28, 43, .16); }

.scene__sun {
  position: absolute; inset-block-start: 6%; inset-inline-end: 10%;
  width: 76px; height: 76px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #FFF3B0, var(--sun) 70%);
  box-shadow: 0 0 0 14px rgba(255, 210, 63, .2), 0 0 0 30px rgba(255, 210, 63, .1);
}
.scene__cloud {
  position: absolute;
  width: 130px; height: 42px;
  background: #fff; border-radius: 999px;
  opacity: .95;
  box-shadow: 34px -16px 0 -4px #fff, -32px -10px 0 -8px #fff;
}
.scene__cloud--a { inset-block-start: 12%; inset-inline-start: -14%; animation: drift 34s linear infinite; }
.scene__cloud--b { inset-block-start: 26%; inset-inline-start: -40%; transform: scale(.7); animation: drift 46s linear infinite 6s; }
.scene__cloud--c { inset-block-start: 5%;  inset-inline-start: -70%; transform: scale(.5); animation: drift 58s linear infinite 2s; }
@keyframes drift { to { transform: translateX(-140vw) scale(var(--cs, 1)); } }
.scene__cloud--b { --cs: .7; }
.scene__cloud--c { --cs: .5; }

.scene__hills {
  position: absolute; inset-inline: -10%; inset-block-end: 30%; height: 15%;
  background:
    radial-gradient(ellipse 34% 78% at 18% 100%, var(--grass-dk) 0 99.5%, transparent 100%),
    radial-gradient(ellipse 44% 118% at 58% 100%, #43B24F 0 99.5%, transparent 100%),
    radial-gradient(ellipse 32% 86% at 95% 100%, var(--grass-dk) 0 99.5%, transparent 100%);
}
.scene__ground {
  position: absolute; inset-inline: 0; inset-block-end: 0; height: 32%;
  background: linear-gradient(180deg, var(--grass) 0%, var(--grass-dk) 100%);
  border-block-start: 6px solid rgba(0, 0, 0, .12);
}

/* ── Wordmark ────────────────────────────────────────────────────────────── */
.wordmark {
  position: relative; z-index: 2;
  margin: var(--s2) 0 0;
  text-align: center;
  font-size: clamp(66px, 20vw, 112px);
  font-weight: 900;
  line-height: .9;
  color: var(--paper);
  letter-spacing: 0;
  -webkit-text-stroke: 5px var(--flame-dk);
  paint-order: stroke fill;
  text-shadow: 0 8px 0 var(--flame-dk), 0 14px 22px rgba(0, 0, 0, .3);
  transform: rotate(-3deg);
}
.wordmark span { color: var(--sun); }

/* ── Home ────────────────────────────────────────────────────────────────── */
.home__car {
  position: relative; z-index: 1;
  flex: 1 1 auto;
  display: grid; place-items: end center;
  padding: var(--s4) 0 0;
  min-height: 0;
}
.home__car svg {
  width: min(92vw, 460px);
  height: auto;
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, .22));
  animation: idle-bob 2.6s ease-in-out infinite;
}
@keyframes idle-bob {
  0%, 100% { transform: translateY(0) rotate(-.6deg); }
  50%      { transform: translateY(-8px) rotate(.6deg); }
}

.home__actions {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; gap: var(--s3);
  padding-block-end: var(--s2);
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--tap);
  padding: var(--s4) var(--s6);
  border: 0;
  border-radius: var(--radius);
  font-size: clamp(20px, 5.4vw, 26px);
  font-weight: 900;
  color: var(--paper);
  background: var(--flame);
  box-shadow: 0 6px 0 var(--flame-dk), 0 10px 18px rgba(0, 0, 0, .2);
  cursor: pointer;
  transition: transform .12s var(--ease-pop), box-shadow .12s ease, opacity .18s ease;
  touch-action: manipulation;
}
.btn__icon { font-size: .9em; }
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 var(--flame-dk), 0 4px 10px rgba(0, 0, 0, .18); }
.btn:focus-visible { outline: 4px solid #fff; outline-offset: 3px; }
.btn:disabled { opacity: .45; cursor: default; }

.btn--grape { background: var(--grape); box-shadow: 0 6px 0 var(--grape-dk), 0 10px 18px rgba(0, 0, 0, .2); }
.btn--grape:active:not(:disabled) { box-shadow: 0 2px 0 var(--grape-dk), 0 4px 10px rgba(0, 0, 0, .18); }
.btn--go { background: var(--go); box-shadow: 0 6px 0 var(--go-dk), 0 10px 18px rgba(0, 0, 0, .2); }
.btn--go:active:not(:disabled) { box-shadow: 0 2px 0 var(--go-dk), 0 4px 10px rgba(0, 0, 0, .18); }
.btn--ghost {
  background: rgba(255, 255, 255, .18);
  color: var(--paper);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .5);
  font-size: 18px;
  min-height: 48px;
}
.btn--ghost:active { transform: translateY(2px); }

.iconbtn {
  position: absolute; z-index: 5;
  inset-block-start: max(var(--s4), env(safe-area-inset-top));
  inset-inline-start: var(--s4);
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .9);
  color: var(--ink);
  box-shadow: 0 4px 0 rgba(0, 0, 0, .16);
  cursor: pointer;
  transition: transform .12s var(--ease-pop);
}
.iconbtn svg { width: 26px; height: 26px; }
.iconbtn:active { transform: translateY(3px); }
/* the chevron points "back", which in RTL is to the right */
[dir='rtl'] .iconbtn svg { transform: scaleX(-1); }

/* ── Lobby panels ────────────────────────────────────────────────────────── */
.screen--panel { justify-content: center; align-items: center; }

.panel {
  position: relative; z-index: 2;
  width: min(100%, 460px);
  display: flex; flex-direction: column; gap: var(--s4);
  padding: var(--s6) var(--s5) var(--s5);
  border-radius: 30px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 14px 0 rgba(0, 0, 0, .16), 0 24px 40px rgba(0, 0, 0, .26);
  max-height: 100%;
  overflow: auto;
}
.panel__kicker {
  margin: 0;
  text-align: center;
  font-size: 19px; font-weight: 700;
  color: #5A6480;
}

.code {
  margin: 0;
  text-align: center;
  font-size: clamp(56px, 19vw, 92px);
  font-weight: 900;
  line-height: 1;
  color: var(--ink);
  letter-spacing: .06em;
  font-variant-numeric: tabular-nums;
}
.code--input {
  min-height: 1em;
  color: var(--flame);
}
.code__rest { color: #C3CAD9; }

.lobby-state { min-height: 30px; display: grid; place-items: center; }
.lobby-state__body {
  display: flex; align-items: center; gap: var(--s2);
  font-size: 17px; font-weight: 700; color: #5A6480;
  text-align: center;
}
.lobby-state__body[data-state='ready'] { color: var(--go-dk); font-size: 20px; }
.lobby-state__body[data-state='error'] { color: var(--flame-dk); }
.lobby-state__body[data-state='warn']  { color: #B26A00; }

.spinner {
  width: 20px; height: 20px; flex: none;
  border: 3px solid rgba(90, 100, 128, .25);
  border-block-start-color: #5A6480;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pulse-dot {
  width: 14px; height: 14px; flex: none; border-radius: 50%;
  background: var(--go);
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.45); opacity: .6; }
}

/* ── Keypad ──────────────────────────────────────────────────────────────── */
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s2);
  /* Digits are digits: a phone keypad is LTR in Hebrew too. */
  direction: ltr;
}
.key {
  min-height: var(--tap);
  border: 0;
  border-radius: 18px;
  font-size: 28px; font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: #EEF2F8;
  box-shadow: 0 4px 0 #C6CEDD;
  cursor: pointer;
  transition: transform .09s var(--ease-pop), box-shadow .09s ease;
  touch-action: manipulation;
}
.key:active { transform: translateY(3px); box-shadow: 0 1px 0 #C6CEDD; }
.key:focus-visible { outline: 4px solid var(--grape); outline-offset: 2px; }
.key--del { background: #FFE0D2; box-shadow: 0 4px 0 #E7B49B; font-size: 24px; }
.key--wide { grid-column: span 2; }
.key--send {
  background: var(--go); color: #fff;
  box-shadow: 0 4px 0 var(--go-dk);
  font-size: 22px;
  direction: rtl; /* its label is Hebrew even though the pad is not */
}
.key--send:active { box-shadow: 0 1px 0 var(--go-dk); }
.key--send:disabled { opacity: .5; }
.key svg { width: 26px; height: 26px; vertical-align: -5px; }

.keypad--race { flex: 1 1 auto; gap: var(--s2); max-height: 560px; width: 100%; max-width: 540px; margin-inline: auto; }
.keypad--race .key { min-height: 0; height: 100%; font-size: clamp(26px, 7vw, 36px); }

/* ── Countdown ───────────────────────────────────────────────────────────── */
.screen--count { align-items: center; justify-content: center; }
.count {
  position: relative; z-index: 2;
  margin: 0;
  font-size: clamp(140px, 46vw, 260px);
  font-weight: 900;
  line-height: 1;
  color: var(--paper);
  text-shadow: 0 8px 0 var(--flame-dk), 0 16px 30px rgba(0, 0, 0, .35);
}
.count[data-go='1'] {
  font-size: clamp(84px, 26vw, 170px);
  color: var(--sun);
  text-shadow: 0 8px 0 var(--flame-dk), 0 16px 30px rgba(0, 0, 0, .35);
}
.count.count--tick { animation: count-pop .62s var(--ease-pop) both; }
@keyframes count-pop {
  0%   { transform: scale(.4) rotate(-8deg); opacity: 0; }
  35%  { transform: scale(1.12) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* ═══ RACE ═══════════════════════════════════════════════════════════════ */
.screen--race { padding: 0; background: linear-gradient(180deg, var(--asphalt-dk) 0%, #1B2033 100%); }

.track {
  position: relative;
  flex: 0 0 clamp(200px, 41dvh, 520px);
  overflow: hidden;
  background: linear-gradient(180deg, var(--sky-hi) 0%, var(--sky-lo) 100%);
  padding-block-start: env(safe-area-inset-top);
  transition: flex-basis .5s var(--ease-pop);
}
/* The finish takes the screen: the play panel drops away and the track grows —
   but only to 62%, because a full-height track stretches the road band out of
   proportion and the crossing stops reading as a crossing. */
.screen--race[data-phase='finish'] .track { flex-basis: 56%; }
.screen--race[data-phase='finish'] .play {
  opacity: 0;
  transform: translateY(100%);
  pointer-events: none;
}

.track__sky { position: absolute; inset-inline: 0; inset-block: 0 52%; background: linear-gradient(180deg, var(--sky-hi), var(--sky-lo)); }
.track__clouds {
  position: absolute; left: 0; top: 4%;
  width: calc(100% + 340px); height: 17%;
  /* period: 300px */
  background:
    radial-gradient(ellipse 32px 46% at 58px 60%, #fff 0 99.5%, transparent 100%) 0 0 / 300px 100% repeat-x,
    radial-gradient(ellipse 20px 32% at 96px 72%, #fff 0 99.5%, transparent 100%) 0 0 / 300px 100% repeat-x,
    radial-gradient(ellipse 24px 34% at 212px 40%, #fff 0 99.5%, transparent 100%) 0 0 / 300px 100% repeat-x;
  opacity: .85;
  will-change: transform;
}
/* Parallax layers. Each has ONE background period; raceview.js scrolls it with
   translate3d modulo that exact period, so the tiling seam never shows. */
.track__hills {
  position: absolute; left: 0; bottom: 56%;
  width: calc(100% + 260px); height: 13%;
  /* period: 220px */
  background:
    radial-gradient(ellipse 74px 100% at 56px 100%, #7FD08B 0 99.5%, transparent 100%) 0 100% / 220px 100% repeat-x,
    radial-gradient(ellipse 58px 74% at 168px 100%, #62BE72 0 99.5%, transparent 100%) 0 100% / 220px 100% repeat-x;
  will-change: transform;
}
.track__trees {
  position: absolute; left: 0; bottom: 52%;
  width: calc(100% + 160px); height: 14%;
  /* period: 120px — trunk and canopy share one tile */
  background:
    linear-gradient(90deg, transparent 0 23px, #7A4A22 23px 30px, transparent 30px) 0 100% / 120px 40% repeat-x,
    radial-gradient(ellipse 22px 66% at 26px 100%, #2C8A3B 0 99.5%, transparent 100%) 0 72% / 120px 100% repeat-x;
  will-change: transform;
}
.track__grass {
  position: absolute; inset-inline: 0; inset-block: 43% 0;
  background: linear-gradient(180deg, var(--grass) 0%, var(--grass-dk) 100%);
}
.track__road {
  position: absolute; inset-inline: 0; inset-block: 52% 3%;
  background: linear-gradient(180deg, #545E7C 0%, var(--asphalt) 30%, var(--asphalt-dk) 100%);
  border-block: 5px solid rgba(0, 0, 0, .18);
  overflow: hidden;
}
/* Your lane is lit; the far lane sits in shade. Both siblings often drive the
   same car, so position and depth — not colour — must say "that one is me". */
.track__road::after {
  content: ''; position: absolute; inset-inline: 0; inset-block: 52% 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, .02));
  pointer-events: none;
}
.track__dashes {
  position: absolute; left: 0; top: 50%;
  width: calc(100% + 140px); height: 7px;
  margin-block-start: -3px;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .92) 0 46px, transparent 46px 130px);
  border-radius: 4px;
  will-change: transform;
}
.track__kerb {
  position: absolute; left: 0;
  width: calc(100% + 100px); height: 9px;
  background: repeating-linear-gradient(90deg, #FF4A3D 0 24px, #fff 24px 48px);
  will-change: transform;
}
.track__kerb--top { top: 0; }
.track__kerb--bottom { bottom: 0; }

.track__world { position: absolute; inset: 0; pointer-events: none; }
.pylon {
  position: absolute; bottom: 47%;
  left: 50%;
  width: 12px; height: 21px;
  margin-left: -6px; /* physical: world coordinates, not text flow */
  background: linear-gradient(180deg, #FF7A2F 0 60%, #fff 60% 78%, #FF7A2F 78% 100%);
  border-radius: 4px 4px 2px 2px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .25);
  will-change: transform;
}

.finishline {
  position: absolute; inset-block: 46% 3%;
  left: 50%; width: 26px; margin-left: -13px;
  background:
    repeating-conic-gradient(#fff 0 25%, #171C2B 0 50%) 0 0 / 13px 13px;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, .25);
  will-change: transform;
}
.finishline span {
  position: absolute; left: 50%; top: -34px;
  width: 74px; margin-left: -37px; height: 30px;
  background: var(--flame);
  border-radius: 6px;
  box-shadow: 0 4px 0 var(--flame-dk);
}
.finishline span::after {
  content: '🏁';
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 20px;
}

.lane { position: absolute; left: 0; right: 0; height: 0; }
.lane--opp { bottom: 27%; }
.lane--me  { bottom: 7%; }

.racer {
  position: absolute; left: 50%; bottom: 0;
  width: clamp(96px, 26vw, 190px);
  margin-left: calc(clamp(96px, 26vw, 190px) / -2);
  will-change: transform;
}
.racer__car { transform-origin: 50% 90%; }
.racer__car svg { display: block; width: 100%; height: auto; filter: drop-shadow(0 5px 6px rgba(0, 0, 0, .3)); }
.racer--me .racer__car { animation: idle-rumble .28s ease-in-out infinite alternate; }
@keyframes idle-rumble {
  from { transform: translateY(0); }
  to   { transform: translateY(-1.5px); }
}
.racer--opp { filter: saturate(.86) brightness(.9); }
.racer--opp .racer__car svg { transform: scale(.78); }
/* Depth does the work: your car is larger and in the near lane, the sibling's
   is smaller, shaded, and further up the road. No label needed. */

.racer__lines {
  position: absolute; top: 40%; height: 40%;
  right: 100%; width: 90px;
  opacity: 0;
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, .95)) 0 20% / 100% 5px no-repeat,
    linear-gradient(90deg, transparent, rgba(255, 255, 255, .8)) 0 55% / 78% 4px no-repeat,
    linear-gradient(90deg, transparent, rgba(255, 255, 255, .7)) 0 88% / 60% 4px no-repeat;
  transition: opacity .1s linear;
  pointer-events: none;
}

.racer__cue[hidden] { display: none; }
.racer__cue {
  position: absolute; top: 100%; left: 50%;
  transform: translate(-50%, 2px);
  display: flex; align-items: center; gap: var(--s1);
  padding: var(--s1) var(--s2);
  border-radius: 999px;
  background: rgba(23, 28, 43, .78);
  color: #fff;
  font-size: 14px; font-weight: 900;
  white-space: nowrap;
}
/* Physical borders on purpose: this arrow points at a place on the track,
   not at a place in a sentence, so it must not flip with the text direction. */
.racer__arrow {
  width: 0; height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 10px solid #FFD23F;
  border-right: 0;
}
.racer__cue[data-dir='behind'] .racer__arrow { transform: scaleX(-1); }
.racer--clamped .racer__car { opacity: .8; transform: scale(.7); transform-origin: 50% 50%; }

/* ── Question + keypad ───────────────────────────────────────────────────── */
.play {
  flex: 1 1 auto;
  display: flex; flex-direction: column; justify-content: center; gap: var(--s3);
  padding: var(--s3) var(--s4) max(var(--s4), env(safe-area-inset-bottom));
  background: linear-gradient(180deg, #FFFFFF 0%, #F2F5FB 100%);
  border-start-start-radius: 26px;
  border-start-end-radius: 26px;
  margin-block-start: -14px;
  position: relative; z-index: 3;
  box-shadow: 0 -8px 20px rgba(0, 0, 0, .22);
  transition: opacity .35s ease, transform .35s var(--ease-pop);
  min-height: 0;
}

.question {
  margin: 0;
  display: flex; align-items: center; justify-content: center; gap: var(--s3);
  font-size: clamp(34px, 9.5vw, 52px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  flex: 0 0 auto;
  padding-block: var(--s1);
}
.question__eq { color: #98A2B9; }
.slot {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2.4ch; min-height: 1.25em;
  padding: 0 var(--s2);
  border-radius: 14px;
  background: #EEF2F8;
  box-shadow: inset 0 0 0 3px #D7DEEB;
  color: var(--flame);
}
.slot:empty::before { content: '?'; color: #B9C2D4; }
.question--surge { animation: q-pop .3s var(--ease-pop); }
@keyframes q-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* ── Finish screens ──────────────────────────────────────────────────────── */
.screen--finish { align-items: center; justify-content: center; }

.screen--win {
  background: radial-gradient(circle at 50% 34%, #FFE98A 0%, var(--flame) 46%, var(--flame-dk) 100%);
}
.confetti { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }

.win__beat {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: var(--s3);
  text-align: center;
}
.win__beat[hidden] { display: none; }
.win__title {
  margin: 0;
  font-size: clamp(56px, 17vw, 104px);
  font-weight: 900;
  color: var(--paper);
  text-shadow: 0 6px 0 var(--flame-dk), 0 14px 26px rgba(0, 0, 0, .32);
  animation: title-slam .55s var(--ease-pop) both;
}
@keyframes title-slam {
  0%   { transform: scale(2.4) rotate(-10deg); opacity: 0; }
  55%  { transform: scale(.92) rotate(3deg);  opacity: 1; }
  100% { transform: scale(1) rotate(-2deg);   opacity: 1; }
}
.win__car svg { width: min(78vw, 400px); height: auto; animation: winner-strut 1.4s ease-in-out infinite; filter: drop-shadow(0 14px 20px rgba(0,0,0,.3)); }
@keyframes winner-strut {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%      { transform: translateY(-14px) rotate(3deg); }
}

.reveal__kicker {
  margin: 0;
  font-size: clamp(26px, 7vw, 38px); font-weight: 900;
  color: var(--paper);
  text-shadow: 0 4px 0 rgba(0, 0, 0, .35), 0 0 20px rgba(0, 0, 0, .25);
}
.reveal__burst {
  position: absolute; inset-block-start: 46%; inset-inline-start: 50%;
  width: 460px; height: 460px;
  translate: -50% -50%;
  border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(255,255,255,.42) 0 8deg, transparent 8deg 30deg);
  -webkit-mask-image: radial-gradient(closest-side, transparent 12%, #000 46%, transparent 98%);
  mask-image: radial-gradient(closest-side, transparent 12%, #000 46%, transparent 98%);
  animation: burst-spin 9s linear infinite;
  pointer-events: none;
}
.win__beat--reveal > :not(.reveal__burst) { position: relative; z-index: 1; }
@keyframes burst-spin { to { transform: rotate(360deg); } }
.reveal__car svg {
  width: min(86vw, 440px); height: auto;
  animation: reveal-in .6s var(--ease-pop) both;
  filter: drop-shadow(0 14px 20px rgba(0,0,0,.3));
}
@keyframes reveal-in {
  0%   { transform: scale(.3) rotate(-16deg); opacity: 0; }
  60%  { transform: scale(1.08) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.reveal__name {
  margin: 0;
  font-size: clamp(34px, 9vw, 52px); font-weight: 900;
  color: var(--sun);
  -webkit-text-stroke: 3px #8A2E00;
  paint-order: stroke fill;
  text-shadow: 0 5px 0 rgba(0, 0, 0, .28);
}

.finish__actions {
  position: absolute; z-index: 4;
  inset-inline: var(--s4);
  inset-block-end: max(var(--s5), env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: var(--s2);
  animation: rise .35s var(--ease-pop) both;
}
.finish__actions[hidden] { display: none; }
@keyframes rise { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }

/* Loser — the sibling's car crossing the line, and one button. Nothing else.
   Physical left/right on purpose: this is a place on a track, not a sentence. */
.screen--lose {
  /* "Not the party" — a calm overcast afternoon, deliberately NOT a dark or
     sad screen. Losing is a moment in a race, not a verdict (#p277). */
  background: linear-gradient(180deg, #9CC4DE 0%, #7796B1 54%, #5C7691 100%);
  justify-content: space-between;
}
.lose__scene {
  position: relative;
  width: 100vw;
  margin-inline: calc(var(--s4) * -1);
  flex: 1 1 auto;
  min-height: 0;
}
.lose__road {
  position: absolute; left: -4%; right: -4%; top: 36%; bottom: 34%;
  background: linear-gradient(180deg, #545E7C 0%, var(--asphalt-dk) 100%);
  border-block: 6px solid rgba(0, 0, 0, .28);
}
.lose__road::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 9px;
  background: repeating-linear-gradient(90deg, #FF4A3D 0 22px, #fff 22px 44px);
  opacity: .85;
}
.lose__line {
  position: absolute; left: 28%; top: 36%; bottom: 34%;
  width: 34px; margin-left: -17px;
  background: repeating-conic-gradient(#fff 0 25%, #171C2B 0 50%) 0 0 / 17px 17px;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, .35);
}
.lose__line i {
  position: absolute; left: 50%; top: -52px;
  width: 158px; height: 34px; margin-left: -79px;
  border-radius: 8px;
  background: repeating-conic-gradient(#fff 0 25%, #171C2B 0 50%) 0 0 / 17px 17px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, .35);
}
.lose__car {
  position: absolute; left: 58%; bottom: 38%;
  width: min(62vw, 300px);
  transform: translateX(-50%);
}
.lose__car svg {
  width: 100%; height: auto;
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, .5));
  animation: lose-cross 1.1s var(--ease-pop) both;
}
@keyframes lose-cross {
  from { transform: translateX(-52%) scale(.9); opacity: .5; }
  to   { transform: translateX(0) scale(1); opacity: 1; }
}
.screen--lose .btn {
  position: relative; z-index: 2;
  width: 100%;
  flex: none;
  animation: rise .4s var(--ease-pop) .35s both;
}

/* ── Overlays ────────────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding: var(--s5);
  background: rgba(23, 28, 43, .72);
  backdrop-filter: blur(3px);
  animation: screen-in .2s ease both;
}
.overlay[hidden] { display: none; }
.overlay__card {
  width: min(100%, 380px);
  display: flex; flex-direction: column; align-items: center; gap: var(--s3);
  padding: var(--s6) var(--s5);
  border-radius: 28px;
  background: var(--paper);
  box-shadow: 0 12px 0 rgba(0, 0, 0, .2);
  text-align: center;
}
.overlay__icon { color: var(--flame); }
.overlay__icon svg { width: 56px; height: 56px; }
.overlay__title { margin: 0; font-size: 24px; font-weight: 900; }
.overlay__sub { margin: 0; font-size: 16px; color: #5A6480; }
.overlay__card .btn { width: 100%; }
.overlay__card .btn--ghost { color: var(--ink); box-shadow: inset 0 0 0 3px #D7DEEB; background: #F2F5FB; }

/* ── Landscape / tablets ─────────────────────────────────────────────────── */
@media (min-width: 700px) {
  .home__actions { flex-direction: row; justify-content: center; }
  .home__actions .btn { flex: 1 1 0; max-width: 320px; }
  .finish__actions { flex-direction: row; justify-content: center; }
  .finish__actions .btn { min-width: 220px; }
  .keypad--code { width: 100%; max-width: 340px; margin-inline: auto; }
  .keypad--race { max-width: 520px; margin-inline: auto; width: 100%; }
  .screen--lose .btn { max-width: 420px; margin-inline: auto; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .track { flex-basis: 44dvh; }
  .question { font-size: clamp(28px, 6vh, 40px); }
  .keypad--race { max-width: 420px; }
  .wordmark { font-size: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .scene__cloud, .home__car svg, .racer--me .racer__car,
  .win__car svg, .reveal__burst, .spinner, .pulse-dot { animation: none !important; }
  .screen, .btn, .key { transition-duration: .01ms !important; }
}
