:root {
  --ink: #101213;
  --ink-2: #303133;
  --muted: #6b7075;
  --faint: #a3a8ad;
  --line: rgba(16, 18, 19, 0.09);
  --panel: rgba(255, 255, 255, 0.9);
  --signal: #e8412c;
  --band-1: #e8412c;
  --band-2: #f0a02c;
  --band-3: #3b82c4;
  --band-4: #203a5c;
  --shadow: 0 1px 2px rgba(16, 18, 19, 0.06), 0 8px 28px rgba(16, 18, 19, 0.08);
  --radius: 14px;
  --sans: "Outfit", "Geomanist", "Avenir Next", system-ui, sans-serif;
  --mono: "DM Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --gap: 18px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #f4f4f2;
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 400;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.hidden { display: none !important; }

#map { position: fixed; inset: 0; }

.panel {
  position: fixed;
  z-index: 5;
  background: var(--panel);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Masthead + race clock */
.masthead {
  top: var(--gap);
  left: var(--gap);
  padding: 16px 20px 16px;
  min-width: 240px;
}
.title { font-size: 16px; font-weight: 500; letter-spacing: 0.01em; }
.title span { color: var(--muted); font-weight: 300; }
.clock {
  margin-top: 6px;
  font-size: 44px;
  line-height: 1;
  font-weight: 400;
  letter-spacing: -0.03em;
}
.clock-sub { margin-top: 8px; color: var(--muted); font-size: 13px; }
.chrome-toggle {
  display: none;
  place-items: center;
  width: 28px; height: 28px;
  border: 0; background: transparent; border-radius: 8px; color: var(--muted); padding: 0;
}
.chrome-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.2s; }
.quiet-search { display: none; }
.clock-modes { margin-top: 12px; }
.clock-modes button { font-size: 12px; padding: 6px 0; }
.byline {
  margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 12px; color: var(--muted);
}
.byline > a { color: var(--muted); text-decoration: none; white-space: nowrap; }
.byline > a:hover { color: var(--ink); }
.byline-links { display: flex; gap: 2px; }
.byline-links a { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; color: var(--muted); }
.byline-links a:hover { background: #f2f3f3; color: var(--ink); }
.byline-links svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.byline-links svg.fill { fill: currentColor; stroke: none; width: 12px; height: 12px; }

/* Flags (PNG, so they render the same on Windows) and bib badge */
.flag {
  width: 20px; height: 14px; object-fit: cover; border-radius: 2.5px;
  box-shadow: inset 0 0 0 1px rgba(16, 18, 19, 0.08);
  vertical-align: -2px; margin-right: 6px; flex: none;
}
.bib {
  display: inline-block; font-family: var(--mono); font-size: 11.5px; line-height: 1;
  padding: 4px 6px 3px; border: 1.5px solid var(--ink); border-radius: 4px;
  color: var(--ink); background: #fff; letter-spacing: 0.02em;
}

/* Search */
.search {
  top: var(--gap);
  left: 50%;
  transform: translateX(-50%);
  width: min(460px, calc(100vw - 600px));
  min-width: 300px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  height: 52px;
}
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; flex: none; }
.search input {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  min-width: 0;
}
.search input::placeholder { color: var(--faint); }
.search input::-webkit-search-cancel-button { display: none; }
.search kbd {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 7px;
}
.search:focus-within { box-shadow: 0 0 0 3px rgba(16, 18, 19, 0.08), var(--shadow); }
.results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: none;
  max-height: 60vh;
  overflow: auto;
}
.results.open { display: block; }
.results li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 9px;
  cursor: pointer;
}
.results li .n { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.results li .c { color: var(--muted); font-size: 13px; display: flex; align-items: center; white-space: nowrap; }
.results li .t { font-family: var(--mono); font-size: 13px; color: var(--ink-2); }
.results li.active, .results li:hover { background: #f2f3f3; }
.results .empty { color: var(--muted); cursor: default; display: block; }

/* Side readout */
.side {
  top: var(--gap);
  right: var(--gap);
  width: 280px;
  padding: 8px 8px 16px;
  max-height: calc(100vh - 128px - 56px);
  overflow: auto;
}
.modes {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  background: #eef0f0;
  border-radius: 10px;
  padding: 3px;
}
.mode {
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 8px 0;
  font-size: 14px;
  color: var(--muted);
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}
.mode.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(16, 18, 19, 0.12); }
.filter-summary {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 8px 2px 0; padding: 6px 6px 6px 12px;
  background: #f5f6f6; border-radius: 10px; font-size: 12.5px; color: var(--ink-2);
}
.fs-text { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fs-reset {
  flex: none; border: 1px solid var(--line); background: #fff; border-radius: 7px;
  padding: 4px 10px; font-size: 12px; color: var(--ink);
  transition: background 0.15s, transform 0.12s;
}
.fs-reset:hover { background: #eef0f0; }
.fs-reset:active { transform: scale(0.96); }
.stats-toggle { display: none; }
.readout { padding: 14px 10px 0; }
.readout .stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.readout .stat b { font-size: 20px; font-weight: 400; }
.readout .stat span { color: var(--muted); font-size: 13px; }

.finish { margin-top: 16px; }
.wall-head { display: flex; justify-content: space-between; align-items: baseline; }
.wall-head span { font-size: 13px; color: var(--ink-2); }
.wall-head b { font-size: 20px; font-weight: 400; color: var(--ink); }
.wall-head b small { font-family: var(--sans); font-size: 11px; color: var(--muted); margin-left: 6px; }
.bar { margin-top: 8px; height: 6px; background: #eceeee; border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--signal); border-radius: 4px; transition: width 0.3s ease; }
#fin-hist { display: block; width: 100%; height: 72px; margin-top: 10px; }
.fin-ticks { position: relative; height: 14px; font-size: 10.5px; color: var(--muted); }
.fin-ticks span { position: absolute; transform: translateX(-50%); }
.finish p { margin: 8px 0 0; font-size: 12px; line-height: 1.45; color: var(--muted); }
.finish p b { font-weight: 400; color: var(--ink); }

/* Country race */
.race { list-style: none; margin: 0; padding: 0; position: relative; }
.race li {
  position: absolute; left: 0; right: 0; height: 34px;
  display: grid; grid-template-columns: 20px minmax(0, 1fr) 54px auto; gap: 8px; align-items: center;
  padding: 0 6px; border-radius: 8px; cursor: pointer; font-size: 13px;
  transition: transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1), background 0.15s;
}
.race li:hover { background: #f2f3f3; }
.race li.on { background: var(--ink); color: #fff; }
.race li .flag { margin: 0; }
.race li .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.race li .bar { margin: 0; height: 5px; background: #eceeee; }
.race li.on .bar { background: rgba(255, 255, 255, 0.25); }
.race li .bar i { background: var(--ink); transition: width 0.3s linear; }
.race li.on .bar i { background: #fff; }
.race li b { font-family: var(--mono); font-weight: 400; font-size: 12px; min-width: 60px; text-align: right; color: var(--ink-2); white-space: nowrap; }
.race li.on b { color: #fff; }

.legend { margin-top: 16px; display: grid; gap: 2px; }
.legend button {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 10px;
  align-items: center;
  border: 0;
  background: transparent;
  padding: 7px 6px;
  margin: 0 -6px;
  border-radius: 8px;
  text-align: left;
  font-size: 14px;
  transition: background 0.15s, opacity 0.15s;
}
.legend button:hover { background: #f2f3f3; }
.legend button i { width: 10px; height: 10px; border-radius: 50%; }
.legend button span.k { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.legend button.off { opacity: 0.35; }

.pace-note { margin: 0 0 10px; font-size: 13px; line-height: 1.45; color: var(--muted); }
.pace-list { list-style: none; margin: 0; padding: 0; }
.pace-list li {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.pace-list li i { width: 10px; height: 10px; border-radius: 3px; }
.pace-list li b { font-family: var(--mono); font-weight: 400; font-size: 14px; }
.ramp { margin-top: 14px; display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); }
.ramp i { height: 6px; border-radius: 4px; background: linear-gradient(90deg, #b9cfe2, #f0a02c, #e8412c); }

/* Filters */
.filters { margin-top: 14px; display: grid; gap: 8px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: #eef0f0; border-radius: 10px; padding: 3px; }
.seg button {
  border: 0; background: transparent; border-radius: 8px;
  padding: 7px 0; font-size: 13px; color: var(--muted);
  transition: background 0.18s, color 0.18s;
}
.seg button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(16, 18, 19, 0.12); }
.select-wrap { position: relative; display: block; }
.select-wrap select {
  width: 100%; appearance: none; -webkit-appearance: none;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 10px; padding: 9px 34px 9px 12px; font: inherit; font-size: 14px;
  outline: none; cursor: pointer;
}
.select-wrap select:focus { box-shadow: 0 0 0 3px rgba(16, 18, 19, 0.08); }
.select-wrap svg { position: absolute; right: 11px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 1.8; pointer-events: none; }

/* Squad card */
.squad {
  left: var(--gap);
  bottom: 128px;
  width: 350px;
  max-height: calc(100vh - 128px - var(--mast-h, 130px) - var(--gap) - 12px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.squad-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px 8px; font-size: 13px; color: var(--muted);
}
.squad-head b { color: var(--ink); font-weight: 500; }
.text-btn { border: 0; background: transparent; color: var(--muted); font-size: 13px; padding: 4px 6px; border-radius: 6px; }
.text-btn:hover { background: #f2f3f3; color: var(--ink); }
.squad-list { list-style: none; margin: 0; padding: 0 8px; flex: none; }
.squad-list li { border-radius: 10px; transition: background 0.15s; }
.squad-list li + li { margin-top: 2px; }
.squad-list li.cam { background: #f5f6f6; }
.squad-list li.open { background: #f5f6f6; }
.squad-list .row {
  display: grid; grid-template-columns: 10px 1fr auto auto auto; gap: 10px; align-items: center;
  padding: 8px 8px; border-radius: 10px; cursor: pointer;
}
.squad-list li:not(.cam) .row:hover { background: #f5f6f6; }
.squad-list .row > i { width: 10px; height: 10px; border-radius: 50%; }
.squad-list .who { min-width: 0; }
.squad-list .n { font-size: 15px; font-weight: 500; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.squad-list .m { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; align-items: center; white-space: nowrap; }
.squad-list .m .live { margin-left: 6px; color: var(--ink); }
.squad-list .m .live:not(:empty)::before { content: ", "; color: var(--muted); margin-right: 1px; }
.squad-list .chev { width: 16px; height: 16px; fill: none; stroke: var(--faint); stroke-width: 1.8; transition: transform 0.2s, stroke 0.2s; }
.squad-list li.cam .chev { stroke: var(--ink); }
.squad-list li.cam.open .chev { transform: rotate(180deg); }
.squad-list .rm {
  border: 0; background: transparent; color: var(--faint); font-size: 18px; line-height: 1;
  width: 26px; height: 26px; border-radius: 7px;
}
.squad-list .rm:hover { background: #e8eaea; color: var(--ink); }
.squad-list .detail { overflow: auto; padding: 2px 8px 10px; }
.squad-list .detail .live div { background: #fff; }
.squad-actions { display: flex; gap: 6px; padding: 10px 16px 12px; flex: none; }
.chip {
  flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 9px;
  padding: 8px 0; font-size: 13px; white-space: nowrap;
  transition: background 0.15s, transform 0.12s, color 0.15s;
}
.chip:active { transform: scale(0.97); }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.detail .meta { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin: 2px 0 10px; }
.detail .meta b { font-weight: 400; color: var(--ink-2); }
.detail .live { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0 0 12px; }
.detail .live div { background: #f5f6f6; border-radius: 10px; padding: 8px 10px; }
.detail .live b { display: block; font-size: 19px; font-weight: 400; }
.detail .live span { font-size: 11.5px; color: var(--muted); }
.detail .live div.next b { color: var(--signal); }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; margin: 0 0 12px; }
.facts div { padding: 6px 0 7px; border-bottom: 1px solid var(--line); min-width: 0; }
.facts div span { display: block; font-size: 11px; color: var(--muted); letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.facts div b { display: block; font-family: var(--mono); font-weight: 400; font-size: 14px; margin-top: 2px; white-space: nowrap; }
.facts div b small { font-family: var(--sans); font-size: 11px; color: var(--muted); }
.facts div b.neg { color: #1a9e6a; }
.facts div b.pos { color: var(--signal); }
.splits { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.splits th { text-align: right; font-weight: 400; color: var(--muted); padding: 4px 0; border-bottom: 1px solid var(--line); }
.splits th:first-child, .splits td:first-child { text-align: left; }
.splits th small { display: block; font-size: 10px; }
.splits td { text-align: right; padding: 4px 0 4px 6px; border-bottom: 1px solid var(--line); color: var(--faint); transition: color 0.2s; }
.splits td small { display: block; font-size: 10.5px; color: var(--faint); }
.splits tr.done td { color: var(--ink); }
.splits tr.next td { color: var(--signal); }

/* Views */
.views { position: relative; }
.views-btn {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  padding: 8px 12px; font-size: 13px; max-width: 200px;
  transition: background 0.15s, transform 0.12s;
}
.views-btn:hover { background: #f5f6f6; }
.views-btn:active { transform: scale(0.97); }
.views-btn svg { width: 16px; height: 16px; fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linejoin: round; flex: none; }
.views-btn span { white-space: nowrap; }
.views-btn.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.views-btn.icon { padding: 9px; }
.views-btn.icon svg { stroke-width: 1.8; stroke-linecap: round; }
.views-btn.on svg { stroke: #fff; }
.views-menu li.sep { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 12px; border-radius: 0 0 9px 9px; }
.view-caption {
  top: 84px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  padding: 6px 8px 6px 14px; font-size: 14px; white-space: nowrap;
}
.view-caption .text-btn { border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; color: var(--ink); }
.views-menu {
  position: absolute; right: 0; bottom: calc(100% + 10px);
  width: 250px; margin: 0; padding: 6px; list-style: none;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  display: none; max-height: 60vh; overflow: auto;
}
.views.open .views-menu { display: block; }
.views-menu li {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 9px 12px; border-radius: 9px; cursor: pointer; font-size: 14px;
}
.views-menu li b { font-family: var(--mono); font-weight: 400; font-size: 12px; color: var(--muted); }
.views-menu li:hover { background: #f2f3f3; }
.views-menu li.active { background: var(--ink); color: #fff; }
.views-menu li.active b { color: rgba(255, 255, 255, 0.7); }

/* Timeline dock */
.dock {
  left: var(--gap);
  right: var(--gap);
  bottom: var(--gap);
  height: 92px;
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  gap: 16px;
  align-items: center;
  padding: 0 18px;
}
.play {
  width: 52px; height: 52px;
  border: 0; border-radius: 50%;
  background: var(--ink);
  display: grid; place-items: center;
  box-shadow: 0 2px 8px rgba(16, 18, 19, 0.25);
  transition: transform 0.12s, box-shadow 0.15s;
}
.play:hover { box-shadow: 0 4px 14px rgba(16, 18, 19, 0.3); }
.play:active { transform: scale(0.93); }
.play svg { width: 22px; height: 22px; fill: #fff; }
.play .i-pause { display: none; }
.playing .play .i-play { display: none; }
.playing .play .i-pause { display: block; }

.track-wrap { position: relative; }
.track {
  position: relative;
  height: 40px;
  cursor: pointer;
  touch-action: none;
  border-radius: 8px;
}
.track canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.track::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 1px; background: rgba(16, 18, 19, 0.25);
}
.progress {
  position: absolute; left: 0; bottom: 0;
  height: 2px; background: var(--ink); width: 0;
  z-index: 1;
}
.knob {
  position: absolute; bottom: 1px; left: 0;
  width: 18px; height: 18px; margin-left: -9px; margin-bottom: -9px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--ink);
  box-shadow: 0 2px 6px rgba(16, 18, 19, 0.25);
  z-index: 2;
  transition: transform 0.12s;
}
.track:hover .knob, .dragging .knob { transform: scale(1.18); }
.hover-tip {
  position: absolute; bottom: 30px;
  transform: translateX(-50%);
  background: var(--ink); color: #fff;
  font-size: 12px; padding: 4px 7px; border-radius: 6px;
  pointer-events: none; opacity: 0; transition: opacity 0.12s;
  white-space: nowrap; z-index: 3;
}
.track:hover .hover-tip { opacity: 1; }
.ticks { position: relative; height: 16px; margin-top: 8px; font-size: 11px; color: var(--muted); }
.ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }

.speeds { position: relative; }
.speed-btn { display: none; }
.speed-menu { display: flex; background: #eef0f0; border-radius: 10px; padding: 3px; }
.speed {
  border: 0; background: transparent; border-radius: 8px;
  padding: 7px 11px; font-size: 13px; color: var(--muted);
  white-space: nowrap;
  transition: background 0.18s, color 0.18s;
}
.speed.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(16, 18, 19, 0.12); }

/* Map labels */
.mat-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-2);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
  pointer-events: none;
  white-space: nowrap;
  transform: translateY(-16px);
}
.mat-label.pace b { font-weight: 500; color: var(--ink); margin-left: 4px; }

/* Intro */
.intro {
  position: fixed;
  z-index: 6;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -52%);
  width: min(560px, calc(100vw - 32px));
  padding: 34px 38px 32px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 2px 4px rgba(16, 18, 19, 0.05), 0 24px 60px rgba(16, 18, 19, 0.12);
  transition: opacity 0.4s, transform 0.4s;
}
.intro.gone { opacity: 0; transform: translate(-50%, -48%); pointer-events: none; }
.intro-kicker { font-size: 13px; letter-spacing: 0.04em; color: var(--muted); }
.intro-big { margin: 10px 0 0; font-size: 34px; line-height: 1.12; font-weight: 400; letter-spacing: -0.02em; }
.intro-small { margin: 16px 0 0; font-size: 16px; line-height: 1.55; color: var(--ink-2); }
.intro-actions { display: flex; gap: 10px; margin-top: 26px; }
.intro-cta, .intro-ghost {
  border: 0; border-radius: 10px; padding: 12px 18px; font-size: 15px;
  transition: transform 0.12s, background 0.15s;
}
.intro-cta { background: var(--ink); color: #fff; }
.intro-ghost { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.intro-ghost:hover { background: #f5f6f6; }
.intro-cta:active, .intro-ghost:active { transform: scale(0.97); }
.intro-foot {
  margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font-size: 13px; color: var(--muted);
}
.intro-foot a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); }
.intro-foot a:hover { border-bottom-color: var(--ink); }
.intro-links { display: flex; gap: 4px; }
.intro-links a { border: 0; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; color: var(--ink-2); }
.intro-links a:hover { background: #f2f3f3; color: var(--ink); }
.intro-links svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.intro-links svg.fill { fill: currentColor; stroke: none; width: 14px; height: 14px; }
.intro-data { flex-basis: 100%; margin-top: -2px; font-size: 11.5px; color: var(--faint); }
body.intro-open .masthead, body.intro-open .side, body.intro-open .squad, body.intro-open .view-caption {
  opacity: 0; pointer-events: none; transform: translateY(-6px);
}
.masthead, .side, .squad, .view-caption { transition: opacity 0.45s, transform 0.45s; }
body.intro-open .search { opacity: 0; pointer-events: none; }
.search { transition: opacity 0.45s; }

.loading {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center;
  background: #f4f4f2; color: var(--muted);
  transition: opacity 0.5s;
}
.loading.done { opacity: 0; pointer-events: none; }

@media (max-width: 980px) {
  :root { --gap: 10px; }
  /* One header card: title and credit, clock and mode switch, then a full-width search inset. */
  .masthead {
    left: var(--gap); right: var(--gap); width: auto; min-width: 0;
    padding: 14px 14px 12px;
    border-radius: 16px;
  }
  .title { font-size: 14px; line-height: 18px; white-space: nowrap; }
  .clock { font-size: 34px; line-height: 34px; margin-top: 6px; }
  .clock-sub, .byline-links { display: none; }
  .clock-modes { margin: 8px 0 0; }
  .clock-modes button { font-size: 12px; padding: 6px 0; }
  .byline {
    margin-top: 68px; padding-top: 0; border-top: 0;
    font-size: 11px; justify-content: flex-start;
  }
  .masthead:has(.clock-modes:not(.hidden)) ~ .search { top: calc(var(--gap) + 124px); }
  .search {
    top: calc(var(--gap) + 84px);
    left: calc(var(--gap) + 12px); right: calc(var(--gap) + 12px);
    transform: none; width: auto; min-width: 0; height: 46px;
    background: #f1f2f2; border: 0; box-shadow: none;
    backdrop-filter: none; -webkit-backdrop-filter: none;
    border-radius: 11px;
  }
  .search:focus-within { background: #fff; box-shadow: 0 0 0 1.5px var(--ink); }
  .search kbd { display: none; }
  .results { left: -12px; right: -12px; }
  .results li .ct { display: none; }
  .side {
    top: calc(var(--gap) + 36px); right: calc(var(--gap) + 12px);
    width: auto; max-height: none; padding: 0; overflow: visible;
    background: transparent; border: 0; box-shadow: none;
    backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  .side:not(.stats-open) .filter-summary {
    position: absolute; top: -32px; right: -4px;
    margin: 0; padding: 0; background: transparent;
  }
  .side:not(.stats-open) .fs-text { display: none; }
  .side:not(.stats-open) .fs-reset { border: 0; background: transparent; color: var(--muted); padding: 4px 6px; }
  .side .readout { display: none; }
  .modes .mode[data-mode="nations"] { display: none; }
  .modes { grid-template-columns: auto auto auto; }
  .side:not(.stats-open) .mode { padding: 7px 14px; }
  .stats-toggle {
    display: grid; place-items: center;
    width: 34px; border: 0; background: transparent; border-radius: 8px; color: var(--muted);
  }
  .stats-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.2s; }
  .side.stats-open .modes {
    position: sticky; top: -6px; z-index: 2;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    padding-bottom: 4px; margin: -6px -8px 0; padding: 6px 8px 4px;
  }
  .side.stats-open .stats-toggle { color: var(--ink); }
  .side.stats-open .stats-toggle svg { transform: rotate(180deg); }
  .side.stats-open {
    left: var(--gap); right: var(--gap); width: auto; height: auto;
    top: calc(var(--mast-h, 164px) + var(--gap) + 8px);
    max-height: calc(100vh - var(--mast-h, 164px) - var(--squad-block, 110px) - 28px);
    overflow: auto; padding: 6px 8px 14px;
    background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
    backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2);
  }
  .side.stats-open .modes { grid-template-columns: 1fr 1fr auto; }
  .side.stats-open .readout { display: block; }
  .dock { height: 76px; gap: 10px; padding: 0 14px; grid-template-columns: auto 1fr auto auto auto; }
  .play { width: 46px; height: 46px; }
  .speed-btn {
    display: flex; align-items: center;
    border: 1px solid var(--line); background: #fff; border-radius: 10px;
    padding: 9px 10px; font-size: 12px; white-space: nowrap;
  }
  .speed-menu {
    display: none; position: absolute; right: 0; bottom: calc(100% + 8px);
    flex-direction: column; background: #fff; border: 1px solid var(--line);
    border-radius: 12px; box-shadow: var(--shadow); padding: 4px; z-index: 6;
  }
  .speeds.open .speed-menu { display: flex; }
  .speeds .speed { text-align: left; padding: 8px 14px; }
  .speeds.open .speed-btn { background: var(--ink); color: #fff; border-color: var(--ink); }
  .views-btn span { display: none; }
  .views-btn { padding: 9px; }
  .views-menu { width: min(260px, calc(100vw - 40px)); }
  .squad { width: auto; right: var(--gap); bottom: 96px; max-height: 52vh; }
  .intro { padding: 26px 24px 24px; }
  .intro-big { font-size: 26px; }
  .intro-actions { flex-direction: column; }
  .view-caption { top: calc(var(--mast-h, 164px) + 20px); }

  /* Phone chrome tucks to a clock bar so the course stays on screen. */
  .chrome-toggle { display: grid; position: absolute; right: 8px; bottom: 6px; }
  .chrome-toggle svg { transform: rotate(180deg); }
  body.quiet .masthead {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 100px 8px 12px; min-height: 46px;
  }
  body.quiet .title,
  body.quiet .byline,
  body.quiet .clock-sub,
  body.quiet .chrome-toggle,
  body.quiet .search { display: none; }
  body.quiet .clock { margin: 0; font-size: 22px; line-height: 28px; flex: none; }
  body.quiet .clock-modes { display: block; margin: 0; padding: 0; background: transparent; min-width: 0; }
  body.quiet .clock-modes button { display: none; }
  body.quiet .clock-modes button.active {
    display: block; box-shadow: none; background: #fff; border: 1px solid var(--line);
    border-radius: 999px; padding: 4px 10px; font-size: 11px; color: var(--ink-2);
    max-width: 118px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  body.quiet .quiet-search {
    display: grid; place-items: center; margin-left: auto; flex: none;
    width: 30px; height: 30px; border: 0; background: transparent; border-radius: 8px; color: var(--ink); padding: 0;
  }
  body.quiet .quiet-search svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
  body.quiet .side:not(.stats-open) { top: calc(var(--gap) + 9px); right: calc(var(--gap) + 8px); }
  body.quiet .side:not(.stats-open) .modes { background: transparent; padding: 0; grid-template-columns: auto auto; }
  body.quiet .side:not(.stats-open) .mode { display: none; }
  body.quiet .side:not(.stats-open) .mode.active {
    display: block; padding: 5px 2px 5px 8px; font-size: 13px; color: var(--ink);
    background: transparent; box-shadow: none; pointer-events: none;
  }
  body.quiet .side:not(.stats-open) .stats-toggle { width: 28px; height: 28px; color: var(--ink); }
  body.quiet .side:not(.stats-open) .filter-summary { top: 34px; right: 0; }
  /* Followed runners: a row of chips, then a stat strip, then the full card. */
  .squad { max-height: none; }
  body.quiet .squad { bottom: 80px; }
  .squad-head { display: none; }
  .squad.sheet .squad-head { display: flex; padding: 10px 14px 0; font-size: 12px; }
  .squad-list {
    display: flex; gap: 6px; padding: 10px 10px 0; overflow-x: auto; scrollbar-width: none;
  }
  .squad-list::-webkit-scrollbar { display: none; }
  .squad-list li, .squad-list li.cam, .squad-list li.open { flex: none; margin: 0; background: transparent; }
  .squad-list li + li { margin: 0; }
  .squad-list .row {
    display: flex; gap: 7px; align-items: center;
    padding: 6px 10px 6px 9px; border: 1px solid var(--line); border-radius: 999px; background: #fff;
  }
  .squad-list li.cam .row { background: #f1f2f2; border-color: #f1f2f2; }
  .squad-list .row > i { width: 9px; height: 9px; flex: none; }
  .squad-list .who { display: flex; align-items: baseline; gap: 6px; }
  .squad-list .n { font-size: 13px; max-width: 120px; }
  .squad-list .m { margin: 0; font-size: 12px; }
  .squad-list .m .flag, .squad-list .m > span:not(.live) { display: none; }
  .squad-list .m .live { margin: 0; }
  .squad-list .m .live:not(:empty)::before { content: none; }
  .squad-list .bib, .squad-list .rm, .squad-list .detail { display: none; }
  .squad-list .chev { display: block; width: 14px; height: 14px; stroke: var(--muted); flex: none; }
  .squad-list li.cam .chev { stroke: var(--ink); }
  .squad-list li.peeking .chev { transform: rotate(180deg); }
  .squad-peek:not([hidden]) { display: block; padding: 10px 12px 0; }
  .squad-peek .detail { padding: 0; overflow: visible; }
  .squad-peek .detail.full { overflow: auto; overscroll-behavior: contain; margin: 0 -2px; padding: 0 10px 0 2px; }
  .squad-peek .meta { margin: 0 0 8px; }
  .squad-peek .live { margin: 0; }
  .squad-peek .detail.full .live { margin: 0 0 12px; }
  .squad-peek .live b { font-size: 16px; }
  .squad-peek .live div { padding: 6px 8px; }
  .peek-foot {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 6px; min-height: 30px;
  }
  .peek-foot .text-btn { font-size: 12.5px; padding: 4px 0; }
  .peek-more {
    display: inline-flex; align-items: center; gap: 4px;
    border: 0; background: transparent; padding: 4px 0 4px 8px;
    font-size: 12.5px; color: var(--ink-2);
  }
  .peek-more svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .peek-more.up svg { transform: rotate(180deg); }
  .squad-peek .detail.full + .peek-foot { border-top: 1px solid var(--line); margin-top: 0; padding-top: 4px; }
  .squad-actions { padding: 8px 10px 10px; }
  .chip { padding: 7px 4px; font-size: 12.5px; }
  body.quiet .dock { height: 62px; gap: 8px; padding: 0 12px; }
  body.quiet .play { width: 40px; height: 40px; }
  body.quiet .play svg { width: 18px; height: 18px; }
  body.quiet .track { height: 26px; }
  body.quiet .ticks { display: none; }
  body.quiet .speed-btn { padding: 7px 8px; }
}

@media (max-width: 380px) {
  .clock { font-size: 30px; line-height: 34px; }
  .side:not(.stats-open) .mode { padding: 7px 10px; }
  .stats-toggle { width: 30px; }
}

