:root {
  --bg: #07090d;
  --panel: #11151d;
  --panel2: #171c26;
  --line: #232a37;
  --text: #f3f5f9;
  --muted: #8a93a6;
  --dim: #5b6476;
  --red: #e10600;
  --green: #2fd16f;
  --yellow: #ffd400;
  --purple: #b36bff;
  --soft: #ff3b3b;
  --medium: #ffd21f;
  --hard: #eef0f3;
  --inter: #3ccf4e;
  --wet: #2f8cff;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Titillium Web", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: #1b1f27; color: var(--text); font-family: var(--sans); }
body { background: radial-gradient(1200px 700px at 50% 20%, #2a303b 0%, #14171d 70%); }
button { font: inherit; color: inherit; }

/* ---------- demo page: device frame + controls ---------- */
#page { min-height: 100%; display: flex; flex-direction: column; align-items: center; padding: 24px 16px 20px; gap: 18px; }
#devwrap { position: relative; }
#device {
  position: absolute; top: 0; left: 0; transform-origin: 0 0;
  width: 1360px; height: 880px; padding: 40px; border-radius: 34px;
  background: linear-gradient(145deg, #2a2e35, #101215 60%);
  box-shadow: 0 0 0 2px #3a3f48 inset, 0 30px 80px rgba(0,0,0,.55), 0 4px 14px rgba(0,0,0,.4);
}
.cam { position: absolute; top: 17px; left: 50%; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: #0a0c10; box-shadow: 0 0 0 2px #22262d; }
#controls { width: min(1000px, 100%); background: rgba(10,12,16,.75); border: 1px solid #2b313c; border-radius: 14px; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.ctl-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ctl-label { color: var(--muted); font-size: 14px; letter-spacing: .04em; }
.ctl-note { margin: 0; color: var(--dim); font-size: 13px; }
.ctl-note code { color: var(--muted); }
.seg { display: inline-flex; background: #171b23; border: 1px solid #2b313c; border-radius: 10px; padding: 3px; }
.seg button { background: none; border: 0; padding: 6px 14px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 15px; }
.seg button.on { background: var(--red); color: #fff; }
.seg button:focus-visible, .iconbtn:focus-visible, #scrub:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.iconbtn { background: #171b23; border: 1px solid #2b313c; border-radius: 10px; width: 42px; height: 36px; cursor: pointer; font-size: 14px; }
#scrub { flex: 1; min-width: 200px; accent-color: var(--red); }
.mono { font-family: var(--mono); }

/* kiosk: just the screen, scaled to the display */
body.kiosk { background: #000; overflow: hidden; }
body.kiosk #page { padding: 0; display: block; }
body.kiosk #controls, body.kiosk .cam { display: none; }
body.kiosk #device { padding: 0; border-radius: 0; background: none; box-shadow: none; width: 1280px; height: 800px; }

/* ---------- the 1280x800 screen ---------- */
.screen {
  position: relative; width: 1280px; height: 800px; overflow: hidden; border-radius: 6px;
  background: var(--bg); color: var(--text);
  font-variant-numeric: tabular-nums;
  --flag: transparent;
}
body.kiosk .screen { border-radius: 0; }
.screen::after { /* flag glow around the whole display */
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  box-shadow: inset 0 0 0 5px var(--flag), inset 0 0 60px -10px var(--flag);
  transition: box-shadow .4s;
}
.screen.f-YELLOW, .screen.f-SC, .screen.f-VSC, .screen.f-SC_ENDING, .screen.f-VSC_ENDING { --flag: var(--yellow); }
.screen.f-RED { --flag: var(--red); }
.boot { height: 100%; display: grid; place-content: center; text-align: center; }
.boot-mark { font-weight: 900; font-size: 64px; letter-spacing: .12em; }
.boot-mark::first-letter { color: var(--red); }
.boot-sub { color: var(--muted); font-size: 20px; }

/* header */
.hdr { height: 76px; display: flex; align-items: center; gap: 18px; padding: 0 26px; background: linear-gradient(180deg, #121722, #0b0e14); border-bottom: 1px solid var(--line); position: relative; }
.hdr::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 8px; background: var(--red); }
.hdr-title { display: flex; flex-direction: column; line-height: 1.02; min-width: 0; }
.hdr-event { font-size: 30px; font-weight: 900; text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 560px; }
.hdr-sub { font-size: 16px; color: var(--muted); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.hdr-mid { margin-left: auto; display: flex; align-items: baseline; gap: 10px; }
.lapword { font-size: 16px; color: var(--muted); font-weight: 700; letter-spacing: .12em; }
.lapnum { font-size: 46px; font-weight: 900; line-height: 1; }
.lapof { font-size: 24px; color: var(--muted); font-weight: 700; }
.hdr-right { display: flex; align-items: center; gap: 16px; margin-left: 26px; }
.clock { font-family: var(--mono); font-size: 22px; color: var(--muted); }
.pill { padding: 8px 16px; border-radius: 8px; font-weight: 900; font-size: 18px; letter-spacing: .08em; white-space: nowrap; }
.pill.GREEN { background: rgba(47,209,111,.15); color: var(--green); box-shadow: inset 0 0 0 2px rgba(47,209,111,.5); }
.pill.YELLOW, .pill.SC, .pill.VSC, .pill.SC_ENDING, .pill.VSC_ENDING { background: var(--yellow); color: #111; }
.pill.RED { background: var(--red); color: #fff; }
.pill.CHEQUERED { background: repeating-conic-gradient(#fff 0 25%, #111 0 50%) 0 0 / 16px 16px; color: #fff; text-shadow: 0 0 4px #000, 0 0 2px #000; box-shadow: inset 0 0 0 2px #fff; }
.pill.REPLAY { background: #232a37; color: var(--muted); font-size: 14px; }
.pill.LIVE { background: var(--red); color: #fff; font-size: 14px; }

.body { height: 724px; padding: 12px 16px 14px; display: flex; gap: 14px; }

/* timing tower */
.tower { width: 812px; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.trow { display: grid; grid-template-columns: 46px 40px 6px 1fr 102px 90px 104px 104px 70px 34px; align-items: center; column-gap: 8px; padding: 0 12px 0 6px; }
.thead { height: 28px; font-size: 12px; font-weight: 700; color: var(--dim); letter-spacing: .12em; border-bottom: 1px solid var(--line); background: #0d1118; }
.thead .r { text-align: right; }
.tbody { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.tbody .trow { flex: 1 1 0; min-height: 0; border-bottom: 1px solid #1a202b; font-size: 19px; line-height: 1.1; }
.tbody .trow > * { min-height: 0; }
.tbody .trow:nth-child(even) { background: rgba(255,255,255,.018); }
.tbody .trow:last-child { border-bottom: 0; }
.pos { text-align: center; font-weight: 900; font-size: 20px; }
.chg { font-size: 13px; font-weight: 700; text-align: left; }
.chg.up { color: var(--green); } .chg.dn { color: #ff5a52; } .chg.eq { color: var(--dim); }
.bar { height: 70%; border-radius: 3px; }
.drv { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.drv b { font-weight: 900; font-size: 21px; letter-spacing: .03em; }
.drv span { color: var(--muted); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t { font-family: var(--mono); font-size: 17px; text-align: right; color: #d9dee8; }
.t.lead { color: var(--muted); font-family: var(--sans); font-weight: 700; font-size: 15px; letter-spacing: .08em; }
.t.pb { color: var(--green); } .t.fl { color: var(--purple); }
.t.dim { color: var(--dim); }
.tyre { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.tyre i { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-weight: 900; font-size: 13px; border: 3px solid currentColor; color: var(--muted); background: #0b0e14; }
.tyre i.SOFT { color: var(--soft); } .tyre i.MEDIUM { color: var(--medium); } .tyre i.HARD { color: var(--hard); }
.tyre i.INTERMEDIATE { color: var(--inter); } .tyre i.WET { color: var(--wet); }
.tyre em { font-style: normal; font-family: var(--mono); font-size: 14px; color: var(--muted); min-width: 20px; text-align: right; }
.pits { text-align: center; font-family: var(--mono); font-size: 15px; color: var(--muted); }
.trow.out { opacity: .4; }
.trow.inpit .drv b::after { content: "PIT"; margin-left: 8px; font-size: 11px; padding: 2px 6px; border-radius: 4px; background: #fff; color: #000; vertical-align: 3px; letter-spacing: .1em; }
.trow.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: rgba(47,209,111,.25); } to { background: transparent; } }

/* side column */
.side { flex: 1; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.card h3 { margin: 0 0 8px; font-size: 13px; letter-spacing: .16em; color: var(--dim); font-weight: 700; text-transform: uppercase; }
.status { padding: 16px 18px; display: flex; align-items: center; gap: 14px; }
.status .flagbox { width: 58px; height: 42px; border-radius: 6px; flex: none; }
.status .flagbox.GREEN { background: var(--green); }
.status .flagbox.YELLOW, .status .flagbox.SC, .status .flagbox.VSC, .status .flagbox.SC_ENDING, .status .flagbox.VSC_ENDING { background: var(--yellow); }
.status .flagbox.RED { background: var(--red); }
.status .flagbox.CHEQUERED { background: repeating-conic-gradient(#fff 0 25%, #111 0 50%) 0 0 / 14px 14px; }
.status .st-main { font-size: 26px; font-weight: 900; line-height: 1; }
.status .st-sub { color: var(--muted); font-size: 15px; margin-top: 4px; }
.fl { display: flex; align-items: center; gap: 12px; }
.fl .bar { width: 6px; height: 38px; }
.fl .who { font-size: 24px; font-weight: 900; }
.fl .time { margin-left: auto; font-family: var(--mono); font-size: 26px; color: var(--purple); }
.rc { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.rc ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; overflow: hidden; }
.rc li { display: grid; grid-template-columns: 46px 1fr; gap: 10px; font-size: 15px; line-height: 1.25; padding-bottom: 8px; border-bottom: 1px solid #1a202b; }
.rc li:last-child { border-bottom: 0; }
.rc .lp { font-family: var(--mono); color: var(--dim); font-size: 13px; padding-top: 2px; }
.rc li.f-YELLOW .tx, .rc li.f-DOUBLE.YELLOW .tx, .rc li.c-SafetyCar .tx { color: var(--yellow); }
.rc li.f-RED .tx { color: #ff6b63; }
.rc li.f-GREEN .tx { color: var(--green); }
.rc li.c-Other .tx { color: #c7cdd9; }
.wx { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.wx div { display: flex; flex-direction: column; }
.wx b { font-size: 24px; font-weight: 700; }
.wx span { font-size: 12px; color: var(--dim); letter-spacing: .12em; text-transform: uppercase; }

/* pre-race */
.pre-left { width: 812px; display: flex; flex-direction: column; gap: 14px; }
.hero { background: linear-gradient(135deg, #1b0f12 0%, #11151d 55%); border: 1px solid var(--line); border-radius: 12px; padding: 22px 26px; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 260px; height: 260px; border-radius: 50%; border: 26px solid rgba(225,6,0,.12); }
.kicker { color: var(--red); font-weight: 900; letter-spacing: .2em; font-size: 15px; }
.hero h1 { margin: 4px 0 0; font-size: 46px; line-height: 1.02; font-weight: 900; text-transform: uppercase; }
.hero .where { color: var(--muted); font-size: 19px; margin-top: 4px; }
.count { display: flex; gap: 14px; margin-top: 18px; align-items: flex-end; }
.count .u { background: #0b0e14; border: 1px solid var(--line); border-radius: 10px; width: 118px; padding: 8px 0 6px; text-align: center; }
.count .u b { display: block; font-family: var(--mono); font-size: 56px; line-height: 1; }
.count .u span { font-size: 12px; letter-spacing: .2em; color: var(--dim); }
.count .to { margin-left: 8px; color: var(--muted); font-size: 18px; line-height: 1.25; padding-bottom: 6px; }
.count .to strong { color: var(--text); display: block; font-size: 24px; }
.sched { flex: 1; min-height: 0; }
.sched ul { list-style: none; margin: 0; padding: 0; }
.sched li { display: grid; grid-template-columns: 1fr 160px 140px; align-items: center; padding: 9px 4px; border-bottom: 1px solid #1a202b; font-size: 19px; }
.sched li:last-child { border-bottom: 0; }
.sched li .nm { font-weight: 700; }
.sched li .dy { color: var(--muted); }
.sched li .tm { text-align: right; font-family: var(--mono); font-size: 18px; }
.sched li.done { color: var(--dim); } .sched li.done .dy, .sched li.done .tm { color: var(--dim); }
.sched li.next { color: #fff; } .sched li.next .nm::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--red); margin-right: 10px; vertical-align: 3px; }
.sched li.race .nm { color: var(--red); }
.lastrace { display: flex; align-items: center; gap: 14px; padding: 12px 16px; }
.lastrace .lbl { color: var(--dim); font-size: 13px; letter-spacing: .14em; font-weight: 700; }
.lastrace .pod { display: flex; gap: 16px; margin-left: auto; font-size: 18px; }
.lastrace .pod span { display: flex; align-items: center; gap: 6px; }
.lastrace .pod i { width: 4px; height: 20px; border-radius: 2px; display: inline-block; }
.notice { background: rgba(255,212,0,.08); border: 1px solid rgba(255,212,0,.35); color: #ffe680; border-radius: 10px; padding: 10px 14px; font-size: 15px; }

/* standings */
.stand { display: flex; flex-direction: column; min-height: 0; }
.stand ol { list-style: none; margin: 0; padding: 0; }
.stand li { display: grid; grid-template-columns: 28px 5px 1fr auto; gap: 10px; align-items: center; padding: 4px 0; font-size: 18px; border-bottom: 1px solid #1a202b; }
.stand li:last-child { border-bottom: 0; }
.stand li .p { color: var(--muted); font-weight: 700; text-align: right; }
.stand li .c { height: 20px; border-radius: 2px; }
.stand li .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stand li .n b { font-weight: 700; }
.stand li .n small { color: var(--dim); font-size: 14px; margin-left: 6px; }
.stand li .pts { font-family: var(--mono); font-size: 17px; }
.stand.compact li { font-size: 16px; padding: 2px 0; }
.stand.compact li .c { height: 16px; }
.stand.compact li .pts { font-size: 15px; }

/* results */
.res .trow { grid-template-columns: 46px 40px 6px 1fr 190px 130px 60px; }
.res .tbody .trow { font-size: 18px; }
.team { color: var(--muted); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pts { text-align: right; font-family: var(--mono); font-weight: 700; }
.pts.z { color: var(--dim); font-weight: 500; }
.p1 .pos { color: #ffd76a; } .p2 .pos { color: #d6dbe4; } .p3 .pos { color: #e0a36a; }
.champ { background: linear-gradient(135deg, #2a2108, #11151d 70%); border-color: #5a4a14; }
.champ .kicker { color: #ffd76a; }
.champ .cname { font-size: 38px; font-weight: 900; line-height: 1.05; text-transform: uppercase; margin-top: 4px; }
.champ .cline { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 17px; margin-top: 4px; }
.champ .cline i { width: 5px; height: 18px; border-radius: 2px; }
.champ .cteam { margin-top: 10px; padding-top: 10px; border-top: 1px solid #3a3216; font-size: 18px; }
.champ .cteam b { font-weight: 900; }
.nextmini { display: flex; align-items: center; gap: 12px; }
.nextmini .nm { font-weight: 900; font-size: 20px; text-transform: uppercase; line-height: 1.1; }
.nextmini .sub { color: var(--muted); font-size: 15px; }
.nextmini .cd { margin-left: auto; font-family: var(--mono); font-size: 24px; text-align: right; }
.nextmini .cd small { display: block; font-family: var(--sans); color: var(--dim); font-size: 12px; letter-spacing: .14em; }
