:root {
  --primary: #C6007E;
  --primary-dark: #8A0058;
  --primary-dimmed: #F9EFF6;
  --secondary: #06038D;
  --secondary-dark: #020057;
  --alert: #FFED24;
  --text: #242424;
  --muted: #7C7C7C;
  --line: #E1E1E1;
  --bg: #FFFFFF;
  --bg-soft: #F6F6F6;
  --row-hover: #FAF3F8;
  --female: #C6007E;
  --male: #06038D;
  --mix: #277C5A;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #EE75C1;
    --primary-dark: #F7BBE0;
    --primary-dimmed: #3a1530;
    --secondary: #9C9AF5;
    --text: #EDEDED;
    --muted: #A0A0A0;
    --line: #343434;
    --bg: #161616;
    --bg-soft: #202020;
    --row-hover: #2a1d27;
    --female: #EE75C1;
    --male: #9C9AF5;
    --mix: #3CBD89;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Montserrat", system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }

/* Unofficial notice: always visible at the top. */
.unofficial {
  background: var(--alert);
  color: #242424;
  text-align: center;
  font-size: 14px;
  padding: 8px 16px;
}
.unofficial a { color: #020057; font-weight: 600; }

/* Header */
header.site {
  background: linear-gradient(110deg, #06038D 0%, #020057 55%, #8A0058 100%);
  color: #fff;
}
header.site .wrap:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 20px;
  padding-bottom: 12px;
  flex-wrap: wrap;
}
.brand { color: #fff; text-decoration: none; display: flex; flex-direction: column; }
.brand:hover { color: #fff; }
.brand-title { font-weight: 800; font-size: clamp(20px, 3vw, 28px); letter-spacing: -0.01em; text-transform: uppercase; }
.brand-sub { font-size: 13px; opacity: .8; font-weight: 500; }

.years { display: flex; gap: 4px; }
.years a {
  color: #fff; text-decoration: none; font-weight: 600; font-size: 14px;
  padding: 4px 10px; border-radius: 999px; border: 1px solid rgba(255,255,255,.35);
}
.years a[aria-current] { background: #fff; color: #06038D; }

nav.races { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 0; scrollbar-width: none; }
nav.races a {
  color: #fff; text-decoration: none; font-weight: 600; white-space: nowrap;
  padding: 10px 16px; border-radius: var(--radius) var(--radius) 0 0;
}
nav.races a:hover { background: rgba(255,255,255,.12); }
nav.races a[aria-current] { background: var(--bg); color: var(--primary); }

/* Intro */
.intro h1 { font-size: clamp(28px, 4vw, 40px); font-weight: 800; margin: 28px 0 4px; color: var(--secondary); letter-spacing: -0.02em; }
.intro p { margin: 0 0 20px; color: var(--muted); }
.intro .lede strong { color: var(--text); }

/* Index cards */
.cards { list-style: none; padding: 0; margin: 0 0 40px; display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.cards a {
  display: flex; flex-direction: column; gap: 4px; padding: 24px; text-decoration: none;
  border-radius: var(--radius); background: var(--primary-dimmed); border: 1px solid transparent;
  transition: border-color .15s, transform .15s;
}
.cards a:hover { border-color: var(--primary); transform: translateY(-2px); }
.card-name { font-weight: 800; font-size: 22px; color: var(--secondary); }
.card-meta { color: var(--muted); font-weight: 500; }

/* Filters */
.filters {
  display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end;
  padding: 16px; background: var(--bg-soft); border-radius: var(--radius); margin-bottom: 12px;
}
.filters label, .filters fieldset { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; border: 0; }
.filters label > span, .filters legend { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 0; }
.filters .f-search { flex: 1 1 220px; }
.filters .f-yob { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; }
.filters .f-yob legend { width: 100%; margin-bottom: 4px; float: left; }
.filters .f-yob input { width: 84px; }
.filters input, .filters select, .filters button {
  font: inherit; font-size: 14px; height: 38px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text);
}
.filters input:focus, .filters select:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.filters button {
  background: var(--primary); color: #fff; border: 0; font-weight: 700; padding: 0 20px; cursor: pointer;
}
.filters button:hover { background: var(--primary-dark); }

.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.toolbar p { margin: 0; }
.toolbar a { font-weight: 600; }

/* Table */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table.results { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.results th, .results td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.results thead th {
  position: sticky; top: 0; background: var(--bg-soft); font-size: 12px; text-transform: uppercase;
  letter-spacing: .04em; white-space: nowrap; z-index: 1;
}
.results th a { color: var(--text); text-decoration: none; }
.results th a:hover { color: var(--primary); }
.results th.sorted a { color: var(--primary); }
.results th.sorted.asc a::after { content: " ▲"; font-size: 10px; }
.results th.sorted.desc a::after { content: " ▼"; font-size: 10px; }
.results .num, .results .time { text-align: right; white-space: nowrap; }
.results tbody tr:hover { background: var(--row-hover); }
.results tbody tr:last-child td { border-bottom: 0; }
.results .rank { font-weight: 800; color: var(--secondary); }
.results .rank-gun { color: var(--muted); }
.results .strong { font-weight: 700; }
.results tr.out td { color: var(--muted); }
.status { font-size: 12px; font-weight: 700; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 32px !important; }

.name { min-width: 180px; }
.name summary { cursor: pointer; font-weight: 600; list-style: none; }
.name summary::-webkit-details-marker { display: none; }
.name summary::after { content: " ＋"; color: var(--primary); font-size: 11px; }
.name details[open] summary::after { content: " －"; }
.club-inline { display: none; font-size: 12px; color: var(--muted); }
.members { margin: 4px 0; font-size: 13px; }
.splits { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 0 2px; font-size: 12px; }
.splits div { display: flex; gap: 4px; }
.splits dt { color: var(--muted); }
.splits dd { margin: 0; font-weight: 600; }
.splits small { color: var(--muted); font-weight: 400; }

.g { display: inline-block; min-width: 22px; text-align: center; font-size: 11px; font-weight: 800; border-radius: 4px; padding: 1px 4px; color: #fff; }
.g-F { background: var(--female); }
.g-M { background: var(--male); }
.g-MIX { background: var(--mix); }

/* Pager */
.pager { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin: 20px 0; }
.pager a, .pager span { min-width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; padding: 0 10px; border-radius: 8px; text-decoration: none; font-weight: 600; }
.pager a { border: 1px solid var(--line); }
.pager a:hover { border-color: var(--primary); }
.pager span[aria-current] { background: var(--primary); color: #fff; }
.pager .gap { color: var(--muted); }

footer { color: var(--muted); font-size: 13px; padding-top: 24px; padding-bottom: 40px; }

@media (max-width: 720px) {
  .col-club, .col-pace, .rank-gun, th:nth-child(2) { display: none; }
  .club-inline { display: block; }
  .results th, .results td { padding: 8px 6px; }
  .filters label:not(.f-search) { flex: 1 1 140px; }
  .filters button { width: 100%; }
}
