/* Layout: the test yard on the left with the driving controls under it, the examiner's notes on the right.
   One column on phones. The yard is tarmac in both themes. */
:root {
  --bg: #e4e8ea; --surface: #f5f6f7; --surface-2: #d8dee2; --ink: #141a1f; --muted: #53606a; --line: #bcc6cc;
  --accent: #d94f09; --on-accent: #ffffff;
  --good: #167a46; --bad: #c22f28; --warn: #915b00; --info: #1c68ab;
  --tarmac: #30373d; --lane: #424a51; --paint: #f0efe6; --cone: #f4701f; --cone-dark: #b3470b;
  --car: #f4f5f2; --glass: #25313a;
  --y-good: #52e39a; --y-bad: #ff5d52; --y-warn: #ffc64d; --y-info: #74c4ff;
  --hud-bg: rgba(12, 15, 18, .74); --hud-ink: #f3f3ee;
  --display: 'Barlow Condensed', 'Arial Narrow', 'Roboto Condensed', sans-serif;
  --body: 'Barlow', 'Segoe UI', system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1316; --surface: #181e23; --surface-2: #232b32; --ink: #e8ecef; --muted: #93a0aa; --line: #323c45;
    --accent: #ff7d33; --on-accent: #1b0d03;
    --good: #46d089; --bad: #ff6f65; --warn: #f1b547; --info: #6eb8f5;
    --tarmac: #1d2327; --lane: #2b3339;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1316; --surface: #181e23; --surface-2: #232b32; --ink: #e8ecef; --muted: #93a0aa; --line: #323c45;
  --accent: #ff7d33; --on-accent: #1b0d03;
  --good: #46d089; --bad: #ff6f65; --warn: #f1b547; --info: #6eb8f5;
  --tarmac: #1d2327; --lane: #2b3339;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.45 var(--body); }
[hidden] { display: none !important; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { max-width: 1240px; margin: 0 auto; padding-inline: 16px; padding-block: 14px 28px; display: flex; flex-direction: column; gap: 14px; }
.top { display: flex; align-items: center; gap: 6px 20px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.mark { width: 28px; height: 28px; flex: none; }
h1 { margin: 0; font: 700 30px/1 var(--display); letter-spacing: .03em; text-transform: uppercase; }
.lede { margin: 0; color: var(--muted); max-width: 62ch; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 368px; gap: 18px; align-items: start; }
.stage { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

/* the yard */
.yard { position: relative; width: 100%; max-width: 100%; aspect-ratio: 1 / 1; max-height: min(72vh, 760px); background: var(--tarmac); border-radius: 6px; overflow: hidden; }
.yard canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.chip { background: var(--hud-bg); color: var(--hud-ink); border: 0; border-radius: 4px; padding: 5px 9px; font: 600 15px/1.15 var(--display); letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }
.chip b { font-weight: 700; font-variant-numeric: tabular-nums; }
.hud { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; align-items: center; gap: 6px; pointer-events: none; }
.hud .spacer { flex: 1; }
.clock { font-variant-numeric: tabular-nums; }
.clock.low { color: var(--y-bad); }
.hud-btn { pointer-events: auto; display: grid; place-items: center; padding: 4px 6px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28); }
.hud-btn svg { width: 20px; height: 20px; display: block; }
.hud-btn.on { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.hud-btn:hover { background: rgba(12, 15, 18, .92); }
.readout { position: absolute; right: 8px; bottom: 8px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; pointer-events: none; }
.readout .chip { font-size: 14px; }
.toast { position: absolute; left: 50%; bottom: 46px; transform: translateX(-50%); width: max-content; max-width: calc(100% - 24px); background: var(--accent); color: var(--on-accent); padding: 7px 12px; border-radius: 4px; font: 600 16px/1.2 var(--display); letter-spacing: .03em; text-align: center; pointer-events: none; }

/* replay strip */
.timeline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tl-wrap { flex: 1; min-width: 0; height: 66px; background: var(--surface); border: 1px solid var(--line); border-radius: 5px; touch-action: none; cursor: ew-resize; }
.tl-wrap canvas { width: 100%; height: 100%; display: block; }
.tl-time { font: 600 16px var(--display); font-variant-numeric: tabular-nums; min-width: 2.8em; text-align: right; }
.legend { flex-basis: 100%; margin: 0; color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 16px; height: 3px; border-radius: 2px; }
.sw.steer { background: var(--accent); }
.sw.speed { background: var(--line); height: 9px; margin-left: 10px; }

/* driving controls */
.deck { display: flex; justify-content: space-between; align-items: stretch; gap: 12px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.steer { display: flex; align-items: center; gap: 6px; }
.pad { width: 52px; height: 92px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; touch-action: none; }
.pad svg { width: 26px; height: 26px; }
.wheel { width: 96px; height: 96px; flex: none; touch-action: none; cursor: grab; }
.wheel svg { width: 100%; height: 100%; display: block; }
.drive { display: flex; flex-direction: column; gap: 6px; }
.gears { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.gears button { border: 0; background: var(--surface); padding: 5px 0; font: 600 16px/1.2 var(--display); letter-spacing: .06em; }
.gears button.on { background: var(--ink); color: var(--bg); }
.pedals { display: flex; gap: 6px; flex: 1; }
.pedal { width: 76px; min-height: 58px; border-radius: 6px; font: 700 18px/1 var(--display); letter-spacing: .08em; text-transform: uppercase; touch-action: none; }
.pedal.race { background: var(--accent); color: var(--on-accent); border: 1px solid var(--accent); }
.pedal.brake { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.pad.down, .pedal.down { transform: translateY(2px); filter: brightness(.88); }
.keys { margin: 0; color: var(--muted); font-size: 13px; }
@media (hover: none) { .keys { display: none; } }

/* buttons */
.btn { background: var(--surface); border: 1px solid var(--line); border-radius: 5px; padding: 7px 12px; font: 600 15px/1.15 var(--display); letter-spacing: .06em; text-transform: uppercase; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.wide { width: 100%; padding-block: 9px; }

/* examiner's side */
.coach { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 14px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.coach h2 { margin: 0; font: 600 16px/1.1 var(--display); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.lab { font: 600 13px/1.1 var(--display); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.pair { display: grid; grid-template-columns: 3fr 2fr; gap: 10px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.seg label { position: relative; display: block; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: block; padding: 7px 4px; text-align: center; font-weight: 500; white-space: nowrap; }
.seg input:checked + span { background: var(--ink); color: var(--bg); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
select { background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 7px 8px; width: 100%; }
input[type="range"] { width: 100%; accent-color: var(--accent); margin: 2px 0; }
.out { font-weight: 500; font-variant-numeric: tabular-nums; }
.hint { color: var(--muted); font-size: 14px; }
.note { margin: 0; padding: 8px 10px; border: 1px solid var(--warn); border-radius: 5px; color: var(--warn); font-size: 14px; }
.checks { display: flex; flex-direction: column; gap: 6px; }
.checks label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.checks input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }

.verdict { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 14px; align-items: center; }
.stamp { grid-row: span 2; align-self: center; padding: 7px 10px 6px; border: 2.5px solid currentColor; border-radius: 4px; font: 700 24px/1 var(--display); letter-spacing: .1em; text-transform: uppercase; transform: rotate(-5deg); }
.verdict.fail .stamp { color: var(--bad); }
.verdict.pass .stamp { color: var(--good); }
.verdict.demo .stamp { color: var(--info); }
.verdict h3 { margin: 0; font: 600 21px/1.12 var(--display); letter-spacing: .01em; text-wrap: balance; }
.verdict p { margin: 0; color: var(--muted); }
.findings { list-style: none; margin: 0; padding: 0; }
.findings li { border-top: 1px solid var(--line); }
.findings button { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 1px 10px; width: 100%; padding: 10px 0; background: none; border: 0; text-align: left; }
.findings .tag { grid-row: span 2; padding-top: 3px; font: 600 13px/1.2 var(--display); letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.findings .bad .tag { color: var(--bad); }
.findings .warn .tag { color: var(--warn); }
.findings .good .tag { color: var(--good); }
.findings .info .tag, .findings .step .tag { color: var(--info); }
.findings strong { font-weight: 600; }
.findings .txt { color: var(--muted); }
.findings button:hover strong { text-decoration: underline; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.small { margin: 0; color: var(--muted); font-size: 13px; }

.rules { display: flex; flex-direction: column; gap: 8px; padding-inline: 2px; }
.rules ol { margin: 0; padding-left: 1.3em; }
.rules p { margin: 0; color: var(--muted); font-size: 14px; }

@media (max-width: 920px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .yard { max-height: none; }
}
@media (max-width: 560px) {
  h1 { font-size: 25px; }
  .lede { font-size: 14px; }
  .tl-wrap { flex-basis: 100%; order: -1; }
  .tl-time { margin-left: auto; }
  .chip { font-size: 13.5px; padding: 4px 7px; }
  .readout .chip { font-size: 13px; }
}
@media (max-width: 400px) {
  .pad { width: 42px; height: 84px; }
  .wheel { width: 84px; height: 84px; }
  .pedal { width: 60px; }
  .deck { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) { .pad.down, .pedal.down { transform: none; } }
