﻿:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --ink: #171a1d;
  --muted: #5b6168;
  --line: #e2ddd5;
  --accent: #c8410f;
  --accent-ink: #ffffff;
  --track: #e8e3da;
  --warn: #8a5a00;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161a;
    --surface: #1b2127;
    --ink: #f1efea;
    --muted: #a0a7ae;
    --line: #2c343c;
    --accent: #e5602a;
    --accent-ink: #1a0d06;
    --track: #2c343c;
    --warn: #f2c063;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
}

h1, h2, p { margin: 0; }
h1 { font-size: 1.15rem; font-weight: 700; line-height: 1.2; }
h2 { font-size: 1.05rem; }

button, a, [role="button"] { touch-action: manipulation; }
button { font: inherit; cursor: pointer; user-select: none; -webkit-user-select: none; }
input, textarea, select { font: inherit; font-size: 16px; }

.top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  max-width: 760px;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 18px 6px;
}
.top-right { display: flex; align-items: center; gap: 8px; flex: none; }
.sub { color: var(--muted); font-size: 0.9rem; }

.pill {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--track);
  color: var(--ink);
  white-space: nowrap;
}
.pill.live { background: var(--accent); color: var(--accent-ink); }

.ghost {
  background: none;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  padding: 3px 9px;
  font-size: 0.82rem;
  min-height: 30px;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 18px;
  display: grid;
  gap: 16px;
}

.hero { padding: 18px 0 6px; }
.eyebrow { font-weight: 700; font-size: 1.05rem; }
.clock {
  font-size: clamp(4.2rem, 24vw, 7.5rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  margin: 4px 0 0;
}
.clock-label { color: var(--muted); }
.bar {
  height: 8px;
  background: var(--track);
  border-radius: 4px;
  overflow: hidden;
  margin: 14px 0 10px;
}
.bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 4px;
  transition: width 600ms ease-out;
}
.signal { color: var(--warn); font-size: 0.92rem; margin-top: 4px; }

.note {
  background: var(--surface);
  border-left: 4px solid var(--accent);
  padding: 10px 14px;
  border-radius: 6px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.stat { background: var(--surface); padding: 12px; min-width: 0; }
.stat .label { display: block; color: var(--muted); font-size: 0.78rem; }
.stat strong { font-size: 1.28rem; font-weight: 750; white-space: nowrap; }

@media (max-width: 420px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  scroll-margin-top: 12px;
}
.hint { color: var(--muted); font-size: 0.88rem; }

.map-card { padding: 0; overflow: hidden; position: relative; isolation: isolate; }
#map { height: min(58svh, 460px); background: var(--track); }
.map-link {
  position: absolute;
  z-index: 500;
  right: 10px;
  top: 10px;
  background: var(--surface);
  color: var(--ink);
  padding: 7px 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}
@media (prefers-color-scheme: dark) {
  .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9); }
}
.leaflet-container a { color: var(--accent); }
.runner-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgb(0 0 0 / 35%);
}
.runner-dot.stale { background: #8d949b; }

form { display: grid; gap: 8px; margin-top: 12px; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--bg);
  color: var(--ink);
  resize: vertical;
}
input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 8px;
  padding: 11px 18px;
  font-weight: 700;
  transition: transform 100ms ease-out;
}
.primary:active, .clap:active { transform: scale(0.97); }

.feed { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.feed li { border-top: 1px solid var(--line); padding-top: 10px; overflow-wrap: anywhere; }
.feed .who { font-weight: 700; }
.feed time { color: var(--muted); font-size: 0.8rem; margin-left: 6px; }

.splits { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 0.94rem; }
.splits th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  text-align: right;
  padding: 0 0 6px;
}
.splits td { text-align: right; padding: 7px 0; border-top: 1px solid var(--line); }
.splits th:first-child, .splits td:first-child { text-align: left; }
.splits td:nth-child(2) { font-weight: 700; }
.splits td:last-child { color: var(--muted); }

.strip {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 1000;
  display: grid;
  grid-template-columns: repeat(3, auto);
  justify-content: space-around;
  gap: 10px;
  padding: calc(7px + env(safe-area-inset-top, 0px)) 14px 7px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.strip .label { display: block; color: var(--muted); font-size: 0.7rem; }
.strip strong { font-size: 1.05rem; }

.latest {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.95rem;
}
.latest b { color: var(--accent); margin-right: 4px; }
.latest time { color: var(--muted); font-size: 0.8rem; margin-left: 4px; white-space: nowrap; }

.chart { margin-top: 10px; }
.chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .zero { stroke: var(--muted); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .line { 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.on { stroke: var(--ink); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .tag { fill: var(--ink); font-size: 12px; font-weight: 700; }
.chart-read { font-size: 0.92rem; min-height: 1.4em; margin-top: 4px; }

.foot { color: var(--muted); font-size: 0.85rem; padding: 6px 0 12px; }

.dock {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 1000;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.clap {
  flex: 1 1 auto;
  max-width: 340px;
  border: 0;
  border-radius: 10px;
  min-height: 48px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  font-size: 1.05rem;
  transition: transform 100ms ease-out;
}
.clap .count { opacity: 0.85; font-weight: 600; margin-left: 4px; }
.dock-link {
  color: var(--ink);
  font-weight: 600;
  padding: 12px 6px;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}

@media (hover: hover) and (pointer: fine) {
  .primary:hover, .clap:hover { filter: brightness(1.08); }
  .ghost:hover { background: var(--track); }
}

/* crew page */
.crew-grid { display: grid; gap: 14px; }
.crew-grid label { display: grid; gap: 4px; font-size: 0.88rem; color: var(--muted); }
.btn {
  background: var(--track);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 14px;
  font-weight: 650;
  text-align: center;
  text-decoration: none;
  display: inline-block;
}
.btn.danger { color: #b3261e; border-color: currentColor; background: none; }
@media (prefers-color-scheme: dark) { .btn.danger { color: #ff8a80; } }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; font-size: 0.92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.ok { color: inherit; }
.bad { color: var(--warn); font-weight: 700; }
.crew-cheer { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.crew-cheer.hidden-cheer span { opacity: 0.5; text-decoration: line-through; }
