/* TV screen: broadcast graphics over the 3D circuit. Solid ink panels and chequered-flag accents,
   no glass, no glow. Dials: VARIANCE 4 · MOTION 4 · DENSITY 5 */
:root {
  --ink: #15130f; --ink-2: #24211b; --paper: #fbf8f1; --soft: rgba(251, 248, 241, 0.62);
  --lead: #ffd23f; --kid: #ff6a3d; --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --font: "Geologica", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #9fb7c9; font-family: var(--font); color: var(--paper); }
canvas#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
[hidden] { display: none !important; }
body.no-hud .hud, body.no-hud .tags, body.no-hud .big, body.no-hud .toast { display: none; }

/* timing tower */
.tower { position: fixed; left: 2.2vh; top: 2.2vh; width: 34vh; min-width: 250px; background: var(--ink); border-radius: 6px; overflow: hidden; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.28); }
.tower-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; font-weight: 800; font-size: 17px; letter-spacing: 0.04em; text-transform: uppercase; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.flag { width: 22px; height: 16px; flex: none; background: conic-gradient(var(--paper) 25%, var(--ink) 0 50%, var(--paper) 0 75%, var(--ink) 0) 0 0 / 8px 8px; border: 1px solid var(--paper); }
.rows { position: relative; list-style: none; margin: 0; padding: 0; transition: height 0.4s var(--ease); }
.row { position: absolute; left: 0; right: 0; top: 0; height: 46px; display: grid; grid-template-columns: 36px 64px 1fr auto; align-items: center; gap: 10px; padding: 0 12px 0 0; transition: transform 0.55s var(--ease), background-color 0.3s ease; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.row .pos { height: 100%; display: grid; place-items: center; background: var(--ink-2); color: var(--paper); font-weight: 900; font-size: 19px; font-variant-numeric: tabular-nums; }
.row.first .pos { background: var(--lead); color: var(--ink); }
.row .pic { height: 34px; display: grid; place-items: center; }
.row .pic img { max-width: 62px; max-height: 32px; display: block; }
.row .nm { font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.kid .nm { color: var(--paper); }
.row.kid .nm::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 8px; border-radius: 50%; background: var(--kid); vertical-align: middle; }
.row .st { font-size: 14px; color: var(--soft); font-variant-numeric: tabular-nums; }

/* big centre words: countdown, GO, final lap, winner */
.big { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%) scale(0.6); opacity: 0; pointer-events: none; font-weight: 900; font-size: 16vh; line-height: 1; color: var(--paper); -webkit-text-stroke: 0.9vh var(--ink); paint-order: stroke fill; letter-spacing: -0.02em; white-space: nowrap; transition: transform 0.35s var(--ease), opacity 0.25s ease; }
.big.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.big.count { font-size: 26vh; }
.big.go { color: var(--lead); font-size: 22vh; }
.big.lapmsg { font-size: 9vh; }
.big.win { font-size: 8vh; color: var(--lead); top: 22%; }

/* results card */
.results { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(62vh, 92vw); background: var(--paper); color: var(--ink); border-radius: 8px; padding: 3vh 3.4vh 2.6vh; box-shadow: 0 14px 50px rgba(0, 0, 0, 0.3); }
.results::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1.2vh; border-radius: 8px 8px 0 0; background: conic-gradient(var(--ink) 25%, var(--paper) 0 50%, var(--ink) 0 75%, var(--paper) 0) 0 0 / 2.4vh 2.4vh; }
.results h2 { margin: 1vh 0 2vh; font-size: 4.4vh; font-weight: 900; letter-spacing: -0.02em; }
.results ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.2vh; }
.results li { display: grid; grid-template-columns: 6vh 13vh 1fr; align-items: center; gap: 1.6vh; padding: 1vh 0; border-top: 1px solid rgba(21, 19, 15, 0.12); }
.results li b { display: grid; place-items: center; height: 6vh; border-radius: 4px; background: var(--ink); color: var(--paper); font-size: 3.4vh; font-weight: 900; }
.results li.p1 b { background: var(--lead); color: var(--ink); }
.results li img { max-width: 13vh; max-height: 6vh; display: block; }
.results li span { font-size: 3.2vh; font-weight: 800; }
.results .next { margin-top: 2vh; color: rgba(21, 19, 15, 0.6); font-size: 2.2vh; }

/* new car toast */
.toast { position: fixed; left: 50%; bottom: 3vh; transform: translate(-50%, 140%); opacity: 0; visibility: hidden; display: flex; align-items: center; gap: 14px; padding: 12px 20px 12px 14px; background: var(--paper); color: var(--ink); border-radius: 8px; font-weight: 800; font-size: 3vh; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); transition: transform 0.5s var(--ease), opacity 0.3s ease, visibility 0.5s; }
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
.toast img { height: 5.5vh; }

/* QR corner */
.qr { position: fixed; right: 2.2vh; bottom: 2.2vh; width: 25vh; min-width: 190px; background: var(--paper); color: var(--ink); border-radius: 8px; padding: 1.6vh 1.6vh 1.3vh; box-shadow: 0 8px 26px rgba(0, 0, 0, 0.25); }
.qr::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 0.9vh; border-radius: 8px 8px 0 0; background: conic-gradient(var(--ink) 25%, var(--paper) 0 50%, var(--ink) 0 75%, var(--paper) 0) 0 0 / 1.8vh 1.8vh; }
.qr-top { display: grid; gap: 2px; margin: 0.6vh 0 1vh; }
.qr-top b { font-size: 2.6vh; font-weight: 900; letter-spacing: -0.01em; }
.qr-top span { font-size: 1.6vh; color: rgba(21, 19, 15, 0.62); }
.qr-box svg { display: block; width: 100%; height: auto; }
.qr-url { margin-top: 0.8vh; font-size: 1.45vh; font-weight: 600; word-break: break-all; }
.qr-print { margin-top: 0.4vh; font-size: 1.35vh; color: rgba(21, 19, 15, 0.6); }

.demo-badge { position: fixed; right: 2.2vh; top: 2.2vh; padding: 6px 12px; background: var(--lead); color: var(--ink); border-radius: 4px; font-weight: 900; font-size: 15px; letter-spacing: 0.08em; text-transform: uppercase; }
.sound { position: fixed; right: 2.2vh; top: 6.6vh; padding: 9px 14px; border: 0; border-radius: 6px; background: var(--ink); color: var(--paper); font: 600 15px var(--font); cursor: pointer; }
.sound:hover { background: var(--ink-2); }
.sound:focus-visible { outline: 3px solid var(--lead); outline-offset: 2px; }

/* name tags over the cars */
.tags { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.tag { position: absolute; left: 0; top: 0; padding: 3px 8px; border-radius: 4px; background: rgba(21, 19, 15, 0.82); color: var(--paper); font-weight: 600; font-size: 14px; white-space: nowrap; will-change: transform; }
.tag.kid { background: var(--kid); color: #fff; font-weight: 800; font-size: 16px; }
.bubble { position: absolute; left: 0; top: 0; padding: 6px 12px; border-radius: 10px; background: var(--paper); color: var(--ink); font-weight: 900; font-size: 22px; border: 3px solid var(--ink); will-change: transform; }

.fps { position: fixed; left: 50%; top: 8px; transform: translateX(-50%); padding: 4px 10px; background: rgba(0, 0, 0, 0.7); color: #9effa8; font: 600 13px ui-monospace, monospace; border-radius: 4px; }
.loading { position: fixed; inset: 0; display: grid; place-items: center; background: var(--ink); transition: opacity 0.6s ease; }
.loading.gone { opacity: 0; pointer-events: none; }
.loading i { width: 60px; height: 40px; background: conic-gradient(var(--paper) 25%, var(--ink) 0 50%, var(--paper) 0 75%, var(--ink) 0) 0 0 / 20px 20px; border: 2px solid var(--paper); animation: wave 1s ease-in-out infinite alternate; }
@keyframes wave { from { transform: skewY(-6deg); } to { transform: skewY(6deg); } }
@media (prefers-reduced-motion: reduce) { .row, .toast, .big { transition: none; } .loading i { animation: none; } }
