:root {
  --bg: #0b1220;
  --panel: #121a2b;
  --panel2: #182235;
  --line: #243049;
  --text: #e8eefc;
  --muted: #93a0b8;
  --accent: #3ddc97;
  --accent2: #ffb020;
  --danger: #ff5c7a;
  --chip: #1c2740;
  --shadow: 0 8px 24px rgba(0,0,0,.35);
  --radius: 14px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: radial-gradient(1200px 600px at 10% -10%, #16233d, var(--bg));
  color: var(--text); min-height: 100vh;
}
.topbar {
  display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line); background: rgba(10,16,28,.9);
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(8px);
}
.brand { display: flex; gap: 12px; align-items: center; }
.logo {
  width: 44px; height: 44px; border-radius: 12px; display:grid; place-items:center;
  background: linear-gradient(135deg, var(--accent), #1f9d6a); color:#04140d; font-weight:800;
  object-fit: cover; flex-shrink: 0; border: 1px solid rgba(212,175,55,.35);
}
.brand h1 { margin:0; font-size:1.15rem; }
.tag { margin:2px 0 0; color:var(--muted); font-size:.8rem; }
.clock-block { text-align:center; }
.clock { font-size:1.6rem; font-variant-numeric: tabular-nums; font-weight:700; letter-spacing:.04em; }
.clock-date { color:var(--muted); font-size:.85rem; }
.refresh-row { margin-top:6px; font-size:.8rem; color:var(--muted); display:flex; gap:8px; justify-content:center; align-items:center; }
button, .chip {
  background: var(--chip); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; cursor: pointer;
}
button:hover { border-color: var(--accent); }
.headline-hit { display:flex; gap:10px; justify-content:flex-end; align-items:center; }
.hit-pill {
  background: var(--panel); border:1px solid var(--line); border-radius:12px; padding:8px 12px; min-width:90px; text-align:center;
}
.hit-pill span { display:block; color:var(--muted); font-size:.7rem; text-transform:uppercase; }
.hit-pill strong { font-size:1.2rem; color: var(--accent); }
.tabs {
  display:flex; gap:8px; overflow-x:auto; padding:10px 12px; border-bottom:1px solid var(--line);
}
.tabs button.active, .subtabs button.active, .h-slider .chip.active {
  background: linear-gradient(135deg, #214d3a, #183528); border-color: var(--accent); color:#d9ffe9;
}
main { padding: 14px 16px 40px; max-width: 1200px; margin: 0 auto; }
.hidden { display:none !important; }
.slider-label { color:var(--muted); font-size:.75rem; text-transform:uppercase; letter-spacing:.08em; margin: 10px 0 6px; }
.h-slider {
  display:flex; gap:8px; overflow-x:auto; padding-bottom:6px; scroll-snap-type:x mandatory;
}
.h-slider .chip { scroll-snap-align:start; white-space:nowrap; }
.banner {
  background:#3a2a12; border:1px solid #7a5a20; color:#ffd89a; padding:10px 12px; border-radius:10px; margin-bottom:10px;
}
.race-panel {
  margin-top:14px; background:var(--panel); border:1px solid var(--line); border-radius:var(--radius);
  padding:14px; box-shadow: var(--shadow);
}
.muted { color: var(--muted); }
.pick-row {
  display:grid; grid-template-columns: repeat(5, minmax(120px,1fr)); gap:8px; margin: 12px 0 16px;
}
.pick-card {
  background: var(--panel2); border:1px solid var(--line); border-radius:12px; padding:10px;
}
.pick-card .pos { color:var(--accent2); font-size:.7rem; text-transform:uppercase; letter-spacing:.06em; }
.pick-card .name { font-weight:700; margin-top:4px; }
.pick-card .meta { color:var(--muted); font-size:.8rem; }
.runners { display:flex; flex-direction:column; gap:8px; }
.runner {
  display:grid; grid-template-columns: 48px 1fr auto; gap:10px; align-items:center;
  background: #0f1626; border:1px solid var(--line); border-radius:12px; padding:8px 10px;
}
.runner.scratched { opacity:.45; text-decoration: line-through; }
.runner.picked { border-color: var(--accent); box-shadow: inset 0 0 0 1px rgba(61,220,151,.35); }
.rug, .silk {
  width:40px; height:40px; border-radius:10px; display:grid; place-items:center; font-weight:800; color:#fff;
  border:1px solid rgba(255,255,255,.15); overflow:hidden;
}
.rug.stripes-bw { background: repeating-linear-gradient(90deg,#111 0 6px,#f5f5f5 6px 12px); color:#111; }
.rug.stripes-gw { background: repeating-linear-gradient(90deg,#43A047 0 6px,#fff 6px 12px); }
.rug.rwb { background: linear-gradient(90deg,#E53935 0 33%,#fff 33% 66%,#1E88E5 66%); color:#111; }
.silk img { width:100%; height:100%; object-fit:cover; }
.runner-name { font-weight:600; }
.runner-meta { color:var(--muted); font-size:.8rem; }
.td-stats { font-size:.78rem; color:var(--muted); }
.td-stats .na { color: var(--danger); }
.runner-actions button { font-size:.75rem; padding:4px 8px; }
.factors { margin-top:8px; display:flex; flex-wrap:wrap; gap:6px; }
.factor {
  font-size:.72rem; background:#101828; border:1px solid var(--line); border-radius:8px; padding:4px 6px;
}
.factor.missing { border-color:#6b3a48; color:#ffb3c1; }


.placeholder-card {
  background:var(--panel); border:1px dashed var(--line); border-radius:var(--radius); padding:28px; text-align:center;
}
.subtabs { display:flex; gap:8px; justify-content:center; margin-top:12px; }
.hit-grid { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.hit-table { width:100%; border-collapse:collapse; background:var(--panel); border-radius:12px; overflow:hidden; }
.hit-table th, .hit-table td { padding:8px 10px; border-bottom:1px solid var(--line); text-align:left; font-size:.9rem; }
.hit-table th { color:var(--muted); font-weight:600; background:#0f1728; }
.footer { text-align:center; color:var(--muted); font-size:.75rem; padding:18px; border-top:1px solid var(--line); }
@media (max-width: 860px) {
  .topbar { grid-template-columns: 1fr; }
  .headline-hit { justify-content:flex-start; }
  .pick-row { grid-template-columns: 1fr 1fr; }
  .hit-grid { grid-template-columns: 1fr; }
}

.ff-attrib { color: #7dd3a0; font-weight: 600; font-size: 0.85em; }

.runner.reserve { opacity: 0.85; border-style: dashed; }
.runner.reserve .runner-name .muted { font-size: 0.75em; }

.pick-card .pick-main { display:flex; align-items:center; gap:8px; margin-top:4px; }
.pick-badge {
  flex:0 0 auto; width:28px; height:28px; border-radius:6px;
  display:flex; align-items:center; justify-content:center;
  font-weight:800; font-size:.85rem; color:#fff; background:#333;
  position:relative; overflow:hidden;
}
.pick-badge.na { opacity:.5; }
.pick-badge.horse-num { background:#1e3a5f; border:1px solid #3d5a80; }
.pick-badge.silk img { width:100%; height:100%; object-fit:cover; }
.pick-badge.silk .num {
  position:absolute; right:0; bottom:0; background:rgba(0,0,0,.65);
  font-size:.65rem; padding:0 3px; line-height:1.2; border-radius:3px 0 0 0;
}
.pick-badge.rug.stripes-bw { background: repeating-linear-gradient(90deg,#111 0 5px,#f5f5f5 5px 10px); color:#111; }
.pick-badge.rug.stripes-gw { background: repeating-linear-gradient(90deg,#43A047 0 5px,#fff 5px 10px); color:#111; }
.pick-badge.rug.rwb { background: linear-gradient(90deg,#E53935 0 33%,#fff 33% 66%,#1E88E5 66%); color:#111; }

/* Stage 2 sports */
.sports-panel { display: grid; gap: 12px; }
.sport-card {
  background: var(--card, #1a2332);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  padding: 14px 16px;
}
.sport-card h3 { margin: 0 0 6px; font-size: 1.05rem; }
.sport-card .meta { color: var(--muted, #9aa4b2); font-size: .85rem; margin-bottom: 8px; }
.sport-card .legs { display: grid; gap: 6px; margin: 8px 0; }
.sport-card .leg {
  background: rgba(255,255,255,.04);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: .9rem;
}
.sport-card .missing { color: #f0b429; font-size: .8rem; }
.sport-card .attr { color: var(--muted, #9aa4b2); font-size: .75rem; margin-top: 8px; }
.sport-card .ev { display:inline-block; margin-left:8px; padding:2px 8px; border-radius:999px; background:#333; font-size:.75rem; }
.sport-card .ev.unavailable { background:#3a2a10; color:#f0b429; }
.subtabs { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:12px; }
.subtabs button {
  background:#243044; color:#fff; border:0; border-radius:999px; padding:6px 12px; cursor:pointer;
}
.subtabs button.active { background: var(--accent, #3d8bfd); }

.sport-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.sport-card.is-locked { border-color: rgba(61,220,151,.45); }
.sport-card.is-building { border-style: dashed; }
.sport-card-head { display:flex; justify-content:space-between; gap:10px; align-items:flex-start; margin-bottom:6px; }
.sport-card-head h3 { margin:0; font-size:1.05rem; }
.sport-card .headline { font-weight:700; margin: 6px 0 10px; }
.sport-card .leg { display:flex; gap:10px; align-items:flex-start; background: var(--panel2); border:1px solid var(--line); }
.sport-card .leg-n {
  flex:0 0 auto; width:28px; height:28px; border-radius:8px; display:grid; place-items:center;
  background:#214d3a; color:#d9ffe9; font-size:.7rem; font-weight:800;
}
.sport-card .leg-body { flex:1; }
.sport-card .leg-desc { font-weight:600; }
.sport-card .leg-meta { color:var(--muted); font-size:.78rem; margin-top:2px; }
.pill {
  display:inline-block; padding:3px 10px; border-radius:999px; font-size:.72rem; font-weight:700;
  white-space:nowrap;
}
.pill.locked { background:#214d3a; color:#d9ffe9; border:1px solid var(--accent); }
.pill.building { background:#3a2a10; color:#ffd89a; border:1px solid #7a5a20; }
.pill.win { background:#1a3d2a; color:var(--accent); }
.pill.loss { background:#3a1a22; color:var(--danger); }

.odds { color: var(--accent2); font-variant-numeric: tabular-nums; font-weight: 600; }
.pick-card .meta { margin-top: 4px; }

.ev.lock { color: #3ddc97; font-weight: 700; }
.ev.lean { color: #f0c14b; font-weight: 700; }
.ev.value { color: #7ec8ff; }
.ev.unavailable { color: #8a93a6; }

/* —— Phone layout (JUMPLINE) —— */
@media (max-width: 480px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px 12px;
    padding-top: max(10px, env(safe-area-inset-top));
  }
  .brand h1 { font-size: 1.05rem; }
  .tag { font-size: .72rem; }
  .logo { width: 38px; height: 38px; border-radius: 10px; font-size: .9rem; }
  .clock { font-size: 1.35rem; }
  .clock-date { font-size: .75rem; }
  .headline-hit {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }
  .hit-pill { min-width: 0; width: 100%; padding: 8px; }
  .hit-pill strong { font-size: 1.05rem; }
  .tabs {
    gap: 6px;
    padding: 8px 10px;
    -webkit-overflow-scrolling: touch;
  }
  .tabs button, .subtabs button, .h-slider .chip {
    padding: 8px 12px;
    font-size: .85rem;
    flex: 0 0 auto;
  }
  main {
    padding: 10px 10px 32px;
    padding-bottom: max(32px, env(safe-area-inset-bottom));
  }
  .pick-row {
    grid-template-columns: 1fr 1fr !important;
    gap: 6px;
  }
  .pick-card { padding: 8px; min-width: 0; }
  .pick-card .name { font-size: .9rem; word-break: break-word; }
  .runner {
    grid-template-columns: 40px 1fr;
    gap: 8px;
    padding: 8px;
  }
  .runner-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
  }
  .race-panel { padding: 10px; margin-top: 10px; }
  .hit-grid { grid-template-columns: 1fr !important; gap: 10px; }
  .hit-table { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .hit-table th, .hit-table td { padding: 8px; font-size: .8rem; white-space: nowrap; }
  .sport-card { padding: 12px; }
  .sport-card-head { flex-wrap: wrap; }
  .sport-card-head h3 { font-size: .98rem; word-break: break-word; }
  
  .footer { padding: 14px 10px; font-size: .7rem; }
}

/* Keep tab/meeting chip rows scrollable without expanding page width */
.tabs, .subtabs, .h-slider, .meetings-row, .races-row {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
body { overflow-x: hidden; }


/* Settled race chip mark — distinct from active highlight */
.h-slider .chip .settled-mark {
  display: inline-flex; align-items: center; justify-content: center;
  margin-left: 5px; width: 15px; height: 15px; border-radius: 50%;
  font-size: 0.65rem; font-weight: 700; line-height: 1;
  background: #243449; color: #9ec0ff; border: 1px solid #3a516e;
}
.h-slider .chip.active .settled-mark {
  background: rgba(0,0,0,.28); color: #cfeadf; border-color: rgba(217,255,233,.35);
}
.scratch-tag {
  display: inline-block; margin-left: 4px; padding: 1px 6px; border-radius: 6px;
  font-size: 0.68rem; font-weight: 600; letter-spacing: .02em;
  background: #3a1820; color: #ff8fa3; border: 1px solid #6a3040;
  text-decoration: none;
}
.missing-info {
  margin-top: 6px; font-size: 0.78rem; color: var(--muted);
}
.missing-info summary {
  cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); user-select: none;
}
.missing-info summary::-webkit-details-marker { display: none; }
.missing-info .info-i {
  display: inline-flex; width: 16px; height: 16px; border-radius: 50%;
  align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700; font-style: italic;
  background: #1c2740; border: 1px solid var(--line); color: var(--accent2);
}
.missing-info[open] summary { color: var(--text); }
.missing-info p { margin: 6px 0 0; padding: 8px 10px; background: #0f1626; border: 1px solid var(--line); border-radius: 8px; }

/* Ranking percentages panel */
.ranking-panel {
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px 12px;
}
.ranking-panel > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  list-style: none;
  padding: 6px 0;
}
.ranking-panel > summary::-webkit-details-marker { display: none; }
.ranking-panel > summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 8px;
  color: var(--muted);
  transition: transform .15s ease;
}
.ranking-panel[open] > summary::before { transform: rotate(90deg); }
.ranking-body { margin-top: 8px; }
.ranking-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ranking-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.ranking-table th {
  text-align: left;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
.ranking-table th:not(:first-child),
.ranking-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.ranking-table td {
  padding: 10px 8px;
  border-bottom: 1px solid rgba(36,48,73,.85);
  vertical-align: top;
}
.ranking-table tr:last-child td { border-bottom: none; }
.factor-name { font-weight: 700; color: var(--text); }
.factor-desc {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  margin-top: 2px;
  max-width: 34rem;
}
.ranking-table td.now { color: #e8eefc; font-weight: 600; }
.move-up { color: #3ddc97; }
.move-down { color: #ff5c7a; }
.move-flat { color: var(--muted); }
.ranking-meta {
  margin: 10px 0 6px;
  font-size: 0.75rem;
  color: var(--muted);
}
.ranking-changes-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 4px;
}
.ranking-changes ul {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  color: var(--text);
}
.ranking-changes li { margin: 4px 0; }
.ranking-changes time { color: var(--muted); font-variant-numeric: tabular-nums; }

@media (max-width: 520px) {
  .ranking-table { font-size: 0.8rem; }
  .factor-desc { font-size: 0.72rem; }
  .ranking-table th, .ranking-table td { padding: 8px 6px; }
}

.hit-table tr.hit-total td {
  border-top: 2px solid var(--line);
  font-weight: 700;
  padding-top: 10px;
  color: var(--text);
}
.hit-table tr.hit-total td:first-child {
  letter-spacing: 0.02em;
}

/* Meeting day switch + live jump countdowns */
.day-switch {
  display: flex;
  gap: 6px;
  margin: 8px 0 4px;
  flex-wrap: wrap;
}
.day-switch button {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  border: 1px solid var(--border, #333);
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.day-switch button.active {
  background: var(--accent, #1db954);
  border-color: var(--accent, #1db954);
  color: #0b0b0b;
  font-weight: 600;
}
.h-slider .chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  line-height: 1.15;
  padding: 8px 12px;
}
.h-slider .chip .chip-title {
  font-weight: 600;
}
.h-slider .chip .chip-cd {
  font-size: 0.72rem;
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
}
.h-slider .chip.chip-done .chip-cd { opacity: 0.55; }
.h-slider .chip.chip-jumped .chip-cd { color: var(--warn, #e6a23c); }
.race-jump-banner {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 6px 0 10px;
  font-variant-numeric: tabular-nums;
  color: var(--accent, #1db954);
}
.race-jump-banner.is-jumped { color: var(--warn, #e6a23c); }
.race-jump-banner.is-done { color: inherit; opacity: 0.7; font-weight: 600; }
@media (max-width: 640px) {
  .h-slider .chip .chip-cd { font-size: 0.68rem; }
  .race-jump-banner { font-size: 1.05rem; }
}


.first-starter-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #f5e6c8;
  background: #3a2f1a;
  border: 1px solid #8a7344;
  vertical-align: middle;
}



/* Jumped race result card */
.result-card {
  margin: 12px 0 16px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #141a22;
  border: 1px solid #2a3340;
}
.result-card.won { border-color: #3d8f5a; }
.result-card.missed { border-color: #8f3d3d; }
.result-card .result-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.result-card .result-label {
  font-weight: 800; font-size: 14px; letter-spacing: 0.04em;
  padding: 2px 10px; border-radius: 6px;
}
.result-card.won .result-label { background: #1f3d2a; color: #7dffa3; }
.result-card.missed .result-label { background: #3d1f1f; color: #ff9a9a; }
.result-card h4 { margin: 8px 0 6px; font-size: 12px; color: #9aa4b2; text-transform: uppercase; letter-spacing: 0.06em; }
.result-first4, .result-picks {
  display: grid; gap: 6px;
}
.result-row {
  display: grid;
  grid-template-columns: 28px 36px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  background: #0e1319;
}
.result-row .pos { font-weight: 700; color: #9aa4b2; }
.result-row .tick { font-weight: 800; font-size: 16px; }
.result-row .tick.hit { color: #7dffa3; }
.result-row .tick.miss { color: #ff9a9a; }
.result-row .tick.scratched, .result-row .tick.unplaced, .result-row .tick.empty { color: #6b7280; font-size: 12px; font-weight: 600; }
.hit-table th:nth-child(n+6), .hit-table td:nth-child(n+6) { font-size: 12px; color: #c5ced8; }
.hit-note { margin-top: 8px; font-size: 12px; }


.hit-chart-wrap { margin-top: 18px; padding: 12px 14px; border-radius: 10px; background: #141a22; border: 1px solid #2a3340; }
.hit-chart-title { margin: 0 0 8px; font-size: 14px; }
.hit-chart-tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.hit-daily-chart { width: 100%; overflow-x: auto; }
.hit-daily-chart svg { display: block; max-width: 100%; height: auto; }
.hit-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; font-size: 12px; color: #c5ced8; }
.hit-legend span { display: inline-flex; align-items: center; gap: 6px; }
.hit-legend i { width: 12px; height: 3px; display: inline-block; border-radius: 2px; }
.pick-change-note {
  margin: 8px 0 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #1a2030;
  border: 1px solid #2e3a4d;
  color: #c5ced8;
  font-size: 13px;
}
.pick-change-note strong { color: #e8eef7; font-weight: 600; }

.subtab-sep {
  display: inline-block;
  width: 1px;
  align-self: stretch;
  min-height: 1.6rem;
  background: rgba(255,255,255,0.18);
  margin: 0 6px;
}
