:root {
  --paper: #F5F6F8;
  --surface: #FFFFFF;
  --ink: #1B2230;
  --muted: #5B6577;
  --line: #DCE1E8;
  --blue: #0E3386;
  --red: #C42E2F;
  --win: #1D6B43;

  /* The standings board stays scoreboard green in both themes */
  --board: #1E4D35;
  --board-edge: #163A28;
  --tile: #173D2A;
  --tile-ink: #F4F3EC;
  --tile-dim: #A9C2B3;

  --display: "Barlow Condensed", "Roboto Condensed", "Arial Narrow", sans-serif;
  --body: "Public Sans", "Segoe UI", system-ui, -apple-system, sans-serif;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12161D;
    --surface: #1A202A;
    --ink: #E7EAF0;
    --muted: #9AA3B2;
    --line: #2A3240;
    --blue: #7D97E6;
    --red: #EE6B66;
    --win: #5DC28E;
    --board-edge: #0F2A1C;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--blue); }

:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Masthead */
.masthead {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 32px;
  padding: 12px clamp(16px, 4vw, 40px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: 0.01em;
  color: var(--blue);
}
.brand-season { color: var(--muted); font-size: 14px; }

.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tabs a {
  padding: 8px 14px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}
.tabs a:hover { color: var(--ink); background: var(--paper); }
.tabs a[aria-current="page"] {
  color: var(--surface);
  background: var(--blue);
}
@media (prefers-color-scheme: dark) {
  .tabs a[aria-current="page"] { color: #0E1420; }
}

main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 40px) 48px;
}

/* Standings board, modeled on a hand-turned outfield scoreboard */
.board {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 28px;
  padding: 24px;
  background: var(--board);
  border: 6px solid var(--board-edge);
  border-radius: 4px;
  color: var(--tile-ink);
}

.board-caption {
  font-family: var(--display);
  font-weight: 600;
  font-size: 18px;
  color: var(--tile-dim);
  margin-bottom: 10px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(76px, 1fr));
  gap: 6px;
}
.tile {
  background: var(--tile);
  border: 1px solid var(--board-edge);
  padding: 10px 8px 8px;
  text-align: center;
}
.tile-value {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  font-size: 40px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tile-label {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--tile-dim);
}

.board-splits {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin-top: 14px;
  font-size: 14px;
  color: var(--tile-dim);
}
.board-splits strong { color: var(--tile-ink); font-weight: 600; }

.tile-table { width: 100%; border-collapse: separate; border-spacing: 0 4px; }
.tile-table th {
  font-size: 12px;
  font-weight: 400;
  color: var(--tile-dim);
  text-align: center;
  padding: 0 6px;
}
.tile-table th:first-child { text-align: left; }
.tile-table td {
  background: var(--tile);
  font-family: var(--display);
  font-weight: 600;
  font-size: 24px;
  text-align: center;
  padding: 4px 8px;
  font-variant-numeric: tabular-nums;
}
.tile-table td:first-child { text-align: left; }
.tile-table tr.is-cubs td { color: #FFFFFF; background: #0E3386; }

/* Gather grid */
.gather-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  margin-top: 24px;
  align-items: start;
}

h2 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 22px;
  margin: 0 0 12px;
}

.section-head { display: flex; justify-content: space-between; align-items: baseline; }

.stories {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px 24px;
}

.sidebar { display: flex; flex-direction: column; gap: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 18px;
}

.nugget {
  border-left: 4px solid var(--red);
  padding: 4px 0 4px 16px;
}
.nugget h2 { font-size: 18px; margin-bottom: 4px; color: var(--red); }
.nugget p { margin: 0; font-size: 16px; }

/* Wild card table */
.wc-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.wc-table th {
  font-size: 12px; font-weight: 400; color: var(--muted);
  text-align: right; padding: 0 4px 6px;
}
.wc-table th:first-child, .wc-table td:first-child { text-align: left; }
.wc-table td { text-align: right; padding: 5px 4px; border-top: 1px solid var(--line); }
.wc-table tr.cutoff td { border-top: 2px solid var(--red); }
.wc-table tr.is-cubs td { font-weight: 600; color: var(--blue); }
.wc-note { margin: 8px 0 0; font-size: 13px; color: var(--muted); }

/* Team stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 8px;
  margin: 0;
}
.stat-grid div { display: flex; flex-direction: column; }
.stat-grid dt { font-size: 12px; color: var(--muted); order: 2; }
.stat-grid dd {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 24px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat-group-label {
  grid-column: 1 / -1;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: 2px;
}

/* Leaders */
.leaders { list-style: none; margin: 0; padding: 0; }
.leaders li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
}
.leaders li:first-child { border-top: 0; }
.leader-cat { font-size: 12px; color: var(--muted); grid-column: 1 / -1; }
.leader-name { font-weight: 600; }
.leader-value { font-family: var(--display); font-weight: 600; font-size: 20px; font-variant-numeric: tabular-nums; }

/* Empty and status states */
.empty-state { color: var(--muted); max-width: 60ch; }
.empty-state.wide {
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 32px;
  max-width: none;
}
.empty-state p { margin: 0 0 8px; }
.empty-title { color: var(--ink); font-weight: 600; }

.status { margin-top: 20px; font-size: 13px; color: var(--muted); }
.status.error { color: var(--red); }
.status button {
  margin-left: 8px;
  font: inherit;
  font-weight: 600;
  color: var(--blue);
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 10px;
  cursor: pointer;
}

.loading { color: var(--muted); font-size: 14px; }

@media (max-width: 900px) {
  .board { grid-template-columns: 1fr; }
  .gather-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .board { padding: 16px; }
  .tile-value { font-size: 32px; }
}

/* ---------- Roundup and feed ---------- */

.main-col { display: flex; flex-direction: column; gap: 24px; min-width: 0; }

.feed {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px 24px;
}

.button {
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  color: #FFFFFF;
  background: var(--blue);
  border: 0;
  border-radius: 6px;
  padding: 7px 14px;
  cursor: pointer;
}
@media (prefers-color-scheme: dark) { .button { color: #0E1420; } }
.button.quiet { color: var(--blue); background: none; border: 1px solid var(--line); }
.button:disabled { opacity: 0.6; cursor: progress; }

.roundup-meta, .feed-note { margin: -4px 0 12px; font-size: 13px; color: var(--muted); }
.feed-note.error, .roundup-meta.error { color: var(--red); }

.story { padding: 16px 0; border-top: 1px solid var(--line); }
.story:first-child { border-top: 0; padding-top: 4px; }
.story h3 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 24px;
  line-height: 1.15;
  margin: 0 0 6px;
}
.story p { margin: 0 0 8px; max-width: 70ch; }
.story .angle { color: var(--muted); }
.story .angle strong { color: var(--ink); font-weight: 600; }
.flag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  font-family: var(--body);
  font-size: 12px;
  font-weight: 600;
  vertical-align: middle;
  color: var(--red);
  border: 1px solid currentColor;
}
.story-sources { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.story-sources li { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src-type { color: var(--muted); margin-right: 6px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  font: inherit;
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.chip[aria-pressed="true"] { border-color: var(--blue); color: var(--blue); font-weight: 600; }

.feed-list { list-style: none; margin: 0; padding: 0; }
.feed-list li { padding: 10px 0; border-top: 1px solid var(--line); }
.feed-list li:first-child { border-top: 0; }
.feed-item-meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.feed-item-text { margin: 0; overflow-wrap: anywhere; }
.feed-item-text a { color: var(--ink); text-decoration: none; }
.feed-item-text a:hover { color: var(--blue); text-decoration: underline; }
.feed-item-link { font-size: 13px; }
.feed-more { margin-top: 12px; }

.source-check { margin-bottom: 12px; font-size: 13px; }
.source-check summary { cursor: pointer; color: var(--blue); font-weight: 600; }
.source-table { width: 100%; margin-top: 8px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.source-table th { font-weight: 400; color: var(--muted); text-align: right; padding: 0 6px 4px; }
.source-table td { text-align: right; padding: 4px 6px; border-top: 1px solid var(--line); }
.source-table th:first-child, .source-table td:first-child { text-align: left; }
.source-table .source-error { text-align: left; color: var(--red); }
