/* REDLINE: a late-80s / early-90s Japanese street car at night, seen from the driver's seat.
   Charcoal dash vinyl, warm amber VFD, white-on-black gauges with orange needles,
   sodium street-light glow. One accent (amber/orange), used sparingly. */
:root {
  --vinyl: #161514;
  --vinyl-2: #1e1c1a;
  --vinyl-hi: #2b2825;
  --vinyl-lo: #0c0b0a;
  --felt: #1b1613;
  --amber: #ffad1f;
  --amber-hot: #ffc566;
  --amber-glow: rgba(255, 173, 31, 0.55);
  --amber-dim: #5e430f;
  --needle: #ff6a1a;
  --red: #e3261a;
  --paper: #efe9da;
  --ink: #1b1712;
  --text: #e6dfd2;
  --muted: #8f867a;
  --sodium: 255, 154, 60;
  --f-cond: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --f-vfd: 'Doto', 'DejaVu Sans Mono', ui-monospace, monospace;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --gutter: clamp(10px, 2vw, 22px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: #070606;
  color: var(--text);
  font-family: var(--f-cond);
  font-size: 17px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }
[hidden] { display: none !important; }
kbd {
  font-family: var(--f-cond); font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 2px 10px; border-radius: 3px; color: #a89c8c;
  background: linear-gradient(180deg, #2a2724, #171513); box-shadow: 0 2px 0 #050505, inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* ---------- the dash: one moulded surface ---------- */
.cockpit {
  position: relative;
  min-height: 100vh; min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  grid-template-rows: auto auto 1fr;
  grid-template-areas: "head head" "bin bin" "console foot";
  gap: 0 var(--gutter);
  padding: 14px var(--gutter) 18px;
  max-width: 1320px; margin: 0 auto;
}
.cockpit::before { /* dash top: vinyl with grain, rounded moulded lower lip */
  content: ""; position: absolute; z-index: -1; left: 0; right: 0; top: 0;
  height: var(--dash-h, 58%);
  border-radius: 0 0 48% 48% / 0 0 46px 46px;
  background:
    var(--grain),
    radial-gradient(ellipse 70% 60% at 50% 0%, rgba(255, 255, 255, 0.05), transparent 70%),
    linear-gradient(180deg, var(--vinyl-2), var(--vinyl) 60%, #121110);
  box-shadow: 0 2px 0 #2c2926, 0 18px 40px rgba(0, 0, 0, 0.9), inset 0 -3px 6px rgba(0, 0, 0, 0.6);
}
.cockpit::after { /* lower cabin: darker plastic and footwell shadow */
  content: ""; position: absolute; z-index: -2; inset: 0;
  background: var(--grain), radial-gradient(ellipse at 70% 100%, rgba(var(--sodium), 0.06), transparent 50%), linear-gradient(180deg, #0b0a09, #060505);
}
.cockpit.racing { grid-template-areas: "head head" "wind wind" "bin foot"; grid-template-rows: auto minmax(260px, 46vh) 1fr; }

/* ---------- head unit: VFD trip computer set into the dash ---------- */
.headunit { /* the binnacle hood: one moulded vinyl piece with the VFD set into its face */
  grid-area: head; position: relative; z-index: 2;
  display: flex; align-items: center; gap: 18px;
  margin: 0 0 -22px; padding: 12px 22px 18px;
  border-radius: 34px 34px 46% 46% / 26px 26px 30px 30px;
  background: var(--grain), linear-gradient(180deg, #26231f 0%, #1a1816 55%, #0e0d0c 100%);
  box-shadow: 0 18px 26px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.08), inset 0 -2px 0 rgba(0, 0, 0, 0.7);
}
.brand { margin: 0; line-height: 1; display: grid; }
.brand-word {
  font-size: 30px; font-weight: 800; font-style: italic; letter-spacing: 0.01em; text-transform: uppercase;
  color: transparent;
  background: linear-gradient(180deg, #f5f5f2 0%, #b9bcbf 48%, #5b5f63 52%, #d9dbdd 100%);
  -webkit-background-clip: text; background-clip: text;
  filter: drop-shadow(0 1px 0 #000) drop-shadow(0 -1px 0 rgba(255, 255, 255, 0.08));
}
.brand-sub { font-size: 12px; font-weight: 700; font-style: italic; color: var(--red); letter-spacing: 0.24em; text-transform: uppercase; margin-top: -2px; }
.vfd {
  flex: 1; display: flex; min-width: 0;
  padding: 7px 4px 6px; border-radius: 3px;
  background:
    linear-gradient(170deg, rgba(255, 255, 255, 0.06) 0 22%, transparent 22.5%),
    radial-gradient(ellipse at 50% 120%, #1c1004, #070402 70%);
  box-shadow: inset 0 3px 10px rgba(0, 0, 0, 0.95), inset 0 0 0 2px #050404, 0 1px 0 rgba(255, 255, 255, 0.07), 0 -1px 0 rgba(0, 0, 0, 0.6);
}
.vfd-cell { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; padding: 0 12px; border-left: 1px solid rgba(255, 173, 31, 0.09); }
.vfd-cell:first-child { border-left: 0; }
.vfd-lab { font-size: 11px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(255, 173, 31, 0.42); }
.vfd-val {
  font-family: var(--f-vfd); font-weight: 800; font-size: 25px; line-height: 1.05; color: var(--amber);
  text-shadow: 0 0 4px rgba(255, 173, 31, 0.8), 0 0 14px rgba(255, 140, 20, 0.35);
  white-space: nowrap; overflow: hidden;
}
.vfd-tier { font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(255, 173, 31, 0.7); }

/* sound: a square push switch with an LED */
.toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; flex: none; position: relative; z-index: 1; line-height: 1; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle-track {
  position: relative; width: 38px; height: 30px; border-radius: 4px;
  background: linear-gradient(180deg, #2b2825, #141210);
  box-shadow: 0 0 0 2px #050404, 0 3px 0 #050404, inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: transform 0.08s;
}
.toggle-bat {
  position: absolute; left: 50%; top: 7px; width: 14px; height: 4px; margin-left: -7px; border-radius: 2px;
  background: #3a2a10; box-shadow: inset 0 1px 1px #000;
}
.toggle input:checked + .toggle-track { transform: none; /* pressed look from shadows only: nothing moves over the VFD */ box-shadow: 0 0 0 2px #050404, 0 1px 0 #050404, inset 0 1px 0 rgba(255, 255, 255, 0.06); }
.toggle input:checked + .toggle-track .toggle-bat { background: var(--amber); box-shadow: 0 0 6px var(--amber), 0 0 12px var(--amber-glow); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--amber); outline-offset: 3px; }
.spk { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.spk .spk-body { fill: rgba(201, 185, 160, 0.15); }
.toggle input:checked ~ .spk { stroke: var(--amber); }
.toggle input:checked ~ .spk .spk-slash { display: none; }
.toggle input:not(:checked) ~ .spk .spk-waves { display: none; }
.toggle input:not(:checked) ~ .spk .spk-slash { stroke: var(--red); }
.toggle-lab { font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.toggle input:checked ~ .toggle-lab { color: #c9b9a0; }

/* ---------- binnacle: hooded cowl over the gauges ---------- */
.binnacle {
  grid-area: bin;
  position: relative;
  display: grid; grid-template-columns: 1fr 1.32fr 1fr; align-items: end; gap: 1%;
  padding: 26px 7% 22px;
  margin-bottom: 18px;
}
.binnacle::before { /* recessed pod housing */
  content: ""; position: absolute; z-index: 0; inset: 26px 3% 6px;
  border-radius: 40% 40% 24% 24% / 85% 85% 40% 40%;
  background: radial-gradient(ellipse at 50% 30%, #0b0a09, #050404 70%);
  box-shadow: inset 0 22px 34px rgba(0, 0, 0, 0.95), inset 0 -2px 0 rgba(255, 255, 255, 0.04), 0 1px 0 #2a2724;
}
.binnacle::after { /* the hood is the head unit now */
  display: none;
  content: ""; position: absolute; z-index: 2; left: 1.5%; right: 1.5%; top: 0; height: 46px;
  border-radius: 50% 50% 40% 40% / 100% 100% 30px 30px;
  background: var(--grain), linear-gradient(180deg, #23201d 0%, #141312 40%, #070606 100%);
  box-shadow: 0 16px 26px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.09);
  pointer-events: none;
}
.gauge { position: relative; z-index: 1; aspect-ratio: 1; max-width: 300px; justify-self: center; width: 100%; }
.g-main { max-width: 360px; }
.gauge > .gset { position: absolute; inset: 0; }
.gauge-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.g-bezel { fill: #0a0909; stroke: #2a2826; stroke-width: 6; }
.g-face { stroke: #000; stroke-width: 1.5; }
.g-bleed { fill: none; stroke: rgba(255, 235, 200, 0.07); stroke-width: 6; }
.g-tick { stroke: #f1ece0; stroke-width: 1.1; }
.g-tick.maj { stroke-width: 2.6; }
.g-tick.red { stroke: var(--red); }
.g-ticks-glow .g-tick { stroke: rgba(255, 236, 205, 0.55); }
.g-ticks-glow .g-tick.red { stroke: rgba(227, 38, 26, 0.7); }
.g-red { fill: none; stroke: var(--red); stroke-width: 5; opacity: 0.9; }
.g-num { fill: #f1ece0; font-family: var(--f-cond); font-weight: 600; font-size: 16px; text-anchor: middle; }
.g-num.red { fill: var(--red); }
.g-gear { fill: var(--amber); font-family: var(--f-cond); font-weight: 700; font-size: 11px; letter-spacing: 0.08em; text-anchor: middle; text-transform: uppercase; filter: drop-shadow(0 0 3px rgba(255, 173, 31, 0.6)); }
.gauge-svg.shift .g-bleed { stroke: rgba(255, 210, 140, 0.55); stroke-width: 10; transition: none; }
.gauge-svg .g-bleed { transition: stroke 0.4s ease-out, stroke-width 0.4s ease-out; }
.gauge-svg.shift .g-num { fill: #fff6dc; }
.g-label { fill: #f1ece0; font-family: var(--f-cond); font-weight: 700; font-size: 14px; text-anchor: middle; letter-spacing: 0.14em; text-transform: uppercase; }
.g-unit { fill: #8f867a; font-family: var(--f-cond); font-size: 10px; text-anchor: middle; letter-spacing: 0.06em; }
.g-lcd { fill: #0d0702; stroke: #000; stroke-width: 1.2; }
.g-read { fill: var(--amber); font-family: var(--f-vfd); font-weight: 800; font-size: 13px; text-anchor: middle; }
.g-needle-body { fill: var(--needle); }
.g-hub { fill: #151413; stroke: #34312e; stroke-width: 1.5; }
.g-hub-dot { fill: #55504a; }
.in-red .g-face { fill: #1d0402; transition: fill 0.1s; }

/* ---------- center console + glovebox interior ---------- */
.console {
  grid-area: console;
  position: relative; min-width: 0;
  padding: 0 0 4px;
}
.switches { /* a row of rocker switches set in the console */
  display: flex; gap: 6px; flex-wrap: wrap; position: relative; z-index: 1;
  padding: 10px 10px 12px; margin-bottom: 0;
  background: var(--grain), linear-gradient(180deg, #1a1816, #0f0e0d);
  border-radius: 6px 6px 0 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.sw {
  flex: 1 1 auto; min-width: 84px; position: relative;
  display: flex; align-items: center; gap: 8px; justify-content: center;
  padding: 9px 12px 9px; border-radius: 3px; cursor: pointer;
  border: 0;
  background: linear-gradient(180deg, #2e2b28 0%, #24221f 48%, #171513 52%, #121110 100%);
  box-shadow: 0 0 0 2px #050404, 0 4px 0 #050404, inset 0 1px 0 rgba(255, 255, 255, 0.09);
  color: #9d9384; font-weight: 600; font-size: 14px; letter-spacing: 0.14em; text-transform: uppercase;
  transition: transform 0.06s, box-shadow 0.06s;
}
.sw::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #2f220c; box-shadow: inset 0 1px 1px #000; flex: none; }
.sw[aria-selected="true"] {
  color: #e9d9bd; transform: translateY(3px);
  background: linear-gradient(180deg, #161412 0%, #1d1b18 48%, #26231f 52%, #2e2b27 100%);
  box-shadow: 0 0 0 2px #050404, 0 1px 0 #050404, inset 0 2px 3px rgba(0, 0, 0, 0.6);
}
.sw[aria-selected="true"]::before { background: var(--amber); box-shadow: 0 0 5px var(--amber), 0 0 10px var(--amber-glow); }
.sw .badge { font-family: var(--f-vfd); font-weight: 800; font-size: 11px; letter-spacing: 0; color: var(--amber); }
.panel-host { /* felt-lined glovebox interior */
  position: relative; z-index: 1;
  padding: 16px 18px 18px;
  background: var(--grain), radial-gradient(ellipse at 50% 0%, #241d18, var(--felt) 70%);
  border-radius: 0 0 8px 8px;
  box-shadow: inset 0 10px 18px rgba(0, 0, 0, 0.75), inset 0 0 0 1px rgba(0, 0, 0, 0.6);
}
.panel h2 { margin: 2px 0 10px; font-size: 24px; font-weight: 700; font-style: italic; text-transform: uppercase; letter-spacing: 0.02em; color: #efe5d2; }
.panel .lede { margin: 0 0 12px; color: var(--muted); font-size: 15px; max-width: 62ch; }
.group-title {
  margin: 18px 0 4px; padding-bottom: 4px; border-bottom: 1px solid rgba(255, 173, 31, 0.25);
  font-size: 14px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--amber);
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.group-title small { color: var(--muted); font-weight: 500; letter-spacing: 0.06em; text-transform: none; font-size: 13px; }

/* parts catalogue entries: ruled, not boxed */
.rows { display: grid; }
.row {
  display: grid; grid-template-columns: 52px 34px minmax(0, 1fr) auto; grid-template-rows: auto auto;
  column-gap: 12px; align-items: center;
  width: 100%; text-align: left; cursor: pointer;
  padding: 10px 6px 10px 2px; border: 0; border-bottom: 1px dashed rgba(239, 233, 218, 0.12);
  background: none; border-radius: 0;
}
.row:hover:not([aria-disabled="true"]) { background: linear-gradient(90deg, rgba(255, 173, 31, 0.07), transparent 80%); }
.row:active:not([aria-disabled="true"]) .row-cost { transform: translateY(1px) rotate(-1deg); }
.part-no { grid-row: 1 / span 2; font-family: var(--f-vfd); font-weight: 800; font-size: 11px; color: rgba(255, 173, 31, 0.55); }
.part-icon { grid-row: 1 / span 2; width: 34px; height: 34px; fill: none; stroke: #d8cfbf; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.row-name { grid-column: 3; font-weight: 600; font-size: 18px; color: #efe7d8; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; line-height: 1.15; }
.row-lvl { font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--amber); }
.row-blurb { grid-column: 3; color: var(--muted); font-size: 14px; }
.row-cost { /* a hang tag */
  grid-column: 4; grid-row: 1 / span 2; position: relative;
  font-family: var(--f-cond); font-weight: 700; font-size: 17px; color: var(--ink);
  padding: 5px 12px 5px 20px; min-width: 84px; text-align: right;
  background: linear-gradient(180deg, #f2ead6, #ddd0b0);
  clip-path: polygon(12px 0, 100% 0, 100% 100%, 12px 100%, 0 50%);
  transition: transform 0.08s;
}
.row-cost::before { content: ""; position: absolute; left: 7px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: #1b1613; }
.row[aria-disabled="true"] { cursor: not-allowed; }
.row[aria-disabled="true"] .row-cost { background: linear-gradient(180deg, #5d564b, #4a443b); color: #1c1916; }
.row[aria-disabled="true"] .row-name { color: #9a9083; }
.row[aria-disabled="true"] .part-icon { stroke: #6a6259; }
.row.maxed .row-cost { background: linear-gradient(180deg, var(--amber-hot), var(--amber)); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 18px; border-radius: 3px; border: 0; cursor: pointer;
  font-weight: 700; font-size: 15px; letter-spacing: 0.12em; text-transform: uppercase;
  background: linear-gradient(180deg, #34302c, #1d1b19);
  box-shadow: 0 0 0 2px #050404, 0 3px 0 #050404, inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.btn:active:not(:disabled):not([aria-disabled="true"]) { transform: translateY(2px); box-shadow: 0 0 0 2px #050404, 0 1px 0 #050404; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn-lit { color: #1a0f02; background: linear-gradient(180deg, var(--amber-hot), var(--amber) 55%, #c77d0a); text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3); }
.btn-danger { color: #fff; background: linear-gradient(180deg, #f0503f, var(--red) 55%, #8f1208); }
.btn-ghost { background: transparent; box-shadow: 0 0 0 1px #3d3833; color: var(--muted); }

/* ---------- footwell: floor mat + drilled pedal ---------- */
.footwell {
  grid-area: foot; z-index: 0;
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 420px; padding: 18px 14px 22px;
  border-radius: 6px;
  background: radial-gradient(ellipse at 50% 120%, rgba(var(--sodium), 0.10), transparent 60%), linear-gradient(180deg, #050404, #0d0b0a 40%, #0a0908);
  box-shadow: inset 0 26px 40px rgba(0, 0, 0, 0.95);
}
.floor-mat {
  position: absolute; left: 6%; right: 6%; bottom: -10%; height: 58%;
  transform: perspective(500px) rotateX(48deg); transform-origin: 50% 100%;
  border-radius: 10px 10px 4px 4px;
  background: repeating-linear-gradient(90deg, #121110 0 6px, #1b1917 6px 9px), #141312;
  box-shadow: inset 0 0 0 3px #0b0a09, inset 0 0 30px rgba(0, 0, 0, 0.8);
  opacity: 0.9; pointer-events: none;
}
.press-readout {
  order: 2; position: relative; z-index: 1;
  font-family: var(--f-vfd); font-weight: 800; color: var(--amber); font-size: 17px;
  text-shadow: 0 0 6px rgba(255, 173, 31, 0.6);
}
.pedal-hint { order: 3; position: relative; z-index: 1; margin: 0; font-size: 13px; color: #8a7f71; letter-spacing: 0.04em; }
.pedal {
  position: relative; z-index: 1; width: min(220px, 62vw); aspect-ratio: 0.62;
  border: 0; padding: 0; background: none; cursor: pointer;
  perspective: 600px; touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
/* Hanging pedal: arm goes up out of frame to its axle; arm + pad + pivot rotate together about it. */
.pedal { --pivot-y: -42%; }
.pedal-bracket { display: none; }
.pedal-assy {
  position: absolute; inset: 0;
  transform-origin: 50% var(--pivot-y);
  transform: rotateX(-10deg);
  transform-style: preserve-3d;
  transition: transform 0.08s cubic-bezier(.2, .9, .3, 1.4);
}
.pedal.down .pedal-assy { transform: rotateX(-24deg); }
.pedal-pivot {
  position: absolute; left: 50%; top: var(--pivot-y); width: 22px; height: 22px; margin: -11px 0 0 -11px;
  border-radius: 50%; background: radial-gradient(circle at 38% 35%, #d9dadb, #6d7074 50%, #2b2d2f 80%);
}
.pedal-arm {
  position: absolute; left: 50%; top: var(--pivot-y); width: 16px; height: calc(-1 * var(--pivot-y) + 26%); margin-left: -8px;
  border-radius: 3px;
  background: linear-gradient(90deg, #1c1d1f, #5e6266 45%, #2a2c2e 60%, #141516);
  box-shadow: 4px 0 8px rgba(0, 0, 0, 0.6);
}
.pedal-plate {
  position: absolute; inset: 22% 6% 4%;
  border-radius: 14px 14px 22px 22px;
  background:
    linear-gradient(105deg, rgba(255, 255, 255, 0.35) 0 12%, transparent 30%, rgba(255, 255, 255, 0.08) 62%, transparent 70%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 2px),
    linear-gradient(180deg, #c9ccce, #8d9195 55%, #5d6165);
  box-shadow: 0 10px 0 -3px #1e1f21, 0 22px 26px rgba(0, 0, 0, 0.85), inset 0 2px 0 rgba(255, 255, 255, 0.6), inset 0 -3px 0 rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(0, 0, 0, 0.35);
  transition: box-shadow 0.08s;
}
.pedal-holes { /* drilled lightening holes */
  position: absolute; inset: 9% 12% 20%;
  background: radial-gradient(circle, #0a0a0a 0 5px, rgba(0, 0, 0, 0.5) 5.5px, transparent 6.5px) 0 0 / 22px 22px;
  -webkit-mask: linear-gradient(#000, #000); mask: linear-gradient(#000, #000);
}
.pedal-heel { /* rubber heel pad at the bottom of the plate */
  position: absolute; left: 10%; right: 10%; bottom: 5%; height: 11%; border-radius: 4px 4px 12px 12px;
  background: repeating-linear-gradient(90deg, #151515 0 5px, #232323 5px 7px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 1px 0 rgba(0, 0, 0, 0.6);
}
.pedal-clevis {
  position: absolute; left: 50%; top: -9px; width: 38px; height: 22px; margin-left: -19px; border-radius: 4px;
  background: linear-gradient(180deg, #4b4e52, #1f2022);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 2px 3px rgba(0, 0, 0, 0.6);
}
.pedal-clevis::before, .pedal-clevis::after { content: ""; position: absolute; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #cfcfcf, #4a4a4a); }
.pedal-clevis::before { left: 6px; }
.pedal-clevis::after { right: 6px; }
.pedal.down .pedal-plate { box-shadow: 0 5px 0 -3px #1e1f21, 0 10px 14px rgba(0, 0, 0, 0.85), inset 0 2px 0 rgba(255, 255, 255, 0.45), inset 0 -3px 0 rgba(0, 0, 0, 0.4); }
.pedal.hot .pedal-plate { box-shadow: 0 10px 0 -3px #1e1f21, 0 0 40px rgba(227, 38, 26, 0.6), inset 0 2px 0 rgba(255, 255, 255, 0.6); }
.pedal:focus-visible { outline: none; }
.pedal:focus-visible .pedal-plate { outline: 2px solid var(--amber); outline-offset: 4px; }
.footwell.flash::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background: radial-gradient(circle at 50% 55%, rgba(var(--sodium), 0.16), transparent 55%);
  animation: flash 0.25s ease-out forwards;
}
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }
.fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 3; }
.fx-num {
  position: absolute; font-family: var(--f-vfd); font-weight: 800; font-size: 17px; color: var(--amber);
  text-shadow: 0 0 8px rgba(255, 173, 31, 0.8); white-space: nowrap;
  animation: rise 0.9s ease-out forwards;
}
.fx-spark { position: absolute; width: 3px; height: 3px; border-radius: 50%; background: #ffd9a0; box-shadow: 0 0 6px #ffab3d; animation: spark 0.5s ease-out forwards; }
@keyframes rise { from { transform: translate(-50%, 0); opacity: 1; } to { transform: translate(-50%, -90px); opacity: 0; } }
@keyframes spark { to { transform: translate(var(--dx), var(--dy)); opacity: 0; } }

/* ---------- dialog: an owner's-manual card from the glovebox ---------- */
.dlg-scrim {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(3, 2, 2, 0.75); backdrop-filter: blur(2px);
}
.dlg {
  position: relative; width: min(460px, 100%);
  padding: 22px 22px 18px; border-radius: 4px;
  background: var(--grain), linear-gradient(180deg, #221f1c, #161413);
  box-shadow: 0 0 0 2px #050404, 0 24px 60px rgba(0, 0, 0, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
.dlg::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--amber); box-shadow: 0 0 12px var(--amber-glow); }
.dlg-plate { display: none; }
.dlg-title { margin: 6px 0 8px; font-size: 26px; font-weight: 800; font-style: italic; text-transform: uppercase; letter-spacing: 0.01em; color: #f1e8d6; }
.dlg-body { color: #d4cabb; font-size: 17px; }
.dlg-body p { margin: 0 0 10px; }
.dlg-body .big { font-family: var(--f-vfd); font-weight: 800; font-size: 30px; color: var(--amber); text-shadow: 0 0 8px var(--amber-glow); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------- toast: a line on the VFD message strip ---------- */
.toasts { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 40; display: grid; gap: 6px; width: min(440px, calc(100% - 32px)); pointer-events: none; }
.toast {
  padding: 8px 14px; border-radius: 2px; background: #0b0603;
  box-shadow: 0 0 0 2px #000, 0 0 0 3px #2a2724, 0 10px 24px rgba(0, 0, 0, 0.7);
  font-size: 15px; color: #e2c48a;
  animation: toast 3.4s ease forwards;
}
.toast b { color: var(--amber); font-weight: 700; text-shadow: 0 0 6px var(--amber-glow); }
@keyframes toast { 0% { opacity: 0; transform: translateY(8px); } 8%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* ---------- garage: spec sheets ---------- */
.cat-title { display: flex; align-items: baseline; gap: 12px; }
.cars { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 18px 22px; }
.car { display: grid; gap: 8px; padding: 12px 0 14px; border-top: 2px solid rgba(239, 233, 218, 0.7); }
.car.selected { border-top-color: var(--amber); }
.car-head { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 0 8px; }
.car-code { grid-column: 1 / -1; font-size: 11px; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.car-name { margin: 0; font-size: 21px; font-weight: 800; font-style: italic; text-transform: uppercase; color: #efe7d8; line-height: 1.05; }
.car-cls { color: var(--muted); font-size: 14px; white-space: nowrap; }
.car-pic { height: 70px; display: grid; place-items: center; }
.car-svg { height: 70px; width: auto; max-width: 100%; overflow: visible; }
.cs-body { fill: none; stroke: #e8dfcd; stroke-width: 1.3; stroke-linejoin: round; }
.cs-win { fill: rgba(255, 255, 255, 0.04); stroke: #e8dfcd; stroke-width: 0.9; }
.cs-line { stroke: #e8dfcd; stroke-width: 0.7; opacity: 0.6; }
.cs-wheel { fill: #120f0d; stroke: #e8dfcd; stroke-width: 1.3; }
.cs-hub { fill: none; stroke: #e8dfcd; stroke-width: 0.8; }
.cs-ground { stroke: rgba(232, 223, 205, 0.3); stroke-width: 0.8; stroke-dasharray: 2 3; }
.cs-line { fill: none; }
.cs-acc { fill: var(--paint); stroke: #e8dfcd; stroke-width: 0.9; stroke-linejoin: round; }
.cs-skirt { fill: #15110e; stroke: #e8dfcd; stroke-width: 1.1; }
.car.owned .cs-skirt { fill: color-mix(in srgb, var(--paint) 35%, #1b1613); stroke: var(--amber-hot); }
.car.owned .cs-body { fill: color-mix(in srgb, var(--paint) 35%, transparent); stroke: var(--amber-hot); }
.car:not(.owned) .car-pic { opacity: 0.55; }
.car-stats { display: grid; gap: 3px; }
.stat { display: grid; grid-template-columns: 52px 1fr 30px; gap: 8px; align-items: center; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.stat-bar { height: 7px; background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0 3px, transparent 3px 5px); }
.stat-bar i { display: block; height: 100%; background: repeating-linear-gradient(90deg, var(--amber) 0 3px, transparent 3px 5px); filter: drop-shadow(0 0 3px var(--amber-glow)); }
.stat-n { font-family: var(--f-vfd); font-weight: 800; color: #e8dfcd; text-align: right; font-size: 13px; }
.car-pwr { font-family: var(--f-vfd); font-weight: 800; font-size: 20px; color: var(--amber); text-shadow: 0 0 6px var(--amber-glow); margin-top: 2px; }
.car-pwr small { font-family: var(--f-cond); font-weight: 600; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); text-shadow: none; }
.car-act .btn { width: 100%; }
.chip { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--amber); }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.car-tune { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tune {
  display: grid; gap: 1px; text-align: left; padding: 7px 8px; border-radius: 3px; cursor: pointer; border: 0;
  background: linear-gradient(180deg, #2a2724, #191715); box-shadow: 0 0 0 1px #050404, 0 2px 0 #050404;
}
.tune:active:not([aria-disabled="true"]) { transform: translateY(1px); }
.tune[aria-disabled="true"] { cursor: not-allowed; opacity: 0.55; }
.tune-name { font-weight: 700; font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; }
.tune-what { font-size: 11.5px; color: var(--muted); line-height: 1.2; }
.tune-cost { font-weight: 700; font-size: 14px; color: var(--amber); }

/* ---------- standings: a timing board ---------- */
.rank-hero { display: flex; align-items: center; gap: 18px; margin: 4px 0 12px; flex-wrap: wrap; }
.rank-big { font-family: var(--f-vfd); font-weight: 900; font-size: 58px; line-height: 1; color: var(--amber); text-shadow: 0 0 10px var(--amber-glow); }
.rank-hash { font-size: 30px; opacity: 0.6; }
.rank-big small { font-family: var(--f-cond); font-weight: 600; font-size: 14px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); text-shadow: none; margin-left: 6px; }
.rank-gap { flex: 1; min-width: 200px; margin: 0; font-size: 17px; }
.ladder { list-style: none; margin: 0 0 12px; padding: 8px 0; display: grid; background: #090503; box-shadow: inset 0 2px 10px #000, 0 0 0 2px #050404; }
.ladder li { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; padding: 3px 12px; color: rgba(255, 173, 31, 0.38); font-size: 15px; }
.ladder li.near { color: rgba(255, 190, 90, 0.85); }
.ladder li.you { color: #160c00; background: var(--amber); font-weight: 700; box-shadow: 0 0 14px var(--amber-glow); }
.l-pos, .l-pwr { font-family: var(--f-vfd); font-weight: 800; font-size: 13px; }

/* ---------- race screen ---------- */
.cockpit.racing .console { display: none; }
.cockpit.racing .gset.main, .cockpit:not(.racing) .gset.race-g { display: none; }
.cockpit.racing::before { top: auto; bottom: 0; height: 42%; border-radius: 48% 48% 0 0 / 40px 40px 0 0; }
.windshield {
  grid-area: wind; position: relative; overflow: hidden; min-height: 240px; margin-bottom: 10px;
  border-radius: 46px 46px 6px 6px / 26px 26px 6px 6px;
  background: #000;
  box-shadow: 0 0 0 3px #050404, 0 0 0 9px #141312, 0 12px 30px rgba(0, 0, 0, 0.8);
}
.windshield canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.windshield::after { /* glass: dust, a diagonal glare, and the tint band at the top */
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background:
    linear-gradient(180deg, rgba(40, 60, 90, 0.35) 0 7%, transparent 14%),
    linear-gradient(115deg, transparent 0 30%, rgba(255, 255, 255, 0.05) 30% 40%, transparent 40%),
    radial-gradient(ellipse at 50% 130%, transparent 55%, rgba(0, 0, 0, 0.6));
}
.pillar { position: absolute; top: 0; bottom: 0; width: 7%; z-index: 3; pointer-events: none; background: var(--grain), linear-gradient(90deg, #0b0a09, #1d1b19); }
.pillar-l { left: 0; clip-path: polygon(0 0, 100% 0, 25% 100%, 0 100%); }
.pillar-r { right: 0; clip-path: polygon(0 0, 100% 0, 100% 100%, 75% 100%); background: var(--grain), linear-gradient(270deg, #0b0a09, #1d1b19); }
.tree { /* drag strip christmas tree */
  position: absolute; z-index: 4; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 8px 10px 10px;
  border-radius: 3px;
  background: linear-gradient(90deg, #0d0d0e, #232426 50%, #0d0d0e);
  box-shadow: 0 0 0 2px #050505, 0 8px 18px rgba(0, 0, 0, 0.8);
  transition: opacity 0.4s;
}
.tree::after { content: ""; position: absolute; left: 50%; top: 100%; width: 8px; height: 200px; margin-left: -4px; background: linear-gradient(90deg, #0b0b0c, #262729, #0b0b0c); }
.tree.gone { opacity: 0; }
.stage-row { display: flex; gap: 6px; margin-bottom: 3px; }
.stage { width: 10px; height: 10px; border-radius: 50%; background: #2a2208; }
.stage.on { background: radial-gradient(circle at 40% 35%, #fff8d0, #ffd23a 60%); box-shadow: 0 0 8px #ffd23a; }
.bulb { width: 24px; height: 24px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #2a241d, #120f0c); box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.9), 0 0 0 2px #050505; }
.bulb.amber.on { background: radial-gradient(circle at 40% 35%, #fff2c8, #ffad1f 45%, #a35800); box-shadow: 0 0 14px var(--amber), 0 0 32px var(--amber-glow), 0 0 0 2px #050505; }
.bulb.amber.on:not(.now) { opacity: 0.55; }
.bulb.amber.now { animation: bulb-pop 0.25s ease-out; }
@keyframes bulb-pop { from { transform: scale(1.4); } to { transform: scale(1); } }
.bulb.green.on { background: radial-gradient(circle at 40% 35%, #eaffea, #39e65a 45%, #0b7a1f); box-shadow: 0 0 16px #39e65a, 0 0 36px rgba(57, 230, 90, 0.6), 0 0 0 2px #050505; }
.bulb.red.on { background: radial-gradient(circle at 40% 35%, #ffd8d2, var(--red) 45%, #8a0e05); box-shadow: 0 0 16px var(--red), 0 0 0 2px #050505; }
.race-tip {
  position: absolute; z-index: 4; left: 50%; bottom: 58px; transform: translateX(-50%); margin: 0;
  max-width: 82%; text-align: center; padding: 3px 12px;
  background: rgba(8, 4, 2, 0.7); box-shadow: 0 0 0 1px rgba(255, 173, 31, 0.25);
  color: var(--amber); font-size: 13px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; pointer-events: none;
}
.race-banner {
  position: absolute; z-index: 4; left: 50%; top: 46%; transform: translate(-50%, -50%) scale(0.96);
  padding: 6px 18px; opacity: 0; pointer-events: none; white-space: nowrap;
  font-weight: 800; font-style: italic; text-transform: uppercase; font-size: clamp(22px, 3.6vw, 38px); color: #fff;
  text-shadow: 0 2px 0 #000, 0 0 18px rgba(0, 0, 0, 0.8); transition: opacity 0.15s, transform 0.15s;
}
.race-banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.race-banner.go { color: #5dff7a; text-shadow: 0 0 16px rgba(93, 255, 122, 0.7), 0 2px 0 #000; }
.race-banner.good { color: var(--amber); }
.race-banner.bad { color: #ff5a45; }
.race-progress { position: absolute; z-index: 4; left: 9%; right: 9%; bottom: 40px; pointer-events: none; }
.rp-track { position: relative; height: 3px; background: rgba(255, 173, 31, 0.2); }
.rp-track::after { content: ""; position: absolute; right: -2px; top: -6px; width: 4px; height: 15px; background: repeating-linear-gradient(180deg, #fff 0 3px, #111 3px 6px); }
.rp-dot { position: absolute; top: 50%; width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px; border-radius: 50%; }
.rp-dot.you { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.rp-dot.rival { background: var(--red); box-shadow: 0 0 6px var(--red); width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; }
.race-names { position: absolute; z-index: 4; left: 9%; right: 9%; top: 10px; display: flex; justify-content: space-between; gap: 190px; font-size: 13px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; pointer-events: none; }
.race-names span { padding: 2px 8px; background: rgba(0, 0, 0, 0.6); max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#rn-you { color: var(--amber); order: 2; }
#rn-rival { color: #ff7a66; order: 1; }
/* result: a printed drag-strip timeslip */
.race-result {
  position: absolute; z-index: 5; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-1.2deg);
  width: min(330px, calc(100% - 24px)); max-height: calc(100% - 16px); overflow-y: auto;
  padding: 16px 18px 14px;
  background: linear-gradient(180deg, #f6f2e7, #e9e3d4);
  color: var(--ink);
  clip-path: polygon(0 6px, 4% 0, 8% 6px, 12% 0, 16% 6px, 20% 0, 24% 6px, 28% 0, 32% 6px, 36% 0, 40% 6px, 44% 0, 48% 6px, 52% 0, 56% 6px, 60% 0, 64% 6px, 68% 0, 72% 6px, 76% 0, 80% 6px, 84% 0, 88% 6px, 92% 0, 96% 6px, 100% 0, 100% 100%, 0 100%);
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.8));
  font-family: 'DejaVu Sans Mono', ui-monospace, monospace;
}
.res-title { margin: 4px 0 0; font-family: var(--f-cond); font-size: 30px; font-weight: 800; font-style: italic; text-transform: uppercase; line-height: 1.05; letter-spacing: 0.02em; }
.race-result.won .res-title { color: #a32012; }
.race-result.lost .res-title { color: #3a342c; }
.res-margin { margin: 2px 0 10px; color: #5a5246; font-size: 13px; border-bottom: 1px dashed #9b9385; padding-bottom: 8px; }
.race-result .kv { font-size: 13px; gap: 3px 12px; }
.race-result .kv dt { color: #5a5246; }
.race-result .kv dd { font-family: inherit; color: var(--ink); font-weight: 700; text-shadow: none; }
.res-kv dd.up { color: #1f6a2a; }
.res-kv dd.down { color: #a32012; }
.res-tier { margin: 0 0 6px; font-weight: 700; color: #a32012; }
.race-result .actions { border-top: 1px dashed #9b9385; padding-top: 10px; }
.cockpit.racing .press-readout { display: none; }
.cockpit.racing .pedal { width: auto; height: min(78%, 300px); }
@media (max-width: 860px) { .cockpit.racing .pedal { height: auto; width: min(150px, 40vw); } }

/* race lobby */
.race-lobby { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.lobby-rating { display: grid; }
.lr-num { font-family: var(--f-vfd); font-weight: 900; font-size: 54px; line-height: 1; color: var(--amber); text-shadow: 0 0 10px var(--amber-glow); }
.lr-tier { font-size: 22px; font-weight: 800; font-style: italic; text-transform: uppercase; color: #efe5d2; }
.lr-next { font-size: 14px; color: var(--muted); }
.lobby-start { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 220px; }
.start-btn { /* engine start push button */
  width: 104px; height: 104px; flex: none; border-radius: 50%; cursor: pointer;
  display: grid; place-content: center; line-height: 1;
  border: 0;
  background: radial-gradient(circle at 50% 38%, #2c2a28, #121110 70%);
  box-shadow: 0 0 0 4px #2f2c29, 0 0 0 7px #0a0909, 0 0 0 9px #3d3934, 0 8px 18px rgba(0, 0, 0, 0.8), inset 0 -4px 8px rgba(0, 0, 0, 0.6), inset 0 3px 4px rgba(255, 255, 255, 0.08);
  color: var(--red); font-weight: 800; font-size: 20px; letter-spacing: 0.1em; text-transform: uppercase;
  text-shadow: 0 0 10px rgba(227, 38, 26, 0.8);
}
.start-btn small { font-size: 11px; font-weight: 700; letter-spacing: 0.22em; color: #b5aa9a; text-shadow: none; }
.start-btn:active:not(:disabled) { transform: scale(0.97); }
.start-btn:disabled { cursor: not-allowed; color: #4a2420; text-shadow: none; }
.lobby-status { margin: 0; color: var(--text); }
.lobby-help { margin-top: 12px; }

/* ---------- trophies: engraved plaques with an indicator lamp ---------- */
.trophies { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 22px; }
.trophies li { display: grid; grid-template-columns: 14px 1fr; gap: 1px 10px; align-items: center; padding: 9px 2px; border-bottom: 1px dashed rgba(239, 233, 218, 0.1); color: #6f675d; }
.trophies .lamp { grid-row: span 2; width: 9px; height: 9px; border-radius: 50%; background: #2a1f0d; box-shadow: inset 0 1px 2px #000; }
.tr-name { font-weight: 700; font-size: 16px; text-transform: uppercase; letter-spacing: 0.04em; }
.tr-desc { font-size: 13.5px; }
.trophies li.lit { color: #efe5d2; }
.trophies li.lit .lamp { background: var(--amber); box-shadow: 0 0 6px var(--amber), 0 0 14px var(--amber-glow); }
.trophies li.lit .tr-desc { color: var(--muted); }

/* glovebox / misc */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 0 0 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: #e9cf9c; font-size: 16px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.manual { margin: 0 0 6px; }
.manual summary { cursor: pointer; font-size: 14px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--amber); padding: 4px 0; }
.manual ol { margin: 6px 0 0; padding-left: 20px; color: #cfc5b6; display: grid; gap: 6px; max-width: 70ch; font-size: 16px; }
.noscript { padding: 20px; }

/* desktop: the cockpit fits the window; the glovebox scrolls inside itself */
@media (min-width: 861px) {
  .cockpit { height: 100vh; height: 100dvh; }
  .cockpit:not(.racing) { grid-template-areas: "head head" "bin foot" "console foot"; grid-template-rows: auto auto minmax(0, 1fr); }
  .cockpit:not(.racing) .footwell { margin-top: 30px; }
  .gauge { width: min(100%, 27vh); }
  .g-main { width: min(100%, 33vh); }
  .console { display: flex; flex-direction: column; min-height: 0; }
  .panel-host { flex: 1; min-height: 0; overflow-y: auto; scrollbar-color: #4a443d transparent; }
  .footwell { min-height: 0; }
  .pedal, .cockpit.racing .pedal { flex: 0 1 auto; min-height: 0; height: min(340px, 100%); width: auto; max-width: 100%; aspect-ratio: 0.62; }
}

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .cockpit, .cockpit.racing { grid-template-columns: minmax(0, 1fr); }
  .cockpit { grid-template-areas: "head" "bin" "foot" "console"; grid-template-rows: none; --dash-h: 420px; }
  .cockpit.racing { grid-template-areas: "head" "wind" "bin" "foot"; grid-template-rows: auto minmax(220px, 38vh) auto auto; }
  .footwell { min-height: 0; padding: 14px 12px 16px; margin-bottom: 12px; }
  .pedal { width: min(190px, 52vw); }
}

/* ---------- phone: dock of console switches + glovebox-lid sheet ---------- */
.dock, .sheet-grip, .sheet-scrim { display: none; }

@media (max-width: 600px) {
  :root { --dock-h: 64px; }
  body { font-size: 16px; }
  .cockpit, .cockpit.racing {
    height: 100vh; height: 100dvh; overflow: hidden;
    gap: 6px;
    padding: calc(8px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) calc(var(--dock-h) + 8px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left));
  }
  .cockpit { grid-template-areas: "head" "bin" "foot"; grid-template-rows: auto auto minmax(0, 1fr); --dash-h: 47%; }
  .cockpit.racing { grid-template-areas: "head" "wind" "bin" "foot"; grid-template-rows: auto minmax(170px, 30dvh) auto minmax(0, 1fr); padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .footwell { min-height: 0; padding: 8px 10px 10px; gap: 4px; margin: 0; }
  .pedal, .cockpit.racing .pedal { flex: 1 1 0; min-height: 0; width: auto; height: auto; max-width: 62vw; max-height: 380px; aspect-ratio: 0.62; }
  .press-readout { font-size: 15px; }
  .pedal-hint { font-size: 12px; }
  .windshield { margin-bottom: 4px; }

  /* the console becomes the glovebox lid, dropping open above the switch row */
  .console {
    position: fixed; z-index: 30; left: 0; right: 0;
    bottom: calc(var(--dock-h) + env(safe-area-inset-bottom));
    height: calc(52dvh - var(--dock-h)); display: flex; flex-direction: column;
    padding: 0;
    transform: translateY(calc(100% + var(--dock-h) + 20px));
    transition: transform 0.26s cubic-bezier(.2, .8, .2, 1);
    border-radius: 10px 10px 0 0;
    background: var(--grain), linear-gradient(180deg, #24211e, #161413);
    box-shadow: 0 -14px 34px rgba(0, 0, 0, 0.8), 0 0 0 2px #050404;
  }
  body.sheet-open .console { transform: none; }
  .console .switches { display: none; }
  .panel-host {
    flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
    margin: 0 10px 10px; border-radius: 4px; padding: 14px 14px 16px;
  }
  .sheet-grip { display: flex; justify-content: center; padding: 8px 0 8px; touch-action: none; cursor: grab; position: relative; z-index: 2; }
  .sheet-handle { width: 96px; height: 24px; border: 0; padding: 0; cursor: pointer; display: grid; place-items: center; border-radius: 3px; background: linear-gradient(180deg, #34302c, #1b1917); box-shadow: 0 0 0 2px #050404, inset 0 1px 0 rgba(255, 255, 255, 0.1); }
  .sheet-handle span { width: 54px; height: 4px; border-radius: 2px; background: #0b0a09; box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08); }
  .sheet-scrim { display: block; position: fixed; inset: 0; z-index: 29; background: rgba(3, 2, 2, 0.55); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
  body.sheet-open .sheet-scrim { opacity: 0; pointer-events: none; } /* non-modal: nothing dims the pedal */
  body.sheet-open .cockpit:not(.racing) {
    grid-template-areas: "head" "foot"; grid-template-rows: auto minmax(0, 1fr);
    padding-bottom: calc(52dvh + 6px + env(safe-area-inset-bottom));
  }
  body.sheet-open .cockpit:not(.racing) .binnacle { display: none; }
  body.sheet-open .cockpit:not(.racing) .headunit { margin-bottom: 6px; }
  .dock {
    display: flex; position: fixed; z-index: 31; left: 0; right: 0; bottom: 0;
    height: calc(var(--dock-h) + env(safe-area-inset-bottom));
    padding: 8px calc(8px + env(safe-area-inset-right)) calc(9px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
    gap: 6px;
    background: var(--grain), linear-gradient(180deg, #1a1816, #0c0b0a);
    box-shadow: 0 -2px 0 #2a2724, 0 -10px 20px rgba(0, 0, 0, 0.7);
  }
  .dock button { /* chunky rocker switch */
    flex: 1 1 0; min-width: 0; position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
    border: 0; border-radius: 3px; cursor: pointer; padding: 0 2px;
    background: linear-gradient(180deg, #34302c 0%, #26231f 46%, #171513 54%, #100f0e 100%);
    box-shadow: 0 0 0 2px #050404, 0 4px 0 #050404, inset 0 1px 0 rgba(255, 255, 255, 0.1);
    color: #a09584; font-weight: 700; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
    text-shadow: 0 -1px 0 #000;
    transition: transform 0.06s;
  }
  .dock-lamp { width: 14px; height: 3px; border-radius: 1px; background: #2f220c; box-shadow: inset 0 1px 1px #000; }
  .dock-lab { white-space: nowrap; overflow: hidden; text-overflow: clip; max-width: 100%; }
  .dock button.on {
    color: #f0dcb4; transform: translateY(3px);
    background: linear-gradient(180deg, #121110 0%, #1a1816 46%, #25221f 54%, #302c28 100%);
    box-shadow: 0 0 0 2px #050404, 0 1px 0 #050404, inset 0 2px 3px rgba(0, 0, 0, 0.6);
  }
  .dock button.on .dock-lamp { background: var(--amber); box-shadow: 0 0 6px var(--amber), 0 0 10px var(--amber-glow); }
  .dock .badge { position: absolute; top: 3px; right: 4px; font-family: var(--f-vfd); font-weight: 800; font-size: 9px; letter-spacing: 0; color: var(--amber); }
  .cockpit.racing ~ .dock, body:has(.cockpit.racing) .sheet-scrim { display: none; }
  .race-result { position: fixed; z-index: 45; top: 50%; max-height: calc(100dvh - 32px); }
  .toasts { top: calc(8px + env(safe-area-inset-top)); bottom: auto; }

  .headunit { flex-wrap: wrap; gap: 12px 12px; padding: 8px 10px 12px; margin-bottom: -14px; border-radius: 18px 18px 40% 40% / 14px 14px 18px 18px; }
  .brand { flex: 1; display: flex; align-items: baseline; gap: 8px; }
  .brand-word { font-size: 22px; }
  .brand-sub { font-size: 10px; }
  .vfd { order: 3; flex-basis: 100%; padding: 5px 2px; }
  .vfd-cell { flex: 1 1 0; padding: 0 6px; }
  .vfd-lab { font-size: 9.5px; }
  .vfd-val { font-size: 17px; }
  .vfd-tier { font-size: 10px; }
  .toggle-track { width: 32px; height: 24px; }
  .toggle-bat { top: 5px; }
  .toggle-lab { font-size: 10px; }
  .binnacle { gap: 0; padding: 18px 2% 12px; margin-bottom: 4px; }
  .binnacle::after { height: 30px; }
  .binnacle::before { inset: 12px 0 2px; border-radius: 40% 40% 18px 18px / 40px 40px 18px 18px; }
  .g-num { font-size: 18px; }
  .row { grid-template-columns: 30px minmax(0, 1fr) auto; column-gap: 10px; padding: 9px 2px; }
  .part-no { display: none; }
  .part-icon { width: 28px; height: 28px; grid-column: 1; }
  .row-name { grid-column: 2; font-size: 17px; }
  .row-blurb { grid-column: 2; font-size: 13px; }
  .row-cost { grid-column: 3; min-width: 0; font-size: 15px; padding: 4px 9px 4px 18px; }
  .cars { grid-template-columns: 1fr; }
  .rank-big { font-size: 44px; }
  .race-names { gap: 70px; font-size: 11px; }
  .bulb { width: 16px; height: 16px; }
  .tree { gap: 4px; padding: 6px; }
  .stage { width: 7px; height: 7px; }
  .race-progress { bottom: 34px; }
  .race-tip { bottom: 46px; left: auto; right: 5%; transform: none; text-align: right; font-size: 10.5px; letter-spacing: 0.04em; max-width: 50%; }
}
@media (prefers-reduced-motion: reduce) {
  .fx-num, .fx-spark, .footwell.flash::before { animation-duration: 0.01s; }
  .pedal-assy, .pedal-plate, .toggle-bat { transition: none; }
}

/* Mobile: no double-tap / input-focus zoom anywhere. */
html, body, button, input, select, textarea, label, a { touch-action: manipulation; }
input, select, textarea { font-size: max(16px, 1em); }

/* Phone: the page itself never scrolls or rubber-bands (iOS Safari). Only the sheet scrolls inside. */
@media (max-width: 600px) {
  html, body { position: fixed; inset: 0; width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
}

/* ---- street events: VFD ticker, race chip, tip jar, weather tints ---- */
.vfd { flex-wrap: wrap; }
.ev-strip {
  flex: 1 0 100%; order: 9; display: flex; align-items: center; gap: 8px; min-width: 0;
  margin: 6px 0 -2px; padding: 3px 10px 3px 4px; border: 0; border-top: 1px solid rgba(255, 173, 31, 0.12);
  background: transparent; color: var(--amber); font: 400 15px/1 var(--f-vfd); letter-spacing: 0.04em; cursor: help; text-align: left;
}
.ev-strip[hidden] { display: none; }
.ev-strip.debuff { color: #ff6b4a; }
.ev-ring { width: 20px; height: 20px; flex: none; transform: rotate(-90deg); }
.ev-ring circle { fill: none; stroke-width: 2.6; }
.ev-ring-bg { stroke: rgba(255, 173, 31, 0.15); }
.ev-ring-fg { stroke: currentColor; transition: stroke-dashoffset 0.25s linear; filter: drop-shadow(0 0 3px currentColor); }
.ev-marquee { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent); }
.ev-text { display: inline-block; white-space: pre; animation: ev-scroll 14s linear infinite; text-shadow: 0 0 6px currentColor; }
@keyframes ev-scroll { to { transform: translateX(-50%); } } /* text is doubled, so -50% loops seamlessly */
.ev-time { flex: none; font-variant-numeric: tabular-nums; text-shadow: 0 0 6px currentColor; }
.race-ev {
  position: absolute; top: 34px; left: 50%; transform: translateX(-50%); z-index: 4; pointer-events: none;
  padding: 3px 10px; border: 1px solid rgba(255, 173, 31, 0.45); border-radius: 3px; background: rgba(10, 8, 6, 0.75);
  color: var(--amber); font: 600 12px/1.2 var(--f-cond); letter-spacing: 0.12em; text-transform: uppercase; white-space: nowrap;
}
.race-ev[hidden] { display: none; }
.race-ev.debuff { color: #ff6b4a; border-color: rgba(255, 107, 74, 0.5); }
.race-ev.idle { opacity: 0.55; }
.tipjar {
  position: fixed; z-index: 40; width: 64px; height: 76px; margin: -38px 0 0 -32px; padding: 0; border: 0; background: none;
  cursor: pointer; touch-action: none; -webkit-tap-highlight-color: transparent; animation: tip-bob 1.6s ease-in-out infinite, tip-in 0.3s ease-out;
  filter: drop-shadow(0 0 14px rgba(255, 196, 60, 0.75));
}
.tipjar .tip-lid { position: absolute; left: 14px; right: 14px; top: 4px; height: 9px; border-radius: 3px; background: linear-gradient(#ffe7a0, #c8901c); }
.tipjar .tip-body {
  position: absolute; left: 8px; right: 8px; top: 12px; bottom: 14px; border-radius: 10px 10px 14px 14px;
  background: radial-gradient(circle at 35% 30%, #fff4c4, #ffc93c 45%, #b5780f); border: 2px solid #fff0b8;
  display: grid; place-items: center; font: 800 22px/1 var(--f-cond); color: #6a4200;
}
.tipjar .tip-lab { position: absolute; left: 0; right: 0; bottom: 0; font: 700 11px/1 var(--f-cond); letter-spacing: 0.16em; text-transform: uppercase; color: #ffd76a; text-align: center; }
.tipjar.caught { animation: tip-catch 0.35s ease-in forwards; pointer-events: none; }
@keyframes tip-bob { 50% { transform: translateY(-7px) rotate(4deg); } }
@keyframes tip-in { from { transform: scale(0.2); opacity: 0; } }
@keyframes tip-catch { to { transform: scale(1.6) translateY(-30px); opacity: 0; } }
/* weather tints the gauge faces a little */
body.wx-rain .binnacle { filter: saturate(0.8) hue-rotate(-8deg) brightness(0.95); }
body.wx-heat .binnacle { filter: sepia(0.18) saturate(1.2); }
body.wx-cool .binnacle { filter: hue-rotate(-14deg) saturate(0.9); }
body.wx-gold .headunit { box-shadow: 0 18px 26px rgba(0, 0, 0, 0.9), 0 0 24px rgba(255, 196, 60, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.08); }
@media (prefers-reduced-motion: reduce) { .ev-text { animation: none; } .tipjar { animation: none; } }

/* chase cam: the view is outside the car, so no A-pillars; the timeslip waits for the photo finish */
.windshield .pillar { display: none; }
.race-result { animation: slip-in 0.35s ease-out 1.4s both; }
@keyframes slip-in { from { opacity: 0; margin-top: 30px; } }
@media (prefers-reduced-motion: reduce) { .race-result { animation-delay: 0.3s; } }
.race-tip { transition: opacity 0.5s; }
.race-tip.gone { opacity: 0; }
/* race overlays stay off the cars: pace tip top-right under the name plate, banner clear of the tree */
.race-tip { top: 36px; bottom: auto; left: auto; right: 4%; transform: none; text-align: right; max-width: 40%; }
@media (max-width: 600px) {
  .race-tip { top: 32px; bottom: auto; max-width: 46%; }
  .race-banner { top: 72%; font-size: 19px; padding: 4px 10px; background: rgba(8, 4, 2, 0.55); }
}

/* NOS: a separate thumb button beside the pedal (desktop: N or Shift), one burst per race */
.nos {
  position: absolute; z-index: 3; left: 8%; bottom: 18%; width: 74px; height: 74px; border-radius: 50%;
  display: grid; place-items: center; align-content: center; gap: 2px; padding: 0; cursor: pointer;
  border: 2px solid #5b3a8f; background: radial-gradient(circle at 40% 35%, #3a2a55, #160f22 70%);
  color: #cdb8ff; font: 800 18px/1 var(--f-cond); letter-spacing: 0.08em;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.nos[hidden] { display: none; }
.nos .nos-key { font: 600 10px/1 var(--f-cond); padding: 1px 4px; border: 1px solid rgba(205, 184, 255, 0.4); border-radius: 2px; color: rgba(205, 184, 255, 0.7); }
.nos.armed { border-color: #a77bff; color: #fff; box-shadow: 0 0 18px rgba(167, 123, 255, 0.7), 0 6px 14px rgba(0, 0, 0, 0.8); animation: nos-pulse 1.2s ease-in-out infinite; }
.nos:disabled { opacity: 0.35; animation: none; box-shadow: none; cursor: default; }
@keyframes nos-pulse { 50% { box-shadow: 0 0 30px rgba(167, 123, 255, 0.95), 0 6px 14px rgba(0, 0, 0, 0.8); } }
body.nos-on .windshield { box-shadow: inset 0 0 60px rgba(150, 90, 255, 0.55), 0 0 30px rgba(150, 90, 255, 0.35); }
.race-banner.nitro { color: #d9c6ff; text-shadow: 0 0 18px rgba(167, 123, 255, 0.9), 0 2px 0 #000; }
@media (max-width: 600px) { .nos { width: 84px; height: 84px; left: 4%; bottom: 14%; font-size: 20px; } .nos .nos-key { display: none; } }
@media (prefers-reduced-motion: reduce) { .nos.armed { animation: none; } }
