:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #eef0ec;
  --border: #d9ddd5;
  --text: #1c211c;
  --text-muted: #5b635a;
  --accent: #1f6b3a;
  --accent-wash: rgba(31, 107, 58, 0.12);
  --loss: #a33a2a;
  --scrim: rgba(20, 24, 20, 0.45);
  --gold: #a87b10;
  --silver: #6b7280;
  --bronze: #9a5a2a;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* Always light, even when the device is in dark mode (form controls and scrollbars too). */
  color-scheme: light only;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--sans); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.site-head { background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 1rem; padding-top: 0.75rem; padding-bottom: 0.5rem; }
.brand h1 { margin: 0; line-height: 0; flex: none; }
.brand h1 img { height: 115px; width: auto; display: block; }
.brand-text { min-width: 0; }
.tagline { margin: 0; font-size: 1.15rem; font-weight: 600; }
.sub { margin: 0.2rem 0 0; color: var(--text-muted); }
.tabs { display: flex; gap: 0.25rem; overflow-x: auto; }
.tabs button { border: 0; background: none; color: var(--text-muted); font: inherit; font-weight: 600;
  padding: 0.6rem 0.9rem; border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.lbl-short { display: none; }

main { padding-top: 1rem; padding-bottom: 2rem; }
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; align-items: center; margin-bottom: 1rem; }
.gender { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.gender button { border: 0; background: var(--surface); color: var(--text); font: inherit; padding: 0.4rem 1.1rem; cursor: pointer; }
.gender button[aria-pressed="true"] { background: var(--accent); color: var(--surface); }

.controls { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 0.75rem; }
input[type=search], select { font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 4px; padding: 0.4rem 0.6rem; max-width: 100%; }
input[type=search] { flex: 1 1 200px; min-width: 0; }
.inline { display: inline-flex; gap: 0.4rem; align-items: center; color: var(--text-muted); }
.check { color: var(--text); cursor: pointer; }
.check input { accent-color: var(--accent); width: 1rem; height: 1rem; }
button.ghost { font: inherit; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 4px; padding: 0.4rem 0.75rem; cursor: pointer; }
button.ghost:hover { border-color: var(--accent); }
button.ghost.small { font-size: 0.85rem; padding: 0.25rem 0.6rem; }
.help { color: var(--text-muted); margin: 0 0 0.75rem; max-width: 75ch; }
.small { font-size: 0.82rem; }
.help.small { margin-top: 0.5rem; }

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.45rem 0.6rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.time { font-family: var(--mono); }
.muted { color: var(--text-muted); }
td.meetcell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; color: var(--text-muted); }
td.wrapcell { white-space: normal; min-width: 140px; }
.divcol { display: none; }
body.show-div .divcol { display: table-cell; }
.divtag { font-family: var(--mono); font-size: 0.75rem; color: var(--text-muted); }

.pick-head { display: flex; align-items: center; gap: 0.75rem; margin: 0.75rem 0 0.4rem; }
.pick-head h3 { margin: 0; font-size: 0.95rem; }
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0.4rem; margin-bottom: 0.5rem; }
.picker label { display: flex; gap: 0.5rem; align-items: center; background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px; padding: 0.45rem 0.6rem; cursor: pointer; }
.picker label:has(input:checked) { border-color: var(--accent); background: var(--accent-wash); }
.picker small { margin-left: auto; color: var(--text-muted); }
#teamPicker { margin-bottom: 1.25rem; }

h2 { font-size: 1.15rem; margin: 1.25rem 0 0.5rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.5rem; }
.place-1 td:first-child { color: var(--gold); font-weight: 700; }
.place-2 td:first-child { color: var(--silver); font-weight: 700; }
.place-3 td:first-child { color: var(--bronze); font-weight: 700; }
.winner td { font-weight: 600; }
tr.qual td, tr.sb td, tr.scorer td { background: var(--accent-wash); }
.chip { display: inline-block; min-width: 1.9rem; text-align: center; font-family: var(--mono); font-size: 0.85rem;
  padding: 0 0.3rem; border-radius: 999px; background: var(--surface-2); margin-right: 0.15rem; }
.chip.disp { background: transparent; border: 1px dashed var(--border); color: var(--text-muted); }
.chip.sb-chip { background: var(--accent); color: var(--surface); font-size: 0.7rem; min-width: 0; padding: 0 0.4rem; }
.badge { display: inline-block; font-size: 0.7rem; padding: 0 0.45rem; border-radius: 999px; border: 1px solid var(--border);
  color: var(--text-muted); margin-left: 0.35rem; vertical-align: 1px; white-space: nowrap; }
.rec-w { color: var(--accent); font-weight: 600; }
.rec-l { color: var(--loss); font-weight: 600; }
.empty { padding: 1.5rem; text-align: center; color: var(--text-muted); }
.note { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.15rem; }
.race { display: inline-block; margin: 0 0.75rem 0.1rem 0; }
.notes { margin: 0; padding-left: 1.2rem; color: var(--text-muted); max-width: 75ch; }
.notes li { margin-bottom: 0.3rem; }
.callout { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 0.25rem 1rem; max-width: 75ch; }
abbr.est { font-family: var(--sans); font-size: 0.72rem; color: var(--text-muted); text-decoration: none;
  border-bottom: 1px dotted var(--text-muted); cursor: help; margin-left: 0.15rem; }

section.champ { border-top: 1px solid var(--border); margin-top: 1.5rem; padding-top: 0.25rem; }
section.champ:first-of-type { border-top: 0; margin-top: 0; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.two-col h3 { margin-top: 0.5rem; }

button.lnk { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; }
button.lnk:hover, button.lnk:focus-visible { color: var(--accent); text-decoration: underline; }
.foot button.lnk { color: var(--accent); }

dialog#detail { width: min(820px, calc(100% - 32px)); max-height: calc(100vh - 32px); padding: 0; flex-direction: column;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; }
dialog#detail[open] { display: flex; }
dialog#detail::backdrop { background: var(--scrim); }
.dhead { display: flex; gap: 0.5rem; align-items: flex-start; padding: 1rem; border-bottom: 1px solid var(--border); }
.dhead .dtitle { flex: 1; min-width: 0; }
.dhead h2 { margin: 0; font-size: 1.3rem; }
.dhead button.ghost { padding: 0.3rem 0.6rem; line-height: 1.2; }
.dhead button[hidden] { display: none; }
.dbody { padding: 1rem; overflow-y: auto; }
.dbody h3 { margin: 1.25rem 0 0.5rem; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.stat { background: var(--surface-2); border-radius: 8px; padding: 0.6rem 0.75rem; min-width: 0; }
.stat-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.stat-value { font-family: var(--mono); font-size: 1.25rem; font-weight: 600; margin-top: 0.1rem; }
.stat-sub { font-size: 0.8rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* progression chart */
.chart-slot { margin-top: 1rem; }
.chart { position: relative; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .tick { stroke: var(--border); }
.chart .axis { fill: var(--text-muted); font: 11px var(--mono); }
.chart .series { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .dot.sb { fill: var(--surface); stroke: var(--accent); stroke-width: 2.5; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .pt.on .dot { stroke: var(--text); }
.chart .tip { position: absolute; transform: translate(-50%, -100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.4rem 0.6rem; font-size: 0.8rem; pointer-events: none; box-shadow: 0 2px 8px var(--scrim);
  white-space: nowrap; z-index: 2; }
.chart .tip-title { color: var(--text-muted); }
.chart .tip-value { font-family: var(--mono); font-weight: 600; font-size: 0.95rem; color: var(--text); }
.chart-note { margin-top: 0.25rem; }

.stale { background: var(--surface); border: 1px solid var(--bronze); border-left-width: 4px; border-radius: 8px;
  padding: 0.6rem 0.9rem; margin-bottom: 1rem; }
.badge.final { background: var(--accent); border-color: var(--accent); color: var(--surface); }

/* virtual meet lineups (what-if scratches) */
details.lineups { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem 0.9rem; margin-bottom: 0.5rem; }
details.lineups summary { cursor: pointer; }
.lineup-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.75rem; margin-top: 0.75rem; }
.lineup-head { display: flex; justify-content: space-between; gap: 0.5rem; align-items: baseline; font-weight: 600; margin-bottom: 0.3rem; }
.lu-list { display: flex; flex-direction: column; gap: 0.15rem; }
.lu { display: flex; align-items: center; gap: 0.4rem; font-size: 0.88rem; padding: 0.15rem 0.35rem; border-radius: 4px; cursor: pointer; }
.lu input { accent-color: var(--accent); margin: 0; }
.lu .time { margin-left: auto; font-size: 0.8rem; }
.lu.in { background: var(--accent-wash); }
.lu.alt { color: var(--text-muted); }
.lu.out { color: var(--text-muted); text-decoration: line-through; }
.foot { margin-top: 2rem; font-size: 0.85rem; color: var(--text-muted); }
.foot p { max-width: 90ch; }

@media (max-width: 860px) {
  .two-col { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .brand h1 img { height: 80px; }
  /* all five tabs share the width evenly, with shorter labels, so nothing scrolls off-screen */
  .tabs { gap: 0; overflow-x: visible; }
  .tabs button { flex: 1 1 0; min-width: 0; padding: 0.6rem 0.15rem; font-size: 0.85rem; text-align: center; }
  .lbl-long { display: none; }
  .lbl-short { display: inline; }
  .tagline { font-size: 1rem; }
  .hide-sm { display: none; }
  body.show-div .divcol.hide-sm { display: none; }
  th, td { padding: 0.4rem 0.45rem; }
  dialog#detail { width: 100%; max-width: 100%; height: 100%; max-height: 100%; margin: 0; border-radius: 0; border: 0; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .dhead { padding: 0.75rem; }
  .dbody { padding: 0.75rem; }
}
