:root {
  color-scheme: dark;
  --bg: #08090b;
  --panel: #101216;
  --line: #292c33;
  --text: #f4f5f7;
  --muted: #a0a5b0;
  --red: #ef2636;
  --mono: ui-monospace, SFMono-Regular, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Arial, sans-serif; }
body { font-size: 14px; background-image: linear-gradient(125deg, #15171c 0, #08090b 36%, #08090b 100%); }
a { color: inherit; text-decoration: none; }
button, a { -webkit-tap-highlight-color: transparent; }
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid #c9d9f0; outline-offset: 4px; }
button { font: inherit; color: #e2e5eb; background: none; border: 0; cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.site-header { max-width: 980px; margin: auto; padding: 20px 28px; display: flex; justify-content: space-between; align-items: center; gap: 20px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark { font-size: 34px; font-weight: 950; font-style: italic; letter-spacing: -3px; }
.brand-slash { color: var(--red); margin-left: 6px; }
.brand-name { font-size: 9px; letter-spacing: 1.6px; line-height: 1.5; font-weight: 700; border-left: 1px solid #464a52; padding-left: 13px; }
.site-header nav { display: flex; gap: 24px; color: #b9bec8; font-size: 11px; font-weight: 700; }
.site-header nav span { color: var(--red); margin-left: 5px; }
.timing-shell { max-width: 820px; margin: auto; padding: 30px 24px 22px; }
.race-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 20px; }
.race-heading > div:first-child { min-width: 0; }
.eyebrow { color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: 2px; margin: 0 0 9px; }
.eyebrow span { color: var(--red); margin-right: 7px; letter-spacing: -1px; }
h1 { font-size: 31px; line-height: 1; font-weight: 950; font-style: italic; letter-spacing: -1.1px; margin: 0; }
h1 span { font-size: 19px; color: #b8bec8; letter-spacing: -.5px; }
.radio-intro { margin: 9px 0 0; color: #9da4b0; font-size: 12px; }
.session-label { margin: 10px 0 0; color: #e0e4ec; font-size: 13px; line-height: 1.4; }
.race-meta { flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.connection { display: inline-flex; align-items: center; justify-content: flex-end; gap: 7px; color: #afb6c1; font-size: 10px; font-weight: 800; line-height: 1.3; padding: 7px 9px; border: 1px solid #373c45; border-radius: 2px; }
.status-dot { width: 6px; height: 6px; flex: 0 0 auto; border-radius: 50%; background: #a0a5b0; }
.connection.live { color: #fff; background: var(--red); border-color: var(--red); letter-spacing: 1.3px; }
.connection.live .status-dot { background: #fff; box-shadow: 0 0 0 3px #ffffff24; }
.connection.stale { color: #e7c18a; border-color: #6c5739; }
.connection.stale .status-dot { background: #e7c18a; }
.race-chips { display: flex; gap: 6px; }
.chip { padding: 5px 8px; color: #e0e4eb; background: #171a20; border: 1px solid #303540; font: 700 10px/1.3 var(--mono); border-radius: 2px; }
.chip.muted { color: #a5adba; }
.tower { background: #080a0d; border: 1px solid var(--line); border-top: 3px solid var(--red); border-radius: 3px 3px 0 0; overflow: hidden; box-shadow: 0 16px 38px #0004; }
.tower-heading { min-height: 39px; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 13px; background: #181b21; border-bottom: 1px solid #313641; }
.tower-brand { display: inline-flex; align-items: center; gap: 12px; white-space: nowrap; }
.tower-brand strong { color: #fff; font-size: 22px; font-style: italic; font-weight: 950; letter-spacing: -1.5px; line-height: 1; }
.tower-brand > span { border-left: 1px solid #555b68; padding-left: 12px; color: #d8dde6; font-size: 9px; font-weight: 800; letter-spacing: 1.5px; }
.update-label { color: #a4acba; font: 9px/1.3 var(--mono); }
.table-wrap { width: 100%; overflow-x: auto; padding: 0 4px 3px; }
table { width: 100%; border-collapse: separate; border-spacing: 0 2px; table-layout: fixed; }
th { height: 28px; color: #8f98a9; font-size: 8px; font-weight: 800; letter-spacing: 1.1px; text-align: left; }
td { height: 44px; padding: 4px 0; background: #14171d; font: 700 12px/1.3 var(--mono); vertical-align: middle; }
tbody tr:nth-child(even) td { background: #101318; }
tbody tr.leader td { background: #1c181d; }
.position-cell { width: 43px; padding-left: 7px; }
td.position-cell { border-left: 2px solid #383d48; }
.leader td.position-cell { border-left-color: var(--red); }
.position { display: inline-block; min-width: 26px; color: #f4f5f8; font: 950 18px/30px Arial,sans-serif; text-align: center; font-style: italic; }
.leader .position { background: var(--red); color: #fff; border-radius: 2px; }
.driver-cell { width: auto; padding-right: 9px; }
.driver-identity { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.driver-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 3px 4px; min-width: 0; }
.driver-code { flex: 0 0 auto; color: #f6f7fa; font: 900 17px/19px Arial,sans-serif; letter-spacing: 1.1px; }
.driver-name { display: block; min-width: 0; max-width: 100%; color: #c4cbd6; font: 500 12px/15px Arial,sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-badge { display: inline-block; color: #ebc68d; background: #383024; border-radius: 2px; padding: 2px 4px; font: 800 9px/1.2 Arial,sans-serif; letter-spacing: .3px; white-space: nowrap; flex: 0 0 auto; }
.row-badge.finished { color: #acd3bf; background: #23352c; }
.row-badge.pit { background: #f1bf43; color: #111218; padding: 3px 5px; font-size: 10px; font-weight: 900; }
.row-badge.pit-count { color: #d7dfed; background: #2b3444; }
.row-badge.time-penalty { color: #ffdb96; background: #49351b; }
.gap-cell { width: 94px; padding-right: 10px; text-align: right; }
.gap { color: #f0f2f6; font-variant-numeric: tabular-nums; }
.gap.leader-gap { color: #e59b9f; font-size: 9px; letter-spacing: .3px; }
.lap-cell { width: 41px; text-align: center; color: #d1d7e1; }
.tyre-cell { width: 57px; text-align: center; }
.time-cell { width: 110px; padding-right: 9px; text-align: right; }
.time { color: #aeb8c8; font-variant-numeric: tabular-nums; }
.unknown { color: #929aaa; }
.tyre { display: inline-flex; align-items: center; gap: 4px; color: #d0d5df; font-size: 10px; }
.tyre-dot { display: inline-block; height: 12px; width: 12px; border: 2px solid #dedfdc; border-radius: 50%; }
.tyre.inter .tyre-dot { border-color: #64d791; }
.tyre.wet .tyre-dot { border-color: #7faff6; }
.tower-note { margin: 0; padding: 10px 13px; color: #98a0ae; background: #11141a; border-top: 1px solid #292e38; font-size: 10px; line-height: 1.5; }
.empty-state { text-align: center; padding: 38px 20px 44px; }
.empty-number { color: #333b48; font: 900 italic 62px/1 var(--mono); letter-spacing: -7px; }
.empty-state h2 { font-size: 16px; margin: 17px 0 10px; }
.empty-state p { color: #a8b1c0; font-size: 12px; line-height: 1.7; max-width: 330px; margin: auto; }
.empty-state[hidden], [data-ers-music-panel] [hidden] { display: none !important; }
.music-card { margin-top: 20px; padding: 20px; border: 1px solid #2b313c; border-top: 2px solid #596271; background: #10141a; display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; border-radius: 3px; }
.music-card h2 { margin: 0; font-size: 17px; }
.music-card p:not(.eyebrow) { color: #b1bac8; font-size: 12px; line-height: 1.6; margin: 8px 0 0; }
.music-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.music-controls button { border: 1px solid #7a879b; border-radius: 3px; min-height: 46px; padding: 11px 16px; color: #fff; font-size: 12px; font-weight: 700; }
.music-volume { display: flex; align-items: center; gap: 10px; color: #b5bece; font-size: 11px; }
.music-volume input { accent-color: var(--red); min-height: 40px; width: 130px; }
.music-message, .ers-radio-note { flex-basis: 100%; }
.ers-radio-source { display: flex; flex-direction: column; gap: 6px; min-width: 0; color: #b5bece; font-size: 11px; }
.ers-radio-source select { min-height: 46px; max-width: 100%; color: #f2f4f7; background: #171e29; border: 1px solid #637087; border-radius: 3px; font: inherit; padding: 10px; }
.ers-radio-note a { color: #e0e7f2; text-decoration: underline; text-underline-offset: 3px; }
.timing-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; color: #98a2b2; font-size: 9px; letter-spacing: .4px; }
.timing-footer strong { color: #d3dbe7; margin-right: 5px; font-style: italic; }
.timing-footer button { min-height: 44px; font-size: 10px; padding: 8px 0 8px 10px; }
.timing-footer button span { font-size: 16px; margin-left: 5px; }
.stream-view .site-header, .stream-view .music-card, .stream-view .timing-footer, .stream-view .tower-note { display: none; }
.stream-view .timing-shell { max-width: 760px; margin: 0; padding: 18px 22px; }
.stream-view .race-heading { margin-bottom: 14px; }
.stream-view .radio-intro { display: none; }
.stream-view td { height: 40px; padding-top: 2px; padding-bottom: 2px; }
.stream-view .driver-code { font-size: 16px; line-height: 18px; }
.stream-view .driver-name { font-size: 11px; line-height: 14px; }
.stream-view .empty-state { min-height: 350px; }
@media (max-width: 700px) {
  .site-header { padding: 16px; gap: 14px; }
  .brand-mark { font-size: 30px; }
  .brand-name { font-size: 8px; padding-left: 10px; }
  .site-header nav { gap: 12px; font-size: 10px; }
  .home-link { display: none; }
  .timing-shell, .stream-view .timing-shell { padding: 22px 12px 16px; }
  .race-heading { flex-direction: column; align-items: flex-start; gap: 13px; margin-bottom: 16px; }
  h1 { font-size: 28px; }
  h1 span { font-size: 17px; }
  .race-meta { width: 100%; flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
  .connection { justify-content: flex-start; font-size: 9px; }
  .chip { font-size: 9px; padding: 5px 6px; }
  .tower-heading { padding-right: 10px; padding-left: 10px; }
  .tower-brand { gap: 8px; }
  .tower-brand strong { font-size: 21px; }
  .tower-brand > span { padding-left: 8px; font-size: 8px; letter-spacing: 1px; }
  .update-label { font-size: 8px; }
  .table-wrap { padding-right: 2px; padding-left: 2px; }
  th { font-size: 8px; letter-spacing: .7px; height: 26px; }
  td { height: 42px; font-size: 11px; }
  .position-cell { width: 39px; padding-left: 5px; }
  .position { min-width: 24px; font-size: 17px; line-height: 28px; }
  .driver-cell { padding-right: 5px; }
  .driver-code { font-size: 16px; line-height: 18px; letter-spacing: .7px; }
  .driver-name { font-size: 11px; line-height: 14px; }
  .gap-cell { width: 82px; padding-right: 6px; }
  .lap-cell { width: 34px; }
  .tyre-cell { display: table-cell; width: 48px; }
  .time-cell { display: none; }
  .tyre-dot { height: 11px; width: 11px; }
  .music-card { padding: 16px; gap: 16px; }
  .music-controls { gap: 12px; }
  .timing-footer > span:nth-child(2) { display: none; }
}
@media (max-width: 520px) {
  .ers-radio-source { width: 100%; }
  .music-controls { width: 100%; }
}
@media (max-width: 380px) {
  .timing-shell, .stream-view .timing-shell { padding-right: 8px; padding-left: 8px; }
  .position-cell { width: 36px; padding-left: 4px; }
  .gap-cell { width: 76px; }
  .lap-cell { width: 30px; }
  .tyre-cell { width: 44px; }
  .music-card { padding: 12px; }
  .timing-footer { font-size: 8px; gap: 8px; }
}
@media (prefers-reduced-motion: no-preference) {
  .connection.live .status-dot { animation: livePulse 1.4s ease-in-out infinite; }
  @keyframes livePulse { 50% { opacity: .45; box-shadow: 0 0 0 1px #ffffff15; } }
}
