/* main.css — Hood 2 Coast Tracker */

/* ─── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ─── Design tokens ──────────────────────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-base:       #f4f4f6;
  --bg-panel:      #ffffff;
  --bg-surface:    #f2f2f5;
  --bg-raised:     #e8e8ec;
  --bg-hover:      #e2e2e7;

  /* Legacy aliases (used by older code) */
  --bg-dark:       var(--bg-base);
  --bg-card:       var(--bg-surface);
  --bg-card-deep:  var(--bg-panel);

  /* Borders — just two levels, used sparingly */
  --border:        rgba(0,0,0,0.07);
  --border-bright: rgba(0,0,0,0.13);

  /* Text — clear 3-level scale */
  --text-primary:   #17181a;
  --text-secondary: #63666e;
  --text-muted:     #a3a5ac;

  /* Accent */
  --accent: #0e7490;

  /* Semantic aliases */
  --pink: var(--accent); --blue: var(--accent); --purple: var(--accent);
  --green: var(--accent); --orange: var(--accent); --yellow: var(--accent);

  /* Gradients */
  --grad-active:   linear-gradient(90deg, rgba(14,116,144,0.55), #0e7490);
  --grad-progress: linear-gradient(90deg, rgba(14,116,144,0.4), #0e7490);
  --grad-van1:     linear-gradient(90deg, rgba(14,116,144,0.35), rgba(14,116,144,0.7));
  --grad-van2:     linear-gradient(90deg, rgba(14,116,144,0.2), rgba(14,116,144,0.5));

  /* Layout */
  --panel-width:           420px;
  --topbar-height:         50px;
  --timeline-strip-height: 90px;
  --tab-bar-height:        60px;
  --radius:    12px;
  --radius-sm:  8px;
  --radius-xs:  5px;
}

/* ─── Base ───────────────────────────────────────────────────────────────────── */
html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app { display: flex; flex-direction: column; height: 100vh; }

/* ─── Top bar ────────────────────────────────────────────────────────────────── */
#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-height);
  padding: 0 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 10px;
  z-index: 100;
}

#top-bar-left  { display: flex; align-items: center; gap: 10px; min-width: 160px; }
#top-bar-right { display: flex; align-items: center; gap: 8px; justify-content: flex-end; min-width: 240px; }

#race-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.2px;
  color: var(--text-primary);
}

.topbar-leg-pill {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  border-radius: 99px;
  padding: 2px 10px;
}

#top-bar-center { display: flex; flex-direction: column; align-items: center; }
#elapsed-label  { font-size: 9px; color: var(--text-muted); letter-spacing: 1px; text-transform: uppercase; }
#elapsed-time   {
  font-size: 19px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
  color: var(--text-primary);
}

/* Est. finish */
#finish-time-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 0 12px;
  border-right: 1px solid var(--border);
  margin-right: 4px;
}
#finish-time-label { font-size: 9px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-muted); }
#finish-time-value { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--accent); }

/* Speed selector */
#speed-label { display: flex; align-items: center; gap: 4px; color: var(--text-secondary); font-size: 11px; }
#sim-speed {
  background: var(--bg-surface); border: 1px solid var(--border-bright);
  color: var(--text-primary); border-radius: var(--radius-xs);
  padding: 2px 6px; font-size: 11px; cursor: pointer;
}

/* Buttons */
.btn {
  padding: 6px 14px; border-radius: var(--radius-sm); border: none;
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: opacity 0.15s; white-space: nowrap;
  letter-spacing: 0.1px;
}
.btn:disabled { opacity: 0.25; cursor: not-allowed; }
.btn-primary   { background: var(--grad-active); color: #fff; }
.btn-primary:hover:not(:disabled) { opacity: 0.85; }
.btn-secondary { background: var(--bg-surface); color: var(--text-primary); border: 1px solid var(--border-bright); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-raised); }
.btn-ghost     { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { color: var(--text-secondary); }

/* Status badges */
.badge { font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 99px; letter-spacing: 0.3px; text-transform: uppercase; }
.badge-pending { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.badge-running { background: rgba(14,116,144,0.1); color: var(--accent); border: 1px solid rgba(14,116,144,0.25); }
.badge-paused  { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-bright); }
.badge-done    { background: transparent; color: var(--text-muted); border: 1px solid var(--border-bright); }

/* ─── Main layout ────────────────────────────────────────────────────────────── */
#main-content { display: flex; flex: 1; overflow: hidden; }

/* ─── Side panel ─────────────────────────────────────────────────────────────── */
#side-panel {
  width: var(--panel-width);
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
#side-panel::-webkit-scrollbar { width: 2px; }
#side-panel::-webkit-scrollbar-track { background: transparent; }
#side-panel::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 2px; }

/* Sections — separated by whitespace, not borders */
.panel-section {
  padding: 20px 20px 22px;
  border-bottom: 1px solid var(--border);
}
/* Remove the left bar gimmick — hierarchy comes from type and spacing */
.panel-section::before { display: none; }
.panel-section:nth-child(even) { background: none; }

.section-title {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1.2px; color: var(--text-muted);
  margin-bottom: 16px;
}
/* Remove the line extension — it adds visual noise */
.section-title::after { display: none; }

/* ─── Active leg section ─────────────────────────────────────────────────────── */
#active-leg-section { padding-bottom: 24px; }
#race-timeline-section { padding: 16px 20px 20px; }

/* Leg header — just the number and badges, no heavy treatment */
.leg-header-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.leg-big-label {
  font-size: 13px; font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.2px;
}

/* Difficulty badges — same subtle palette */
.diff-badge {
  font-size: 10px; font-weight: 600; padding: 2px 8px;
  border-radius: 99px; text-transform: uppercase; letter-spacing: 0.3px;
}
.diff-easy     { background: rgba(14,116,144,0.05); color: rgba(14,116,144,0.45); border: 1px solid rgba(14,116,144,0.12); }
.diff-moderate { background: rgba(14,116,144,0.07); color: rgba(14,116,144,0.6);  border: 1px solid rgba(14,116,144,0.18); }
.diff-hard     { background: rgba(14,116,144,0.10); color: rgba(14,116,144,0.8);  border: 1px solid rgba(14,116,144,0.25); }
.diff-veryhard { background: rgba(14,116,144,0.14); color: var(--accent);         border: 1px solid rgba(14,116,144,0.35); }

.phase-badge {
  font-size: 10px; font-weight: 500; padding: 2px 8px; border-radius: 99px;
  color: var(--text-muted); border: 1px solid var(--border); margin-left: auto;
}

/* ── ETA — the hero ── */
/* New layout: ETA fills full width, runner info below it */
.eta-clock-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.eta-clock {
  font-size: 56px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -2px;
  color: var(--text-primary);
}

.eta-clock-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.eta-clock-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.eta-runner-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.eta-runner-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.eta-runner-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 1px;
}

/* Runner avatar (small) */
.runner-avatar-sm {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #fff;
  background: var(--bg-raised); flex-shrink: 0;
}

/* ── Pacer row — contextual, not a box ── */
.pacer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  margin-bottom: 18px;
}
.pacer-label  { font-size: 10px; font-weight: 500; color: var(--text-muted); flex-shrink: 0; text-transform: uppercase; letter-spacing: 0.8px; }
.pacer-name   { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.pacer-detail { font-size: 12px; color: var(--text-secondary); margin-left: auto; }

/* ── Stats — inline row, no boxes ── */
.stat-chips-row {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
}

.stat-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex: 1;
  padding: 0 0 0 12px;
  border-left: 1px solid var(--border);
  background: none;
  border-top: none;
  border-right: none;
  border-bottom: none;
  border-radius: 0;
  min-width: 0;
}

.stat-chip:first-child { padding-left: 0; border-left: none; }

.chip-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.chip-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 1px;
  letter-spacing: 0.2px;
}

/* Accent chips — just color the value, no box */
.chip-accent-orange .chip-value,
.chip-accent-teal   .chip-value { color: var(--accent); }
.chip-accent-orange,
.chip-accent-teal   { border-left-color: var(--border); background: none; }

/* Progress bar */
.progress-bar-wrap { margin-bottom: 0; }
.progress-bar-track {
  height: 3px;
  background: var(--border-bright);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 6px;
}
.progress-bar-fill {
  height: 100%;
  background: var(--grad-progress);
  border-radius: 99px;
  transition: width 0.4s ease;
  min-width: 3px;
}
.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
}

/* ─── Race timeline bar ──────────────────────────────────────────────────────── */
.timeline-bar-wrap { display: flex; align-items: center; gap: 12px; }
.timeline-stat      { flex-shrink: 0; }
.timeline-stat-right { text-align: right; }
.tl-value { font-size: 14px; font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.tl-label { font-size: 10px; color: var(--text-muted); margin-top: 1px; }

.timeline-track-wrap { flex: 1; }
.timeline-track {
  position: relative;
  height: 4px;
  background: var(--border-bright);
  border-radius: 99px;
  overflow: visible;
  margin-bottom: 6px;
}
.timeline-fill {
  height: 100%;
  background: var(--grad-progress);
  border-radius: 99px;
  transition: width 1s linear;
}
.timeline-marker {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 10px; height: 10px; background: #fff;
  border: 2px solid rgba(14,116,144,0.8); border-radius: 50%; z-index: 2;
  transition: left 1s linear;
}
.timeline-legs-row { position: relative; height: 6px; }
.tl-leg-tick { position: absolute; top: 0; width: 1px; height: 5px; background: var(--border-bright); transform: translateX(-50%); }
.tl-leg-tick.van-switch { background: rgba(14,116,144,0.4); width: 1px; height: 6px; }

/* ─── Van status ─────────────────────────────────────────────────────────────── */
#van-status-section { padding: 16px 20px 20px; }
#van-cards-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.van-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.van-header { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.van-label  { font-weight: 600; font-size: 12px; color: var(--text-secondary); }

.van-status-badge {
  margin-left: auto; font-size: 9px; font-weight: 600;
  padding: 1px 7px; border-radius: 99px;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.van-badge-running { background: rgba(14,116,144,0.1); color: var(--accent); border: 1px solid rgba(14,116,144,0.25); }
.van-badge-waiting { color: var(--text-muted); border: 1px solid var(--border); }
.van-badge-driving { color: rgba(14,116,144,0.5); border: 1px solid rgba(14,116,144,0.15); }
.van-badge-standby { color: var(--text-muted); border: 1px solid var(--border); }
.van-badge-done    { color: var(--text-muted); border: 1px solid var(--border); }

.van-detail { font-size: 10px; color: var(--text-muted); margin-bottom: 8px; line-height: 1.4; min-height: 14px; }
.van-runners { display: flex; flex-direction: column; gap: 1px; }

.van-runner-row { display: flex; align-items: center; gap: 5px; padding: 3px 4px; border-radius: var(--radius-xs); }
.van-runner-active { background: rgba(14,116,144,0.06); }
.van-runner-dot  { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.van-runner-name { flex: 1; font-size: 11px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.van-runner-legs { display: flex; gap: 2px; flex-shrink: 0; }

.leg-pip { width: 6px; height: 6px; border-radius: 50%; background: var(--border-bright); display: inline-block; }
.leg-pip.done   { background: rgba(14,116,144,0.35); }
.leg-pip.active { background: var(--accent); box-shadow: 0 0 5px rgba(14,116,144,0.6); }
.leg-pip-clickable { cursor: pointer; transition: transform 0.1s; }
.leg-pip-clickable:hover { transform: scale(1.6); }
.van-runner-clickable { cursor: pointer; }
.van-runner-clickable:hover { background: var(--bg-raised); border-radius: var(--radius-xs); }

/* ─── Map container ──────────────────────────────────────────────────────────── */
#map-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#map {
  flex: 1;
  z-index: 0;
  min-height: 0;
}

/* Map controls — cleaner, more integrated */
#map-controls {
  position: absolute;
  top: 14px; right: 14px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.map-btn {
  background: rgba(255,255,255,0.85);
  border: 1px solid rgba(0,0,0,0.08);
  color: var(--text-secondary);
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: color 0.15s, background 0.15s;
  letter-spacing: 0.1px;
}
.map-btn:hover  { color: var(--text-primary); background: rgba(22,22,22,0.9); }
.map-btn.active { color: var(--accent); border-color: rgba(14,116,144,0.2); background: rgba(14,116,144,0.06); }

/* Map legend — softer */
#map-legend {
  position: absolute;
  bottom: calc(var(--timeline-strip-height) + 14px); right: 14px;
  z-index: 500;
  background: rgba(255,255,255,0.85);
  border: 1px solid rgba(0,0,0,0.07);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 10px; color: var(--text-muted); }
.legend-dot  { width: 14px; height: 2px; border-radius: 2px; display: inline-block; }
.legend-dot.completed { background: rgba(0,0,0,0.22); }
.legend-dot.pending   { background: var(--border-bright); }
.legend-swatch { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.active-swatch   { background: var(--accent); }
.exchange-swatch { background: rgba(0,0,0,0.55); }

/* ─── Exchange markers (Leaflet divIcon) ─────────────────────────────────────── */
.ex-marker {
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.08);
  cursor: pointer; transition: transform 0.15s;
}
.ex-marker:hover { transform: scale(1.2); }
.ex-start  { background: var(--accent); color: #fff; width: 26px; height: 26px; font-size: 11px; font-weight: 800; }
.ex-finish { background: var(--accent); color: #fff; width: 26px; height: 26px; font-size: 11px; font-weight: 800; }
.ex-major  { background: #1a1a1a; color: rgba(14,116,144,0.8); width: 18px; height: 18px; font-size: 9px; border-color: rgba(14,116,144,0.2); }
.ex-minor  { background: #0f0f0f; color: #3a3a3a; width: 12px; height: 12px; font-size: 8px; border-color: #1e1e1e; }
.ex-highlight { border-color: rgba(255,255,255,0.4) !important; box-shadow: 0 0 10px rgba(14,116,144,0.4); transform: scale(1.25); }

/* ─── Runner marker ──────────────────────────────────────────────────────────── */
.runner-marker {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
  border: 2px solid rgba(255,255,255,0.6);
  box-shadow: 0 2px 16px rgba(0,0,0,0.9);
  animation: runner-pulse 2.5s ease-in-out infinite;
}
@keyframes runner-pulse {
  0%,100% { box-shadow: 0 2px 16px rgba(0,0,0,0.9), 0 0 0 0 rgba(255,255,255,0.2); }
  50%      { box-shadow: 0 2px 16px rgba(0,0,0,0.9), 0 0 0 8px rgba(255,255,255,0); }
}
.runner-label-tooltip {
  background: rgba(255,255,255,0.95) !important;
  border: 1px solid var(--border-bright) !important;
  color: var(--text-primary) !important;
  font-size: 11px !important; font-weight: 500 !important;
  border-radius: var(--radius-xs) !important;
  box-shadow: 0 2px 10px rgba(0,0,0,0.18) !important;
  padding: 3px 8px !important; white-space: nowrap;
}
.runner-label-tooltip::before { display: none !important; }

/* ─── Van marker ─────────────────────────────────────────────────────────────── */
.van-marker {
  display: flex; align-items: center; justify-content: center;
  background: #0a0a0a; border: 1px solid rgba(14,116,144,0.35);
  border-radius: 5px; font-size: 10px; font-weight: 700; color: #fff;
  width: 32px; height: 22px; box-shadow: 0 2px 8px rgba(0,0,0,0.7);
}

/* ─── Timeline strip ─────────────────────────────────────────────────────────── */
#timeline-strip {
  height: var(--timeline-strip-height);
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  z-index: 200;
  position: relative;
}

#tl-strip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px 3px;
  flex-shrink: 0;
}

#tl-strip-label {
  font-size: 9px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-muted);
}

#tl-strip-hint { font-size: 9px; color: var(--text-muted); }

#tl-strip-scroll-wrap {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 14px 6px;
  scroll-behavior: smooth;
}
#tl-strip-scroll-wrap::-webkit-scrollbar { height: 2px; }
#tl-strip-scroll-wrap::-webkit-scrollbar-track { background: transparent; }
#tl-strip-scroll-wrap::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 2px; }

#tl-strip-track {
  position: relative;
  height: 100%;
  min-width: 1800px;
  width: 3200px;
}

/* Leg blocks */
.tl-leg-block {
  position: absolute;
  top: 0;
  height: calc(100% - 14px);
  border-radius: 4px;
  cursor: pointer;
  overflow: hidden;
  border: 1px solid transparent;
  transition: filter 0.15s, border-color 0.15s;
  --runner-color: #888;
}

.tl-leg-block.tl-leg-1 { background: rgba(14,116,144,0.11); }
.tl-leg-block.tl-leg-2 { background: rgba(14,116,144,0.06); }

.tl-leg-block.tl-status-completed {
  background: rgba(0,0,0,0.035);
  border-color: transparent;
}
.tl-leg-block.tl-status-active {
  border-color: rgba(14,116,144,0.5);
  border-width: 1px;
  box-shadow: 0 0 8px rgba(14,116,144,0.2);
}
.tl-leg-block.tl-status-pending { opacity: 0.6; }

.tl-leg-block:hover {
  filter: brightness(0.96);
  border-color: rgba(0,0,0,0.18) !important;
  z-index: 5;
}

.tl-block-progress {
  position: absolute;
  bottom: 0; left: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 0 4px;
  transition: width 0.4s ease;
}

.tl-block-inner {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2px 5px;
  height: 100%;
  gap: 1px;
  pointer-events: none;
}

.tl-block-num {
  font-size: 8px; font-weight: 700;
  color: rgba(0,0,0,0.35);
  line-height: 1; text-transform: uppercase; letter-spacing: 0.4px;
}

.tl-block-name {
  font-size: 9px; font-weight: 600;
  color: rgba(0,0,0,0.68);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2;
}

.tl-status-active .tl-block-num  { color: rgba(14,116,144,0.8); }
.tl-status-active .tl-block-name { color: var(--text-primary); }
.tl-status-completed .tl-block-name { color: rgba(0,0,0,0.25); }
.tl-status-completed .tl-block-num  { color: rgba(0,0,0,0.15); }

.tl-van-divider {
  position: absolute;
  top: 0; bottom: 14px;
  width: 1px;
  background: rgba(0,0,0,0.16);
  z-index: 3;
  transform: translateX(-50%);
}
.tl-van-divider::before {
  content: '';
  position: absolute;
  top: 0; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px;
  background: rgba(14,116,144,0.6);
  border-radius: 50%;
}
.tl-van-divider-label {
  position: absolute;
  top: 3px; left: 5px;
  font-size: 8px; font-weight: 600;
  color: rgba(14,116,144,0.6);
  white-space: nowrap; letter-spacing: 0.4px; text-transform: uppercase;
}

.tl-time-label {
  position: absolute;
  bottom: 0;
  font-size: 8px;
  color: var(--text-muted);
  transform: translateX(-50%);
  white-space: nowrap;
}

#tl-strip-scrubber {
  position: absolute;
  top: 0; bottom: 14px;
  width: 1px;
  background: rgba(0,0,0,0.55);
  z-index: 10;
  transform: translateX(-50%);
  pointer-events: none;
  transition: left 0.5s linear;
  display: none;
}
#tl-strip-scrubber::before {
  content: '';
  position: absolute;
  top: -1px; left: 50%; transform: translateX(-50%);
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
}

.race-started #tl-strip-scrubber { display: block; }

/* ─── Leg popup ──────────────────────────────────────────────────────────────── */
.leg-popup-wrap .leaflet-popup-content-wrapper {
  background: #ffffff;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  padding: 0;
  min-width: 260px; max-width: 300px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.18);
}
.leg-popup-wrap .leaflet-popup-content { margin: 0; width: 100% !important; }
.leg-popup-wrap .leaflet-popup-tip-container { display: none; }

.leg-popup { padding: 14px 16px; font-family: inherit; font-size: 12px; color: var(--text-primary); }

.popup-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.popup-leg-num { font-size: 16px; font-weight: 700; color: var(--text-primary); }

.popup-status-badge { font-size: 9px; font-weight: 600; padding: 2px 7px; border-radius: 99px; text-transform: uppercase; letter-spacing: 0.3px; }
.popup-active  { background: rgba(14,116,144,0.1); color: var(--accent); border: 1px solid rgba(14,116,144,0.25); }
.popup-done    { color: var(--text-muted); border: 1px solid var(--border-bright); }
.popup-pending { color: var(--text-muted); border: 1px solid var(--border); }

.popup-runner-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.popup-avatar { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0; }
.popup-runner-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.popup-runner-sub  { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }

.popup-route-row {
  display: flex; align-items: center; gap: 5px; font-size: 11px;
  color: var(--text-secondary); margin-bottom: 10px;
  background: var(--bg-surface); padding: 6px 8px; border-radius: var(--radius-xs);
}
.popup-exchange { flex: 1; }
.popup-arrow    { color: var(--text-muted); flex-shrink: 0; }

.popup-progress-bar  { height: 3px; background: var(--border); border-radius: 99px; overflow: hidden; margin-bottom: 4px; }
.popup-progress-fill { height: 100%; border-radius: 99px; min-width: 3px; }
.popup-progress-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-muted); margin-bottom: 10px; }

.popup-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 5px; margin-bottom: 10px; }
.popup-stat  { background: var(--bg-surface); border-radius: var(--radius-xs); padding: 5px 7px; text-align: center; }
.popup-stat-val { font-size: 13px; font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.popup-stat-lbl { font-size: 9px; letter-spacing: 0.4px; color: var(--text-muted); margin-top: 1px; }

.popup-comparison {
  background: var(--bg-surface);
  border-radius: var(--radius-xs); padding: 8px 10px; margin-bottom: 10px;
  display: flex; flex-direction: column; gap: 4px;
}
.popup-comp-row  { display: flex; justify-content: space-between; align-items: center; font-size: 11px; }
.popup-comp-lbl  { color: var(--text-secondary); }
.popup-comp-val  { font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }

.popup-times { display: flex; flex-direction: column; gap: 3px; margin-bottom: 10px; }
.popup-time-row { display: flex; justify-content: space-between; font-size: 11px; }
.popup-time-lbl { color: var(--text-muted); }
.popup-time-val { font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }

.popup-desc {
  font-size: 11px; color: var(--text-secondary); line-height: 1.5;
  border-top: 1px solid var(--border); padding-top: 8px; margin-top: 2px;
}

.popup-dir-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(14,116,144,0.1); border: 1px solid rgba(14,116,144,0.2);
  color: var(--accent); text-decoration: none; flex-shrink: 0;
  transition: background 0.15s; margin-left: 4px;
}
.popup-dir-btn:hover { background: rgba(14,116,144,0.18); }
.popup-dir-btn svg { width: 12px; height: 12px; }

/* ─── Misc ───────────────────────────────────────────────────────────────────── */
.running-now {
  font-size: 9px; font-weight: 600; color: var(--accent);
  background: rgba(14,116,144,0.08); padding: 1px 6px; border-radius: 99px;
  animation: blink 1.8s ease-in-out infinite;
}
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

.empty-row { color: var(--text-muted); text-align: center; padding: 16px; font-size: 12px; }
.runner-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 4px; flex-shrink: 0; }

/* ─── Leaflet overrides ──────────────────────────────────────────────────────── */
.leaflet-container { background: #eceef0; font-family: inherit; }
.leaflet-popup-content-wrapper { background: #ffffff; color: var(--text-primary); border: 1px solid var(--border-bright); border-radius: var(--radius-sm); box-shadow: 0 4px 24px rgba(0,0,0,0.16); }
.leaflet-popup-tip { background: #ffffff; }
.leaflet-tooltip { background: #ffffff; border: 1px solid var(--border-bright); color: var(--text-primary); font-size: 11px; border-radius: var(--radius-xs); box-shadow: 0 2px 10px rgba(0,0,0,0.14); padding: 4px 8px; }
.leaflet-tooltip::before { border-top-color: var(--border-bright); }
.leaflet-control-zoom a { background: rgba(255,255,255,0.9) !important; color: var(--text-secondary) !important; border-color: var(--border-bright) !important; backdrop-filter: blur(8px); }
.leaflet-control-zoom a:hover { background: var(--bg-raised) !important; color: var(--text-primary) !important; }
.leaflet-control-attribution { background: rgba(255,255,255,0.75) !important; color: var(--text-muted) !important; font-size: 9px !important; }
.leaflet-control-attribution a { color: var(--text-muted) !important; }

/* ─── Mobile tab bar (hidden on desktop) ────────────────────────────────────── */
#mobile-tabs { display: none; }
.tab-panel   { display: none; }

/* ─── Mobile ─────────────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  :root {
    --panel-width: 100%;
    --tab-bar-height: 60px;
  }

  html, body { overflow: hidden; }

  /* Top bar */
  #top-bar { padding: 0 16px; gap: 8px; height: 50px; }
  #race-title { font-size: 14px; }
  #elapsed-time { font-size: 17px; }
  #top-bar-right { gap: 6px; min-width: auto; }
  .btn { padding: 6px 12px; font-size: 12px; }
  #speed-label { display: none; }

  /* Main content */
  #app { position: relative; }
  #main-content { flex-direction: column; height: calc(100vh - 50px - var(--tab-bar-height)); overflow: hidden; }
  #map-container { flex: 1; height: auto; min-height: 0; }
  #side-panel { display: none; }
  #van-cards-wrap { grid-template-columns: 1fr 1fr; }
  #timeline-strip { height: 72px; }

  /* ── Bottom tab bar ── */
  #mobile-tabs {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--tab-bar-height);
    background: rgba(255,255,255,0.95);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    flex-shrink: 0;
    z-index: 600;
  }

  .tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: color 0.2s;
    padding: 6px 0 4px;
    -webkit-tap-highlight-color: transparent;
  }

  .tab-btn svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 1.75; }
  .tab-btn.active { color: var(--accent); }
  .tab-btn.active svg { filter: none; }

  /* ── Tab panels ── */
  .tab-panel {
    position: fixed;
    top: 50px;
    left: 0; right: 0;
    bottom: var(--tab-bar-height);
    background: var(--bg-panel);
    overflow-y: auto;
    z-index: 500;
    -webkit-overflow-scrolling: touch;
  }

  .tab-panel[hidden] { display: none !important; }
  .tab-panel:not([hidden]) { display: block; }

  #app.tab-map    #main-content   { display: flex; }
  #app.tab-map    #tab-panel-timeline,
  #app.tab-map    #tab-panel-team { display: none !important; }
  #app.tab-timeline #main-content,
  #app.tab-team     #main-content { display: none; }

  /* ── Mobile Timeline tab ── */
  .mob-tl-header {
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-panel);
    z-index: 10;
  }

  .mob-tl-race-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
  }

  .mob-tl-race-stat {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
  }

  .mob-tl-race-stat strong {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.3px;
  }

  .mob-tl-track {
    flex: 1;
    height: 3px;
    background: var(--border-bright);
    border-radius: 99px;
    overflow: hidden;
  }

  .mob-tl-fill {
    height: 100%;
    background: var(--grad-progress);
    border-radius: 99px;
    transition: width 1s linear;
  }

  /* Leg list */
  .mob-leg-list { padding: 6px 0 24px; }

  .mob-leg-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.12s;
    -webkit-tap-highlight-color: transparent;
    min-height: 60px;
  }

  .mob-leg-row:active { background: var(--bg-surface); }

  .mob-leg-row.mob-leg-active {
    background: rgba(14,116,144,0.04);
  }

  .mob-leg-row.mob-leg-completed { opacity: 0.55; }

  .mob-leg-row.mob-leg-van-switch {
    margin-top: 2px;
    border-top: 1px solid rgba(14,116,144,0.12);
  }

  .mob-leg-num {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 24px;
    text-align: center;
  }

  .mob-leg-active .mob-leg-num { color: var(--accent); }

  .mob-leg-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: #fff;
    flex-shrink: 0;
  }

  .mob-leg-info { flex: 1; min-width: 0; }

  .mob-leg-name {
    font-size: 15px; font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }

  .mob-leg-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
  }

  .mob-leg-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
  }

  .mob-leg-dist {
    font-size: 13px; font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
  }

  .mob-leg-status-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--border-bright);
  }

  .mob-leg-active    .mob-leg-status-dot { background: var(--accent); }
  .mob-leg-completed .mob-leg-status-dot { background: rgba(14,116,144,0.35); }

  .mob-leg-progress-wrap {
    width: 100%; height: 2px;
    background: var(--border);
    border-radius: 99px; margin-top: 4px; overflow: hidden;
  }

  .mob-leg-progress-fill {
    height: 100%; background: var(--grad-progress);
    border-radius: 99px; transition: width 0.4s ease;
  }

  .mob-van-divider-label {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 20px 4px;
    font-size: 10px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.8px;
    color: var(--text-muted);
  }

  /* ── Mobile Team tab ── */
  .mob-team-list {
    padding: 16px 20px 80px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .mob-van-group-label {
    font-size: 10px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 1.2px;
    color: var(--text-muted);
    padding: 8px 0 4px;
  }

  .mob-van-group-label::after { display: none; }

  .mob-runner-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
  }

  .mob-runner-card.mob-runner-active {
    border-color: rgba(14,116,144,0.18);
  }

  .mob-runner-card-header {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 14px;
  }

  .mob-runner-card-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0;
  }

  .mob-runner-card-name {
    font-size: 16px; font-weight: 600;
    color: var(--text-primary); letter-spacing: -0.2px;
  }

  .mob-runner-card-sub {
    font-size: 12px; color: var(--text-secondary); margin-top: 2px;
  }

  .mob-runner-card-badge {
    margin-left: auto;
    font-size: 9px; font-weight: 600;
    padding: 3px 9px; border-radius: 99px;
    text-transform: uppercase; letter-spacing: 0.3px;
  }

  .mob-runner-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    margin-bottom: 14px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
  }

  .mob-runner-stat {
    padding: 0 12px 0 0;
    border-right: 1px solid var(--border);
    background: none;
    border-radius: 0;
  }

  .mob-runner-stat:last-child { border-right: none; padding-right: 0; padding-left: 12px; }
  .mob-runner-stat:first-child { padding-left: 0; }

  .mob-runner-stat-val {
    font-size: 15px; font-weight: 600;
    color: var(--text-primary); font-variant-numeric: tabular-nums;
  }

  .mob-runner-stat-val.accent { color: var(--accent); }

  .mob-runner-stat-lbl {
    font-size: 10px; color: var(--text-muted); margin-top: 2px;
  }

  .mob-runner-legs-row {
    display: flex; gap: 5px; flex-wrap: wrap;
  }

  .mob-runner-leg-chip {
    font-size: 11px; font-weight: 500;
    padding: 4px 10px; border-radius: 99px;
    border: 1px solid var(--border);
    color: var(--text-muted);
    background: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: border-color 0.1s, color 0.1s;
    min-height: 28px;
    display: flex; align-items: center;
  }

  .mob-runner-leg-chip.done {
    border-color: rgba(14,116,144,0.2);
    color: rgba(14,116,144,0.6);
  }

  .mob-runner-leg-chip.active {
    border-color: rgba(14,116,144,0.4);
    color: var(--accent);
    background: rgba(14,116,144,0.08);
  }
}

@media (max-width: 480px) {
  #top-bar-center { display: none; }
}

/* ─── Mobile bottom sheet ────────────────────────────────────────────────────── */
/* Desktop: hidden entirely */
#mob-sheet { display: none; }

@media (max-width: 860px), html.mobile-forced {
  #mob-sheet {
    display: flex;
    flex-direction: column;
    position: absolute;
    left: 0; right: 0; bottom: 0;
    /* Total available height = viewport - topbar - tabbar */
    --sheet-full:  calc(100% - 0px);   /* full = basically the whole map area */
    --sheet-mid:   62%;                /* default: 62% of map-container height */
    --sheet-peek:  68px;               /* collapsed: just the handle + peek row */
    height: var(--sheet-full);
    transform: translateY(calc(100% - var(--sheet-mid)));
    transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
    will-change: transform;
    z-index: 400;
    border-radius: 20px 20px 0 0;
    background: var(--bg-panel);
    /* Subtle shadow upward */
    box-shadow: 0 -4px 32px rgba(0,0,0,0.55);
    touch-action: none; /* we handle touch manually */
  }

  /* Snap states */
  #mob-sheet.mob-sheet--peek {
    transform: translateY(calc(100% - var(--sheet-peek)));
  }
  #mob-sheet.mob-sheet--mid {
    transform: translateY(calc(100% - var(--sheet-mid)));
  }
  #mob-sheet.mob-sheet--full {
    transform: translateY(0px);
    border-radius: 0;
  }

  /* No transition while dragging */
  #mob-sheet.mob-sheet--dragging {
    transition: none;
  }

  /* Handle */
  #mob-sheet-handle-wrap {
    padding: 10px 0 6px;
    display: flex;
    justify-content: center;
    flex-shrink: 0;
    cursor: grab;
  }
  #mob-sheet-handle-wrap:active { cursor: grabbing; }

  .mob-sheet-handle {
    width: 36px; height: 4px;
    background: rgba(0,0,0,0.18);
    border-radius: 99px;
  }

  #mob-sheet-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
  }

  /* ── Peek row (always visible when not full) ── */
  #mob-sheet-peek {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px 10px;
    flex-shrink: 0;
  }

  /* peek: show compact peek row only */
  /* mid + full: show full body, hide peek row */
  #mob-sheet.mob-sheet--peek #mob-sheet-body  { display: none; }
  #mob-sheet.mob-sheet--peek #mob-sheet-peek  { display: flex; }
  #mob-sheet:not(.mob-sheet--peek) #mob-sheet-peek { display: none; }
  #mob-sheet:not(.mob-sheet--peek) #mob-sheet-body  { display: block; }

  .mob-sheet-peek-runner {
    display: flex; align-items: center; gap: 10px;
  }

  .mob-sheet-peek-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: #fff;
    background: var(--bg-raised); flex-shrink: 0;
  }

  .mob-sheet-peek-name {
    font-size: 15px; font-weight: 600;
    color: var(--text-primary); letter-spacing: -0.2px;
  }

  .mob-sheet-peek-sub {
    font-size: 12px; color: var(--text-secondary); margin-top: 1px;
  }

  .mob-sheet-peek-eta {
    font-size: 22px; font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.5px;
    color: var(--text-primary);
    flex-shrink: 0;
  }

  /* ── Expanded body ── */
  #mob-sheet-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 20px 24px;
  }

  /* ── Sections ── */
  .mob-sheet-section {
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
  }
  .mob-sheet-section:last-child { border-bottom: none; }

  /* Leg header: Leg N · diff badge · phase badge */
  .mob-sheet-leg-header {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 14px;
  }

  .mob-sheet-leg-num {
    font-size: 13px; font-weight: 700; color: var(--text-primary);
    letter-spacing: -0.2px;
  }

  /* Runner row: avatar | name+sub | ETA block */
  .mob-sheet-runner-row {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 16px;
  }

  .mob-sheet-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; color: #fff;
    background: var(--bg-raised); flex-shrink: 0;
  }

  .mob-sheet-runner-info { flex: 1; min-width: 0; }

  .mob-sheet-runner-name {
    font-size: 15px; font-weight: 600;
    color: var(--text-primary); letter-spacing: -0.2px;
  }

  .mob-sheet-runner-sub {
    font-size: 12px; color: var(--text-secondary); margin-top: 2px;
  }

  /* ETA block — right side of runner row */
  .mob-sheet-eta-block {
    text-align: right; flex-shrink: 0;
  }

  .mob-sheet-eta-label {
    font-size: 10px; text-transform: uppercase;
    letter-spacing: 0.8px; color: var(--text-muted); margin-bottom: 2px;
  }

  .mob-sheet-eta {
    font-size: 22px; font-weight: 700; line-height: 1;
    font-variant-numeric: tabular-nums; letter-spacing: -0.5px;
    color: var(--text-primary);
  }

  /* Progress */
  .mob-sheet-progress-wrap { margin-bottom: 16px; }

  .mob-sheet-progress-track {
    height: 3px; background: var(--border-bright);
    border-radius: 99px; overflow: hidden; margin-bottom: 7px;
  }

  .mob-sheet-progress-fill {
    height: 100%; background: var(--grad-progress);
    border-radius: 99px; transition: width 0.4s ease; min-width: 3px;
  }

  .mob-sheet-progress-labels {
    display: flex; justify-content: space-between;
    font-size: 11px; color: var(--text-muted);
  }

  /* Stats inline */
  .mob-sheet-stats {
    display: flex; gap: 0;
    margin-bottom: 16px;
  }

  .mob-sheet-stat {
    flex: 1;
    padding-left: 14px;
    border-left: 1px solid var(--border);
  }

  .mob-sheet-stat:first-child { padding-left: 0; border-left: none; }

  .mob-sheet-stat-val {
    font-size: 15px; font-weight: 600;
    color: var(--text-primary); font-variant-numeric: tabular-nums;
    line-height: 1.2;
  }

  .mob-sheet-stat-val.accent { color: var(--accent); }

  .mob-sheet-stat-lbl {
    font-size: 10px; color: var(--text-muted); margin-top: 2px;
  }

  /* Pace history card */
  .mob-sheet-pace-history { margin-top: 4px; }

  .mob-sheet-pace-history-inner {
    background: var(--bg-raised);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
  }

  .mob-sheet-pace-title {
    font-size: 10px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.8px; color: var(--text-muted);
    margin-bottom: 8px;
  }

  .mob-sheet-pace-row {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; padding: 4px 0;
    border-top: 1px solid var(--border);
  }

  .mob-sheet-pace-row:first-of-type { border-top: none; }

  .mob-sheet-pace-leg {
    font-size: 11px; color: var(--text-muted);
    width: 24px; flex-shrink: 0;
  }

  .mob-sheet-pace-val {
    font-weight: 600; color: var(--text-primary);
    font-variant-numeric: tabular-nums; flex: 1;
  }

  .mob-sheet-pace-delta {
    font-size: 11px; color: var(--text-muted);
  }

  .mob-sheet-pace-faster { color: #4ade80; }
  .mob-sheet-pace-slower { color: var(--accent); }

  .mob-sheet-pace-est-row { opacity: 0.6; }

  /* ── Next section carousel ── */
  .mob-sheet-section--next { padding-bottom: 12px; }

  .next-carousel-viewport {
    overflow: hidden;
    width: 100%;
  }

  .next-carousel-track {
    display: flex;
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
    will-change: transform;
  }

  .next-carousel-track.no-transition { transition: none; }

  .next-carousel-card {
    flex: 0 0 100%;
    min-width: 0;
    background: var(--bg-raised);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
  }

  .next-card-label {
    font-size: 10px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.8px; color: var(--text-muted);
    margin-bottom: 10px;
  }

  .next-card-meta {
    text-align: right; flex-shrink: 0;
  }

  .next-card-leg-num {
    font-size: 13px; font-weight: 700; color: var(--text-primary);
    letter-spacing: -0.2px;
  }

  .next-card-dist {
    font-size: 12px; color: var(--text-muted); margin-top: 2px;
  }

  .mob-sheet-next-row {
    display: flex; align-items: center; gap: 10px;
  }

  .mob-sheet-next-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 700; color: #fff;
    background: var(--bg-surface); flex-shrink: 0;
  }

  .mob-sheet-next-info { flex: 1; min-width: 0; }

  .mob-sheet-next-name {
    font-size: 14px; font-weight: 600; color: var(--text-primary);
  }

  .mob-sheet-next-detail {
    font-size: 12px; color: var(--text-secondary); margin-top: 1px;
  }

  /* Handoff row (inside carousel card) */
  .mob-sheet-handoff-row {
    display: flex; align-items: center; gap: 10px;
    font-size: 14px; color: var(--text-primary);
  }

  .mob-sheet-handoff-icon {
    width: 16px; height: 16px; flex-shrink: 0;
    color: var(--accent);
  }

  .mob-sheet-handoff-row span {
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-weight: 500;
  }

  /* Dot indicators */
  .next-carousel-dots {
    display: flex; justify-content: center; gap: 5px;
    margin-top: 10px;
  }

  .next-carousel-dot {
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--border-bright);
    transition: background 0.2s, transform 0.2s;
  }

  .next-carousel-dot--active {
    background: var(--accent);
    transform: scale(1.2);
  }

  /* Directions button — shared style */
  .mob-sheet-dir-btn {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px;
    border-radius: 50%;
    background: rgba(14,116,144,0.1);
    border: 1px solid rgba(14,116,144,0.2);
    color: var(--accent);
    text-decoration: none;
    flex-shrink: 0;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
  }

  .mob-sheet-dir-btn:active { background: rgba(14,116,144,0.2); }
  .mob-sheet-dir-btn svg { width: 15px; height: 15px; }

  .mob-sheet-dir-btn--sm {
    width: 30px; height: 30px;
    background: var(--bg-raised);
    border-color: var(--border-bright);
    color: var(--text-secondary);
  }

  .mob-sheet-dir-btn--sm svg { width: 13px; height: 13px; }

  /* Hide Leaflet zoom controls — pinch to zoom is intuitive on mobile */
  .leaflet-control-zoom { display: none !important; }
  #map-legend { display: none !important; }
}

/* ─── Force-mobile class (iframe preview with ?mobile=1) ─────────────────────── */
html.mobile-forced #mobile-tabs { display: flex; }
html.mobile-forced #top-bar { padding: 0 16px; gap: 8px; height: 50px; }
html.mobile-forced #race-title { font-size: 14px; }
html.mobile-forced #elapsed-time { font-size: 17px; }
html.mobile-forced #top-bar-right { gap: 6px; min-width: auto; }
html.mobile-forced .btn { padding: 6px 12px; font-size: 12px; }
html.mobile-forced #speed-label { display: none; }
html.mobile-forced #app { position: relative; }
html.mobile-forced #main-content { flex-direction: column; height: calc(100vh - 50px - 60px); overflow: hidden; }
html.mobile-forced #map-container { flex: 1; height: auto; min-height: 0; }
html.mobile-forced #side-panel { display: none; }
html.mobile-forced #van-cards-wrap { grid-template-columns: 1fr 1fr; }
html.mobile-forced #timeline-strip { height: 72px; }
html.mobile-forced #mobile-tabs {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  background: rgba(255,255,255,0.95);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 600;
}
html.mobile-forced .tab-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; background: none; border: none;
  color: var(--text-muted); font-size: 10px; font-weight: 500;
  letter-spacing: 0.3px; cursor: pointer; transition: color 0.2s;
  padding: 6px 0 4px; -webkit-tap-highlight-color: transparent;
}
html.mobile-forced .tab-btn svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 1.75; }
html.mobile-forced .tab-btn.active { color: var(--accent); }
html.mobile-forced .tab-panel {
  position: fixed;
  top: 50px; left: 0; right: 0;
  bottom: 60px;
  background: var(--bg-panel);
  overflow-y: auto; z-index: 500;
  -webkit-overflow-scrolling: touch;
}
html.mobile-forced .tab-panel[hidden] { display: none !important; }
html.mobile-forced .tab-panel:not([hidden]) { display: block; }
html.mobile-forced #app.tab-map #main-content { display: flex; }
html.mobile-forced #app.tab-map #tab-panel-timeline,
html.mobile-forced #app.tab-map #tab-panel-team { display: none !important; }
html.mobile-forced #app.tab-timeline #main-content,
html.mobile-forced #app.tab-team #main-content { display: none; }
html.mobile-forced .leaflet-control-zoom { display: none !important; }
html.mobile-forced #map-legend { display: none !important; }
