:root {
  --ink: #101820;
  --muted: #65717c;
  --paper: #f6f4ef;
  --surface: #ffffff;
  --line: #d9ddd9;
  --red: #c82e2e;
  --red-dark: #9f2024;
  --green: #16745b;
  --gold: #d9a928;
  --shadow: 0 10px 28px rgba(16, 24, 32, .07);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--paper); }
a { color: inherit; }
button, input { font: inherit; }

.skip-link {
  position: fixed; left: 1rem; top: -4rem; z-index: 20;
  padding: .65rem 1rem; color: #fff; background: var(--ink); border-radius: .35rem;
}
.skip-link:focus { top: 1rem; }

.site-header {
  position: sticky; top: 0; z-index: 10;
  background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.header-rule { height: 4px; background: linear-gradient(90deg, var(--red) 0 33%, #fff 33% 66%, #1b5c9b 66%); }
.header-inner {
  width: min(1180px, calc(100% - 2rem)); min-height: 70px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr auto auto; gap: 1.25rem; align-items: center;
}
.brand { display: inline-flex; align-items: center; gap: .75rem; width: max-content; text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 38px; height: 38px;
  color: white; background: var(--red); border-radius: 50%;
  font-size: .78rem; font-weight: 900; letter-spacing: -.02em;
  box-shadow: inset 0 0 0 3px #fff, 0 0 0 1px var(--red);
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: .95rem; letter-spacing: .01em; }
.brand small { margin-top: .1rem; color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .14em; }

.view-nav {
  display: flex; gap: .35rem; padding: .35rem;
  background: var(--ink); border: 2px solid #fff; border-radius: .72rem;
  box-shadow: 0 3px 0 rgba(16,24,32,.28), 0 7px 18px rgba(16,24,32,.14);
}
.view-nav a {
  min-width: 84px; padding: .72rem 1.05rem; border-radius: .46rem;
  text-align: center; text-decoration: none; color: #fff; font-size: .95rem; font-weight: 900;
  letter-spacing: .025em; transition: color .12s, background .12s, transform .12s;
}
.view-nav a:hover { color: var(--ink); background: #f0c64d; }
.view-nav a:focus-visible { outline: 3px solid #f0c64d; outline-offset: 2px; }
.view-nav a[aria-current="page"] {
  color: #fff; background: var(--red);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.28), 0 2px 0 var(--red-dark);
}

.update-button {
  min-width: 96px; padding: .68rem 1rem; border: 0; border-radius: .48rem;
  display: inline-flex; justify-content: center; align-items: center; gap: .45rem;
  color: #fff; background: var(--red); cursor: pointer; font-weight: 800;
  box-shadow: 0 3px 0 var(--red-dark); transition: transform .12s, background .12s;
}
.update-button:hover { background: #b9282c; }
.update-button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--red-dark); }
.update-button:disabled { opacity: .65; cursor: wait; }
.update-button.is-loading .update-icon { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.shell { width: min(1180px, calc(100% - 2rem)); margin: 0 auto; }
.event-hero {
  padding: clamp(2.2rem, 6vw, 4.6rem) 0 2rem;
  display: grid; grid-template-columns: 1fr auto; gap: 2rem; align-items: end;
}
.eyebrow { margin: 0 0 .55rem; color: var(--red); font-size: .72rem; font-weight: 900; text-transform: uppercase; letter-spacing: .19em; }
h1 { margin: 0; font-size: clamp(2rem, 5vw, 4.15rem); line-height: .98; letter-spacing: -.055em; }
.event-name { margin: .85rem 0 0; color: var(--muted); font-size: clamp(.9rem, 2vw, 1.05rem); }
.event-stats { display: flex; margin: 0; border: 1px solid var(--line); border-radius: .65rem; background: rgba(255,255,255,.65); overflow: hidden; }
.event-stats div { min-width: 100px; padding: .8rem 1rem; border-left: 1px solid var(--line); }
.event-stats div:first-child { border-left: 0; }
.event-stats dt { margin-bottom: .25rem; color: var(--muted); font-size: .64rem; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; }
.event-stats dd { margin: 0; font-size: .9rem; font-weight: 850; font-variant-numeric: tabular-nums; }
.event-stats a { text-decoration: none; }

.status-line {
  min-height: 42px; padding: .65rem .9rem; margin-bottom: 1rem;
  display: flex; align-items: center; gap: .6rem;
  border: 1px solid var(--line); border-radius: .5rem; background: rgba(255,255,255,.65);
  color: var(--muted); font-size: .8rem;
}
.status-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 4px rgba(217,169,40,.15); }
.status-line.is-live .status-dot { background: var(--green); box-shadow: 0 0 0 4px rgba(22,116,91,.14); }
.status-line.is-error { color: #792329; border-color: #e2b8b9; background: #fff4f3; }
.status-line.is-error .status-dot { background: var(--red); box-shadow: 0 0 0 4px rgba(200,46,46,.13); }

.class-jump { margin: 1.1rem 0 1.5rem; display: flex; flex-wrap: wrap; gap: .4rem; }
.class-jump a {
  padding: .38rem .6rem; border: 1px solid var(--line); border-radius: 99px;
  background: #fff; color: #42505a; text-decoration: none; font-size: .72rem; font-weight: 850;
}
.class-jump a:hover { color: #fff; border-color: var(--red); background: var(--red); }

.results-content { padding-bottom: 2.5rem; }
.class-section, .overall-card { margin-bottom: 1.35rem; border: 1px solid var(--line); border-radius: .7rem; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.class-heading { padding: .9rem 1rem; display: flex; align-items: baseline; gap: .7rem; border-bottom: 1px solid var(--line); background: #f0f1ef; }
.class-code { color: var(--red); font-size: 1rem; font-weight: 950; letter-spacing: .03em; }
.class-name { font-size: .86rem; font-weight: 750; }
.entry-count { margin-left: auto; color: var(--muted); font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .09em; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
th { padding: .62rem .7rem; color: var(--muted); background: #fafafa; font-size: .64rem; text-align: left; text-transform: uppercase; letter-spacing: .09em; white-space: nowrap; }
td { padding: .72rem .7rem; border-top: 1px solid #eceeeb; vertical-align: middle; }
tbody tr:hover { background: #fbfaf6; }
.rank-cell { width: 56px; color: var(--muted); text-align: center; font-weight: 900; font-variant-numeric: tabular-nums; }
.place-top { color: var(--red); }
.class-pill { display: inline-block; min-width: 42px; padding: .23rem .42rem; border-radius: .28rem; color: #fff; background: var(--ink); text-align: center; font-size: .68rem; font-weight: 900; }
.number-cell { width: 54px; font-weight: 850; font-variant-numeric: tabular-nums; }
.driver-cell strong { display: block; font-size: .84rem; }
.driver-cell small { display: block; max-width: 360px; margin-top: .15rem; overflow: hidden; color: var(--muted); font-size: .7rem; text-overflow: ellipsis; white-space: nowrap; }
.time-cell { white-space: nowrap; font-weight: 900; font-variant-numeric: tabular-nums; }
.leader-time { color: var(--red); }
.gap-cell { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.gap-ahead { color: var(--green); font-weight: 850; }
.runs-cell { max-width: 320px; color: var(--muted); font-size: .72rem; font-variant-numeric: tabular-nums; }
.run { display: inline-block; margin: .1rem .28rem .1rem 0; white-space: nowrap; }
.run-invalid { color: #a64b4e; text-decoration: line-through; text-decoration-thickness: 1px; }
.dns-row { color: #8b949b; }
.empty-state { padding: 3rem 1.25rem; text-align: center; color: var(--muted); }
.empty-state strong { display: block; margin-bottom: .4rem; color: var(--ink); }

footer { padding: 1.4rem 1rem 2.4rem; border-top: 1px solid var(--line); color: var(--muted); text-align: center; font-size: .72rem; }
footer p { margin: 0; }

@media (max-width: 760px) {
  .header-inner { width: min(100% - 1rem, 1180px); min-height: 62px; grid-template-columns: 1fr auto; gap: .55rem; }
  .brand small { display: none; }
  .brand strong { font-size: .8rem; }
  .brand-mark { width: 32px; height: 32px; }
  .view-nav { grid-row: 2; grid-column: 1 / -1; margin-bottom: .5rem; justify-content: stretch; }
  .view-nav a { min-width: 0; flex: 1; padding: .68rem .8rem; font-size: .9rem; }
  .update-button { min-width: 84px; padding: .58rem .75rem; }
  .shell { width: min(100% - 1rem, 1180px); }
  .event-hero { grid-template-columns: 1fr; gap: 1.3rem; padding-top: 2rem; }
  .event-stats { width: 100%; }
  .event-stats div { min-width: 0; flex: 1; padding: .7rem; }
  .hide-mobile { display: none; }
  th, td { padding-left: .55rem; padding-right: .55rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
