:root {
  --bg: #0f1419; --panel: #1a2029; --ink: #e6edf3; --muted: #8b98a5;
  --line: #2a323d; --accent: #3fb950; --accent2: #58a6ff; --bad: #f85149;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar {
  display: flex; align-items: center; gap: 24px; padding: 12px 24px;
  background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0;
}
.brand { font-weight: 700; font-size: 18px; color: var(--ink); }

/* ── Sport-grouped dropdown nav (Phase N0) ─────────────────────────────── */
.mainnav { display: flex; align-items: center; gap: 6px; }
.navgroup { position: relative; }
.navbtn {
  display: inline-flex; align-items: center; gap: 5px;
  background: none; border: 0; padding: 6px 10px; border-radius: 7px;
  color: var(--muted); font: inherit; font-size: 15px; cursor: pointer;
}
.navbtn:hover, .navbtn:focus-visible, .navgroup.open .navbtn { color: var(--ink); }
.navbtn:focus-visible { outline: 2px solid var(--accent2); outline-offset: 1px; }
.navbtn .caret { font-size: 11px; opacity: 0.8; }
.navtop { margin-left: 6px; padding: 6px 10px; color: var(--muted); border-radius: 7px; }
.navtop:hover, .navtop:focus-visible { color: var(--ink); text-decoration: none; }

.navmenu {
  display: none; position: absolute; left: 0; top: calc(100% + 6px); z-index: 40;
  min-width: 148px; margin: 0; padding: 6px; list-style: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
/* Desktop: hover- or keyboard-focus-open. Mobile/tap: .open toggled by nav.js. */
.navgroup:hover .navmenu,
.navgroup:focus-within .navmenu,
.navgroup.open .navmenu { display: block; }
.navmenu a {
  display: block; padding: 7px 12px; border-radius: 6px;
  color: var(--muted); white-space: nowrap;
}
.navmenu a:hover, .navmenu a:focus-visible { color: var(--ink); background: #171d26; text-decoration: none; }

@media (max-width: 620px) {
  .topbar { gap: 12px; padding: 12px 16px; }
  .navmenu { min-width: 132px; }
}
main { max-width: 1180px; margin: 0 auto; padding: 24px; }
footer { max-width: 1180px; margin: 40px auto 24px; padding: 0 24px; color: var(--muted); font-size: 13px; }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 19px; margin: 28px 0 10px; }
h3 { font-size: 16px; margin: 18px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
code { background: var(--panel); padding: 1px 6px; border-radius: 4px; }
.empty { color: var(--muted); padding: 24px; background: var(--panel); border-radius: 8px; }

table.grid { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 14px; }
table.grid th, table.grid td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; }
table.grid thead th { color: var(--muted); font-weight: 600; position: sticky; top: 49px; background: var(--bg); }
table.sortable thead th { cursor: pointer; user-select: none; }
table.sortable thead th:hover { color: var(--ink); }
table.grid tbody tr:hover { background: #171d26; }

.btn {
  display: inline-block; padding: 7px 14px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); cursor: pointer; font-size: 14px;
}
.btn:hover { border-color: var(--accent2); text-decoration: none; }
.btn.primary { background: var(--accent); color: #04260d; border-color: var(--accent); font-weight: 600; }
.slate-head, .result-head, .form-grid { display: flex; }
.slate-head, .result-head { justify-content: space-between; align-items: center; gap: 16px; }
.filter { width: 320px; max-width: 100%; padding: 8px 12px; margin: 8px 0; border-radius: 7px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); }

.badge { font-size: 11px; padding: 1px 6px; border-radius: 10px; background: var(--line); color: var(--muted); }
.badge.ok { background: var(--accent); color: #04260d; }

.form-grid { flex-wrap: wrap; gap: 14px; margin: 16px 0; }
.form-grid label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); gap: 4px; }
.form-grid label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
.form-grid input, .form-grid select { padding: 6px 8px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); min-width: 120px; }
.spinner { margin-left: 12px; color: var(--accent2); }
.lineup { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin: 12px 0; }
.lineup-meta { margin-bottom: 6px; }

.cards { display: flex; gap: 16px; flex-wrap: wrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin: 8px 0; }
.card.metric { text-align: center; min-width: 150px; }
.card .big { font-size: 30px; font-weight: 700; color: var(--accent2); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.pos { color: var(--accent); } .neg { color: var(--bad); }

svg.scatter { width: 340px; max-width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
svg.scatter .diag { stroke: var(--muted); stroke-dasharray: 4 4; }
svg.scatter .pt { fill: var(--accent2); opacity: .6; }
svg.scatter .pt.pitcher { fill: #e3853f; }

svg.trend { width: 100%; height: 160px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
svg.trend .line { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; }
svg.trend .line.hitter { stroke: var(--accent2); }
svg.trend .line.pitcher { stroke: #e3853f; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
.dot.hitter { background: var(--accent2); } .dot.pitcher { background: #e3853f; }
.card.metric.hit .big { color: var(--accent2); } .card.metric.pit .big { color: #e3853f; }
.freshness { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }

.banner { padding: 12px 16px; border-radius: 8px; margin: 12px 0; }
.banner.ok { background: rgba(63,185,80,.15); border: 1px solid var(--accent); }
.banner.bad { background: rgba(248,81,73,.15); border: 1px solid var(--bad); }
.pill { padding: 2px 9px; border-radius: 11px; font-size: 12px; }
.pill.success { background: rgba(63,185,80,.2); color: var(--accent); }
.pill.error { background: rgba(248,81,73,.2); color: var(--bad); }
.pill.running { background: rgba(88,166,255,.2); color: var(--accent2); }
.pill.over { background: rgba(63,185,80,.2); color: var(--accent); }
.pill.under { background: rgba(248,81,73,.2); color: var(--bad); }
.row-bad td { background: rgba(248,81,73,.06); }

@media (max-width: 720px) { .two-col { grid-template-columns: 1fr; } }

/* ── Live page ─────────────────────────────────────────────────── */
.live-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.live-card { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.live-card.live { border-color: #35506a; }
.live-card.final { opacity: .72; }
.live-card-top { display: flex; justify-content: space-between; align-items: center; }
.matchup { font-size: 16px; font-weight: 600; }
.matchup .at { color: var(--muted); margin: 0 4px; font-weight: 400; }
.live-badge { animation: livepulse 2s infinite; }
@keyframes livepulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

.live-score { display: flex; align-items: center; gap: 8px; }
.live-score .score { font-size: 26px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.live-score .score.lead { color: var(--ink); }
.live-score .dash { color: var(--muted); }
.live-score .inning { margin-left: 6px; color: var(--accent2); font-weight: 600; }
.final-score .score, .final-score .dash { font-size: 22px; }
.preview-score { min-height: 20px; }

.outs { display: inline-flex; gap: 4px; margin-left: 4px; }
.out-dot { width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--line); background: transparent; display: inline-block; }
.out-dot.on { background: var(--bad); border-color: var(--bad); }

.bases-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.bases { position: relative; display: inline-block; width: 42px; height: 30px; }
.base { position: absolute; width: 12px; height: 12px; background: transparent; border: 1px solid var(--line); transform: rotate(45deg); }
.base.on { background: var(--accent2); border-color: var(--accent2); }
.base.second { left: 15px; top: 0; }
.base.third { left: 2px; top: 13px; }
.base.first { left: 28px; top: 13px; }

.pitcher .pc { margin-left: 6px; padding: 1px 6px; border-radius: 8px; font-size: 11px; font-weight: 600; }
.pc.pc-ok { background: rgba(63,185,80,.18); color: var(--accent); }
.pc.pc-mild { background: rgba(210,180,60,.20); color: #d2b43c; }
.pc.pc-mod { background: rgba(227,133,63,.22); color: #e3853f; }
.pc.pc-high { background: rgba(248,81,73,.22); color: var(--bad); }

.pitchers { display: flex; flex-direction: column; gap: 2px; }
.prob-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.prob-head { font-weight: 600; margin-bottom: 2px; }
.prob-col div { font-variant-numeric: tabular-nums; }

.total-row { display: flex; align-items: baseline; gap: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.total { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.total.proj-confirmed { color: var(--accent); }
.total.proj-provisional { color: var(--muted); }

.leadoff-cols { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.lead-team.lead-projected { opacity: .55; font-style: italic; }
.lead-team.lead-pending .pending { color: var(--muted); font-style: italic; }
.live-err { color: var(--bad); }
.freshness { margin: 8px 0 14px; }

/* Per-team confirmation flags (L=lineup, P=pitcher) */
.team-conf { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.conf-flags { display: inline-flex; gap: 4px; }
.conf-flag { font-size: 10px; padding: 0 4px; border-radius: 4px; font-variant-numeric: tabular-nums;
  border: 1px solid var(--line); }
.conf-flag.flag-ok { color: #04260d; background: var(--accent); border-color: var(--accent); }
.conf-flag.flag-pending { color: var(--muted); background: var(--line); }
.conf-flag.warn { color: #3b2c05; background: #d29922; border-color: #d29922; }

/* NFL projections filter chips */
.nfl-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.chip {
  display: inline-block; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); background: var(--panel); font-size: 13px;
}
.chip:hover { color: var(--ink); text-decoration: none; }
.chip.on { color: var(--ink); background: var(--accent2); border-color: var(--accent2); }
td.lead { color: var(--ink); font-weight: 600; }
.btn.small { padding: 3px 10px; font-size: 13px; }

/* Final-card pregame reference line */
.pregame-ref { border-top: 1px solid var(--line); padding-top: 6px; }

/* Live-Model market comparison (model vs closing line) */
.market-compare { border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; margin: 10px 0; background: var(--panel); }
.market-compare h4 { margin: 6px 0; }
.line-movement { border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 6px; }
.line-movement p { margin: 4px 0; }

/* HRs & Ks props tables */
.props-table td.num, .props-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.props-table tr.prop-projected td { color: var(--muted); }
.props-table .ast { color: var(--muted); margin-left: 2px; }
.first-pitch { margin: 2px 0 6px; }
.props-foot { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 8px; }

/* HR / Ks segmented control (same chip family as the futures sort chips) */
.seg { display: inline-flex; gap: 6px; margin: 10px 0 2px; }
.seg-btn { cursor: pointer; font: inherit; font-size: 13px; line-height: 1.4; }
.seg-btn.on { color: var(--ink); background: var(--accent2); border-color: var(--accent2); font-weight: 600; }
.seg-btn:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }
.prop-panel[hidden] { display: none; }

/* Client-side text filter (ephemeral — never in the URL). Sits on its own row
   below the segmented control so it never crowds it. */
.prop-filter { margin: 8px 0 2px; }
.filter-input { position: relative; max-width: 340px; }
.filter-field {
  width: 100%; padding: 9px 34px 9px 13px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font: inherit; font-size: 16px; /* 16px: comfortably tappable + no iOS focus zoom */
}
.filter-field::placeholder { color: var(--muted); }
.filter-field:focus {
  outline: none; border-color: var(--accent2);
  box-shadow: 0 0 0 2px rgba(88, 166, 255, .35);
}
.filter-clear {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; color: var(--muted); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 8px 10px; border-radius: 50%;
}
.filter-clear:hover { color: var(--ink); }
.filter-count, .filter-empty { margin: 6px 0 0; }
.filter-empty[hidden], .filter-count[hidden] { display: none; }

/* Mobile polish: tighten props columns so all fit at ~390px without dropping any.
   overflow-wrap lets a long name break so the width:100% table always shrinks to
   the viewport (no horizontal page scroll); the num columns stay on one line. */
@media (max-width: 480px) {
  .props-table { font-size: 13px; }
  .props-table th, .props-table td { padding: 6px 6px; overflow-wrap: anywhere; }
  .props-table th:first-child, .props-table td:first-child { padding-left: 2px; }
  .props-table th:last-child, .props-table td:last-child { padding-right: 2px; }
  .props-table td.num, .props-table th.num { overflow-wrap: normal; white-space: nowrap; }
}
