:root {
  --ink: #1a1814;
  --muted: #5c574c;
  --cream: #f4efe3;
  --paper: #fffdf7;
  --green: #163a5f;
  --green-2: #1f5285;
  --gold: #c4a35a;
  --line: #d9d0bc;
  --stripe: #f7f3e9;
  --sticky: #fffdf7;
  --sticky-stripe: #f7f3e9;
  --danger: #8b2e2e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.4;
}

.mast {
  background: linear-gradient(160deg, var(--green) 0%, var(--green-2) 100%);
  color: #f6f0e0;
  border-bottom: 4px solid var(--gold);
}

.mast-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.4rem 0.8rem 1.2rem;
}

.eyebrow {
  margin: 0 0 0.25rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--gold);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.brand-mark {
  height: 2.5rem;
  width: auto;
  object-fit: contain;
  border-radius: 0.2rem;
  flex: 0 0 auto;
}

.mast h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: 2rem;
  letter-spacing: 0.02em;
}

.lede {
  margin: 0.4rem 0 0;
  color: #d7ccb4;
  font-size: 0.95rem;
}

.disclaimer {
  margin: 0.45rem 0 0;
  max-width: 42rem;
  color: #cfc4aa;
  font-size: 0.82rem;
  line-height: 1.45;
}

.disclaimer + .disclaimer { margin-top: 0.15rem; }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 0.8rem 2.5rem;
}

.tablist {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin: 0 0 0.5rem;
}

.season-bar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin: 0 0 0.9rem;
}

.season-bar[hidden] {
  display: none;
}

.season-bar label {
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--muted);
}

.season-bar select {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  padding: 0.38rem 2rem 0.38rem 0.8rem;
  font: inherit;
  font-weight: 550;
  font-size: 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 1.05rem) 50%, calc(100% - 0.7rem) 50%;
  background-size: 0.35rem 0.35rem, 0.35rem 0.35rem;
  background-repeat: no-repeat;
}

.season-bar select:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.player-bar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin: 0 0 0.9rem;
}

.player-bar[hidden] {
  display: none;
}

.player-bar label {
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--muted);
}

.player-bar select {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  padding: 0.38rem 2rem 0.38rem 0.8rem;
  font: inherit;
  font-weight: 550;
  font-size: 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  max-width: min(18rem, 100%);
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 1.05rem) 50%, calc(100% - 0.7rem) 50%;
  background-size: 0.35rem 0.35rem, 0.35rem 0.35rem;
  background-repeat: no-repeat;
}

.player-bar select:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.trends-wrap {
  padding: 0.35rem 0.7rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.trends-wrap[hidden] {
  display: none;
}

.trend-panel {
  margin: 0;
}

.trend-panel[hidden] {
  display: none;
}

.trend-panel figcaption {
  margin: 0 0 0.25rem;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--muted);
}

.trend-svg {
  display: block;
  width: 100%;
  height: 10.5rem;
  background: var(--paper);
}

.tablist button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  padding: 0.45rem 0.9rem;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  border-radius: 999px;
}

.tablist.sub button {
  font-weight: 550;
  padding: 0.32rem 0.8rem;
  font-size: 0.92rem;
}

.tablist button[aria-selected="true"] {
  background: var(--green);
  color: #f6f0e0;
  border-color: var(--green);
}

.tablist button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(20, 53, 40, 0.06);
}

.status {
  margin: 0;
  padding: 1.4rem 1rem;
  color: var(--muted);
}

.scoring-note {
  margin: 0;
  padding: 0.9rem 1rem 0.15rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.status.error { color: var(--danger); }

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 36rem;
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
}

table.narrow { min-width: 0; max-width: 28rem; }

table.compact {
  width: 100%;
  table-layout: fixed;
  min-width: 0;
}

table.compact th:first-child,
table.compact td:first-child {
  width: 10rem;
  max-width: none;
}

table:has(.groups) { min-width: 58rem; }

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--green);
  color: #f6f0e0;
  font-weight: 650;
  text-align: right;
  padding: 0.55rem 0.55rem;
  white-space: nowrap;
  border-bottom: 2px solid var(--gold);
}

thead th.group-taken,
td.group-taken { box-shadow: inset 1px 0 0 rgba(196, 163, 90, 0.28); }

thead tr.groups th {
  text-align: center;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  border-bottom: 1px solid rgba(196, 163, 90, 0.45);
  padding: 0.35rem 0.55rem;
}

thead th.group-bowl,
td.group-bowl { box-shadow: inset 1px 0 0 rgba(196, 163, 90, 0.28); }

thead th:first-child,
tbody td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 5.2rem;
  max-width: 8.5rem;
  box-shadow: 4px 0 8px -6px rgba(0, 0, 0, 0.25);
}

td.pair {
  white-space: normal;
  overflow-wrap: break-word;
  min-width: 6.2rem;
  max-width: 8.5rem;
}

thead th:first-child { z-index: 3; }

th button {
  appearance: none;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  font-weight: 650;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

th button .arrow { font-size: 0.75em; color: var(--gold); }

td, th { padding: 0.42rem 0.55rem; }
td { text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:nth-child(even) td { background: var(--stripe); }
tbody tr:nth-child(odd) td { background: var(--paper); }
tbody tr:nth-child(even) td:first-child { background: var(--sticky-stripe); }
tbody tr:nth-child(odd) td:first-child { background: var(--sticky); }
tbody td:first-child {
  font-weight: 650;
  white-space: normal;
  overflow-wrap: break-word;
}

tbody tr:hover td { background: #ece6d4; }
tbody tr:hover td:first-child { background: #ece6d4; }

.empty {
  padding: 1.6rem 1rem;
  color: var(--muted);
  text-align: center;
}

footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 0.8rem 2rem;
  color: var(--muted);
  font-size: 0.85rem;
}

footer p { margin: 0; }

@media (max-width: 640px) {
  .mast-inner { padding: 1.1rem 0.8rem 1rem; }
  .mast h1 { font-size: 1.65rem; }
  .brand-mark { height: 1.9rem; width: auto; }
  table { font-size: 0.86rem; min-width: 0; }
  table:has(.groups) { min-width: 58rem; }
  table.compact th:first-child,
  table.compact td:first-child { width: 5.5rem; }
  td, th { padding: 0.38rem 0.32rem; }
  thead th:first-child,
  tbody td:first-child {
    min-width: 4.4rem;
    max-width: 6.2rem;
  }
  td.pair {
    min-width: 5rem;
    max-width: 6.4rem;
  }
}
