/* PURPLE concept race — pit-wall timing screen around the game view. Tokens from docs/DESIGN_SYSTEM.md (copied here so the page
   stands alone). Dark only. 1440×900: game view left, timing column right (340 px); below 1000 px wide the column goes under. */
:root {
  --bg: #0a0a0c; --panel: #121216; --line: #26262c; --text: #e8e8ec; --muted: #8a8a94;
  --purple: #b26cff; --purple-dim: #3a2460; --green: #4ade80; --amber: #fbbf24; --red: #f0506e;
  --rb: #3671c6; --merc: #27f4d2;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 6px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 500 13px/1.45 var(--mono); -webkit-font-smoothing: antialiased; display: flex; flex-direction: column; overflow: hidden; }
button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
[hidden] { display: none !important; }
.label { font: 500 11px/1.2 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.src { font: 400 11px/1.35 var(--sans); color: var(--muted); }
.muted { color: var(--muted); } .pu { color: var(--purple); } .gr { color: var(--green); } .rd { color: var(--red); } .am { color: var(--amber); }

/* header */
.top { flex: none; height: 44px; display: flex; align-items: center; gap: 14px; padding: 0 14px; border-bottom: 1px solid var(--line); background: var(--panel); min-width: 0; }
.brand { font: 700 14px/1 var(--sans); letter-spacing: .18em; color: var(--purple); flex: none; }
.sub { font: 400 12px/1.2 var(--sans); color: var(--muted); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
.spacer { flex: 1 1 0; min-width: 0; }
.tabs { display: flex; gap: 0; flex: none; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.tab { padding: 5px 10px; border: 0; border-right: 1px solid var(--line); background: #1a1a20; font: 600 12px/1.2 var(--sans); color: var(--muted); }
.tab:last-child { border-right: 0; }
.tab[aria-selected="true"] { background: var(--purple-dim); color: var(--text); }
.ctl { display: flex; align-items: center; gap: 6px; flex: none; }
.btn { padding: 5px 10px; border: 1px solid var(--line); border-radius: var(--r); background: #1a1a20; font: 600 12px/1.2 var(--sans); }
.btn:hover:not(:disabled) { border-color: var(--purple); }
.ctl select { background: #1a1a20; border: 1px solid var(--line); border-radius: var(--r); padding: 4px 6px; font: 500 12px/1.2 var(--mono); }
.back { color: var(--muted); text-decoration: none; font: 500 12px/1 var(--sans); flex: none; }
.back:hover { color: var(--purple); }
#banner { flex: none; margin: 8px 12px 0; padding: 7px 10px; background: #2a1118; border: 1px solid var(--red); border-radius: var(--r); font: 500 12px/1.45 var(--sans); }
#banner b { color: var(--red); }

/* frame */
.main { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 372px; gap: 12px; padding: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); min-height: 0; min-width: 0; }
.stage { position: relative; overflow: hidden; display: flex; flex-direction: column; }
.stage .ph { flex: none; }
.stage iframe { flex: 1 1 auto; width: 100%; min-height: 0; border: 0; display: block; background: #000; }
.stage .wait { position: absolute; inset: 40px 0 0; display: flex; align-items: center; justify-content: center; text-align: center; font: 500 13px/1.5 var(--sans); color: var(--muted); padding: 20px; pointer-events: none; }
.ph { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 8px 12px 7px; border-bottom: 1px solid var(--line); min-width: 0; }
.ph .src { text-align: right; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow: hidden auto; scrollbar-width: thin; }
.side .panel { flex: none; }
.pb { padding: 8px 12px 10px; }

/* lap table */
table.lap { width: 100%; border-collapse: collapse; font-size: 12px; }
table.lap th { font: 500 10px/1.2 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); text-align: right; padding: 0 0 4px; }
table.lap th:first-child, table.lap td:first-child { text-align: left; }
table.lap td { text-align: right; padding: 3px 0 0; white-space: nowrap; }
table.lap td.nm { font: 600 12px/1.2 var(--sans); max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
table.lap tr.srcrow td { font: 400 10px/1.3 var(--sans); color: var(--muted); text-align: left; padding: 0 0 4px; white-space: normal; border-bottom: 1px solid var(--line); }
table.lap tr.srcrow:last-child td { border-bottom: 0; }
.sw { display: inline-block; width: 4px; height: 11px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
td.best { color: var(--purple); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 12px; }
.kv .k { font: 400 11.5px/1.45 var(--sans); color: var(--muted); }
.kv .v { text-align: right; }
.note { font: 400 11px/1.45 var(--sans); color: var(--muted); margin-top: 6px; }
.progress { height: 2px; background: var(--line); margin-top: 8px; border-radius: 1px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--purple); transition: width .3s linear; }

/* qualifying-lap timing tower (positions by distance covered, then lap times) */
.tw-legend { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-bottom: 6px; }
.tg { font: 600 9.5px/1.2 var(--sans); font-style: normal; letter-spacing: .04em; padding: 1px 4px; border-radius: 3px; border: 1px solid var(--line); color: var(--muted); }
.tg.sim { border-color: var(--purple-dim); color: var(--purple); }
.tg.ts { border-color: #5a4a1a; color: var(--amber); }
.tower { display: grid; grid-template-columns: 22px 4px 40px minmax(0, 1fr) auto 64px 62px; gap: 0 6px; align-items: center; font-size: 12px; }
.tower .r { display: contents; }
.tower .r > span { padding: 2px 0; border-bottom: 1px solid #1b1b20; white-space: nowrap; }
.tower .r.me > span { background: rgba(58, 36, 96, .45); }
.tower .p { color: var(--muted); text-align: right; }
.tower .sw2 { width: 4px; height: 12px; border-radius: 2px; padding: 0 !important; align-self: center; }
.tower .cd { font: 700 11.5px/1.2 var(--sans); }
.tower .nm { font: 400 11px/1.2 var(--sans); color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.tower .v, .tower .g { text-align: right; }
.tower .fin .v { color: var(--text); }
.tower .r.best .v { color: var(--purple); }
footer.honest { flex: none; padding: 6px 14px 8px; border-top: 1px solid var(--line); font: 400 10.5px/1.45 var(--sans); color: var(--muted); }

@media (max-width: 1000px) {
  html, body { height: auto; }
  body { overflow: auto; min-height: 100%; }
  .main { grid-template-columns: 1fr; flex: none; }   /* the page grows with the column; the footer no longer sits on the timing tower */
  .stage { height: 62vh; }
  .side { overflow: visible; }
  .top { flex-wrap: wrap; height: auto; padding: 8px 12px; row-gap: 8px; }
  .sub { flex-basis: 100%; order: 9; white-space: normal; }
}
/* phones: the six mode tabs scroll sideways inside their own box instead of widening the page */
@media (max-width: 640px) {
  .tabs { flex: 0 1 auto; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: none; white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) { .progress i { transition: none; } }

/* Drive it yourself / Race the grid: the entry button, the result card over the view, the laps panel */
.btn.go { border-color: var(--purple); color: var(--text); background: var(--purple-dim); }
.btn.go:hover { background: #4a2e7a; }
.stage .ph .btn.go { padding: 3px 9px; font-size: 11.5px; flex: none; }
a.btn { text-decoration: none; display: inline-block; color: var(--text); }
.card { position: absolute; top: 48px; right: 12px; width: min(380px, calc(100% - 24px)); background: rgba(14, 14, 18, .94); border: 1px solid var(--purple); border-radius: var(--r); padding: 10px 12px 12px; box-shadow: 0 8px 30px rgba(0, 0, 0, .5); z-index: 5; }
.card-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.card .x { border: 0; background: none; color: var(--muted); font: 600 18px/1 var(--sans); padding: 0 2px; }
.card .x:hover { color: var(--text); }
.card-line { font: 600 14px/1.45 var(--mono); margin-bottom: 8px; }
.card-line .you { color: var(--purple); }
.card .kv .v small { color: var(--muted); font: 400 10.5px/1.2 var(--sans); }
.card-b { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.keys { font: 400 10.5px/1.45 var(--sans); color: var(--muted); margin-top: 6px; border-top: 1px solid var(--line); padding-top: 6px; }
.lapsList { display: grid; grid-template-columns: 34px 1fr auto auto; gap: 1px 8px; font-size: 12px; margin-top: 6px; }
.lapsList .del { color: var(--muted); text-decoration: line-through; }
.lapsList .pb { color: var(--purple); padding: 0; }
@media (max-width: 1000px) { .card { top: 44px; } }

/* several model cars: who races, "Models + pole" | "Everyone" (race.js fieldToggle; a reload with only / real / field) */
.fieldsw { display: inline-flex; flex: none; gap: 2px; padding: 2px; background: #1a1a20; border: 1px solid var(--line); border-radius: var(--r); }
.fieldsw .btn { padding: 3px 9px; border: 0; background: transparent; color: var(--muted); white-space: nowrap; }
.fieldsw .btn.on { background: var(--purple-dim); color: var(--text); }
/* phones: a car's full name ("Claude Haiku", "ChatGPT") wraps in the timing tower instead of being cut */
@media (max-width: 640px) { .tower .nm { white-space: normal; overflow-wrap: anywhere; } }
