:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --ink: #1c2430;
  --muted: #5d6b7a;
  --line: #dfe4ea;
  --line-soft: #eef1f5;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --good: #157347;
  --bad: #b42318;
  --warn: #9a6700;
  --bar: #eaeff7;
  --bar-ink: #1c2430;
  --bar-muted: #59677a;
  --bar-btn-bg: rgba(255, 255, 255, 0.72);
  --bar-btn-border: rgba(16, 24, 38, 0.16);
  --row-hover: #eaf1fd;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 38, 0.06);
  --tabs-h: 52px;
}

[data-theme="dark"] {
  --bg: #0e131b;
  --surface: #151c26;
  --surface-2: #1b2533;
  --ink: #e7edf5;
  --muted: #93a1b3;
  --line: #26303d;
  --line-soft: #1f2833;
  --accent: #4c8dff;
  --accent-ink: #0b1220;
  --good: #3fb950;
  --bad: #f85149;
  --warn: #d29922;
  --bar: #161f2b;
  --bar-ink: #e7edf5;
  --bar-muted: #93a1b3;
  --bar-btn-bg: rgba(255, 255, 255, 0.08);
  --bar-btn-border: rgba(255, 255, 255, 0.18);
  --row-hover: #1d2836;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body { min-height: 100vh; }

.wrap {
  width: min(1700px, 100% - 2rem);
  margin: 0 auto;
}

.hidden { display: none !important; }

.site-header {
  background: var(--bar);
  color: var(--bar-ink);
  padding: 1.1rem 0 1rem;
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.site-header h1 { margin: 0; font-size: 1.5rem; letter-spacing: 0.2px; }

.site-header .sub { margin: 0.25rem 0 0.7rem; color: var(--bar-muted); font-size: 0.9rem; }

.status { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; font-size: 0.9rem; color: var(--bar-muted); }

.btn {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  cursor: pointer;
  font: inherit;
}

.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn:focus-visible, .tab:focus-visible, .seg:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.theme-btn { white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; padding: 0.4rem 0.55rem; }
.theme-btn .icon-sun { display: none; }
[data-theme="dark"] .theme-btn .icon-sun { display: block; }
[data-theme="dark"] .theme-btn .icon-moon { display: none; }
.theme-btn svg, .swap svg { width: 18px; height: 18px; display: block; }
.swap { width: 2.2rem; padding-left: 0; padding-right: 0; display: inline-flex; align-items: center; justify-content: center; }

.site-header .btn {
  background: var(--bar-btn-bg);
  border-color: var(--bar-btn-border);
  color: var(--bar-ink);
}
.site-header .btn:hover { border-color: var(--accent); }

.tabs {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.tab-row { display: flex; gap: 0.15rem; flex-wrap: wrap; }

.tab {
  border: 0;
  background: none;
  padding: 0.8rem 0.9rem;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
}

.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.panel { padding: 1.1rem 0 2rem; }

.toolbar { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.toolbar-label { color: var(--muted); font-size: 0.9rem; }

input[type="search"], input[type="text"], select {
  font: inherit;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

input[type="search"] { min-width: 240px; }

.combo { position: relative; display: inline-block; }
.combo input { min-width: 240px; }
.combo-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  min-width: 100%;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.combo-item { display: flex; justify-content: space-between; gap: 1rem; padding: 0.4rem 0.7rem; cursor: pointer; font-size: 0.88rem; }
.combo-item:hover, .combo-item.active { background: var(--row-hover); }
.combo-item .ci-name { font-weight: 600; white-space: nowrap; }
.combo-item .ci-meta { color: var(--muted); white-space: nowrap; }
.combo-empty { padding: 0.5rem 0.7rem; color: var(--muted); font-size: 0.85rem; }

.inline-label { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; color: var(--muted); }

.count { color: var(--muted); font-size: 0.85rem; margin-left: auto; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; flex-wrap: wrap; }

.seg {
  border: 0;
  background: var(--surface);
  padding: 0.45rem 0.9rem;
  font: inherit;
  cursor: pointer;
  color: var(--muted);
}

.seg.active { background: var(--accent); color: var(--accent-ink); }

.table-scroll {
  overflow: visible;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.data-table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: 0.88rem; }

.data-table thead th {
  position: sticky;
  top: var(--tabs-h);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  text-align: right;
  padding: 0.5rem 0.6rem;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  z-index: 5;
}

.data-table thead th:first-child,
.data-table thead th.left { text-align: left; }
.data-table thead th:hover { color: var(--accent); }
.data-table thead th .arrow { color: var(--accent); font-size: 0.7rem; margin-left: 0.25rem; }

.data-table tbody td {
  padding: 0.4rem 0.65rem;
  border-bottom: 1px solid var(--line-soft);
  text-align: right;
  white-space: nowrap;
}

.data-table tbody td.left { text-align: left; }
.data-table tbody tr:nth-child(even) { background: var(--surface-2); }
.data-table tbody tr:hover { background: var(--row-hover); }

.team-cell { font-weight: 600; }
.level-badge { display: inline-block; font-size: 0.65rem; font-weight: 700; padding: 0.05rem 0.3rem; border-radius: 4px; margin-left: 0.35rem; vertical-align: middle; background: var(--line-soft); color: var(--muted); }
.level-badge.aa { background: #fdeecd; color: #8a5a00; }
[data-theme="dark"] .level-badge.aa { background: #4a3a12; color: #f2d38a; }

.home-mark { color: var(--accent); font-weight: 700; margin-right: 0.2rem; }
.win { color: var(--good); font-weight: 600; }
.loss { color: var(--bad); font-weight: 600; }
.dim { color: var(--muted); }

.team-logo { display: inline-flex; align-items: center; vertical-align: middle; margin-right: 0.45rem; width: 22px; height: 22px; }
.team-logo img { width: 22px; height: 22px; object-fit: contain; }
.team-logo .logo-dark { display: none; }
[data-theme="dark"] .team-logo .logo-light { display: none; }
[data-theme="dark"] .team-logo .logo-dark { display: inline-block; }
.team-name { vertical-align: middle; }
.ap-rank { display: inline-block; min-width: 1.3rem; text-align: center; font-weight: 700; color: var(--accent); }
.ap-badge { display: inline-block; font-size: 0.65rem; font-weight: 700; padding: 0.05rem 0.35rem; border-radius: 4px; margin-left: 0.4rem; vertical-align: middle; background: var(--surface-2); color: var(--accent); border: 1px solid var(--line); }

.section-title { font-size: 1.05rem; margin: 1.4rem 0 0.6rem; }

.summary { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.summary .chip { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.5rem 0.8rem; box-shadow: var(--shadow); }
.summary .chip .k { display: block; color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.4px; }
.summary .chip .v { font-size: 1.15rem; font-weight: 700; }

.sim-results { display: flex; flex-direction: column; gap: 1rem; }
.sim-block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1rem; box-shadow: var(--shadow); }
.sim-block h3 { margin: 0 0 0.5rem; font-size: 0.95rem; }
.sim-more { color: var(--muted); font-size: 0.78rem; margin: 0.5rem 0 0; }
.sim-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.3rem 1rem; }
.sim-list .row { display: grid; grid-template-columns: minmax(0, 1fr) 84px 52px; align-items: center; gap: 0.5rem; font-size: 0.88rem; }
.sim-list .row > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sim-list .row > span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.bar-track { background: var(--line-soft); border-radius: 4px; height: 8px; overflow: hidden; }
.bar-fill { display: block; background: var(--accent); height: 100%; }

/* bracket */
.bracket { display: flex; gap: 0.9rem; overflow-x: auto; padding: 0.4rem 0 1rem; align-items: stretch; }
.bracket-col { display: flex; flex-direction: column; justify-content: space-around; gap: 0.6rem; min-width: 230px; flex: 1; }
.bracket-col-title { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); text-align: center; margin-bottom: 0.3rem; }
.game-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.game-team { display: flex; justify-content: space-between; gap: 0.5rem; padding: 0.35rem 0.55rem; font-size: 0.85rem; }
.game-team + .game-team { border-top: 1px solid var(--line-soft); }
.game-team .seed { color: var(--muted); min-width: 1.6rem; }
.game-team .name { flex: 1 1 auto; }
.game-team .team-logo { width: 16px; height: 16px; margin-right: 0.35rem; }
.game-team .team-logo img { width: 16px; height: 16px; }
.game-team.winner { font-weight: 700; color: var(--accent); }
.game-team .score { font-variant-numeric: tabular-nums; }
.site-tag { font-size: 0.68rem; color: var(--muted); padding: 0.15rem 0.55rem; background: var(--surface-2); border-top: 1px solid var(--line-soft); }
.champ-box { border: 2px solid var(--accent); }

.matchup-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1rem; box-shadow: var(--shadow); margin-bottom: 1.4rem; }
.matchup-panel > .inline-label { margin-bottom: 0.8rem; }
.matchup-controls { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem; align-items: end; }
.matchup-controls label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); }
.matchup-controls select { min-width: 0; width: 100%; }
.matchup-controls .swap { align-self: end; justify-self: center; }

/* Head to Head: projection and comparison on the left, polls on the right. */
.h2h-top { display: grid; grid-template-columns: minmax(0, 820px) minmax(0, 1fr); gap: 1.4rem; align-items: start; }
.h2h-col, .h2h-side { min-width: 0; }
#matchupPolls { display: grid; gap: 1rem; }

/* Team comparison: the two teams side by side, one row per metric. */
.h2h-cmp { width: 100%; max-width: 820px; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); font-variant-numeric: tabular-nums; }
.h2h-cmp thead th { padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: bottom; font-weight: 400; }
.h2h-cmp-away, .h2h-cmp-home { text-align: left !important; }
.h2h-head-role { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; color: var(--muted); margin-bottom: 0.3rem; }
.h2h-head-name { font-weight: 700; font-size: 1rem; display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.h2h-head-name .team-logo { width: 26px; height: 26px; }
.h2h-head-name .team-logo img { width: 26px; height: 26px; }
.h2h-cmp tbody th { text-align: left; font-weight: 500; color: var(--muted); font-size: 0.85rem; padding: 0.5rem 0.9rem; border-bottom: 1px solid var(--line-soft); }
.h2h-cmp tbody td { text-align: left; padding: 0.5rem 0.9rem; border-bottom: 1px solid var(--line-soft); font-size: 0.95rem; }
.h2h-cmp tbody tr:last-child th, .h2h-cmp tbody tr:last-child td { border-bottom: 0; }
.h2h-cmp tbody tr.h2h-lead th { color: var(--accent); font-weight: 700; }
.h2h-cmp tbody tr.h2h-lead td { font-weight: 700; color: var(--accent); }

.h2h-proj-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; max-width: 820px; }
.h2h-proj-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem 1rem; box-shadow: var(--shadow); }
.h2h-proj-site { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; color: var(--muted); margin-bottom: 0.45rem; }
.h2h-proj-fav { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: 0.4rem; }
.h2h-proj-fav .team-logo { width: 22px; height: 22px; }
.h2h-proj-fav .team-logo img { width: 22px; height: 22px; }
.h2h-proj-margin { font-size: 2rem; font-weight: 700; color: var(--accent); line-height: 1.15; margin: 0.2rem 0 0.6rem; }
.h2h-proj-label { font-size: 0.8rem; font-weight: 400; color: var(--muted); margin-left: 0.3rem; }
.h2h-proj-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--line-soft); }
.h2h-proj-bar span { background: var(--muted); }
.h2h-proj-bar span.fav { background: var(--accent); }
.h2h-proj-probs { display: flex; justify-content: space-between; gap: 0.6rem; margin-top: 0.4rem; font-size: 0.82rem; color: var(--muted); }

.h2h-last5 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; max-width: 820px; }
.h2h-last { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem 0.85rem; box-shadow: var(--shadow); }
.h2h-last-title { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; color: var(--muted); margin-bottom: 0.4rem; display: flex; align-items: center; gap: 0.4rem; }
.h2h-last-title .team-logo { width: 18px; height: 18px; }
.h2h-last-title .team-logo img { width: 18px; height: 18px; }
.h2h-last-list { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.86rem; }
.h2h-last-item { display: grid; grid-template-columns: 4.8rem 1fr; align-items: center; gap: 0.5rem; }
.h2h-last-item .team-logo { width: 16px; height: 16px; }
.h2h-last-item .team-logo img { width: 16px; height: 16px; }
.h2h-last-res { font-variant-numeric: tabular-nums; }
.h2h-last-opp { color: var(--ink); display: flex; align-items: center; gap: 0.35rem; }
.h2h-next { margin-top: 0.5rem; padding-top: 0.4rem; border-top: 1px solid var(--line-soft); font-size: 0.8rem; display: grid; grid-template-columns: 4.8rem 1fr; align-items: center; gap: 0.5rem; }
.h2h-next-label { color: var(--muted); }
.h2h-next .team-logo { width: 16px; height: 16px; }
.h2h-next .team-logo img { width: 16px; height: 16px; }

.h2h-conf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.h2h-conf-grid.single { grid-template-columns: minmax(0, calc(50% - 0.5rem)); justify-content: center; }
.h2h-conf { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.h2h-conf-title { padding: 0.55rem 0.8rem; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line-soft); }
.h2h-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; font-variant-numeric: tabular-nums; }
.h2h-table th { text-align: left; font-weight: 600; font-size: 0.68rem; letter-spacing: 0.3px; text-transform: uppercase; color: var(--muted); padding: 0.35rem 0.7rem; border-bottom: 1px solid var(--line-soft); }
.h2h-table th.left, .h2h-table td.left { text-align: left; }
.h2h-table th:nth-child(1), .h2h-table td:nth-child(1) { width: 2.5rem; text-align: center; }
.h2h-table th:nth-child(2), .h2h-table td:nth-child(2) { width: 1%; }
.h2h-table td { padding: 0.3rem 0.7rem; border-bottom: 1px solid var(--line-soft); text-align: left; white-space: nowrap; }
.h2h-table tbody tr:last-child td { border-bottom: 0; }
.h2h-table tbody tr:nth-child(even) { background: var(--surface-2); }
.h2h-table tr.h2h-me { background: var(--row-hover); font-weight: 700; }
.h2h-table td .team-logo { width: 18px; height: 18px; margin-right: 0.35rem; vertical-align: middle; }
.h2h-table td .team-logo img { width: 18px; height: 18px; vertical-align: middle; }
.h2h-table tr.h2h-gap { background: transparent; }
.h2h-table tr.h2h-gap td { text-align: center; background: transparent; }
.h2h-expand, .h2h-collapse { border: 0; background: none; color: var(--accent); cursor: pointer; font: inherit; font-size: 0.78rem; padding: 0.15rem 0.6rem; border-radius: 4px; }
.h2h-expand:hover, .h2h-collapse:hover { background: var(--row-hover); }
.h2h-tag { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.3px; text-transform: uppercase; color: var(--accent); }

.h2h-notes { margin-top: 1rem; }

.watch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0.8rem; margin-bottom: 0.4rem; }
.watch-window { margin-bottom: 0.9rem; }
.watch-window-title { margin: 0 0 0.4rem; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); }
.watch-window-title .dim { text-transform: none; letter-spacing: 0; font-weight: 400; }
.legend { margin: 0 0 0.7rem; }
.legend summary { cursor: pointer; color: var(--accent); font-size: 0.82rem; }
.legend p { color: var(--muted); font-size: 0.82rem; margin: 0.45rem 0 0; max-width: 60ch; }
.watch-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.7rem 0.8rem; box-shadow: var(--shadow); }
.watch-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.35rem; }
.watch-score { display: inline-block; min-width: 2.1rem; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent-ink); background: var(--accent); border-radius: 6px; padding: 0.05rem 0.4rem; }
.watch-tag { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.3px; color: var(--muted); }
.watch-tier { font-size: 0.7rem; font-weight: 700; color: var(--accent); }
.watch-match { font-weight: 600; font-size: 0.9rem; }
.watch-meta { color: var(--muted); font-size: 0.78rem; margin-top: 0.25rem; }

.ccg-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0.8rem; margin-bottom: 0.6rem; }
@media (min-width: 1080px) { .ccg-board { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.ccg-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.7rem 0.8rem; box-shadow: var(--shadow); }
.ccg-conf { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); margin-bottom: 0.35rem; }
.ccg-team { display: flex; align-items: center; gap: 0.4rem; font-weight: 600; font-size: 0.9rem; }
.ccg-team.winner { color: var(--accent); }
.ccg-proj { margin-left: auto; color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.ccg-pct { color: var(--accent); font-weight: 700; }
.ccg-site { color: var(--muted); font-size: 0.72rem; margin-top: 0.35rem; }

.note { color: var(--muted); font-size: 0.82rem; margin: 0.2rem 0 0.9rem; }

.site-footer { border-top: 1px solid var(--line); padding: 1rem 0 2rem; color: var(--muted); font-size: 0.82rem; }
.site-footer p { margin: 0.2rem 0; }

.loading { padding: 1rem; color: var(--muted); }

@media (max-width: 1200px) {
  .h2h-top { grid-template-columns: 1fr; }
  #matchupPolls { max-width: 820px; }
}

@media (max-width: 720px) {
  input[type="search"] { min-width: 0; width: 100%; }
  .combo { display: block; }
  .combo input { min-width: 0; width: 100%; }
  .count { margin-left: 0; }
  .header-inner { flex-direction: column; }
  .matchup-controls { grid-template-columns: 1fr; }
  .matchup-controls .swap { justify-self: start; }
  .h2h-proj-cards,
  .h2h-conf-grid,
  .h2h-last5 { grid-template-columns: 1fr; }
  .h2h-conf-grid.single { grid-template-columns: minmax(0, 1fr); }
}
