/* The game frame: HUD, screens and touch controls.
   Glass panels over the scene; the display face is Nunito (rounded, heavy)
   so it matches SF Pro Rounded in the app. Tokens come from /styles.css. */

.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  max-width: 1640px;
  margin: 0 auto;
  padding: 0 20px;
}
@media (min-width: 1480px) {
  .play-layout { grid-template-columns: minmax(0, 1fr) 300px; }
}
.play-rail { display: none; }
@media (min-width: 1480px) {
  .play-rail { display: block; padding-top: 0; }
  .ad-rail { position: sticky; top: 90px; min-height: 600px; }
}

.game {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(100svh - 96px);
  margin: 0 auto;
  border-radius: 22px;
  overflow: hidden;
  background: radial-gradient(120% 100% at 70% 20%, #2a1424 0%, #0a0b0d 60%);
  isolation: isolate;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.9), 0 0 0 1px var(--hairline);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  font-family: var(--display);
}
.game canvas#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

@media (max-width: 760px) {
  .play-layout { padding: 0; }
  .game { aspect-ratio: auto; height: calc(100svh - 64px); max-height: none; border-radius: 0; box-shadow: none; }
}

/* Immersive: the run fills the screen (CSS-only, so it works on iPhone too). */
body.immersive { overflow: hidden; }
body.immersive .game {
  position: fixed; inset: 0; z-index: 100; width: 100vw; height: 100dvh;
  max-height: none; aspect-ratio: auto; border-radius: 0; box-shadow: none;
}
.game:fullscreen { border-radius: 0; max-height: none; aspect-ratio: auto; }

/* ── glass ──────────────────────────────────────────────────────── */
.glass {
  background: rgba(10, 11, 13, 0.42);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  backdrop-filter: blur(12px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 16px;
}
.glass-strong {
  background: rgba(10, 11, 13, 0.66);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  backdrop-filter: blur(22px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.8);
}
.label { font-size: 10px; font-weight: 900; letter-spacing: 0.2em; color: var(--muted); text-transform: uppercase; }

/* ── HUD ────────────────────────────────────────────────────────── */
.hud { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.4s ease; color: var(--ink); }
.game[data-state="driving"] .hud, .game[data-state="paused"] .hud { opacity: 1; }

.hud-top-left { position: absolute; left: 18px; top: 18px; padding: 12px 16px 14px; min-width: 240px; }
.hud-road { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; font-size: 12px; }
.hud-road span { color: var(--blaze); font-weight: 900; letter-spacing: 0.12em; }
.hud-road b { font-weight: 800; font-size: 15px; }
.progress { margin-top: 10px; }
.progress-track { position: relative; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); }
.progress-track .tick { position: absolute; top: -3px; width: 2px; height: 12px; background: rgba(255, 176, 31, 0.5); border-radius: 1px; }
.progress-track .dot { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; left: 0; }
.dot-you { background: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.18); }
.dot-ghost { background: var(--amber); box-shadow: 0 0 12px var(--amber); opacity: 0.85; }

.minimap { position: absolute; right: 18px; top: 18px; width: 132px; height: 132px; border-radius: 50%; }

.split {
  position: absolute; left: 50%; top: 18px; transform: translateX(-50%);
  display: flex; align-items: baseline; gap: 12px;
  padding: 10px 18px; border-radius: 999px;
  background: rgba(10, 11, 13, 0.6); border: 1px solid rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  animation: split-in 0.45s cubic-bezier(.2, .9, .3, 1.2);
}
.split[hidden] { display: none; }
.split-label { font-size: 11px; letter-spacing: 0.2em; color: var(--muted); font-weight: 900; }
.split-delta { font-size: 26px; font-weight: 900; font-variant-numeric: tabular-nums; }
.split.ahead .split-delta { background: linear-gradient(100deg, var(--blaze), var(--amber)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.split.behind .split-delta { color: #c7ccd4; }
.split-vs { font-size: 12px; color: var(--muted); font-weight: 800; letter-spacing: 0.08em; }
@keyframes split-in { from { opacity: 0; transform: translate(-50%, -12px) scale(0.96); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }

.hud-bottom-left { position: absolute; left: 18px; bottom: 18px; padding: 10px 14px 10px 10px; display: flex; align-items: center; gap: 10px; }
.cup { width: 84px; height: 84px; }
.cup-meta { display: grid; gap: 2px; }
.cup-meta b { font-size: 26px; font-weight: 900; font-variant-numeric: tabular-nums; }

.hud-speed { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; align-items: baseline; gap: 8px; text-shadow: 0 2px 18px rgba(0, 0, 0, 0.6); }
.hud-speed b { font-size: 64px; font-weight: 900; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; min-width: 2.2ch; text-align: right; }
.hud-speed > span { font-size: 12px; font-weight: 900; letter-spacing: 0.16em; color: var(--muted); }
.limit { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: #f4f4ef; border: 5px solid #d8222a; color: #111; font-weight: 900; font-size: 17px; align-self: center; margin-left: 6px; transition: transform 0.2s ease; }
.limit.mph { border-radius: 6px; border: 3px solid #111; width: 42px; height: 50px; font-size: 18px; }
.limit.over { animation: limit-pulse 0.9s ease-in-out infinite; }
@keyframes limit-pulse { 50% { transform: scale(1.12); box-shadow: 0 0 22px #d8222a; } }

.hud-bottom-right { position: absolute; right: 18px; bottom: 18px; padding: 10px 14px 12px; width: 220px; }
.pace { position: relative; height: 10px; margin: 9px 0 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); overflow: visible; }
/* Calm plateau of the pace curve: ratio 1.0–1.35 on a 0.75–2.0 axis. */
.pace-band { position: absolute; left: 20%; width: 28%; top: 0; bottom: 0; border-radius: 999px; background: linear-gradient(90deg, var(--blaze), var(--amber)); opacity: 0.85; }
.pace-needle { position: absolute; top: -5px; width: 3px; height: 20px; margin-left: -1.5px; border-radius: 2px; background: #fff; box-shadow: 0 0 10px rgba(255, 255, 255, 0.8); left: 20%; transition: left 0.25s linear; }
.pace-labels { display: flex; justify-content: space-between; font-size: 9px; letter-spacing: 0.14em; color: var(--muted); font-weight: 900; }

.hint { position: absolute; left: 50%; bottom: 110px; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); text-align: center; padding: 10px 18px; border-radius: 999px; background: rgba(10, 11, 13, 0.55); border: 1px solid rgba(255, 255, 255, 0.1); font-weight: 800; font-size: 14px; transition: opacity 0.4s; }
.hint.gone { opacity: 0; }
kbd { display: inline-block; min-width: 1.7em; padding: 1px 6px; border-radius: 6px; border: 1px solid rgba(255, 255, 255, 0.22); border-bottom-width: 2px; background: rgba(255, 255, 255, 0.06); font: 800 0.86em var(--display); text-align: center; color: var(--ink); }

/* ── screens ────────────────────────────────────────────────────── */
.screen { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; opacity: 0; visibility: hidden; transition: opacity 0.35s ease, visibility 0s linear 0.35s; color: var(--ink); overflow: auto; }
.game[data-state="loading"] .screen-loading,
.game[data-state="title"] .screen-title,
.game[data-state="paused"] .screen-pause,
.game[data-state="results"] .screen-results,
.game[data-state="error"] .screen-error,
.game.settings-open .screen-settings,
.game[data-state="garage"] .screen-garage,
.game[data-state="summary"] .screen-summary,
.game[data-state="crashed"] .screen-crash { opacity: 1; visibility: visible; transition: opacity 0.35s ease, visibility 0s; }
.game[data-state="crashed"] .screen-crash { background: radial-gradient(80% 70% at 50% 50%, rgba(140, 20, 10, 0.32), rgba(5, 6, 8, 0.55)); }
.game.settings-open .screen-settings { background: rgba(5, 6, 8, 0.4); z-index: 5; }
.game[data-state="paused"] .screen-pause { background: rgba(5, 6, 8, 0.35); }

.screen-loading { gap: 16px; align-content: center; justify-items: center; background: radial-gradient(80% 80% at 50% 40%, rgba(255, 95, 31, 0.12), transparent 70%); }
.loading-mark { border-radius: 18px; animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.05); filter: drop-shadow(0 0 22px rgba(255, 95, 31, 0.6)); } }
.loading-text { font-weight: 800; color: var(--muted); letter-spacing: 0.04em; }
.loading-bar { width: 200px; height: 4px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.loading-bar i { display: block; height: 100%; width: 8%; background: linear-gradient(90deg, var(--blaze), var(--amber)); transition: width 0.4s ease; }

/* Title card */
.screen-title { place-items: center start; padding: 28px clamp(20px, 4vw, 56px); }
.title-card { width: min(440px, 100%); padding: 24px 24px 20px; }
.title-meta { display: flex; justify-content: space-between; font-size: 11px; letter-spacing: 0.2em; font-weight: 900; color: var(--blaze); }
.title-meta span:last-child { color: var(--muted); }
.title-name { font-size: clamp(30px, 4.2vw, 46px); line-height: 1; margin: 10px 0 12px; font-weight: 900; letter-spacing: -0.025em; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 11px; font-weight: 900; letter-spacing: 0.12em; padding: 5px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.08); color: var(--ink); text-transform: uppercase; }
.chip.wet { color: #9fd3ff; border-color: rgba(159, 211, 255, 0.3); }
.road-shape { width: 100%; height: 92px; margin: 14px 0 6px; overflow: visible; }
.road-shape path { fill: none; stroke-linecap: round; stroke-linejoin: round; }

.ghosts-label { margin: 12px 0 0; font: 900 10px var(--display); letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.medals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0 14px; }
.medal { display: grid; gap: 2px; justify-items: center; padding: 10px 6px 9px; border-radius: 14px; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.07); font: inherit; color: var(--ink); cursor: pointer; transition: border-color 0.2s, background 0.2s, box-shadow 0.2s; }
.medal:hover { background: rgba(255, 255, 255, 0.07); }
.medal:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
/* The ghost that drives alongside. */
.medal[aria-checked="true"] { border-color: var(--amber); background: rgba(255, 176, 31, 0.12); box-shadow: 0 0 0 1px var(--amber), 0 8px 22px rgba(255, 95, 31, 0.22); }
/* Your best and a friend's ghost: full-width rows under the medals. */
.medal.extra { grid-column: 1 / -1; grid-template-columns: auto 1fr auto; justify-items: start; align-items: center; gap: 10px; padding: 8px 12px; }
.medal.best i { background: radial-gradient(circle at 35% 30%, #ffffff, #ff8a3d 75%); }
.medal.friend i { background: radial-gradient(circle at 35% 30%, #d8ecff, #4a8bd6 75%); }
.medal i { width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25), 0 0 0 2px rgba(255, 255, 255, 0.12); }
.medal.bronze i { background: radial-gradient(circle at 35% 30%, #f4c3a0, #b4703f 70%); }
.medal.silver i { background: radial-gradient(circle at 35% 30%, #ffffff, #9aa3ae 70%); }
.medal.gold i { background: radial-gradient(circle at 35% 30%, #fff1b8, #f0a51e 70%); }
.medal span { font-size: 9px; letter-spacing: 0.18em; font-weight: 900; color: var(--muted); }
.medal b { font-size: 17px; font-weight: 900; font-variant-numeric: tabular-nums; }
.medal.earned span::after { content: " ✓"; color: var(--amber); }
.best { font-size: 13px; color: var(--muted); margin: 4px 0 2px; font-family: var(--body); }
.best b { color: var(--ink); }

.btn-drive { width: 100%; justify-content: center; font-size: 17px; padding: 15px; }
/* When the card is taller than the screen (small or sideways phones) it scrolls, and Drive stays in reach. */
.title-card > .btn-drive { position: sticky; bottom: 6px; z-index: 1; }
.controls-hint { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 11.5px; color: var(--muted); margin: 14px 0 0; font-family: var(--body); }
.lesson { margin: 12px 0 0; font-size: 12.5px; color: var(--amber); font-weight: 800; }
.title-tools { position: absolute; right: 18px; bottom: 18px; display: flex; gap: 8px; align-items: center; }
.streak { font-weight: 900; font-size: 13px; padding: 8px 12px; border-radius: 999px; background: rgba(255, 95, 31, 0.14); border: 1px solid rgba(255, 95, 31, 0.35); color: var(--amber); }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.12); background: rgba(10, 11, 13, 0.5); color: var(--ink); font-size: 18px; cursor: pointer; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.icon-btn:hover { background: rgba(255, 255, 255, 0.1); }

/* Panels (pause, settings, error) */
.panel { width: min(380px, 100%); padding: 24px; display: grid; gap: 10px; }
.panel h2 { margin: 0 0 6px; font-size: 26px; }
.panel p { color: var(--muted); font-family: var(--body); }
.settings .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-family: var(--body); font-size: 14px; padding: 6px 0; border-bottom: 1px solid var(--hairline); }
.settings select, .settings input[type="text"] { font: 600 14px var(--body); color: var(--ink); background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 10px; padding: 7px 10px; }
.settings input[type="text"] { width: 150px; }
.settings input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--blaze); }
.swatches { display: flex; gap: 6px; }
.swatches button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.2); cursor: pointer; }
.swatches button[aria-pressed="true"] { border-color: var(--amber); box-shadow: 0 0 0 2px rgba(255, 176, 31, 0.4); }

/* Results */
.screen-results { background: linear-gradient(90deg, rgba(5, 6, 8, 0.72) 0%, rgba(5, 6, 8, 0.25) 55%, rgba(5, 6, 8, 0.6) 100%); }
.results { width: min(960px, 100%); padding: 24px; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 26px; max-height: 100%; overflow: auto; }
.result-head { display: flex; gap: 8px; min-height: 26px; }
.medal-badge, .tag { font-size: 11px; font-weight: 900; letter-spacing: 0.18em; padding: 6px 11px; border-radius: 999px; }
.medal-badge.gold { color: #2a1a00; background: linear-gradient(100deg, #ffe08a, #f0a51e); }
.medal-badge.silver { color: #15181c; background: linear-gradient(100deg, #ffffff, #a9b1bb); }
.medal-badge.bronze { color: #2a1206; background: linear-gradient(100deg, #f4c3a0, #b4703f); }
.medal-badge.none { color: var(--muted); background: rgba(255, 255, 255, 0.06); }
.tag { color: #000; background: linear-gradient(100deg, var(--blaze), var(--amber)); }
.tag.dim { color: var(--muted); background: rgba(255, 255, 255, 0.06); }
.score { display: grid; margin: 6px 0 2px; }
.score b { font-size: clamp(64px, 9vw, 104px); font-weight: 900; line-height: 0.95; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; background: linear-gradient(180deg, #ffffff 20%, var(--amber) 100%); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 6px 30px rgba(255, 95, 31, 0.45)); }
.score span { font-size: 11px; letter-spacing: 0.32em; font-weight: 900; color: var(--blaze); }
.versus { font-size: 15px; font-weight: 800; margin: 8px 0 14px; }
.versus .up { color: var(--amber); }
.disciplines { display: grid; gap: 10px; }
.disc { display: grid; grid-template-columns: 92px 1fr 40px; gap: 4px 12px; align-items: center; }
.disc .name { font-size: 10px; letter-spacing: 0.18em; font-weight: 900; color: var(--muted); }
.disc .bar { height: 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.disc .bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--blaze), var(--amber)); transition: width 1s cubic-bezier(.2, .8, .2, 1); }
.disc b { font-size: 18px; text-align: right; font-variant-numeric: tabular-nums; }
.disc .note { grid-column: 2 / 4; font: 500 12.5px var(--body); color: var(--muted); }
.insight { margin: 16px 0 0; padding: 12px 14px; border-radius: 14px; background: rgba(255, 95, 31, 0.1); border: 1px solid rgba(255, 95, 31, 0.28); font: 600 13.5px var(--body); color: var(--ink); }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.results-side { display: grid; gap: 10px; align-content: start; }
.card-preview { width: 100%; max-width: 300px; height: auto; aspect-ratio: 3 / 4; border-radius: 18px; justify-self: center; box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.9), 0 0 0 1px var(--hairline); background: #0a0b0d; }
.share-row { display: flex; gap: 8px; justify-content: center; }
.app-cta { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 16px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.08); text-decoration: none; color: var(--ink); }
.app-cta img { border-radius: 10px; }
.app-cta b { display: block; font-size: 14px; }
.app-cta small { color: var(--muted); font: 500 12px var(--body); }
.ad-results { min-height: 100px; }
@media (max-width: 860px) {
  .results { grid-template-columns: 1fr; }
  .card-preview { max-width: 220px; }
}

/* Toast */
.toast { position: absolute; left: 50%; top: 84px; transform: translateX(-50%); padding: 10px 16px; border-radius: 12px; background: rgba(10, 11, 13, 0.78); border: 1px solid rgba(255, 255, 255, 0.12); font: 700 13.5px var(--body); color: var(--ink); max-width: 80%; text-align: center; z-index: 6; }
.toast[hidden] { display: none; }

/* ── touch ──────────────────────────────────────────────────────── */
.touch { display: none; position: absolute; inset: 0; pointer-events: none; }
.game.touch-mode[data-state="driving"] .touch { display: block; }
.touch button { pointer-events: auto; font: 900 13px var(--display); letter-spacing: 0.1em; color: var(--ink); border: 1px solid rgba(255, 255, 255, 0.16); background: rgba(10, 11, 13, 0.38); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); touch-action: none; }
.touch button.down { background: rgba(255, 95, 31, 0.35); border-color: rgba(255, 176, 31, 0.6); }
.touch-steer { position: absolute; left: max(14px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom)); display: none; gap: 12px; }
.game.steer-buttons .touch-steer { display: flex; }
.game.steer-buttons .touch-pad { display: none; }
.touch-steer button { width: 84px; height: 84px; border-radius: 22px; font-size: 26px; }
.touch-pedals { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); display: flex; gap: 12px; align-items: flex-end; }
.pedal-brake { width: 84px; height: 84px; border-radius: 22px; }
.pedal-gas { width: 92px; height: 120px; border-radius: 22px; }
.touch-pause { position: absolute; top: max(14px, env(safe-area-inset-top)); right: 160px; width: 44px; height: 44px; border-radius: 50%; }
.game.touch-mode .hud-bottom-left { bottom: auto; top: 120px; }
.game.touch-mode .road-rules { top: 14px; bottom: auto; }
.game.touch-mode .hud-top-left { max-width: 38vw; }
.game.touch-mode .hud-bottom-right { display: none; }
.game.touch-mode .hud-speed { bottom: 22px; }
.game.touch-mode .hint { bottom: auto; top: 40%; }
.game.touch-mode .hint-roll { display: none; }

@media (max-width: 760px) {
  .hud-top-left { min-width: 0; max-width: 56vw; padding: 10px 12px; }
  .minimap { width: 96px; height: 96px; }
  .hud-speed b { font-size: 46px; }
  /* The tools row runs along the top; the card starts below it. */
  .screen-title { place-items: end center; padding: 66px 14px 14px; }
  .title-card { padding: 18px; }
  .controls-hint { display: none; }
  .title-tools { top: 14px; bottom: auto; right: 14px; left: 14px; justify-content: flex-end; }
  .road-shape { height: 64px; margin: 8px 0 2px; }
  .chip { font-size: 10px; padding: 4px 8px; }
  .title-name { margin: 8px 0 10px; }
  .streak { padding: 7px 10px; font-size: 12px; }
  .streak-words { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@media (max-height: 500px) {
  .title-card { padding: 14px 16px; }
  .road-shape { display: none; }
  .hud-bottom-left .cup { width: 64px; height: 64px; }
}

/* ── content below the game ─────────────────────────────────────── */
.content-below { padding-top: 36px; }
.content-below section { margin: 0 0 46px; }
.content-below details { border-top: 1px solid var(--hairline); padding: 14px 0; }
.content-below summary { cursor: pointer; font-family: var(--display); font-weight: 800; font-size: 16px; color: var(--ink); }
.content-below details p { margin: 10px 0 0; }
.app-band { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; justify-content: space-between; padding: 28px; border-radius: 24px; background: linear-gradient(120deg, rgba(255, 95, 31, 0.16), rgba(255, 176, 31, 0.06)); border: 1px solid rgba(255, 176, 31, 0.22); }
.app-band h2 { margin-top: 0; }
.app-band p { max-width: 560px; margin: 0; }
.noscript { padding: 20px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .loading-mark, .limit.over { animation: none; }
  .split { animation: none; }
}

/* ── road rules HUD: keep side, centre line ahead, following gap ──── */
.road-rules { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-radius: 999px; font-size: 11px; font-weight: 900; letter-spacing: 0.14em; }
.game:has(.split:not([hidden])) .road-rules { top: 74px; }
.road-rules .keep { color: var(--ink); }
.line-glyph { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: #1d1f23; border: 1px solid rgba(255, 255, 255, 0.14); }
.line-glyph i { display: block; width: 3px; height: 16px; border-radius: 1px; background: repeating-linear-gradient(180deg, var(--line-colour, #e8b21a) 0 5px, transparent 5px 9px); }
.line-glyph.solid i { width: 7px; background: linear-gradient(90deg, var(--line-colour, #e8b21a) 0 2.5px, transparent 2.5px 4.5px, var(--line-colour, #e8b21a) 4.5px); }
.line-glyph.solid.single i { width: 3px; background: var(--line-colour, #ecece6); }
.road-rules .gap { padding: 3px 8px; border-radius: 999px; background: rgba(60, 200, 120, 0.18); color: #9ff0c0; }
.road-rules .gap[hidden] { display: none; }
.road-rules .gap.warn { background: rgba(255, 176, 31, 0.2); color: var(--amber); }
.road-rules .gap.close { background: rgba(255, 70, 50, 0.24); color: #ff9a8a; }
.road-rules .gap b { font-variant-numeric: tabular-nums; }

.ping { position: absolute; left: 50%; top: 112px; transform: translateX(-50%); padding: 8px 14px; border-radius: 999px; font: 800 13px var(--display); letter-spacing: 0.02em; background: rgba(10, 11, 13, 0.7); border: 1px solid rgba(255, 255, 255, 0.12); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); white-space: nowrap; animation: split-in 0.35s cubic-bezier(.2, .9, .3, 1.2); }
.ping[hidden] { display: none; }
.ping.bad { border-color: rgba(255, 95, 31, 0.55); color: #ffd2bd; }
.ping.good { border-color: rgba(120, 220, 160, 0.5); color: #c8f5da; }

/* Indicator lamps either side of the speed. */
.blinker { width: 0; height: 0; border-top: 9px solid transparent; border-bottom: 9px solid transparent; align-self: center; opacity: 0.18; }
.blinker.left { border-right: 14px solid var(--amber); margin-right: 4px; }
.blinker.right { border-left: 14px solid var(--amber); margin-left: 4px; }
.blinker.on { animation: blink 0.66s steps(1, end) infinite; }
@keyframes blink { 0% { opacity: 1; filter: drop-shadow(0 0 8px var(--amber)); } 50% { opacity: 0.18; filter: none; } }

/* ── title: the car ───────────────────────────────────────────────── */
.car-pick { display: flex; align-items: center; gap: 12px; width: 100%; margin: 12px 0 4px; padding: 8px 10px; border-radius: 14px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1); color: var(--ink); cursor: pointer; text-align: left; font: inherit; }
.car-pick:hover { background: rgba(255, 255, 255, 0.09); }
.car-pick:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.car-pick img { width: 72px; height: 40px; object-fit: cover; border-radius: 8px; background: #111; }
.car-pick-text { display: grid; flex: 1; min-width: 0; }
.car-pick-text b { font-size: 15px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.car-pick-text small { font: 600 11.5px var(--body); color: var(--muted); }
.car-pick-cta { font-size: 11px; font-weight: 900; letter-spacing: 0.14em; color: var(--amber); }

/* ── garage ───────────────────────────────────────────────────────── */
.screen-garage { place-items: stretch end; padding: 18px; background: linear-gradient(90deg, rgba(5, 6, 8, 0) 30%, rgba(5, 6, 8, 0.55)); }
.garage { width: min(520px, 100%); max-height: 100%; overflow: auto; padding: 20px; display: grid; grid-auto-rows: max-content; gap: 14px; align-content: start; overscroll-behavior: contain; }
.garage-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.garage-head h2 { margin: 4px 0 2px; font-size: clamp(24px, 3vw, 34px); line-height: 1.05; letter-spacing: -0.02em; }
.garage-meta { margin: 0; font: 600 13px var(--body); color: var(--muted); }
.garage-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }
.stat { display: grid; grid-template-columns: 1fr auto; gap: 3px 8px; align-items: baseline; }
.stat span { font-size: 9.5px; letter-spacing: 0.18em; font-weight: 900; color: var(--muted); }
.stat b { font-size: 14px; font-variant-numeric: tabular-nums; }
.stat .bar { grid-column: 1 / 3; height: 5px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.stat .bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--blaze), var(--amber)); transition: width 0.5s cubic-bezier(.2, .8, .2, 1); }
.garage-paint { display: flex; align-items: center; gap: 12px; }
.garage-paint .swatches { flex-wrap: wrap; }
.swatches button.factory { background: conic-gradient(from 45deg, #ff5f1f, #ffb01f, #e9e6df, #2b2e34, #ff5f1f) !important; }
.garage-filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.garage-filters::-webkit-scrollbar { display: none; }
.garage-filters button { flex: none; font: 800 11px var(--display); letter-spacing: 0.08em; padding: 7px 11px; border-radius: 999px; color: var(--ink); background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1); cursor: pointer; }
.garage-filters button[aria-selected="true"] { color: #000; background: linear-gradient(100deg, var(--blaze), var(--amber)); border-color: transparent; }
.garage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.car-card { display: grid; gap: 4px; padding: 8px; border-radius: 14px; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.08); color: var(--ink); text-align: left; cursor: pointer; font: inherit; }
.car-card:hover { background: rgba(255, 255, 255, 0.08); }
.car-card[aria-pressed="true"] { border-color: rgba(255, 176, 31, 0.7); background: rgba(255, 176, 31, 0.1); box-shadow: 0 0 0 1px rgba(255, 176, 31, 0.35); }
.car-card:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.car-card .thumb { position: relative; aspect-ratio: 16 / 9; border-radius: 9px; background: radial-gradient(120% 90% at 50% 100%, #2a2c31, #111215); overflow: hidden; display: grid; place-items: center; }
.car-card .thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: opacity 0.25s ease; }
.car-card .thumb img.pending { opacity: 0; }
.car-card .thumb .swatch { width: 38%; aspect-ratio: 2.2; border-radius: 40% 40% 12px 12px / 60% 60% 12px 12px; box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.35); }
.car-card .make { font-size: 9.5px; letter-spacing: 0.14em; font-weight: 900; color: var(--muted); text-transform: uppercase; }
.car-card .model { font-size: 13.5px; font-weight: 900; line-height: 1.15; }
.car-card .spec { font: 600 11px var(--body); color: var(--muted); }
.garage-fine { margin: 0; font: 500 11px var(--body); color: var(--muted); }
@media (max-width: 760px) {
  .screen-garage { padding: 10px; place-items: stretch center; background: rgba(5, 6, 8, 0.35); }
  .garage { padding: 16px; align-self: end; max-height: 74%; }
  .garage-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── touch: slide pad and indicators ──────────────────────────────── */
.touch-pad { position: absolute; left: max(10px, env(safe-area-inset-left)); bottom: max(10px, env(safe-area-inset-bottom)); width: min(46vw, 260px, calc(50% - 140px)); height: 118px; border-radius: 26px; pointer-events: auto; touch-action: none; display: grid; place-items: center; background: rgba(10, 11, 13, 0.32); border: 1px solid rgba(255, 255, 255, 0.12); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.touch-pad.active { border-color: rgba(255, 176, 31, 0.5); background: rgba(255, 95, 31, 0.12); }
.pad-rail { position: absolute; left: 22px; right: 22px; top: 50%; height: 4px; margin-top: -2px; border-radius: 2px; background: linear-gradient(90deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.05)); }
.pad-knob { width: 54px; height: 54px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #fff, #c9ccd2 60%, #8d929a); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5); transition: transform 0.05s linear; }
.pad-hint { position: absolute; bottom: 8px; font-size: 9px; letter-spacing: 0.2em; font-weight: 900; color: rgba(255, 255, 255, 0.45); }
.touch-pad.active .pad-hint { opacity: 0; }
.touch-signals { position: absolute; left: max(10px, env(safe-area-inset-left)); bottom: calc(max(10px, env(safe-area-inset-bottom)) + 128px); display: flex; gap: 10px; }
/* Indicator stalk buttons: small, amber outline chevrons, clearly not steering. */
.touch .sig { width: 58px; height: 34px; border-radius: 999px; display: grid; place-items: center; border-color: rgba(255, 176, 31, 0.35); }
.sig i { width: 12px; height: 12px; border: solid var(--amber); border-width: 0 0 3px 3px; border-radius: 1px; }
.sig-left i { transform: rotate(45deg); margin-left: 6px; }
.sig-right i { transform: rotate(-135deg); margin-right: 6px; }
.sig.on { background: rgba(255, 176, 31, 0.3); border-color: rgba(255, 176, 31, 0.85); animation: blink 0.66s steps(1, end) infinite; }
/* Both stop short of the speed in the middle (about 240px wide), however narrow the screen. */
.touch-signals { width: min(46vw, 260px, calc(50% - 140px)); justify-content: space-between; }

.rotate-hint { display: none; }
@media (orientation: portrait) and (pointer: coarse) {
  /* First in the tools row, so it shrinks and wraps beside the buttons rather than covering them. */
  .game[data-state="title"] .rotate-hint { display: block; flex: 0 1 auto; min-width: 0; max-width: 260px; margin-right: auto; padding: 5px 10px; border-radius: 12px; background: rgba(10, 11, 13, 0.6); font: 700 11px/1.3 var(--body); color: var(--muted); pointer-events: none; }
  .title-tools:has(.streak:not([hidden])) .rotate-hint { display: none; }
  .game.touch-mode .pedal-gas { width: 84px; height: 112px; }
  .game.touch-mode .pedal-brake { width: 76px; height: 76px; }
  .game.touch-mode .hud-bottom-left { top: 116px; }
  .game.touch-mode .hud-bottom-left .cup { width: 64px; height: 64px; }
  .game.endless.touch-mode .hud-bottom-left { top: 136px; }
  .game.touch-mode .minimap { width: 84px; height: 84px; }
  .game.touch-mode .hud-top-left { max-width: 56vw; }
  .game.touch-mode .touch-pause { top: 110px; right: 30px; }
  .game.touch-mode .hud-speed { bottom: auto; top: 208px; left: auto; right: 14px; transform: none; }
  .game.endless.touch-mode .hud-speed { top: 228px; }
  .game.touch-mode .hud-speed b { font-size: 40px; }
  .game.touch-mode .road-rules { top: auto; bottom: 186px; left: max(10px, env(safe-area-inset-left)); transform: none; }
  .touch-pad, .touch-signals { width: min(50%, calc(100% - 206px)); }
  .game[data-state="garage"] .garage { max-height: 56%; }
}
@media (max-width: 760px) {
  .road-rules { top: auto; bottom: 86px; font-size: 10px; }
  .ping { top: 76px; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .blinker.on { animation-duration: 1.2s; }
  .ping { animation: none; }
}

/* ── title: today's road or Unlimited ─────────────────────────────── */
.play-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: -6px 0 14px; border-radius: 999px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.08); }
.play-tabs button { font: 900 12px var(--display); letter-spacing: 0.08em; padding: 8px 10px; border-radius: 999px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.play-tabs button[aria-selected="true"] { color: #000; background: linear-gradient(100deg, var(--blaze), var(--amber)); }
.play-tabs button:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.game.choosing-endless .daily-only { display: none; }
.endless-hint { display: none; }
.game.choosing-endless .endless-hint { display: inline; }
.unlimited-title { margin-top: 0; }
.unlimited-lede { margin: 0 0 10px; font: 500 13px var(--body); color: var(--muted); }
.u-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--hairline); font: 700 13px var(--body); }
.u-row small { display: block; font: 500 11px var(--body); color: var(--muted); }
.u-row select { font: 600 13px var(--body); color: var(--ink); background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 10px; padding: 6px 8px; max-width: 60%; }
.u-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--blaze); }
.u-rules { margin: 2px 0 4px; font: 700 11px var(--display); letter-spacing: 0.1em; color: var(--amber); text-transform: uppercase; }
.seg { display: flex; gap: 3px; padding: 3px; border-radius: 999px; background: rgba(255, 255, 255, 0.05); }
.seg button { font: 800 11px var(--display); letter-spacing: 0.04em; padding: 5px 9px; border-radius: 999px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { color: #000; background: var(--amber); }
.seg button:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }

/* ── Unlimited while driving ──────────────────────────────────────── */
.hud-odo { display: none; align-items: baseline; gap: 6px; margin-top: 8px; font-weight: 900; }
.hud-odo > b { font-size: 22px; font-variant-numeric: tabular-nums; }
.hud-odo > span { font-size: 10px; letter-spacing: 0.16em; color: var(--muted); }
.hud-smooth { margin-left: auto; color: var(--amber) !important; }
.hud-smooth b { color: var(--ink); font-variant-numeric: tabular-nums; }
.game.endless .hud-odo { display: flex; }
.game.endless .progress, .game.endless .hud-bottom-right, .game.endless .split { display: none; }
.autodrive-btn { display: none; position: absolute; left: 50%; top: 58px; transform: translateX(-50%); pointer-events: auto; font: 900 11px var(--display); letter-spacing: 0.14em; padding: 6px 12px; border-radius: 999px; color: var(--ink); background: rgba(10, 11, 13, 0.55); border: 1px solid rgba(255, 255, 255, 0.14); cursor: pointer; }
.game.endless .autodrive-btn { display: block; }
.autodrive-btn[aria-pressed="true"] { color: #000; background: linear-gradient(100deg, var(--blaze), var(--amber)); border-color: transparent; }
.game.touch-mode .autodrive-btn { top: auto; bottom: 150px; left: auto; right: max(14px, env(safe-area-inset-right)); transform: none; }
.endless-only { display: none; }
.game.endless .endless-only { display: inline-flex; justify-content: center; }
.game.endless .screen-pause .daily-only { display: none; }

/* Unlimited summary */
.summary h2 { font-size: 22px; }
.summary-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 4px 0 8px; }
.summary-stats div { display: grid; gap: 2px; }
.summary-stats dt { font-size: 10px; letter-spacing: 0.16em; font-weight: 900; color: var(--muted); text-transform: uppercase; }
.summary-stats dd { margin: 0; font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }

/* Japanese speed signs: blue numerals. */
.limit.jp { color: #1d4fbf; }

/* Stats, streak and sync (panel styles in stats.css) */
.screen-stats { place-items: center; padding: 12px; }
.game.stats-open .screen-stats { opacity: 1; visibility: visible; z-index: 6; background: rgba(5, 6, 8, 0.55); transition: opacity 0.35s ease, visibility 0s; }

/* ── touch: tilt to steer ─────────────────────────────────────────── */
/* The road card's steering chooser is for touch screens only. */
.steer-row { display: none; }
@media (pointer: coarse) { .steer-row { display: flex; } }
.pedal-brake-left, .tilt-bar, .tilt-note { display: none; }
/* Tilting (once the first reading has come): no pad; brake under the left thumb, gas under the right. */
.game.tilt-live .touch-pad, .game.tilt-live .touch-steer, .game.tilt-live .touch-pedals .pedal-brake { display: none; }
.game.tilt-live .pedal-brake-left { display: block; position: absolute; left: max(14px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom)); width: 104px; height: 104px; border-radius: 24px; }
.game.tilt-live .pedal-gas { width: 104px; height: 128px; }
/* Where the tilt has the wheel: a dot under the speed. */
.game.tilt-live .tilt-bar { display: block; position: absolute; left: 50%; bottom: -12px; width: 96px; height: 4px; margin-left: -48px; border-radius: 2px; background: rgba(255, 255, 255, 0.16); }
.tilt-bar i { position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 8px var(--amber); transition: transform 0.05s linear; }
.game.tilt-live .tilt-note { display: block; margin: 0; font: 600 13px var(--body); color: var(--muted); }
@media (orientation: portrait) and (pointer: coarse) {
  .game.tilt-live .pedal-brake-left { width: 92px; height: 92px; }
  .game.tilt-live .pedal-gas { width: 92px; height: 120px; }
}

/* Sideways phones: the hint sits higher, clear of the indicators; on a short
   screen the spill cup shrinks so it clears them too. */
@media (orientation: landscape) and (pointer: coarse) {
  .game.touch-mode .hint { top: 30%; }
}
@media (orientation: landscape) and (max-height: 420px) {
  .game.touch-mode .hud-bottom-left { top: 92px; padding: 6px 10px 6px 6px; }
  .game.touch-mode .hud-bottom-left .cup { width: 48px; height: 48px; }
  .game.endless.touch-mode .hud-bottom-left { top: 120px; }
}

/* ── under the game: this is the game; the app is the real thing ────── */
.reality { display: grid; grid-template-columns: 1fr 1fr; margin: 22px 0 6px; border-radius: 22px; overflow: hidden; border: 1px solid var(--hairline-strong); }
.reality-side { padding: 20px 22px; background: var(--surface); display: grid; gap: 8px; align-content: start; }
.reality-side p { margin: 0; font: 500 14.5px/1.5 var(--body); color: var(--muted); }
.reality-side strong { color: var(--ink); font-weight: 800; }
.reality-app { background: linear-gradient(120deg, rgba(255, 95, 31, 0.18), rgba(255, 176, 31, 0.07)); border-left: 1px solid rgba(255, 176, 31, 0.28); }
.reality-app .btn { justify-self: start; margin-top: 4px; }
.reality .reality-tag { font: 900 11px var(--display); letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.reality-app .reality-tag { color: var(--amber); }
.reality-dot { width: 8px; height: 8px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 0 3px rgba(61, 220, 132, 0.18); }
@media (max-width: 760px) {
  .reality { grid-template-columns: 1fr; }
  .reality-app { border-left: 0; border-top: 1px solid rgba(255, 176, 31, 0.28); }
}

/* Settings rows that only mean something on a touch screen. */
.settings .touch-row { display: none; }
@media (pointer: coarse) { .settings .touch-row { display: flex; } }

/* ── how to play (first visit, and from Settings) ───────────────────── */
.screen-guide { place-items: center; padding: 12px; }
.game.guide-open .screen-guide { opacity: 1; visibility: visible; z-index: 6; background: rgba(5, 6, 8, 0.6); transition: opacity 0.35s ease, visibility 0s; }
.guide { width: min(460px, 100%); max-height: 100%; overflow-y: auto; gap: 12px; }
.guide h2 { margin: 0; font-size: clamp(26px, 5vw, 34px); letter-spacing: -0.02em; }
.guide-kicker { margin: 0; font: 900 11px var(--display); letter-spacing: 0.18em; text-transform: uppercase; color: var(--blaze); }
.guide-steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 10px; }
.guide-steps li { counter-increment: step; position: relative; padding: 10px 12px 10px 44px; border-radius: 14px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--hairline); font: 500 14px/1.45 var(--body); color: var(--muted); }
.guide-steps li::before { content: counter(step); position: absolute; left: 12px; top: 10px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font: 900 12px var(--display); color: #000; background: linear-gradient(100deg, var(--blaze), var(--amber)); }
.guide-steps b { color: var(--ink); }
.guide-touch { display: none; }
@media (pointer: coarse) { .guide-touch { display: block; } .guide-keys { display: none; } }
.guide-foot { margin: 0; font: 600 13px var(--body); color: var(--amber); }

/* ── after a drive on a phone: play full screen from the Home Screen ── */
/* The words get the width; Add sits under them, ✕ in the corner. */
.home-nudge { position: relative; display: grid; grid-template-columns: auto 1fr; align-items: start; gap: 10px 12px; margin-top: 14px; padding: 12px 50px 12px 14px; border-radius: 16px; background: rgba(255, 176, 31, 0.08); border: 1px solid rgba(255, 176, 31, 0.3); }
.home-nudge[hidden] { display: none; }
.home-nudge p { grid-column: 2; margin: 0; font: 500 13.5px/1.45 var(--body); color: var(--muted); }
.home-nudge .btn { grid-column: 2; justify-self: start; }
.home-nudge b { color: var(--ink); }
.home-nudge-icon { grid-row: 1 / span 2; font-size: 22px; line-height: 1.2; color: var(--amber); }
.home-nudge-close { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--hairline-strong); background: transparent; color: var(--muted); font-size: 14px; cursor: pointer; }
.home-nudge-close:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* On a phone the road's name keeps to one line (a long Unlimited name is cut
   short), so the road card never grows into what sits below it. */
.game.touch-mode .hud-road b { min-width: 0; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (orientation: landscape) and (max-height: 420px) {
  /* Clear of the keep-side pill in the middle of the top edge. */
  .game.touch-mode .hud-top-left { max-width: min(38vw, calc(50% - 92px)); }
  /* One line for the label and the name (cut short): no room for a second. */
  .game.touch-mode .hud-road { flex-wrap: nowrap; }
  .game.touch-mode .hud-road span { flex: none; }
  /* No room for the start hint between the road card and the indicators; the
     keep-side pill already says which side to keep. */
  .game.touch-mode .hint { display: none; }
}

/* Results on a phone (upright or sideways): what to do next sits under the
   score, and the breakdown follows, so Drive again is not a long scroll away. */
@media (max-width: 760px), (max-height: 500px) {
  .results-main { display: flex; flex-direction: column; }
  .results-main > .result-head { order: 1; }
  .results-main > .score { order: 2; }
  .results-main > .versus { order: 3; }
  .results-main > .result-actions { order: 4; margin-top: 4px; margin-bottom: 18px; }
  .results-main > .disciplines { order: 5; }
  .results-main > .insight { order: 6; }
  .results-main > .home-nudge { order: 7; }
}

/* A sideways phone: the road card scrolls under a floating Drive; a fade
   above the button lets what scrolls beneath it go quietly. */
@media (max-height: 500px) {
  .title-card > .btn-drive::before { content: ""; position: absolute; left: -18px; right: -18px; bottom: 100%; height: 26px; background: linear-gradient(to top, rgba(14, 15, 18, 0.9), rgba(14, 15, 18, 0)); pointer-events: none; }
}

/* In reverse: an R beside the speed. */
.hud-speed > .hud-reverse { align-self: center; font: 900 13px var(--display); letter-spacing: 0.06em; padding: 3px 8px; border-radius: 7px; background: #f4f4ef; color: #0a0b0d; }
.hud-speed > .hud-reverse[hidden] { display: none; }
