:root {
  color-scheme: dark;
  --page: #0b0b12;
  --surface: #13131e;
  --raised: #191925;
  --line: #2e2d40;
  --text: #f2f0fa;
  --muted: #aaa8bf;
  --purple: #b29aff;
  --purple-hover: #c5b2ff;
  --mint: #50dbc9;
  --pink: #f49bc8;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
html { scroll-padding-top: 6rem; }
body {
  display: flex; flex-direction: column; min-height: 100vh; margin: 0;
  background: var(--page); color: var(--text); font: 1rem/1.55 system-ui, sans-serif;
}
::selection { background: #713e69; color: #fff; }
a { color: var(--purple); text-underline-offset: .2em; }
a:hover { color: var(--purple-hover); }
:focus-visible { outline: 2px solid var(--purple); outline-offset: 4px; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3 { line-height: 1.12; }

.inner, main { width: min(100%, 73rem); margin-inline: auto; padding-inline: clamp(1rem, 4vw, 2.25rem); }
.topbar { position: sticky; top: 0; z-index: 2; border-bottom: 1px solid var(--line); background: var(--page); }
.topbar .inner { display: flex; align-items: center; justify-content: space-between; min-height: 4.25rem; gap: .2rem 1rem; }
.brand { display: inline-flex; align-items: center; gap: .65rem; color: var(--text); font-size: .95rem; font-weight: 800; text-decoration: none; }
.brand svg { width: 1.85rem; height: 1.85rem; flex: none; }
.brand small { color: var(--muted); font-weight: 600; font-size: .875rem; }
.nav { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem 1.3rem; }
.nav a {
  display: inline-flex; align-items: center; min-height: 2.75rem;
  color: var(--muted); font-size: .925rem; font-weight: 650; text-decoration: none;
}
.nav a:hover, .nav a.nav-current { color: var(--text); }
.nav .nav-panel { padding: .15rem .75rem; border: 1px solid var(--line); border-radius: .45rem; }
.nav .nav-panel:hover { border-color: var(--purple); }
main { flex: 1; padding-bottom: 3rem; }
footer { border-top: 1px solid var(--line); }
footer .inner { display: flex; flex-wrap: wrap; gap: .6rem 1rem; padding-block: 1.15rem; color: var(--muted); font-size: .875rem; }
footer a { color: inherit; }
footer .sep { flex: 1; }

.race-hero { padding-block: clamp(2.2rem, 6vw, 4.6rem) clamp(1.7rem, 4vw, 2.9rem); border-bottom: 1px solid var(--line); }
.race-hero h1 {
  max-width: 100%; font-size: clamp(2.15rem, 6vw, 4.5rem); font-weight: 790;
  letter-spacing: -.065em; overflow-wrap: anywhere;
}
.race-hero h1 span { color: var(--purple); }
.race-hero p { max-width: 48ch; margin-top: .75rem; color: var(--muted); font-size: clamp(1rem, 2vw, 1.125rem); }
.race-hero::before {
  content: ""; display: block; width: 2.25rem; height: 3px; margin-bottom: .85rem; border-radius: 2px;
  background: linear-gradient(90deg, var(--mint), var(--purple) 55%, var(--pink));
}
.race-event {
  display: flex; flex-wrap: wrap; gap: .25rem .8rem; align-items: baseline; margin-top: 1.3rem;
  padding: .8rem 1rem; border: 1px solid var(--line); border-radius: .6rem;
  background: var(--surface); color: var(--text); text-decoration: none;
}
.race-event span { color: var(--muted); }
.race-event:hover { border-color: var(--purple); }

.race-section-head {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .75rem 1.35rem;
  margin-block: 1.75rem .85rem;
}
.race-section-head h2, .race-guide h2 { font-size: clamp(1.3rem, 3vw, 1.6rem); font-weight: 740; letter-spacing: -.022em; }
.race-tools { display: flex; flex-wrap: wrap; gap: .55rem; }
.race-tools input {
  width: 16rem; min-width: 0; min-height: 2.75rem; padding: .45rem .75rem;
  border: 1px solid var(--line); border-radius: .45rem; background: var(--surface); color: var(--text);
  font: inherit; font-size: .925rem;
}
.race-tools input::placeholder { color: var(--muted); }
.race-button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 2.75rem;
  padding: .45rem .85rem; border: 1px solid transparent; border-radius: .45rem;
  background: var(--purple); color: #19102e; font: inherit; font-size: .925rem; font-weight: 740;
  text-decoration: none; cursor: pointer;
}
.race-button:hover { background: var(--purple-hover); color: #19102e; }
.race-button.secondary { background: transparent; color: var(--muted); border-color: var(--line); }
.race-button.secondary:hover { background: var(--raised); color: var(--text); border-color: var(--purple); }
.race-feedback { color: var(--mint); font-size: .925rem; }
.race-feedback:not(:empty) { margin-bottom: .6rem; }

.race-grid { border: 1px solid var(--line); border-radius: .65rem; background: var(--surface); }
.race-card {
  display: grid; grid-template-columns: minmax(10rem, .95fr) minmax(12rem, 1.25fr) auto;
  align-items: center; gap: .65rem 1.35rem; padding: 1rem clamp(.85rem, 2vw, 1.25rem); overflow-wrap: anywhere;
}
.race-card + .race-card { border-top: 1px solid var(--line); }
.race-card header { min-width: 0; display: flex; flex-wrap: wrap; align-items: flex-start; gap: .35rem .6rem; }
.race-card h3 { font-size: 1.1rem; font-weight: 770; }
.race-mode, .race-card dt { color: var(--muted); font-size: .875rem; }
.race-mode { margin-top: .22rem; }
.race-status {
  display: inline-flex; gap: .33rem; align-items: center;
  color: var(--muted); font-size: .8125rem; font-weight: 680; white-space: nowrap;
}
.race-status::before { content: ""; width: .36rem; height: .36rem; border-radius: 50%; background: currentColor; }
.online .race-status { color: var(--mint); }
.race-card dl { display: grid; grid-template-columns: minmax(0, 1fr) minmax(3.15rem, auto); gap: .85rem; }
.race-card dd { font-weight: 650; font-variant-numeric: tabular-nums; }
.race-card dd > span { color: var(--muted); font-size: .875rem; font-weight: 500; }
.race-card-actions { display: flex; justify-content: flex-end; gap: .45rem; }
.race-note, .race-cup { grid-column: 1 / -1; color: var(--muted); font-size: .9rem; }
.race-cup { display: flex; align-items: baseline; flex-wrap: wrap; column-gap: .5rem; }
.race-cup strong { color: var(--text); }
.race-offline { margin-top: .9rem; }
.race-offline summary {
  width: fit-content; padding: .55rem .7rem; min-height: 2.75rem; cursor: pointer; font-size: .925rem;
  color: var(--muted); border: 1px solid var(--line); border-radius: .45rem;
}
.race-offline summary:hover { color: var(--text); }
.race-offline[open] summary { margin-bottom: .55rem; }
.race-empty { margin-top: .55rem; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: .55rem; color: var(--muted); }
.race-guide { margin-top: 2rem; padding-top: 1.65rem; border-top: 1px solid var(--line); }
.race-guide ol { max-width: 64ch; margin: .7rem 0 0; padding-left: 1.4rem; color: var(--muted); }
.race-guide li + li { margin-top: .4rem; }
.race-guide li::marker { color: var(--purple); }
.race-guide strong, .race-guide code { color: var(--text); }
.flash { margin-top: .75rem; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: .45rem; }
.flash.err { color: var(--pink); }
.flash.ok { color: var(--mint); }

@media (max-width: 56rem) {
  .race-card { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); }
  .race-card-actions { grid-column: 1 / -1; justify-content: flex-start; flex-wrap: wrap; }
}
@media (max-width: 39rem) {
  html { scroll-padding-top: 8rem; }
  .topbar .inner { flex-wrap: wrap; justify-content: flex-start; padding-block: .45rem; }
  .nav { gap: .15rem .8rem; }
  .nav a { min-height: 2.4rem; }
  .race-tools { width: 100%; }
  .race-tools input { flex: 1 1 10rem; width: auto; }
  .race-card { grid-template-columns: minmax(0, 1fr); }
  .race-card header { justify-content: space-between; }
  .race-card dl { grid-template-columns: minmax(0, 1fr) minmax(4rem, auto); }
  footer .sep { display: none; }
}
