:root {
  --bg: #f2f4f0;
  --surface: #ffffff;
  --surface-2: #e8ebe4;
  --ink: #171a16;
  --ink-soft: #4b5147;
  --line: #d3d8cc;
  --accent: #2f6f4e;
  --accent-ink: #ffffff;
  --accent-soft: #e4efe6;
  --gold: #a8791a;
  --gold-soft: #f4ead0;
  --mono: #5c6156;
  --win: #2f6f4e;
  --win-soft: #e4efe6;
  --loss: #a8503a;
  --loss-soft: #f6e6e1;
  --tie: #a8791a;
  --tie-soft: #f4ead0;
  --shadow: 0 1px 2px rgba(23,26,22,0.06), 0 8px 20px rgba(23,26,22,0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14170f;
    --surface: #1b1f17;
    --surface-2: #22271b;
    --ink: #eef0e8;
    --ink-soft: #b7bcae;
    --line: #333a2a;
    --accent: #5fa87e;
    --accent-ink: #0d1a12;
    --accent-soft: #1e2b21;
    --gold: #d6af49;
    --gold-soft: #2c2510;
    --mono: #9aa190;
    --win: #5fa87e;
    --win-soft: #1e2b21;
    --loss: #d98165;
    --loss-soft: #2c1e18;
    --tie: #d6af49;
    --tie-soft: #2c2510;
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 8px 20px rgba(0,0,0,0.35);
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; background: var(--bg); }

body {
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15.5px;
  line-height: 1.5;
}

h1, h2, h3, h4, .eyebrow, nav a, .btn, .pill, .stat-label, th {
  font-family: 'Barlow Condensed', 'Arial Narrow', sans-serif;
}

.mono, .num, td.num, .score, .kickoff {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------- top nav ---------------- */
.topbar {
  background: var(--ink);
  color: var(--bg);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.topbar .brand {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.3px;
  color: var(--bg);
  white-space: nowrap;
}
.topbar .brand .gold { color: var(--gold); }
.topbar .pool-meta { font-size: 0.8rem; color: #a9b09b; font-family: 'IBM Plex Mono', monospace; }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.topbar nav a, .topbar nav span.locked {
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: #cfd3c5;
}
.topbar nav a:hover { background: rgba(255,255,255,0.08); text-decoration: none; }
.topbar nav a.active { background: var(--accent); color: var(--accent-ink); }
.topbar .sync-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.25);
  color: var(--bg);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.85rem;
}
.topbar .sync-btn:hover { background: rgba(255,255,255,0.08); }
.topbar .last-synced { font-size: 0.72rem; color: #8d9482; font-family: 'IBM Plex Mono', monospace; }

/* ---------------- layout ---------------- */
main#app { max-width: 1080px; margin: 0 auto; padding: 32px 24px 80px; }
.page-head { margin-bottom: 24px; }
.page-head h1 { font-size: 2rem; font-weight: 700; margin: 0 0 4px; text-wrap: balance; }
.page-head p { color: var(--ink-soft); margin: 0; max-width: 60ch; }

section { margin-bottom: 36px; }
h2 { font-size: 1.4rem; font-weight: 700; margin: 0 0 14px; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  display: block;
  margin-bottom: 4px;
}

/* ---------------- cards / grids ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.matchup-card { display: flex; flex-direction: column; gap: 10px; }
.matchup-card .party-name { font-family: 'Barlow Condensed', sans-serif; font-weight: 600; font-size: 1.1rem; }
.matchup-card.leader { border-color: var(--accent); }
.matchup-card .big-num { font-size: 2.6rem; font-weight: 700; font-family: 'IBM Plex Mono', monospace; line-height: 1; }
.matchup-card .big-num-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 1px; color: var(--mono); }
.matchup-card .subline { font-size: 0.9rem; color: var(--ink-soft); }
.matchup-card .delta { font-size: 0.85rem; }
.delta.pos { color: var(--win); }
.delta.neg { color: var(--loss); }
.delta.zero { color: var(--mono); }

.leader-banner {
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 18px;
  margin-bottom: 20px;
  font-size: 0.95rem;
}
.leader-banner.tied { background: var(--surface-2); }
.leader-banner strong { color: var(--ink); }

/* ---------------- tables ---------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; min-width: 480px; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); }
thead th { text-transform: uppercase; letter-spacing: 1px; font-size: 0.7rem; color: var(--mono); background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; }

/* ---------------- pills / badges ---------------- */
.pill { display: inline-block; font-size: 0.72rem; font-weight: 600; padding: 2px 9px; border-radius: 20px; letter-spacing: 0.3px; }
.pill.party-A { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--line); }
.pill.party-B { background: var(--gold-soft); color: var(--gold); border: 1px solid var(--line); }
.pill.result-W { background: var(--win-soft); color: var(--win); }
.pill.result-L { background: var(--loss-soft); color: var(--loss); }
.pill.result-T { background: var(--tie-soft); color: var(--tie); }
.pill.status { background: var(--surface-2); color: var(--mono); }

/* ---------------- forms ---------------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.8px; color: var(--mono); font-family: 'Barlow Condensed', sans-serif; }
.field input, .field select {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.95rem;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 7px;
  padding: 10px 18px;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.secondary { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.btn.small { padding: 6px 12px; font-size: 0.85rem; }

.banner { border-radius: 8px; padding: 12px 16px; margin-bottom: 18px; font-size: 0.92rem; }
.banner.error { background: var(--loss-soft); color: var(--loss); border: 1px solid var(--line); }
.banner.info { background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--line); }

/* ---------------- draft room ---------------- */
.division-card { margin-bottom: 16px; }
.division-card .division-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; flex-wrap: wrap; gap: 6px; }
.division-card h3 { margin: 0; font-size: 1.2rem; font-weight: 600; }
.division-card .picker-tag { font-size: 0.85rem; color: var(--ink-soft); }
.team-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 720px) { .team-grid { grid-template-columns: repeat(2, 1fr); } }
.team-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 600;
  transition: transform 0.05s ease;
}
.team-chip.selected { outline: 2px solid var(--accent); background: var(--accent-soft); }
.team-chip.assigned-A { background: var(--accent-soft); border-color: var(--accent); cursor: default; }
.team-chip.assigned-B { background: var(--gold-soft); border-color: var(--gold); cursor: default; }
.team-chip .chip-text { display: flex; flex-direction: column; min-width: 0; }
.team-chip .abbr { font-family: 'IBM Plex Mono', monospace; font-size: 0.72rem; font-weight: 500; color: var(--mono); }
.division-card .confirm-row { margin-top: 10px; display: flex; align-items: center; gap: 10px; }

/* ---------------- team logos ---------------- */
.team-logo { width: 28px; height: 28px; object-fit: contain; flex-shrink: 0; background: var(--surface); border-radius: 4px; }
.team-logo-sm { width: 18px; height: 18px; object-fit: contain; flex-shrink: 0; vertical-align: text-bottom; margin: 0 2px; }
.team-logo-lg { width: 64px; height: 64px; object-fit: contain; flex-shrink: 0; background: var(--surface); border-radius: 8px; border: 1px solid var(--line); padding: 6px; }
.team-header { display: flex; align-items: center; gap: 18px; }
.team-header h1 { margin: 0 0 4px; }
.team-cell { display: flex; align-items: center; gap: 10px; }
.matchup-cell { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ---------------- weekly digest ---------------- */
.digest-card ul { margin: 8px 0 0; padding-left: 18px; font-size: 0.9rem; }
.digest-card li { margin-bottom: 4px; }
.digest-card .lead-line { font-size: 0.95rem; margin: 6px 0 10px; }

.week-picker { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.week-picker select { padding: 7px 10px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }

.muted { color: var(--ink-soft); }
.center-note { text-align: center; color: var(--mono); font-size: 0.85rem; padding: 24px 0; }
