:root {
  --bg: #f1f1ee;
  --paper: rgba(252, 252, 249, 0.94);
  --paper-strong: #ffffff;
  --ink: #171717;
  --muted: #5f5f5b;
  --accent: #1f1f1d;
  --accent-soft: #ecece7;
  --accent-deep: #0f0f0e;
  --pill-bg: #1f1f1d;
  --pill-bg-strong: #0f0f0e;
  --pill-ink: #ffffff;
  --line: rgba(23, 23, 23, 0.1);
  --line-strong: rgba(23, 23, 23, 0.16);
  --shadow: 0 22px 60px rgba(20, 20, 20, 0.08);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0e0e0d;
  --paper: rgba(20, 20, 18, 0.9);
  --paper-strong: #181816;
  --ink: #f4f4ef;
  --muted: #bbbbb2;
  --accent: #f1f1ec;
  --accent-soft: #232320;
  --accent-deep: #ffffff;
  --pill-bg: #f1f1ec;
  --pill-bg-strong: #d8d8d2;
  --pill-ink: #121212;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.16);
  --shadow: 0 26px 72px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--accent) 10%, transparent), transparent 32%),
    radial-gradient(circle at top right, color-mix(in srgb, var(--muted) 10%, transparent), transparent 30%),
    linear-gradient(180deg, color-mix(in srgb, var(--paper-strong) 94%, var(--bg)) 0%, var(--bg) 100%);
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

.page-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 0.75rem 0 2rem;
}

.hero,
.controls,
.results,
.ad-slot {
  background: var(--paper);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow);
}

.hero {
  padding: 0.82rem 1.1rem 0.9rem;
}

.hero-copy {
  display: grid;
  align-content: start;
  gap: 0.34rem;
  max-width: none;
}

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

.hero-league {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  justify-self: end;
  min-width: 0;
  color: var(--muted);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex: 0 0 auto;
}

.hero-league-label {
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.hero-league select {
  min-width: 18.5rem;
  width: auto;
  padding: 0.52rem 2.1rem 0.52rem 0.75rem;
  border-radius: 11px;
  font-size: 0.82rem;
}

.hero h1 {
  margin: 0;
  max-width: 44rem;
  font-size: clamp(1.7rem, 2.7vw, 2.4rem);
  line-height: 0.96;
  letter-spacing: -0.04em;
}

.lede,
.page-context,
.meta,
.results-bar,
.venue,
.team-label {
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

.lede {
  max-width: none;
  margin: 0.2rem 0 0;
  font-size: 0.86rem;
  line-height: 1.36;
  color: var(--muted);
}

.meta {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.1rem;
}

.page-context {
  max-width: 60rem;
  margin: 0.1rem 0 0;
  color: var(--ink);
  font-size: 0.84rem;
  line-height: 1.35;
}

.controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 0.5rem;
  padding: 0.82rem;
}

.controls label {
  display: grid;
  gap: 0.35rem;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  font-size: 0.85rem;
  color: var(--muted);
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper-strong);
  color: var(--ink);
  padding: 0.7rem 0.85rem;
  font: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.ad-slot {
  display: grid;
  place-items: center;
  margin-top: 0.65rem;
  padding: 0.65rem;
  box-shadow: none;
}

.ad-slot[hidden] {
  display: none;
}

.ad-slot-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  width: 100%;
  min-height: 5.6rem;
  border: 1px dashed var(--line-strong);
  border-radius: 18px;
  color: var(--muted);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 6%, transparent) 25%, transparent 25%) 0 0 / 18px 18px,
    color-mix(in srgb, var(--paper-strong) 72%, transparent);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  font-size: 0.78rem;
  text-align: center;
}

.ad-slot strong {
  color: var(--ink);
  font-size: 0.86rem;
}

.ad-label {
  padding: 0.24rem 0.5rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.ad-slot-inline .ad-slot-inner {
  min-height: 6.4rem;
}

.ad-slot-footer {
  flex: 1 1 28rem;
  max-width: 44rem;
  margin-top: 0;
  padding: 0;
  border: 0;
  background: transparent;
  backdrop-filter: none;
  box-shadow: none;
}

.ad-slot-footer .ad-slot-inner {
  min-height: 3.2rem;
  border-radius: 14px;
}

.theme-control {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  color: var(--muted);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: none;
}

.theme-mode-label {
  color: var(--muted);
  white-space: nowrap;
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.theme-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-switch-track {
  display: inline-flex;
  align-items: center;
  width: 2.9rem;
  padding: 0.18rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 16%, var(--paper-strong));
  border: 1px solid var(--line);
  transition: background 160ms ease, border-color 160ms ease;
}

.theme-switch-thumb {
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: var(--paper-strong);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  transform: translateX(0);
  transition: transform 160ms ease, background 160ms ease;
}

.theme-switch input:checked + .theme-switch-track .theme-switch-thumb {
  transform: translateX(1.36rem);
}

.theme-switch input:focus-visible + .theme-switch-track {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
}

:root[data-theme="dark"] .theme-mode-label:last-child,
:root:not([data-theme="dark"]) .theme-mode-label:first-child {
  color: var(--accent);
  text-transform: uppercase;
}

.page-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.7rem;
  padding: 0 0.25rem;
}

.results-eyebrow {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.subtle-button {
  border: 0;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
  transition:
    transform 140ms ease,
    opacity 140ms ease,
    background 140ms ease,
    color 140ms ease;
}

.results {
  margin-top: 0.75rem;
  padding: 1rem;
}

.standings-panel {
  margin-top: 0.75rem;
}

.standings-bar {
  align-items: end;
}

.standings-title,
.standings-note {
  margin: 0;
}

.standings-title {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
}

.standings-note {
  max-width: 28rem;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
  text-align: right;
}

.standings-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--paper-strong) 92%, transparent);
}

.standings-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

.standings-table th,
.standings-table td {
  padding: 0.78rem 0.72rem;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.standings-table th:nth-child(2),
.standings-table td:nth-child(2) {
  text-align: left;
}

.standings-table thead th {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.standings-table tbody tr:last-child td {
  border-bottom: 0;
}

.standings-table tbody tr.is-active {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.results-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.85rem;
  color: var(--muted);
}

.results-bar p {
  margin: 0;
}

.results-actions {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.55rem;
}

#resultsCount {
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 700;
}

.subtle-button {
  padding: 0.62rem 0.9rem;
  background: rgba(23, 23, 23, 0.08);
  color: var(--accent);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  font-weight: 700;
}

.subtle-button:hover,
.subtle-button:focus-visible {
  background: var(--accent);
  color: white;
  outline: none;
}

.subtle-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.subtle-button:disabled:hover,
.subtle-button:disabled:focus-visible {
  background: rgba(23, 23, 23, 0.08);
  color: var(--accent);
  outline: none;
}

.match-list {
  display: grid;
  gap: 0.8rem;
}

.date-group {
  padding-top: 0.25rem;
}

.date-heading-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem;
}

.date-heading {
  display: inline-flex;
  padding: 0.4rem 0.82rem;
  border-radius: 999px;
  background: rgba(23, 23, 23, 0.08);
  color: var(--accent);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.date-note {
  margin: 0;
  color: var(--muted);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  font-size: 0.76rem;
  letter-spacing: 0.02em;
}

.match-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0.95rem;
  background: color-mix(in srgb, var(--paper-strong) 88%, transparent);
}

.match-topline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  color: var(--muted);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.33rem 0.7rem;
  border-radius: 999px;
  background: var(--pill-bg);
  color: var(--pill-ink);
  font-weight: 700;
}

.teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.9rem;
  align-items: center;
  margin-top: 0.35rem;
}

.teams-labels {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.9rem;
  align-items: end;
  margin-top: 0.85rem;
}

.teams h2 {
  margin: 0;
  font-size: clamp(1rem, 1.7vw, 1.32rem);
  line-height: 1.15;
}

.team-label {
  margin: 0;
  color: var(--muted);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.teams-labels .team-label:last-child {
  text-align: right;
}

.teams > div:first-child {
  text-align: left;
}

.teams > div:last-child {
  text-align: right;
}

.team-name-button {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: color 140ms ease, opacity 140ms ease;
}

.team-name-button:hover,
.team-name-button:focus-visible {
  color: var(--accent);
  opacity: 0.72;
  outline: none;
}

.team-name-button.is-active {
  color: var(--accent);
  font-weight: 700;
}

.team-logo {
  width: 2rem;
  height: 2rem;
  object-fit: contain;
  flex: 0 0 auto;
}

.standings-table .team-name-button {
  justify-content: flex-start;
}

.standings-table .team-logo {
  width: 2.1rem;
  height: 2.1rem;
}

.teams .team-logo {
  width: 2.85rem;
  height: 2.85rem;
}

.teams > div:last-child .team-name-button {
  justify-content: flex-end;
}

.teams > div:last-child .team-name-button .team-logo {
  order: 2;
}

.score-block {
  min-width: 4.4rem;
  padding: 0.7rem 0.85rem;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--pill-bg-strong), var(--pill-bg));
  color: var(--pill-ink);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  font-weight: 700;
  white-space: nowrap;
  text-align: center;
  letter-spacing: 0.08em;
}

.venue {
  margin: 0.7rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 0.75rem, 1120px);
    padding-top: 0.5rem;
  }

  .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero {
    padding: 0.82rem 0.9rem 0.88rem;
    border-radius: 20px;
  }

  .hero-topline {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .hero-league {
    flex-wrap: wrap;
    justify-self: start;
  }

  .hero-league select {
    width: 100%;
    min-width: 0;
  }

  .theme-control {
    width: 100%;
    justify-content: flex-start;
  }

  .ad-slot-inner {
    min-height: 4.8rem;
  }

  .ad-slot-inline .ad-slot-inner {
    min-height: 5.2rem;
  }

  .results,
  .controls,
  .ad-slot {
    border-radius: 20px;
  }

  .hero h1 {
    font-size: 1.55rem;
  }

  .lede {
    font-size: 0.81rem;
  }

  .meta {
    font-size: 0.76rem;
  }

  .page-context {
    font-size: 0.78rem;
  }

  .results-bar {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
  }

  .results-actions {
    justify-content: flex-start;
  }

  .standings-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .standings-note {
    max-width: none;
    text-align: left;
  }

  .score-block {
    min-width: 3.4rem;
    width: auto;
    margin: 0;
    padding: 0.55rem 0.7rem;
    border-radius: 12px;
    justify-self: center;
    align-self: center;
    font-size: 0.9rem;
    letter-spacing: 0.04em;
  }

  .match-card {
    padding: 0.8rem 0.78rem;
  }

  .match-topline {
    gap: 0.35rem 0.5rem;
    font-size: 0.7rem;
  }

  .teams-labels {
    gap: 0.7rem;
    margin-top: 0.75rem;
  }

  .teams {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 0.7rem;
    align-items: center;
  }

  .teams > div:first-child {
    text-align: left;
  }

  .teams > div:last-child {
    text-align: right;
  }

  .team-label {
    font-size: 0.68rem;
  }

  .teams h2 {
    margin: 0;
    font-size: 0.96rem;
    line-height: 1.18;
  }

  .team-logo {
    width: 1.7rem;
    height: 1.7rem;
  }

  .standings-table .team-logo {
    width: 1.8rem;
    height: 1.8rem;
  }

  .teams .team-logo {
    width: 2.3rem;
    height: 2.3rem;
  }

  .venue {
    font-size: 0.8rem;
  }
}

@media (max-width: 520px) {
  .controls {
    grid-template-columns: 1fr;
  }

  .hero-copy {
    gap: 0.24rem;
  }

  .theme-control {
    gap: 0.4rem;
  }

  .hero h1 {
    font-size: 1.42rem;
  }

  .lede {
    line-height: 1.4;
  }

  .results-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .subtle-button {
    width: 100%;
  }

  .results-actions {
    width: 100%;
  }

  .page-footer {
    flex-direction: column;
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
  }

  .ad-slot-inner {
    flex-direction: column;
    gap: 0.35rem;
    min-height: 4.6rem;
  }

  .ad-slot-footer {
    max-width: none;
  }
}
