:root {
  color-scheme: dark;
  --bg: #090b0f;
  --surface: #11151b;
  --surface-2: #181d25;
  --line: #29303a;
  --muted: #929ba8;
  --text: #f4f6f8;
  --red: #ff2b2b;
  --red-dark: #a90f1a;
  --cyan: #67e8f9;
  --gold: #ffd166;
  --green: #79e6ad;
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 83% 2%, rgba(255,43,43,.12), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button, select { font: inherit; }
button { color: inherit; }
a { color: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 68px;
  padding: .85rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid rgba(255,255,255,.09);
  background: rgba(9,11,15,.88);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  color: white;
  font-weight: 850;
  letter-spacing: .08em;
  text-decoration: none;
}
.brand > span:last-child { display: grid; line-height: 1.05; }
.brand strong { font-size: .83rem; letter-spacing: .12em; }
.brand small { margin-top: .2rem; color: var(--muted); font-size: .59rem; letter-spacing: .16em; }
.brand-mark { display: grid; grid-template-columns: repeat(2, 12px); grid-template-rows: repeat(2, 12px); overflow: hidden; border-radius: 4px; transform: skewX(-8deg); }
.brand-mark i:nth-child(1), .brand-mark i:nth-child(4) { background: white; }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(3) { background: var(--red); }

.timezone-control { display: flex; align-items: center; gap: .7rem; }
.timezone-control label { color: var(--muted); font-size: .83rem; }
select {
  max-width: 230px;
  padding: .6rem 2.3rem .6rem .8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #12161c;
  color: var(--text);
}

main, footer { width: min(1380px, calc(100% - 2rem)); margin-inline: auto; }

.race-control {
  display: grid;
  grid-template-columns: minmax(300px, .6fr) minmax(640px, 1.4fr);
  column-gap: clamp(2rem, 6vw, 6rem);
  row-gap: 2.25rem;
  align-items: end;
  min-height: 475px;
  padding: clamp(4rem, 8vw, 8rem) clamp(.4rem, 2vw, 1.5rem) 4rem;
}
.hero-heading { grid-column: 1 / -1; }
.season-copy { align-self: start; }
.eyebrow {
  margin: 0 0 .85rem;
  color: var(--red);
  font-size: .75rem;
  font-weight: 850;
  letter-spacing: .14em;
}
h1 {
  margin: 0;
  font-size: clamp(3.15rem, 6.8vw, 6.9rem);
  font-weight: 900;
  letter-spacing: -.065em;
  line-height: .82;
  text-transform: uppercase;
}
.hero-heading h1 { white-space: nowrap; }
h1 span { color: transparent; -webkit-text-stroke: 1.5px rgba(255,255,255,.7); }
.season-intro { max-width: 650px; margin: 2rem 0 0; color: #b7bec8; font-size: clamp(1rem, 1.5vw, 1.2rem); }
.timezone-status { display: inline-flex; align-items: center; gap: .45rem; margin: 1.2rem 0 0; color: var(--muted); font-size: .83rem; }
.timezone-status strong { color: var(--text); }
.timezone-detected { color: var(--muted); }
.timezone-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(121,230,173,.12); }

.next-race {
  overflow: hidden;
  position: relative;
  min-height: 0;
  padding: 0;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 26px;
  background: linear-gradient(145deg, #181d25, #0f1217 67%);
  box-shadow: 0 35px 80px rgba(0,0,0,.35);
}
.next-race { padding-bottom: 1.2rem; }
.next-race > :not(.countdown-tabs) { margin-right: 1.25rem; margin-left: 1.25rem; }
.next-race::after {
  content: "";
  position: absolute;
  inset: auto -5% -35% 25%;
  height: 190px;
  opacity: .09;
  transform: skewX(-22deg);
  background: repeating-linear-gradient(90deg, white 0 18px, transparent 18px 36px);
}
.countdown-tabs { display: grid; grid-template-columns: repeat(var(--countdown-tab-count), minmax(0, 1fr)); gap: .2rem; position: relative; z-index: 2; margin: 0 0 .75rem; padding: .35rem .35rem 0; border-bottom: 1px solid var(--line); background: #0d1015; }
.countdown-tab { min-width: 0; cursor: pointer; padding: .38rem .12rem .42rem; border: 1px solid transparent; border-bottom: 0; border-radius: 10px 10px 0 0; background: #151a21; color: var(--muted); font-size: .62rem; font-weight: 800; letter-spacing: .02em; line-height: 1.2; text-align: center; transition: background .2s, border-color .2s, color .2s; }
.countdown-tab:hover { background: #1b222b; color: var(--text); }
.countdown-tab.active { position: relative; z-index: 1; border-color: #3b4551; background: #181d25; color: white; }
.countdown-tab.active::after { content: ""; position: absolute; right: 0; bottom: -1px; left: 0; height: 1px; background: #181d25; }
.next-race-top { display: flex; justify-content: space-between; gap: 1rem; align-items: center; position: relative; z-index: 1; }
.live-label { display: inline-flex; align-items: center; gap: .5rem; color: var(--green); font-size: .78rem; font-weight: 800; letter-spacing: .1em; }
.live-label::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 5px rgba(121,230,173,.12); }
.round-label { color: var(--muted); font-size: .8rem; font-weight: 750; }
.next-race h2 { margin: 1.05rem 0 .3rem; font-size: clamp(1.8rem, 3.1vw, 2.65rem); line-height: .98; letter-spacing: -.04em; position: relative; z-index: 1; }
.next-location { margin: 0; color: var(--muted); position: relative; z-index: 1; }
.countdown { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-top: 1.2rem; position: relative; z-index: 1; }
.next-start { margin: .6rem 0 0; color: var(--muted); font-size: .86rem; position: relative; z-index: 1; }
.next-start strong { color: var(--text); }
.next-start span { display: inline-block; margin-left: .35rem; }
.next-relative { color: var(--cyan); font-weight: 800; }
.next-track-time { position: relative; z-index: 1; margin: .35rem 0 0; color: var(--muted); font-size: .78rem; }
.next-track-time strong { color: #dce1e7; }
.countdown-cell { padding: .7rem .4rem; border-top: 1px solid var(--line); }
.countdown-number { display: block; color: white; font-size: clamp(2.25rem, 4.6vw, 3.5rem); font-weight: 900; letter-spacing: -.06em; font-variant-numeric: tabular-nums; }
.countdown-label { display: block; color: var(--muted); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }

.controls {
  position: sticky;
  top: 68px;
  z-index: 15;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .8rem 0;
  background: rgba(9,11,15,.94);
  backdrop-filter: blur(14px);
}
.filter-group { display: flex; gap: .5rem; overflow-x: auto; padding: .2rem; }
.filter, .jump-next {
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  padding: .67rem 1rem;
  transition: border-color .2s, background .2s, transform .2s;
}
.filter span { margin-left: .35rem; color: var(--muted); }
.filter:hover, .jump-next:hover { border-color: #596474; transform: translateY(-1px); }
.filter.active { border-color: var(--red); background: var(--red); color: white; }
.filter.active span { color: white; }
.schedule-actions { display: flex; align-items: center; gap: .75rem; }
.track-time-toggle { display: inline-flex; align-items: center; gap: .45rem; color: var(--muted); font-size: .8rem; cursor: pointer; white-space: nowrap; }
.track-time-toggle input { accent-color: var(--red); }
.jump-next { border-radius: 10px; border-color: #46505d; }

.calendar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  padding: 1.25rem 0 5rem;
}
.race-card {
  scroll-margin-top: 145px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color .25s, transform .25s, box-shadow .25s;
}
.race-card:hover { border-color: #444e5c; transform: translateY(-3px); box-shadow: 0 18px 40px rgba(0,0,0,.25); }
.race-card.next { border-color: rgba(255,43,43,.72); box-shadow: 0 0 0 1px rgba(255,43,43,.2), 0 20px 55px rgba(169,15,26,.14); }
.card-head { padding: 1.15rem 1.15rem .9rem; }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.round { color: var(--red); font-size: .73rem; font-weight: 850; letter-spacing: .1em; }
.status { padding: .25rem .55rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .7rem; font-weight: 750; }
.status.upcoming { background: rgba(103,232,249,.1); color: var(--cyan); }
.status.next { background: rgba(255,43,43,.13); color: #ff8080; }
.card-title-row { display: grid; grid-template-columns: 1fr auto; gap: .75rem; align-items: start; margin-top: 1.5rem; }
.card-title-row h2 { margin: 0; font-size: 1.45rem; letter-spacing: -.035em; line-height: 1.05; }
.flag { font-size: 1.7rem; line-height: 1; }
.circuit { margin: .5rem 0 0; color: var(--muted); font-size: .85rem; }

.sessions { margin: 0; padding: 0 1.15rem .9rem; list-style: none; }
.session { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .75rem; padding: .72rem 0; border-top: 1px solid rgba(255,255,255,.07); }
.session-name { font-size: .86rem; color: #c7cdd5; }
.session-name.sprint { color: var(--gold); }
.session-name.race { color: white; font-weight: 800; }
.session-time { text-align: right; }
.session-relative { display: block; min-height: 1.05em; color: var(--cyan); font-size: .66rem; font-weight: 800; letter-spacing: .04em; }
.session-day { display: block; color: var(--muted); font-size: .7rem; }
.session-clock { display: block; font-size: .9rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.track-time { display: block; margin-top: .16rem; color: #8d98a5; font-size: .66rem; font-variant-numeric: tabular-nums; }

.recap-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: .95rem 1.15rem;
  border: 0;
  border-top: 1px solid var(--line);
  background: #151a21;
  text-align: left;
  font-weight: 760;
}
.recap-toggle[aria-controls]::after { content: "+"; color: var(--red); font-size: 1.3rem; }
.recap-toggle[aria-expanded="true"]::after { content: "−"; }
.official-event-link { text-decoration: none; }
.recap { padding: 1.15rem; border-top: 1px solid var(--line); background: #0e1116; }
.recap[hidden] { display: none; }
.podium { display: grid; grid-template-columns: 1.15fr 1fr 1fr; gap: .5rem; margin-bottom: 1rem; }
.podium-place { padding: .7rem; border-radius: 10px; background: var(--surface-2); }
.podium-place strong, .podium-place span { display: block; }
.podium-place strong { color: var(--red); font-size: .68rem; letter-spacing: .08em; }
.podium-place span { margin-top: .25rem; font-size: .77rem; font-weight: 700; }
.recap p { margin: 0; color: #b5bdc8; font-size: .87rem; }
.session-results { margin-top: 1.1rem; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.results-heading { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; padding: .8rem .9rem; background: #171c23; }
.results-heading span { color: white; font-size: .7rem; font-weight: 850; letter-spacing: .1em; }
.results-heading small { color: var(--muted); font-size: .67rem; }
.result-session { border-top: 1px solid var(--line); background: #10141a; }
.result-session summary { display: grid; grid-template-columns: 1fr minmax(0, 1.2fr); gap: .75rem; align-items: center; padding: .78rem .9rem; cursor: pointer; list-style: none; font-size: .78rem; font-weight: 760; }
.result-session summary::-webkit-details-marker { display: none; }
.result-session summary::after { content: "+"; color: var(--red); grid-column: 3; }
.result-session[open] summary::after { content: "−"; }
.result-winner { overflow: hidden; color: #c7cdd5; font-weight: 650; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.result-top-three { margin: 0; padding: .1rem 1rem .55rem 2.6rem; color: #dce1e7; font-size: .78rem; }
.result-top-three li { padding: .25rem 0 .25rem .2rem; }
.result-top-three li::marker { color: var(--red); font-weight: 850; }
.classification-link { display: inline-block; margin: 0 .9rem .85rem; color: var(--muted); font-size: .72rem; text-underline-offset: 3px; }
.recap-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-top: 1rem; }
.highlight-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: .65rem .85rem;
  border-radius: 9px;
  background: var(--red);
  color: white;
  font-size: .78rem;
  font-weight: 820;
  text-decoration: none;
  transition: transform .18s ease, background .18s ease;
}
.highlight-link:hover { background: #ff2d3d; transform: translateY(-1px); }
.official-link { color: white; font-size: .8rem; font-weight: 760; text-underline-offset: 4px; }

.data-note {
  display: grid;
  grid-template-columns: .75fr 1.25fr;
  gap: clamp(2rem, 6vw, 6rem);
  align-items: start;
  margin-bottom: 5rem;
  padding: clamp(1.5rem, 4vw, 3rem);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(145deg, #151920, #0f1217);
}
.data-note h2 { margin: 0; font-size: clamp(2rem, 4vw, 3.4rem); line-height: 1; letter-spacing: -.045em; }
.data-note > p { margin: 0; color: #b3bbc6; font-size: 1.02rem; }
footer { display: flex; justify-content: space-between; gap: 2rem; padding: 2rem 0 3rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .76rem; }
footer strong { color: var(--text); }
footer p { max-width: 700px; margin: .35rem 0 0; }
.footer-meta { display: flex; flex-wrap: wrap; justify-content: flex-end; align-content: start; gap: .8rem 1rem; text-align: right; }
.footer-meta a { color: var(--text); text-underline-offset: 3px; }

.legal-page { width: min(820px, calc(100% - 2rem)); margin: 0 auto; padding: clamp(3rem, 8vw, 7rem) 0; }
.legal-page h1 { font-size: clamp(2.5rem, 7vw, 5rem); line-height: .92; }
.legal-page h2 { margin: 2.4rem 0 .7rem; font-size: 1.25rem; }
.legal-page p, .legal-page li { color: #b7bec8; }
.legal-page a { text-underline-offset: 3px; }
.legal-back { display: inline-block; margin-bottom: 2rem; color: var(--text); font-weight: 750; }

@media (max-width: 1180px) {
  .race-control { grid-template-columns: 1fr; padding-top: 5rem; }
  .hero-heading { grid-column: auto; }
  .hero-heading h1 { white-space: normal; }
  .next-race { max-width: 760px; }
  .calendar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .topbar { align-items: flex-start; }
  .brand { font-size: .78rem; }
  .brand-mark { grid-template-columns: repeat(2, 10px); grid-template-rows: repeat(2, 10px); }
  .timezone-control { align-items: flex-end; flex-direction: column; gap: .25rem; }
  .timezone-control label { font-size: .68rem; }
  select { max-width: 155px; font-size: .78rem; }
  main, footer { width: min(100% - 1.1rem, 1380px); }
  .race-control { min-height: auto; padding: 4rem .15rem 2.5rem; }
  .season-intro { margin-top: 1.5rem; }
  .next-race > :not(.countdown-tabs) { margin-right: 1.15rem; margin-left: 1.15rem; }
  .controls { align-items: stretch; flex-direction: column; top: 67px; }
  .filter-group { width: 100%; }
  .schedule-actions { justify-content: space-between; }
  .calendar { grid-template-columns: 1fr; padding-top: .5rem; }
  .data-note { grid-template-columns: 1fr; }
  footer { flex-direction: column; gap: 1rem; }
  .footer-meta { justify-content: flex-start; text-align: left; }
}

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