/* Layout: a sunset test range fills the stage while glowing teal instrument pods hug its
   corners like a dashboard; the site around it is a calm dark-teal reading column. */
:root {
  --ink: #071214;
  --panel: #0c1c1f;
  --panel-2: #112629;
  --line: #1d3539;
  --text: #e8f6f4;
  --dim: #86a6a4;
  --teal: #2ee6d6;
  --teal-soft: rgba(46, 230, 214, 0.14);
  --pod: rgba(5, 32, 36, 0.66);
  --pod-solid: #072a2e;
  --orange: #ff8a3d;
  --amber: #ffbe3d;
  --go: #59f08a;
  --danger: #ff6159;
  --font: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --radius: 18px;
  color-scheme: dark;
}

[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { margin: 0; }
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--text); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
kbd {
  font-family: var(--font);
  font-size: 0.8em;
  font-weight: 700;
  padding: 0.05em 0.45em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  white-space: nowrap;
}

.wrap {
  max-width: 1320px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

.lbl, .eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}
.eyebrow { margin: 0; }

/* ---------- Site chrome */
.site-head { border-bottom: 1px solid var(--line); }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; text-decoration: none; font-size: 18px; font-weight: 800; font-style: italic; letter-spacing: -0.01em; }
.brand-mark { width: 36px; height: 18px; color: var(--text); }
.site-nav { display: flex; gap: 22px; flex-wrap: wrap; }
.site-nav a { color: var(--dim); text-decoration: none; font-weight: 600; font-size: 15px; }
.site-nav a:hover { color: var(--teal); }

main.wrap { padding-block: 14px 48px; display: grid; gap: 22px; }
.stage-row { display: grid; gap: 22px; grid-template-columns: minmax(0, 1fr); }

/* ---------- Game stage */
.game {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(100svh - 84px);
  min-height: 340px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #241433;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  isolation: isolate;
  container: stage / size;
}
.game:fullscreen { max-height: none; border-radius: 0; aspect-ratio: auto; width: 100%; height: 100%; }
.game canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; }

.boot { position: absolute; inset: 0; z-index: 9; display: grid; place-items: center; background: linear-gradient(180deg, #1b1240, #a2406f 70%, #f2a271); font-size: 15px; font-weight: 700; font-style: italic; color: var(--text); transition: opacity 0.6s; }
.boot.done { opacity: 0; pointer-events: none; }

/* Instrument pods: teal rings with a soft glow, as on a racing dashboard */
.hud, .controls {
  --S: clamp(86px, 22cqmin, 148px);
  --B: clamp(54px, 15cqmin, 88px);
}
.hud { position: absolute; inset: 0; z-index: 2; pointer-events: none; font-variant-numeric: tabular-nums; }
.pod, .cbtn {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, rgba(18, 78, 82, 0.78), var(--pod) 70%);
  border: 2px solid var(--teal);
  box-shadow: 0 0 0 4px rgba(46, 230, 214, 0.1), 0 0 22px rgba(46, 230, 214, 0.32), inset 0 0 16px rgba(46, 230, 214, 0.2);
  color: var(--teal);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.pod-read { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; line-height: 1; gap: 2px; }
.pod-read b { font-weight: 800; font-style: italic; letter-spacing: -0.03em; color: var(--teal); text-shadow: 0 0 12px rgba(46, 230, 214, 0.55); }
.pod-read span { font-size: 11px; font-weight: 700; font-style: italic; color: var(--teal); opacity: 0.85; }

.cluster { position: absolute; top: calc(var(--S) * 0.17 + 4px); left: 14px; width: calc(var(--S) * 1.62); height: calc(var(--S) * 1.5); }
.speedo { left: calc(var(--S) * 0.4); top: 0; width: var(--S); height: var(--S); }
.speedo .pod-read b { font-size: calc(var(--S) * 0.32); }
.speedo .pod-read span { font-size: calc(var(--S) * 0.1); }
.pod .ticks { position: absolute; inset: -22%; width: 144%; height: 144%; overflow: visible; }
.ticks line { stroke: rgba(46, 230, 214, 0.18); stroke-width: 7; stroke-linecap: round; }
.ticks line.on { stroke: var(--teal); filter: drop-shadow(0 0 3px rgba(46, 230, 214, 0.9)); }
.ticks line.hot { stroke: var(--orange); }
.pod-score { left: 0; top: calc(var(--S) * 0.82); width: calc(var(--S) * 0.62); height: calc(var(--S) * 0.62); }
.pod-score .pod-read b { font-size: calc(var(--S) * 0.14); }
.pod-score .pod-read span { font-size: calc(var(--S) * 0.075); }
.pod-flips { left: calc(var(--S) * 0.66); top: calc(var(--S) * 1.03); width: calc(var(--S) * 0.38); height: calc(var(--S) * 0.38); border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255, 138, 61, 0.12), 0 0 18px rgba(255, 138, 61, 0.4), inset 0 0 12px rgba(255, 138, 61, 0.25); background: radial-gradient(circle at 50% 38%, rgba(90, 40, 20, 0.8), rgba(40, 16, 8, 0.72) 70%); }
.pod-flips .pod-read b { font-size: calc(var(--S) * 0.17); color: var(--orange); text-shadow: 0 0 10px rgba(255, 138, 61, 0.6); }
.pod-flips .pod-read span { font-size: calc(var(--S) * 0.06); color: var(--orange); }
.pod-rings { left: calc(var(--S) * 1.1); top: calc(var(--S) * 0.94); width: calc(var(--S) * 0.5); height: calc(var(--S) * 0.5); }
.pod-rings svg { width: calc(var(--S) * 0.16); height: calc(var(--S) * 0.16); }
.pod-rings .pod-read b { font-size: calc(var(--S) * 0.12); }

.fuel { top: 66px; right: 22px; width: calc(var(--S) * 0.66); height: calc(var(--S) * 0.66); }
.fuel .pod-read svg { width: calc(var(--S) * 0.2); height: calc(var(--S) * 0.2); }
.fuel .pod-read b { font-size: calc(var(--S) * 0.13); }
.fuel .pod-read span { font-size: calc(var(--S) * 0.06); }
.fuel.low { border-color: var(--amber); }
.fuel.low .pod-read, .fuel.low .pod-read b, .fuel.low .pod-read span { color: var(--amber); }
.fuel.empty { border-color: var(--danger); }
.fuel.empty .pod-read, .fuel.empty .pod-read b, .fuel.empty .pod-read span { color: var(--danger); }

.topbar { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: grid; justify-items: center; gap: 6px; text-align: center; max-width: 44%; }
.topbar .lvl { font-size: 13px; font-weight: 700; font-style: italic; color: var(--text); text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6); white-space: nowrap; }
.alt-strip { display: flex; align-items: center; gap: 10px; padding: 6px 14px; border-radius: 999px; background: var(--pod); border: 1.5px solid rgba(46, 230, 214, 0.55); color: var(--teal); font-size: 13px; font-weight: 600; white-space: nowrap; }
.alt-strip b { font-size: 17px; font-weight: 800; font-style: italic; }
.alt-strip .sep { width: 1px; height: 14px; background: rgba(46, 230, 214, 0.4); }
#sinkWrap.warn { color: var(--amber); }
#sinkWrap.bad { color: var(--danger); }
.wind { font-size: 13px; font-weight: 700; font-style: italic; color: var(--amber); text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6); }

.corner { position: absolute; top: 14px; right: 62px; display: flex; gap: 8px; pointer-events: auto; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; padding: 0;
  border: 1.5px solid rgba(46, 230, 214, 0.6); border-radius: 50%;
  background: var(--pod); color: var(--teal); cursor: pointer;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { border-color: var(--teal); box-shadow: 0 0 14px rgba(46, 230, 214, 0.4); }
.icon-btn.muted .wave { opacity: 0.15; }
.fs-btn { position: absolute; top: 14px; right: 14px; z-index: 6; }
.fs-btn.behind { display: none; }

/* On-screen controls: lean buttons bottom-left, camera centre, pedals bottom-right */
.controls { position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; padding: 0 max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); pointer-events: none; }
.ctl-left, .ctl-right { display: flex; align-items: flex-end; gap: calc(var(--B) * 0.28); }
.cbtn { position: relative; width: var(--B); height: var(--B); padding: 0; display: grid; place-items: center; cursor: pointer; pointer-events: auto; touch-action: none; transition: transform 0.08s, background 0.08s; }
.cbtn svg { width: 46%; height: 46%; filter: drop-shadow(0 0 6px rgba(46, 230, 214, 0.6)); }
.cbtn.on, .cbtn:active { transform: scale(0.94); background: radial-gradient(circle, rgba(46, 230, 214, 0.45), rgba(5, 32, 36, 0.7) 75%); }
.cbtn-cam { width: calc(var(--B) * 0.74); height: calc(var(--B) * 0.74); margin-bottom: calc(var(--B) * 0.1); }
.pedal { align-content: center; gap: 2px; }
.pedal svg { width: 60%; height: 38%; }
.pedal span { font-size: calc(var(--B) * 0.13); font-weight: 800; font-style: italic; text-transform: uppercase; letter-spacing: 0.04em; line-height: 1; }
.pedal-thrust { width: calc(var(--B) * 1.32); height: calc(var(--B) * 1.32); }
.pedal-thrust svg { height: 44%; width: 36%; }
.khint { position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%); font-size: 10px; padding: 0 6px; background: var(--pod-solid); border-color: rgba(46, 230, 214, 0.5); color: var(--teal); }
.game.is-touch .khint { display: none; }

/* Trick callouts */
.callout { position: absolute; left: 0; right: 0; top: 34%; z-index: 3; text-align: center; pointer-events: none; opacity: 0; padding: 0 16px; display: grid; justify-items: center; gap: 6px; }
.callout-big { font-size: clamp(26px, 6cqmin, 54px); font-weight: 800; font-style: italic; letter-spacing: -0.02em; line-height: 1; text-transform: uppercase; color: #fff; text-shadow: 0 0 18px rgba(46, 230, 214, 0.75), 0 3px 0 rgba(4, 40, 44, 0.9); text-wrap: balance; }
.callout-small { padding: 3px 12px; border-radius: 999px; background: var(--orange); color: #241005; font-size: clamp(12px, 2.4cqmin, 16px); font-weight: 800; font-style: italic; }
.callout-small:empty { display: none; }
.callout.bad .callout-big { color: #ffd9d6; text-shadow: 0 0 18px rgba(255, 97, 89, 0.85), 0 3px 0 rgba(60, 10, 8, 0.9); }
.callout.bad .callout-small { background: var(--danger); color: #2a0503; }
.callout.show { animation: callout 1.9s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes callout {
  0% { opacity: 0; transform: scale(1.35) skewX(-8deg); }
  12% { opacity: 1; transform: scale(1) skewX(-8deg); }
  75% { opacity: 1; transform: skewX(-8deg); }
  100% { opacity: 0; transform: translateY(-10px) skewX(-8deg); }
}

/* Launch tree */
.tree { position: absolute; left: 50%; top: 24%; transform: translateX(-50%); z-index: 3; display: flex; align-items: center; gap: 16px; pointer-events: none; width: max-content; max-width: 92%; }
.tree-pole { display: grid; gap: 8px; padding: 10px; border-radius: 999px; background: rgba(4, 22, 26, 0.85); border: 2px solid var(--teal); box-shadow: 0 0 20px rgba(46, 230, 214, 0.35); }
.tree-pole i { display: block; width: 24px; height: 24px; border-radius: 50%; background: #1b3134; box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.5); }
.tree-pole i.amber { background: var(--amber); box-shadow: 0 0 14px var(--amber); }
.tree-pole i.green { background: var(--go); box-shadow: 0 0 20px var(--go); }
.tree-side { display: grid; gap: 8px; min-width: 0; }
.tree-hint { font-size: clamp(16px, 3.4cqmin, 24px); font-weight: 800; font-style: italic; color: #fff; text-shadow: 0 2px 10px rgba(0, 0, 0, 0.55); }
.brief { padding: 10px 14px; border-radius: 12px; background: rgba(4, 22, 26, 0.8); border: 1px solid rgba(46, 230, 214, 0.35); display: grid; gap: 4px; }
.brief h3 { margin: 0; font-size: 15px; font-weight: 800; font-style: italic; color: var(--teal); }
.brief ul { margin: 0; padding: 0; list-style: none; font-size: 14px; color: var(--text); }
.brief li::before { content: "▸ "; color: var(--orange); }

/* Overlay screens */
.screen { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; padding: 18px; overflow-y: auto; }
.screen-menu { justify-content: flex-start; background: linear-gradient(90deg, rgba(7, 18, 20, 0.88) 0%, rgba(7, 18, 20, 0.5) 42%, rgba(7, 18, 20, 0) 70%); }
.menu-card { max-width: 460px; display: grid; gap: 16px; padding-left: clamp(4px, 3vw, 40px); }
.title { margin: 0; font-size: clamp(40px, 11cqmin, 84px); font-weight: 800; font-style: italic; line-height: 0.92; letter-spacing: -0.04em; text-transform: uppercase; }
.title span { display: block; }
.title span:last-child { color: var(--teal); text-shadow: 0 0 26px rgba(46, 230, 214, 0.45); }
.menu-copy { margin: 0; color: #c9dedb; font-size: 17px; max-width: 38ch; }
.menu-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.keys { margin: 4px 0 0; display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 14px; }
.keys div { display: grid; gap: 2px; }
.keys dt { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.keys dd { margin: 0; color: var(--text); }
.game.is-touch .keys { display: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 24px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid rgba(46, 230, 214, 0.55); background: rgba(5, 32, 36, 0.6); color: var(--teal);
  font-size: 16px; font-weight: 800; font-style: italic; letter-spacing: -0.01em;
}
.btn:hover { border-color: var(--teal); box-shadow: 0 0 16px rgba(46, 230, 214, 0.35); }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #032224; box-shadow: 0 6px 24px rgba(46, 230, 214, 0.35); }
.btn-primary:hover { background: #5ff0e3; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--dim); }
.btn-ghost:hover { color: var(--text); border-color: transparent; box-shadow: none; }
.btn-wide { flex: 1 1 200px; }

/* Levels */
.screen-levels, .screen-results, .screen-pause, .screen-scenery { background: rgba(7, 18, 20, 0.7); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.levels-panel { width: min(880px, 100%); max-height: 100%; display: grid; gap: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-head h2 { margin: 0; font-size: 26px; font-weight: 800; font-style: italic; letter-spacing: -0.02em; }
.level-grid { display: grid; gap: 18px; }
.chapter { display: grid; gap: 10px; }
.chapter-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.chapter-head h3 { margin: 0; font-size: 20px; font-weight: 800; font-style: italic; color: var(--teal); }
.chapter-head span { font-size: 13px; color: var(--dim); font-variant-numeric: tabular-nums; }
.chapter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.car-tag { padding: 2px 8px; border-radius: 999px; background: rgba(255, 138, 61, 0.16); color: var(--orange); font-size: 11px; font-weight: 800; font-style: italic; }
.level-card {
  position: relative; text-align: left; cursor: pointer; padding: 16px 16px 14px; border-radius: 16px; min-width: 0;
  background: rgba(7, 28, 31, 0.86); border: 1.5px solid var(--line);
  display: grid; gap: 6px; align-content: start;
}
.level-card:hover:not([disabled]) { border-color: var(--teal); box-shadow: 0 0 18px rgba(46, 230, 214, 0.25); }
.level-card[disabled] { cursor: not-allowed; opacity: 0.45; }
.level-card .num { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--teal); color: var(--teal); font-weight: 800; font-style: italic; font-size: 15px; }
.level-card[disabled] .num { border-color: var(--dim); color: var(--dim); }
.level-card h3 { margin: 4px 0 0; font-size: 18px; font-weight: 800; font-style: italic; letter-spacing: -0.01em; }
.level-card p { margin: 0; font-size: 14px; color: #b7cdca; line-height: 1.4; }
.level-card .meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 4px; font-size: 13px; color: var(--dim); font-variant-numeric: tabular-nums; }
.mini-stars { display: inline-flex; gap: 2px; }
.star { width: 16px; height: 16px; fill: rgba(255, 255, 255, 0.14); }
.star.on { fill: var(--amber); filter: drop-shadow(0 0 4px rgba(255, 190, 61, 0.7)); }

/* Results */
.result-card {
  width: min(680px, 100%); margin: auto; padding: 22px clamp(16px, 3vw, 28px);
  border-radius: 22px; background: rgba(7, 26, 29, 0.95); border: 2px solid rgba(46, 230, 214, 0.5);
  box-shadow: 0 0 40px rgba(46, 230, 214, 0.18);
  display: grid; gap: 16px; font-variant-numeric: tabular-nums;
}
.rc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.rc-titles { display: grid; gap: 2px; min-width: 0; }
.result-title { margin: 0; font-size: clamp(28px, 5cqmin, 42px); font-weight: 800; font-style: italic; line-height: 1.02; letter-spacing: -0.03em; color: var(--teal); text-wrap: balance; }
.result-card.wipeout .result-title { color: var(--danger); }
.rc-trick { margin: 0; font-size: 16px; font-weight: 700; font-style: italic; color: var(--orange); }
.rc-trick:empty { display: none; }
.stars { display: flex; gap: 4px; flex: none; }
.stars .star { width: 30px; height: 30px; }
.rc-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 18px; }
.rc-score { display: grid; gap: 4px; align-content: start; min-width: 0; }
.score-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.score-row b { font-size: clamp(38px, 7cqmin, 56px); font-weight: 800; font-style: italic; letter-spacing: -0.03em; line-height: 1; }
.badge { padding: 3px 10px; border-radius: 999px; background: var(--orange); color: #241005; font-size: 12px; font-weight: 800; font-style: italic; }
.rc-best { font-size: 14px; color: var(--dim); }
.rc-best b { color: var(--text); }
.breakdown { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 14px; }
.breakdown li { display: flex; justify-content: space-between; gap: 10px; padding-bottom: 4px; border-bottom: 1px dashed var(--line); color: #b7cdca; }
.breakdown li b { color: var(--text); font-weight: 700; }
.breakdown li.mult b { color: var(--orange); }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; align-content: start; }
.stat { padding: 8px 12px; border-radius: 12px; background: var(--teal-soft); display: grid; gap: 0; min-width: 0; }
.stat .lbl { font-size: 11px; color: #9cc3bf; }
.stat b { font-size: 18px; font-weight: 800; font-style: italic; white-space: nowrap; color: var(--text); }
.stat b small { font-size: 12px; font-weight: 600; font-style: normal; color: var(--dim); margin-left: 3px; }
.goals { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.goals li { display: inline-flex; gap: 6px; align-items: center; padding: 5px 12px; border-radius: 999px; font-size: 14px; font-weight: 600; }
.goals li.ok { background: rgba(89, 240, 138, 0.14); color: var(--go); }
.goals li.no { background: rgba(255, 97, 89, 0.14); color: #ff9c96; }
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hint { margin: 0; text-align: center; font-size: 13px; color: var(--dim); }
.game.is-touch .hint { display: none; }

.pause-card { display: grid; gap: 10px; width: min(300px, 100%); text-align: center; }
.pause-card h2 { margin: 0 0 6px; font-size: 30px; font-weight: 800; font-style: italic; color: var(--teal); }

/* Crash screen: 5-second timer with a banner, then Tap to continue */
.screen-crash { background: rgba(20, 6, 6, 0.72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.crash-card { width: min(520px, 100%); margin: auto; padding: 20px clamp(16px, 3vw, 26px); border-radius: 22px; background: rgba(12, 18, 20, 0.96); border: 2px solid rgba(255, 97, 89, 0.55); box-shadow: 0 0 40px rgba(255, 97, 89, 0.2); display: grid; gap: 16px; text-align: center; }
.crash-head { display: grid; gap: 4px; justify-items: center; }
.crash-title { margin: 0; font-size: clamp(32px, 7cqmin, 52px); font-weight: 800; font-style: italic; line-height: 1; letter-spacing: -0.03em; color: var(--danger); text-transform: uppercase; }
.crash-sub { margin: 0; font-size: 15px; color: #c9dedb; }
.crash-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 6px; }
.crash-stats span { padding: 4px 10px; border-radius: 999px; background: var(--teal-soft); font-size: 13px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.crash-stats b { font-weight: 800; font-style: italic; }
.ad-box { display: grid; gap: 4px; justify-items: center; }
.ad-label { font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); }
.ad-fill { width: 100%; max-width: 336px; min-height: 100px; }
.crash-foot { display: grid; justify-items: center; min-height: 64px; align-items: center; margin-top: 6px; }
.timer { position: relative; width: 60px; height: 60px; }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 4; }
.timer-track { stroke: rgba(46, 230, 214, 0.18); }
.timer-val { stroke: var(--teal); stroke-linecap: round; stroke-dasharray: 100 100; }
.timer b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 22px; font-weight: 800; font-style: italic; color: var(--teal); }
.btn-continue { min-width: 220px; min-height: 54px; font-size: 18px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(46, 230, 214, 0.15), 0 6px 24px rgba(46, 230, 214, 0.35); } }

/* Scenery picker */
.panel-note { margin: -6px 0 0; font-size: 14px; color: #b7cdca; }
.scenery-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.scene-card { display: grid; gap: 10px; align-content: start; padding: 10px; border-radius: 16px; background: rgba(7, 28, 31, 0.86); border: 1.5px solid var(--line); min-width: 0; }
.scene-card.selected { border-color: var(--teal); box-shadow: 0 0 18px rgba(46, 230, 214, 0.3); }
.scene-swatch { position: relative; aspect-ratio: 4 / 3; max-width: 100%; border-radius: 10px; overflow: hidden; }
.scene-swatch::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 30%; background: var(--ground); clip-path: polygon(0 40%, 18% 0, 30% 0, 40% 45%, 62% 30%, 70% 0, 84% 0, 92% 40%, 100% 35%, 100% 100%, 0 100%); }
.scene-card h3 { margin: 0; font-size: 16px; font-weight: 800; font-style: italic; }
.scene-card .btn { min-height: 40px; padding: 0 14px; font-size: 14px; width: 100%; }
.scene-progress { display: flex; gap: 4px; }
.scene-progress i { flex: 1; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); }
.scene-progress i.on { background: var(--amber); }
.scene-msg { margin: 0; font-size: 12px; color: var(--amber); min-height: 1em; }

/* Practice ads (shown until AdSense is connected) */
.practice-ad { position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; padding: 18px; background: rgba(3, 8, 10, 0.88); }
.practice-ad-card { width: min(440px, 100%); padding: 24px; border-radius: 20px; background: #f4f1ea; color: #102a2e; display: grid; gap: 12px; text-align: center; }
.practice-ad-card h3 { margin: 0; font-size: 24px; font-weight: 800; font-style: italic; }
.practice-ad-card p { margin: 0; font-size: 15px; color: #3d5a5e; }
.practice-tag { justify-self: center; padding: 2px 10px; border-radius: 999px; background: #ffbe3d; color: #2a1a00; font-size: 12px; font-weight: 800; }
.practice-bar { height: 6px; border-radius: 3px; background: rgba(16, 42, 46, 0.15); overflow: hidden; }
.practice-bar i { display: block; height: 100%; width: 100%; background: #1fb8ab; transform-origin: left; animation: fillbar linear both; }
@keyframes fillbar { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.practice-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.practice-ad-card .btn-ghost { color: #3d5a5e; }
.practice-banner { display: grid; gap: 4px; place-content: center; min-height: 100px; padding: 12px; border-radius: 12px; border: 1.5px dashed rgba(255, 190, 61, 0.6); background: rgba(255, 190, 61, 0.08); color: var(--amber); font-size: 13px; }
.practice-banner b { font-size: 15px; font-style: italic; }

/* Narrow or portrait stages */
@container stage (orientation: portrait) {
  .scenery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { top: calc(var(--S) * 1.5 + 22px); max-width: 92%; }
  .tree { top: calc(var(--S) * 1.5 + 90px); }
  .callout { top: 40%; }
  .rc-body { grid-template-columns: minmax(0, 1fr); }
}
@container stage (max-height: 420px) {
  .crash-card { gap: 10px; padding: 14px 16px; }
  .crash-sub { display: none; }
  .ad-fill { min-height: 60px; }
  .tree { top: 12%; }
  .brief { display: none; }
  .fuel { top: 60px; }
}

/* ---------- Ads */
.ad { display: grid; place-items: center; min-height: 100px; border: 1.5px dashed var(--line); border-radius: 14px; color: var(--dim); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; text-align: center; padding: 8px; }
.ad.is-live { display: block; border: 0; min-height: 0; padding: 0; }
.ad-rail { display: none; }

/* ---------- Content */
.info { display: grid; gap: 22px; padding-top: 18px; }
.info-head { display: grid; gap: 4px; }
.info h2 { margin: 0; font-size: clamp(26px, 3.4vw, 38px); font-weight: 800; font-style: italic; line-height: 1.1; letter-spacing: -0.03em; text-wrap: balance; }
.info h3 { margin: 0; font-size: 19px; font-weight: 800; font-style: italic; letter-spacing: -0.01em; }
.info p { margin: 0; color: #bcd2cf; }
.phases { margin: 0; padding: 0; list-style: none; counter-reset: phase; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.phases li { counter-increment: phase; display: grid; gap: 8px; align-content: start; padding: 18px; border-radius: 16px; background: var(--panel); min-width: 0; }
.phases li::before { content: counter(phase); width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--teal); color: var(--teal); font-weight: 800; font-style: italic; box-shadow: 0 0 12px rgba(46, 230, 214, 0.3); }
.phases li p { font-size: 15px; }
.tables { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.table-block { display: grid; gap: 10px; min-width: 0; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 9px 12px 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--dim); }
td:first-child { font-weight: 700; white-space: nowrap; color: var(--teal); }
.level-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 22px; }
.level-list article { display: grid; gap: 6px; padding-top: 14px; border-top: 1px solid var(--line); min-width: 0; }
.level-list p { font-size: 15px; }

.site-foot { border-top: 1px solid var(--line); }
.foot-row { display: flex; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; padding-block: 22px; font-size: 14px; color: var(--dim); }
.foot-row nav { display: flex; gap: 18px; }
.foot-row a { color: var(--dim); }

/* ---------- Text pages (about, privacy) */
.doc { max-width: 72ch; padding-block: 36px 64px; display: grid; gap: 16px; }
.doc h1 { margin: 0 0 6px; font-size: clamp(30px, 5vw, 44px); font-weight: 800; font-style: italic; line-height: 1.08; letter-spacing: -0.03em; text-wrap: balance; }
.doc h2 { margin: 18px 0 0; font-size: 20px; font-weight: 800; font-style: italic; color: var(--teal); }
.doc p, .doc li { margin: 0; color: #bcd2cf; }
.doc ul { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }
.doc .updated { color: var(--dim); font-size: 14px; }
.doc .cta { justify-self: start; text-decoration: none; margin-top: 8px; }

/* ---------- Responsive page */
@media (min-width: 1400px) {
  .stage-row { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
  .ad-rail { display: grid; height: 600px; }
}
@media (max-width: 980px) {
  .phases { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tables { grid-template-columns: minmax(0, 1fr); }
  .level-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) and (orientation: portrait) {
  .game { aspect-ratio: auto; height: calc(100svh - 80px); max-height: none; min-height: 500px; }
}
@media (max-width: 640px) {
  .site-nav { gap: 14px; }
  .site-nav a { font-size: 14px; }
  .brand { font-size: 16px; gap: 8px; }
  .brand-mark { width: 30px; height: 15px; }
  .phases, .level-list { grid-template-columns: minmax(0, 1fr); }
  .chapter-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .corner { top: 12px; right: 58px; }
  .fs-btn { top: 12px; right: 12px; }
  .fuel { top: 62px; right: 16px; }
  .screen-menu { align-items: flex-end; background: linear-gradient(0deg, rgba(7, 18, 20, 0.94) 0%, rgba(7, 18, 20, 0.7) 50%, rgba(7, 18, 20, 0) 85%); }
  .menu-card { padding: 0 0 8px; }
  .result-card { padding: 18px 16px; gap: 12px; }
  .stars .star { width: 24px; height: 24px; }
}
@media (max-width: 480px) {
  .site-nav a[href="#levels-list"] { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .btn-continue { animation: none; }
  .callout.show { animation-name: callout-still; animation-duration: 2.2s; }
  .boot { transition: none; }
  @keyframes callout-still { 0% { opacity: 0; } 8% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }
}

/* Garage */
.garage-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.car-card.locked { opacity: 0.55; }
.car-swatch { position: relative; aspect-ratio: 16 / 9; border-radius: 10px; background: linear-gradient(180deg, #2c1d5e, #a2406f 60%, #f2a271); overflow: hidden; }
.car-swatch i { position: absolute; left: 14%; right: 14%; bottom: 22%; height: 26%; background: var(--paint); clip-path: polygon(0 100%, 2% 45%, 40% 30%, 55% 0, 85% 5%, 100% 50%, 100% 100%); box-shadow: inset 0 -4px 0 var(--accent); animation: idle 2.4s ease-in-out infinite; }

/* First-run coach marks */
.coach { position: absolute; inset: 0; z-index: 9; cursor: pointer;
  background: radial-gradient(circle at var(--cx) var(--cy), transparent calc(var(--r) - 2px), rgba(2, 8, 10, 0.86) calc(var(--r) + 40px)); }
.coach-ring { position: absolute; left: calc(var(--cx) - var(--r)); top: calc(var(--cy) - var(--r)); width: calc(var(--r) * 2); height: calc(var(--r) * 2); border-radius: 50%; border: 3px solid var(--teal); box-shadow: 0 0 24px var(--teal), inset 0 0 18px rgba(46, 230, 214, 0.5); animation: ring 1.4s ease-in-out infinite; }
.coach-arrow { position: absolute; left: calc(var(--cx) - 18px); top: calc(var(--cy) - var(--r) - 70px); width: 36px; height: 54px; background: var(--teal); clip-path: polygon(30% 0, 70% 0, 70% 55%, 100% 55%, 50% 100%, 0 55%, 30% 55%); filter: drop-shadow(0 0 10px var(--teal)); animation: bob 0.9s ease-in-out infinite; }
.coach-card { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); width: min(420px, 86%); display: grid; gap: 6px; text-align: center; }
.coach-card p { margin: 0; font-size: clamp(18px, 4cqmin, 26px); font-weight: 800; font-style: italic; line-height: 1.2; color: #fff; text-shadow: 0 0 18px rgba(46, 230, 214, 0.6); }
.coach-step, .coach-key { font-size: 13px; font-weight: 700; color: var(--teal); }
.coach-tap { font-size: 13px; color: var(--dim); }
.coach.in .coach-card { animation: rise 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes ring { 50% { transform: scale(1.12); opacity: 0.7; } }
@keyframes bob { 50% { transform: translateY(10px); } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 16px); } }
@keyframes idle { 50% { transform: translateY(-3px); } }

/* Phones held upright: ask to rotate */
.rotate { display: none; }
@media (pointer: coarse) and (orientation: portrait) {
  .rotate { display: grid; position: absolute; inset: 0; z-index: 10; place-content: center; justify-items: center; gap: 18px; background: rgba(7, 18, 20, 0.95); color: var(--text); font-size: 18px; font-weight: 800; font-style: italic; text-align: center; padding: 24px; }
  .rotate-phone { width: 46px; height: 80px; border: 3px solid var(--teal); border-radius: 10px; box-shadow: 0 0 18px rgba(46, 230, 214, 0.5); animation: turn 1.8s ease-in-out infinite; }
  .game { aspect-ratio: auto; height: calc(100svh - 80px); }
}
@keyframes turn { 0%, 20% { transform: rotate(0); } 50%, 80% { transform: rotate(-90deg); } }
@media (pointer: coarse) and (orientation: landscape) and (max-height: 520px) {
  .site-head { display: none; }
  main.wrap { padding-block: 0; }
  .game { max-height: 100svh; height: 100svh; border-radius: 0; aspect-ratio: auto; }
}

/* Entrance animations */
.menu-card > * { animation: rise-in 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.menu-card > *:nth-child(2) { animation-delay: 0.08s; }
.menu-card > *:nth-child(3) { animation-delay: 0.16s; }
.menu-card > *:nth-child(4) { animation-delay: 0.24s; }
.menu-card > *:nth-child(5) { animation-delay: 0.32s; }
.level-card, .scene-card { animation: rise-in 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.level-card:nth-child(2), .scene-card:nth-child(2) { animation-delay: 0.05s; }
.level-card:nth-child(3), .scene-card:nth-child(3) { animation-delay: 0.1s; }
.level-card:nth-child(4), .scene-card:nth-child(4) { animation-delay: 0.15s; }
.level-card:nth-child(5), .scene-card:nth-child(5) { animation-delay: 0.2s; }
.level-card:nth-child(6), .scene-card:nth-child(6) { animation-delay: 0.25s; }
.result-card, .crash-card { animation: pop-in 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.2) both; }
.btn { transition: transform 0.12s, box-shadow 0.2s, background 0.2s; }
.btn:active { transform: scale(0.96); }
.pod { transition: transform 0.2s; }
@keyframes rise-in { from { opacity: 0; transform: translateY(14px); } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.92); } }
@media (prefers-reduced-motion: reduce) {
  .menu-card > *, .level-card, .scene-card, .result-card, .crash-card, .coach-ring, .coach-arrow, .rotate-phone, .car-swatch i { animation: none !important; }
}

/* Short stages (phones held sideways): compact level cards */
@container stage (max-height: 520px) {
  .level-card p { display: none; }
  .level-card { padding: 10px 12px; gap: 4px; }
  .level-card h3 { font-size: 15px; }
  .chapter-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

.level-chapter { display: grid; gap: 10px; }
.chapter-title { color: var(--teal); }
