/* fonts are served from this folder (the site only allows its own fonts) */
@font-face { font-family: "Lilita One"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/lilita-one-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/nunito-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/nunito-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-style: normal; font-weight: 800; font-display: swap; src: url("fonts/nunito-latin-800-normal.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-style: normal; font-weight: 900; font-display: swap; src: url("fonts/nunito-latin-900-normal.woff2") format("woff2"); }
/* Pit Stop Maths. Layout: a night-time pit wall. Paddock (setup) is one scrolling column of
   decisions; the race screen is track canvas + timing tower, with the question panel and keypad
   beside it on wide screens and under it on phones. One committed dark look (no light theme). */
:root {
  --night: #0f1420;        /* page ground: pit wall at dusk */
  --panel: #182033;        /* raised panels */
  --panel-2: #212b42;      /* inputs, chips */
  --line: #2e3a55;         /* hairlines */
  --ink: #eef2f9;          /* main text */
  --ink-soft: #9aa7bf;     /* secondary text */
  --signal: #ff7a1a;       /* default accent; replaced by the driver's own car colour */
  --purple: #b26bff;       /* timing colours: fastest */
  --green: #2fd36b;        /* personal best */
  --yellow: #ffd23f;       /* slower */
  --red: #ff3b4e;          /* start lights, mistakes */
  --display: "Lilita One", "Arial Black", Impact, sans-serif;
  --body: "Nunito", "Segoe UI", system-ui, sans-serif;
  --r: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--night); color: var(--ink);
  font-family: var(--body); font-size: 16px; line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.wrap {
  max-width: 1080px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 18px 32px;
}
.screen[hidden] { display: none !important; }

/* ---------- brand bar ---------- */
.brand { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.logo-word { font-family: var(--display); font-size: clamp(28px, 6vw, 44px); line-height: 1; letter-spacing: .5px; transform: skewX(-6deg); }
.logo-word b { color: var(--signal); font-weight: 400; }
.logo-flag { width: 34px; height: 34px; border-radius: 6px; flex: none;
  background: conic-gradient(#fff 25%, #111 0 50%, #fff 0 75%, #111 0) 0 0 / 12px 12px; transform: skewX(-6deg); }
.iconbtn { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 8px 14px; font-weight: 700; }
.iconbtn:hover { background: var(--panel-2); }

/* ---------- paddock ---------- */
.paddock { display: grid; gap: 18px; margin-top: 18px; }
.driver-card {
  display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center;
  background: linear-gradient(100deg, color-mix(in srgb, var(--signal) 26%, var(--panel)) 0%, var(--panel) 55%);
  border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px;
}
.driver-card canvas { width: 120px; height: 72px; display: block; }
.driver-name { font-family: var(--display); font-size: 26px; line-height: 1.05; transform: skewX(-6deg); overflow-wrap: anywhere; }
.driver-meta { color: var(--ink-soft); font-weight: 600; font-size: 14px; }
.driver-meta b { color: var(--ink); }
.driver-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.step { display: grid; gap: 10px; }
.step-h { display: flex; align-items: baseline; gap: 10px; }
.step-h h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 22px; letter-spacing: .3px; }
.step-h span { color: var(--ink-soft); font-size: 14px; font-weight: 600; }
.sections { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sec {
  display: grid; gap: 2px; justify-items: start; text-align: left;
  border: 2px solid var(--line); background: var(--panel); border-radius: var(--r); padding: 12px 14px;
}
.sec .sym { font-family: var(--display); font-size: 34px; line-height: 1; }
.sec b { font-size: 17px; }
.sec small { color: var(--ink-soft); font-weight: 600; }
.sec[aria-pressed="true"] { border-color: var(--signal); background: color-mix(in srgb, var(--signal) 16%, var(--panel)); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 8px 14px; font-weight: 700; color: var(--ink-soft); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--night); }
.seg-label { font-weight: 700; color: var(--ink-soft); font-size: 14px; min-width: 64px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-width: 42px; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 6px 8px; font-weight: 800; }
.chip[aria-pressed="true"] { background: var(--signal); border-color: var(--signal); color: #111; }
.tracks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.trk {
  position: relative; display: grid; gap: 6px; text-align: left; padding: 10px;
  border: 2px solid var(--line); background: var(--panel); border-radius: var(--r);
}
.trk canvas { width: 100%; aspect-ratio: 100 / 62; display: block; border-radius: 8px; max-width: 100%; }
.trk-name { font-family: var(--display); font-size: 19px; line-height: 1; }
.trk-meta { display: flex; justify-content: space-between; gap: 6px; color: var(--ink-soft); font-size: 13px; font-weight: 600; }
.trk[aria-pressed="true"] { border-color: var(--signal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--signal) 30%, transparent); }
.trk.locked { opacity: .55; }
.trk.locked::after { content: "🔒 Podium at " attr(data-need) " to unlock"; position: absolute; inset: 14px 14px auto 14px; background: rgba(10,14,22,.86);
  border-radius: 8px; padding: 6px 8px; font-size: 13px; font-weight: 700; color: var(--ink); }
.medal { font-weight: 800; }
.go-bar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  border-top: 1px solid var(--line); padding-top: 16px; }
.summary { color: var(--ink-soft); font-weight: 600; }
.summary b { color: var(--ink); }
.btn-go {
  border: 0; background: var(--signal); color: #111; border-radius: 14px; padding: 14px 26px;
  font-family: var(--display); font-size: 24px; letter-spacing: .5px; box-shadow: 0 5px 0 color-mix(in srgb, var(--signal) 55%, #000);
}
.btn-go:active { transform: translateY(3px); box-shadow: 0 2px 0 color-mix(in srgb, var(--signal) 55%, #000); }
.btn { border: 1px solid var(--line); background: var(--panel-2); border-radius: 12px; padding: 10px 16px; font-weight: 800; }
.btn.primary { background: var(--ink); color: var(--night); border-color: var(--ink); }
.standings { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 6px; }
.standings-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.standings-h b { font-family: var(--display); font-weight: 400; font-size: 20px; }
.standings ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.standings li { display: grid; grid-template-columns: 24px 6px 1fr auto; gap: 8px; align-items: center; font-weight: 700; }
.standings li.me { color: var(--signal); }
.standings .sw { width: 6px; height: 18px; border-radius: 2px; }
.foot { color: var(--ink-soft); font-size: 13px; text-align: center; margin-top: 8px; }
.foot a { color: var(--ink-soft); }
.foot button { background: none; border: 0; color: var(--ink-soft); text-decoration: underline; font-size: 13px; }

/* ---------- garage ---------- */
.garage { display: grid; gap: 18px; margin-top: 18px; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: start; }
.car-stage { background: radial-gradient(120% 90% at 50% 40%, #2a3550, var(--night)); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; display: grid; gap: 8px; justify-items: center; position: sticky; top: 12px; }
.car-stage canvas { width: 100%; max-width: 420px; aspect-ratio: 4 / 5; display: block; }
.stage-name { font-family: var(--display); font-size: 26px; transform: skewX(-6deg); }
.garage-form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field label, .field .lab { font-weight: 800; font-size: 14px; color: var(--ink-soft); letter-spacing: .4px; text-transform: uppercase; }
.field input[type="text"], .field input[type="number"] {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink); border-radius: 10px; padding: 10px 12px; font: inherit; font-weight: 700; font-size: 18px; width: 100%;
}
.liveries { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.liv { border: 2px solid var(--line); background: var(--panel); border-radius: 12px; padding: 6px; display: grid; gap: 4px; justify-items: center; }
.liv canvas { width: 100%; height: 44px; display: block; }
.liv span { font-weight: 800; font-size: 13px; }
.liv[aria-pressed="true"] { border-color: var(--ink); }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--panel-2); background: var(--c); padding: 0; box-shadow: 0 0 0 1px #4a5878; }
.swatch[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--night) inset; }
.drivers { display: flex; gap: 8px; flex-wrap: wrap; }
.drv { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 12px; font-weight: 800; display: inline-flex; align-items: center; gap: 6px; }
.drv i { width: 12px; height: 12px; border-radius: 50%; background: var(--c); display: inline-block; }
.drv[aria-pressed="true"] { border-color: var(--ink); background: var(--panel-2); }
.garage-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- race ---------- */
.race-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.race-title { font-family: var(--display); font-size: 22px; line-height: 1; }
.race-title small { display: block; font-family: var(--body); font-size: 13px; color: var(--ink-soft); font-weight: 700; margin-top: 2px; }
.race-stats { display: flex; gap: 8px; align-items: stretch; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px; display: grid; justify-items: center; min-width: 74px; }
.stat small { font-size: 11px; font-weight: 800; color: var(--ink-soft); letter-spacing: .6px; text-transform: uppercase; }
.stat b { font-family: var(--display); font-weight: 400; font-size: 26px; line-height: 1.05; }
.race-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 14px; margin-top: 12px; align-items: start; }
.track-box { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.track-box canvas { display: block; width: 100%; aspect-ratio: 100 / 62; max-width: 100%; }
.tower { position: absolute; top: 8px; left: 8px; background: rgba(10, 13, 22, .82); border-radius: 8px; padding: 4px; display: grid; gap: 1px; min-width: 112px; }
.tower div { display: grid; grid-template-columns: 18px 4px 34px 1fr; gap: 5px; align-items: center; font-size: 12px; font-weight: 800; padding: 1px 4px; border-radius: 4px; }
.tower div.me { background: color-mix(in srgb, var(--signal) 40%, transparent); }
.tower i { width: 4px; height: 13px; border-radius: 1px; display: block; }
.tower em { font-style: normal; color: var(--ink-soft); text-align: right; font-weight: 700; }
.lights { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.lights-row { display: flex; gap: 10px; background: #0b0d12; padding: 12px 14px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.lamp { width: clamp(22px, 5vw, 38px); aspect-ratio: 1; border-radius: 50%; background: #2a1014; box-shadow: inset 0 0 0 3px #000; }
.lamp.on { background: radial-gradient(circle at 40% 35%, #ff9aa3, var(--red) 55%, #8b0010); box-shadow: 0 0 18px var(--red), inset 0 0 0 3px #000; }
.banner { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) skewX(-6deg); font-family: var(--display); font-size: clamp(28px, 7vw, 56px);
  color: #fff; text-shadow: 0 4px 0 #000, 0 0 30px rgba(0,0,0,.6); white-space: nowrap; pointer-events: none; }
.drs { position: absolute; right: 10px; top: 10px; background: var(--green); color: #062; font-weight: 900; padding: 4px 10px; border-radius: 6px; letter-spacing: 1px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: grid; gap: 12px; }
.q { display: flex; align-items: center; justify-content: center; gap: 12px; font-family: var(--display); font-size: clamp(38px, 8vw, 58px); line-height: 1; min-height: 72px; flex-wrap: wrap; }
.q .ans { min-width: 2.6ch; padding: 4px 12px; border-radius: 12px; background: var(--night); border: 3px solid var(--line); text-align: center; }
.q .ans.good { border-color: var(--green); color: var(--green); }
.q .ans.bad { border-color: var(--red); color: var(--red); }
.feedback { min-height: 30px; display: flex; justify-content: center; align-items: center; gap: 8px; font-weight: 800; text-align: center; flex-wrap: wrap; }
.sector { padding: 3px 10px; border-radius: 6px; color: #111; font-weight: 900; }
.sector.purple { background: var(--purple); }
.sector.green { background: var(--green); }
.sector.yellow { background: var(--yellow); }
.sector.red { background: var(--red); color: #fff; }
.speedo { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; }
.speedo b { font-family: var(--display); font-weight: 400; font-size: 30px; min-width: 3ch; text-align: right; }
.speedo small { font-weight: 800; color: var(--ink-soft); font-size: 12px; }
.bar { height: 12px; border-radius: 6px; background: var(--night); overflow: hidden; border: 1px solid var(--line); }
.bar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--yellow), var(--green) 60%, var(--purple)); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button { border: 0; border-radius: 12px; background: var(--panel-2); font-family: var(--display); font-size: 28px; padding: 10px 0; box-shadow: 0 4px 0 #0b0f19; }
.keypad button:active { transform: translateY(2px); box-shadow: 0 2px 0 #0b0f19; }
.keypad .ok { background: var(--green); color: #052; }
.keypad .del { background: #3a2230; }
.race-actions { display: flex; gap: 8px; justify-content: space-between; }

/* ---------- results ---------- */
.results { display: grid; gap: 16px; margin-top: 16px; }
.podium-h { font-family: var(--display); font-size: clamp(34px, 7vw, 60px); line-height: 1; transform: skewX(-6deg); margin: 0; }
.podium-sub { color: var(--ink-soft); font-weight: 700; margin: 4px 0 0; }
.res-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
table.class { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--r); overflow: hidden; }
.class td:nth-child(n+3) { white-space: nowrap; }
.class th, .class td { padding: 8px 10px; text-align: left; font-weight: 700; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.class th { color: var(--ink-soft); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
.class tr.me td { background: color-mix(in srgb, var(--signal) 22%, transparent); }
.class .sw { display: inline-block; width: 6px; height: 16px; border-radius: 2px; vertical-align: -3px; margin-right: 8px; }
.class .fl { color: var(--purple); font-weight: 900; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; }
.tile small { display: block; color: var(--ink-soft); font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.tile b { font-family: var(--display); font-weight: 400; font-size: 28px; }
.practice { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; display: grid; gap: 8px; }
.practice h3 { margin: 0; font-size: 16px; }
.facts { display: flex; flex-wrap: wrap; gap: 6px; }
.fact { background: var(--panel-2); border-radius: 8px; padding: 4px 10px; font-weight: 800; font-variant-numeric: tabular-nums; }
.fact.slow { box-shadow: inset 0 0 0 2px var(--yellow); }
.fact.miss { box-shadow: inset 0 0 0 2px var(--red); }
.res-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--night); font-weight: 800;
  padding: 10px 16px; border-radius: 12px; z-index: 50; max-width: calc(100% - 32px); text-align: center; }

@media (max-width: 860px) {
  .race-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .garage { grid-template-columns: minmax(0, 1fr); }
  .car-stage { position: static; }
  .car-stage canvas { max-width: 300px; aspect-ratio: 5 / 4; }
  .res-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) { .tracks { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) {
  .logo-word { font-size: 26px; }
  .logo-flag { width: 26px; height: 26px; }
  #soundBtn { padding: 6px 10px; }
  .sb-l { display: none; }
  .trk-name { font-size: 16px; }
  .class th, .class td { padding: 7px 6px; }
  .sections { grid-template-columns: 1fr; }
  .sec { grid-template-columns: auto 1fr; column-gap: 12px; align-items: center; }
  .sec .sym { grid-row: span 2; font-size: 30px; }
  .driver-card { grid-template-columns: auto 1fr; }
  .driver-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .driver-card canvas { width: 96px; height: 58px; }
  .wrap { padding-block: 10px 24px; }
  .q { min-height: 56px; }
  .keypad button { font-size: 24px; padding: 8px 0; }
  .panel { padding: 10px; gap: 8px; }
  .race-title { font-size: 18px; }
  .stat { min-width: 60px; padding: 3px 8px; }
  .stat b { font-size: 22px; }
  .tower { transform: scale(.85); transform-origin: top left; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* iPhone: a quick double tap on a button (2 then 2) must not zoom the page */
html,body,button,input,label,a{touch-action:manipulation}
