:root {
  --cream: #f4efe4;
  --paper: #fffaf3;
  --ink: #17261f;
  --forest: #1b4332;
  --forest-deep: #10281e;
  --clay: #e7c4b0;
  --clay-deep: #8e3e24;
  --muted: #3e4c45;
  --line: #e2d8c6;
  --home: #1b4332;
  --away: #8e3e24;
  --sans: "Avenir Next", "Segoe UI", "Liberation Sans", "Helvetica Neue", Arial, sans-serif;
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { background: var(--cream); min-height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.4;
  background: linear-gradient(180deg, #f7f3ea 0%, #ebe2d2 100%);
  min-height: 100vh;
}
img { max-width: 100%; }
a { color: var(--forest); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--clay-deep); outline-offset: 2px; }

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: #fff;
  padding: 8px 12px;
  z-index: 5;
}
.skip:focus { top: 8px; }

.site-header {
  background: var(--forest);
  color: var(--cream);
  border-bottom: 6px solid var(--clay);
}
.header-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 16px 12px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px 14px;
  align-items: center;
}
.logos { display: flex; align-items: center; gap: 8px; }
.logos img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  background: #fff;
  border-radius: 12px;
  padding: 3px;
}
.logos .club-logo { width: 64px; height: 48px; }
.kicker {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--clay);
}
.site-header h1 {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1.1;
  font-weight: 700;
}
.powered { margin: 4px 0 0; font-size: 15px; color: #f4efe4; }
.powered a { color: var(--clay); font-weight: 700; }

.nav {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  min-width: 0;
}
.nav a, .switch select {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 999px;
  background: transparent;
  color: var(--cream);
  text-decoration: none;
  border: 2px solid rgba(244, 239, 228, 0.45);
  font-weight: 700;
  font-size: 16px;
}
.nav a[aria-current="page"] { background: var(--clay); color: var(--forest-deep); border-color: var(--clay); }
.switch { display: flex; align-items: center; }
.switch select { background: var(--forest-deep); }

.wrap { max-width: 980px; margin: 0 auto; padding: 16px 14px 48px; }
.lede { margin: 0 0 8px; color: var(--muted); font-size: 17px; }

.filters {
  position: static;
  background: rgba(244, 239, 228, 0.96);
  border-bottom: 1px solid var(--line);
  padding: 8px 0 6px;
  margin: 0 -14px 14px;
  padding-left: 14px;
  padding-right: 14px;
}
.chip-row { display: grid; gap: 4px; margin: 0 0 8px; min-width: 0; }
.chip-label { font-size: 14px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.chips { display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; padding-bottom: 2px; max-width: 100%; }
.chip {
  flex: none;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 2px solid var(--forest);
  background: #fff;
  font-weight: 700;
}
.chip.is-on { background: var(--forest); color: var(--cream); }
.search {
  width: 100%;
  min-height: 48px;
  border: 2px solid var(--forest);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
}
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; }
.btn {
  min-height: 48px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 2px solid var(--forest);
  background: var(--forest);
  color: var(--cream);
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-ghost { background: #fff; color: var(--forest); }
.btn-small { min-height: 40px; padding: 6px 12px; }

.week-nav, .day-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 10px;
  position: sticky;
  top: 0;
  z-index: 3;
  background: rgba(244, 239, 228, 0.96);
  padding: 6px 0;
}
.week-nav h2, .day-nav h2 {
  margin: 0;
  text-align: center;
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1.15;
}
.week-nav p, .day-nav p { margin: 2px 0 0; text-align: center; color: var(--muted); font-size: 16px; }

.day-block { margin: 0 0 22px; }
.day-block h3 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 24px;
}

.tie {
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 8px solid var(--forest);
  border-radius: 16px;
  padding: 14px 14px 12px;
  margin: 0 0 12px;
  box-shadow: 0 6px 16px rgba(23, 38, 31, 0.05);
}
.tie.is-away { border-left-color: var(--away); }
.tie.is-tbc { border-left-color: var(--clay); }
.tie-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.when { margin: 0; font-weight: 700; font-size: 18px; }
.time { margin: 0; font-family: var(--serif); font-size: 32px; line-height: 1; }
.team { margin: 8px 0 0; font-size: 26px; line-height: 1.15; font-weight: 800; }
.versus { margin: 2px 0 0; font-size: 20px; }
.grade-line { margin: 8px 0 0; color: var(--muted); font-size: 17px; }
.venue { margin: 8px 0 0; font-size: 20px; }
.venue strong { font-size: 22px; }
.address { margin: 2px 0 0; font-size: 18px; }
.courts { margin: 6px 0 0; font-weight: 700; }
.badge {
  display: inline-block;
  min-width: 88px;
  text-align: center;
  padding: 6px 10px;
  border-radius: 8px;
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 18px;
}
.badge-home { background: var(--home); color: #fff; }
.badge-away { background: var(--away); color: #fff; }
.badge-tbc { background: #fff; color: var(--clay-deep); border: 2px solid var(--clay-deep); }
.map-link { font-weight: 800; }

.time-group { margin: 0 0 18px; }
.time-group h3 {
  margin: 0;
  padding: 10px 12px;
  background: var(--forest);
  color: var(--cream);
  border-radius: 12px 12px 0 0;
  font-family: var(--serif);
  font-size: 36px;
}
.slot {
  background: #fff;
  border: 1px solid var(--line);
  border-top: 0;
  padding: 12px;
}
.slot:last-child { border-radius: 0 0 12px 12px; }
.slot .courts { font-size: 20px; margin: 0 0 4px; }
.slot .matchup { margin: 0; font-size: 24px; font-weight: 800; line-height: 1.2; }
.slot .grade-line { margin: 4px 0 0; }

.state, .banner {
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  margin: 0 0 14px;
}
.state-error { border-color: var(--clay-deep); }
.state-title { margin: 0 0 6px; font-family: var(--serif); font-size: 26px; }
.state-copy { margin: 0 0 12px; }
.banner { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.banner p { margin: 0; }

.tiles { display: grid; gap: 12px; }
.tile {
  display: block;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  text-decoration: none;
  color: inherit;
  min-height: 112px;
}
.tile:hover, .tile:focus-visible { border-color: var(--forest); }
.tile h2 { margin: 0; font-family: var(--serif); font-size: 28px; color: var(--forest); }
.tile p { margin: 6px 0 0; color: var(--muted); }
.section-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  margin: 0 0 14px;
}
.section-card h2 { margin: 0 0 10px; font-family: var(--serif); color: var(--forest); }
.link-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.link-list a {
  display: block;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  text-decoration: none;
  color: inherit;
}
.link-list .name { display: block; font-weight: 800; color: var(--forest); font-size: 18px; }
.link-list .desc { display: block; margin-top: 3px; color: var(--muted); font-size: 16px; }
.club-grid { display: grid; gap: 12px; }
.club-card {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 12px;
  align-items: center;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  text-decoration: none;
  color: inherit;
}
.club-card img { width: 84px; height: 64px; object-fit: contain; }
.club-card h3 { margin: 0; font-size: 22px; color: var(--forest); }
.club-card p { margin: 4px 0 0; color: var(--muted); font-size: 16px; }
.club-card[hidden] { display: none !important; }
.club-search {
  width: 100%;
  min-height: 52px;
  border: 2px solid var(--forest);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
  margin: 0 0 8px;
}
.picker-meta { margin: 0 0 12px; color: var(--muted); font-weight: 700; }
.tag {
  display: inline-block;
  margin-top: 6px;
  background: var(--clay);
  color: var(--forest-deep);
  font-weight: 800;
  font-size: 14px;
  border-radius: 999px;
  padding: 2px 8px;
}

.site-footer {
  max-width: 980px;
  margin: 0 auto;
  padding: 8px 16px 28px;
  color: var(--muted);
  font-size: 16px;
}
.site-footer img { width: 36px; height: 36px; vertical-align: middle; background: #fff; border-radius: 50%; margin-right: 6px; }

.md-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin: 0 0 12px; }
.md-card h3 { margin: 8px 0 0; font-size: 24px; line-height: 1.15; }
.score-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.score-row .opp { text-align: right; }
.score-num { font-family: var(--serif); font-size: 40px; text-align: center; line-height: 1; }
.score-cap { display: block; text-align: center; font-size: 14px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.status { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 14px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.status-final { background: var(--forest); color: #fff; }
.status-live { background: var(--clay); color: var(--forest-deep); }
.status-pending { background: #efe8da; color: var(--muted); }
.expand {
  width: 100%;
  margin-top: 10px;
  min-height: 44px;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: var(--cream);
  font-weight: 800;
}
.rubber { display: grid; gap: 2px; padding: 8px 0; border-top: 1px solid var(--line); }
.rubber b { font-size: 16px; }
.won { color: var(--forest); font-weight: 800; }

.grade-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 12px; margin: 0 0 14px; }
.table-scroll { overflow-x: auto; }
table.ladder { width: 100%; border-collapse: collapse; font-size: 16px; }
table.ladder th, table.ladder td { padding: 8px 6px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.ladder th.team, table.ladder td.team { text-align: left; white-space: normal; }
table.ladder tr.is-us { background: #efe4c4; font-weight: 800; }
.sort-btn { background: none; border: 0; font-weight: 800; padding: 4px; min-height: 44px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 8px 0 0; list-style: none; }
.pills li { background: var(--cream); border-radius: 999px; padding: 6px 10px; }
.pills li.is-us { background: #efe4c4; font-weight: 800; }

.select {
  min-height: 48px;
  border: 2px solid var(--forest);
  border-radius: 12px;
  background: #fff;
  padding: 8px 10px;
}

body.tv { background: #10281e; }
body.tv .site-header, body.tv .filters, body.tv .site-footer, body.tv .no-tv { display: none; }
body.tv .wrap { max-width: none; padding: 12px; }
body.tv .time-group h3 { font-size: 64px; }
body.tv .slot .matchup { font-size: 42px; }
body.tv .slot .courts, body.tv .slot .grade-line { font-size: 28px; color: var(--ink); }
body.tv .tv-scroll { height: 100vh; overflow: hidden; }

@media (min-width: 800px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .club-grid { grid-template-columns: 1fr 1fr; }
  .header-inner { grid-template-columns: auto 1fr auto; }
  .nav { grid-column: auto; justify-content: flex-end; }
}

@media print {
  body { background: #fff; color: #000; font-size: 12pt; }
  .site-header { background: #fff; color: #000; border-bottom: 2px solid #000; }
  .nav, .filters, .toolbar, .site-footer, .no-print, .map-link, .expand { display: none !important; }
  .kicker, .powered, .powered a { color: #000; }
  .tie, .slot, .grade-card, .md-card, .tile { box-shadow: none; break-inside: avoid; border-color: #000; }
  .badge-home, .badge-away { background: #fff; color: #000; border: 2px solid #000; }
  .time-group h3 { background: #fff; color: #000; border: 2px solid #000; }
  a { color: #000; text-decoration: none; }
  @page { size: A4; margin: 12mm; }
}
