:root {
  color-scheme: light;
  --surface-1: #ffffff;
  --page-plane: #f7f7f5;
  --text-primary: #0b0b0b;
  --text-secondary: #56554f;
  --text-muted: #8f8d85;
  --gridline: #ebe9e3;
  --border: rgba(11, 11, 11, 0.08);

  --good: #0ca30c;
  --critical: #d03b3b;
  --diverge-pos: #2a78d6;
  --diverge-neg: #e34948;

  /* Categorical manager colors, fixed order -- slots 1-8 are the
     validated dataviz-skill palette; slot 9 is a pragmatic addition
     since this league has 9 members. Every manager keeps the same
     color everywhere on the site. */
  --m1: #2a78d6;
  --m2: #eb6834;
  --m3: #1baf7a;
  --m4: #eda100;
  --m5: #e87ba4;
  --m6: #008300;
  --m7: #4a3aa7;
  --m8: #e34948;
  --m9: #8a5a2f;

  --radius: 14px;
  --tap: 44px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-1: #171716;
    --page-plane: #0c0c0b;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8d85;
    --gridline: #2a2a28;
    --border: rgba(255, 255, 255, 0.09);
    --good: #0ca30c;
    --critical: #e66767;
    --diverge-pos: #3987e5;
    --diverge-neg: #e66767;
    --m1: #3987e5; --m2: #d95926; --m3: #199e70; --m4: #c98500; --m5: #d55181;
    --m6: #008300; --m7: #9085e9; --m8: #e66767; --m9: #a9713f;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #171716;
  --page-plane: #0c0c0b;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #8f8d85;
  --gridline: #2a2a28;
  --border: rgba(255, 255, 255, 0.09);
  --good: #0ca30c;
  --critical: #e66767;
  --diverge-pos: #3987e5;
  --diverge-neg: #e66767;
  --m1: #3987e5; --m2: #d95926; --m3: #199e70; --m4: #c98500; --m5: #d55181;
  --m6: #008300; --m7: #9085e9; --m8: #e66767; --m9: #a9713f;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--page-plane);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tap) + 36px + env(safe-area-inset-bottom));
}

/* ---------- header ---------- */
header.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--page-plane) 88%, transparent);
  backdrop-filter: blur(10px);
  padding: 14px 16px 10px;
}

header.site-header h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

header.site-header p.subtitle {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ---------- layout ---------- */
main {
  max-width: 560px;
  margin: 0 auto;
  padding: 4px 16px 8px;
}

section.tab-panel { display: none; }
section.tab-panel.active { display: block; }

.panel-note {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 4px 0 16px;
}

h2.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 22px 0 10px;
  letter-spacing: -0.01em;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

@media (min-width: 640px) {
  .card-grid.two-col { grid-template-columns: 1fr 1fr; }
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
}

.card h3 {
  margin: 0 0 2px;
  font-size: 0.95rem;
  font-weight: 700;
}

.card .card-caption {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

/* ---------- primary bottom nav ---------- */
nav.bottom-tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  gap: 4px;
  background: var(--surface-1);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
  border-top: 1px solid var(--border);
  padding: 8px max(10px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom));
}

nav.bottom-tabs button {
  flex: 1;
  appearance: none;
  border: none;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 6px 4px;
  min-height: var(--tap);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
}

nav.bottom-tabs button svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

nav.bottom-tabs button .pill {
  padding: 5px 16px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

nav.bottom-tabs button.active {
  color: var(--m1);
}

nav.bottom-tabs button.active .pill {
  background: color-mix(in srgb, var(--m1) 14%, transparent);
}

/* ---------- secondary pill nav (within a tab) ---------- */
nav.pill-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 0 12px;
  scrollbar-width: none;
}
nav.pill-tabs::-webkit-scrollbar { display: none; }

nav.pill-tabs button {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
  min-height: 36px;
}

nav.pill-tabs button.active {
  background: var(--text-primary);
  color: var(--surface-1);
  border-color: var(--text-primary);
}

.sub-panel { display: none; }
.sub-panel.active { display: block; }

/* ---------- tables & lists ---------- */
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
}

table th, table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--gridline);
  white-space: nowrap;
}

table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

table td.num, table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Rank-style list row: used for most leaderboards instead of dense
   multi-column tables -- reads cleanly on a phone with no horizontal
   scroll needed. */
ul.rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

ul.rank-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--gridline);
  font-size: 0.9rem;
}

ul.rank-list li:last-child { border-bottom: none; }

ul.rank-list .rank-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

ul.rank-list .rank-num {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  width: 1.2em;
  flex-shrink: 0;
}

ul.rank-list .rank-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

ul.rank-list .rank-sub {
  color: var(--text-muted);
  font-size: 0.78rem;
}

ul.rank-list .rank-value {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
}

/* good/critical leaderboard pairs */
.leaderboard-pair {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 480px) {
  .leaderboard-pair { grid-template-columns: 1fr 1fr; }
}

.leaderboard-pair h4 {
  margin: 0 0 4px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.leaderboard-pair .good h4 { color: var(--good); }
.leaderboard-pair .critical h4 { color: var(--critical); }

.leaderboard-pair ul.rank-list li {
  padding: 7px 8px;
  border-bottom: none;
  border-radius: 8px;
  margin-bottom: 2px;
}
.leaderboard-pair .good ul.rank-list li {
  background: color-mix(in srgb, var(--good) 10%, transparent);
}
.leaderboard-pair .critical ul.rank-list li {
  background: color-mix(in srgb, var(--critical) 10%, transparent);
}

/* signed deltas: subtle color + arrow, used for jammy delta, transfer
   net points, captain gain/loss, vs-average margins */
.delta { font-weight: 700; }
.delta.pos { color: var(--good); }
.delta.neg { color: var(--critical); }

/* ---------- charts ---------- */
.chart-wrap {
  position: relative;
  height: 220px;
}
.chart-wrap.tall { height: 280px; }

.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

select.manager-picker {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--page-plane);
  color: var(--text-primary);
  min-height: 36px;
}

.empty-state {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.85rem;
  padding: 20px 0;
}

/* ---------- hero stat ---------- */
.hero-stat {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.hero-stat .value {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.hero-stat .label {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ---------- accordion (All-Time: League by Year) ---------- */
details.accordion-item {
  border-bottom: 1px solid var(--gridline);
}
details.accordion-item:last-child { border-bottom: none; }

details.accordion-item summary {
  padding: 12px 0;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
details.accordion-item summary::-webkit-details-marker { display: none; }
details.accordion-item summary::after {
  content: "+";
  color: var(--text-muted);
  font-weight: 400;
  font-size: 1.1rem;
}
details.accordion-item[open] summary::after { content: "\2212"; }

details.accordion-item .accordion-body { padding-bottom: 12px; }

footer.site-footer {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 4px;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-align: center;
}
