:root {
  --red: #bf0d3e;
  --red-dark: #8f0a2e;
  --blue: #002f6c;
  --blue-bright: #0b4f9c;
  --ink: #10213a;
  --muted: #5a6879;
  --line: #d7deea;
  --pale: #f4f7fb;
  --white: #ffffff;
  --shadow: 0 18px 50px rgba(0, 47, 108, .11);
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: linear-gradient(180deg, #eef3f9 0, #fff 520px);
  color: var(--ink);
  font-family: Inter, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
button { font: inherit; }

.site-header { background: var(--white); border-bottom: 1px solid var(--line); }
.flag-rail { display: grid; grid-template-columns: 1.1fr 1.9fr 1.9fr; height: 7px; }
.flag-rail span:nth-child(1) { background: var(--blue); }
.flag-rail span:nth-child(2) { background: var(--white); }
.flag-rail span:nth-child(3) { background: var(--red); }
.header-inner {
  width: min(1180px, calc(100% - 40px));
  margin: auto;
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand { display: flex; align-items: center; gap: 13px; color: var(--blue); text-decoration: none; }
.brand-mark {
  width: 48px; height: 48px; display: grid; place-items: center;
  color: #fff; background: var(--blue); border-radius: 50%;
  box-shadow: inset 0 0 0 5px #fff, 0 0 0 2px var(--blue);
  font-size: 22px;
}
.brand strong, .brand small { display: block; }
.brand strong { font-family: "Barlow Condensed", sans-serif; font-size: 2rem; line-height: .8; letter-spacing: .04em; }
.brand small { color: var(--red); margin-top: 7px; font-size: .78rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.header-note { color: var(--muted); margin: 0; font-size: .9rem; }

main { width: min(1180px, calc(100% - 40px)); margin: 34px auto 70px; }
.control-deck, .results { background: #fff; border: 1px solid rgba(0,47,108,.12); box-shadow: var(--shadow); }
.control-deck { border-radius: 22px; overflow: hidden; }
.deck-heading {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 26px 30px 21px;
  color: white;
  background: linear-gradient(118deg, var(--blue) 0 62%, var(--blue-bright) 62% 100%);
  position: relative;
}
.deck-heading::after { content: "★"; position: absolute; right: 9%; top: -25px; color: rgba(255,255,255,.08); font-size: 8rem; line-height: 1; }
.eyebrow { margin: 0 0 3px; color: var(--red); font-size: .76rem; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.deck-heading .eyebrow { color: #d7e8ff; }
h1, h2, h3 { font-family: "Barlow Condensed", sans-serif; letter-spacing: .01em; }
h1 { margin: 0; font-size: clamp(2rem, 4vw, 3rem); line-height: 1; }
h2 { margin: 0; color: var(--blue); font-size: clamp(2rem, 3.4vw, 2.75rem); line-height: 1.05; }
.source-badge { position: relative; z-index: 1; padding: 8px 13px; border: 1px solid rgba(255,255,255,.45); border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.selector-block { padding: 22px 30px; }
.selector-row { display: grid; grid-template-columns: 1.15fr .85fr; border-top: 1px solid var(--line); }
.selector-row .selector-block + .selector-block { border-left: 1px solid var(--line); }
.step-label { margin: 0 0 12px; color: var(--blue); font-weight: 800; font-size: .82rem; letter-spacing: .08em; text-transform: uppercase; }
.step-label span { display: inline-grid; place-items: center; width: 23px; height: 23px; margin-right: 7px; border-radius: 50%; background: var(--red); color: white; font-size: .75rem; }
.sport-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.sport-button {
  border: 1px solid var(--line); border-radius: 13px; background: #fff; color: var(--ink);
  min-height: 62px; padding: 10px 14px; text-align: left; cursor: pointer; font-weight: 700;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.sport-button small { display: block; margin-top: 2px; color: var(--muted); font-size: .72rem; font-weight: 600; }
.sport-button:hover { transform: translateY(-2px); border-color: #8da8c9; }
.sport-button[aria-checked="true"] { color: #fff; border-color: var(--blue); background: var(--blue); box-shadow: 0 8px 20px rgba(0,47,108,.2); }
.sport-button[aria-checked="true"] small { color: #cddcf0; }
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip, .district-chip {
  min-width: 48px; border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px;
  color: var(--blue); background: white; font-weight: 800; cursor: pointer;
}
.chip[aria-checked="true"], .district-chip[aria-pressed="true"] { border-color: var(--red); color: white; background: var(--red); }
.view-switch { display: inline-flex; width: 100%; padding: 4px; background: var(--pale); border-radius: 12px; }
.view-switch button { flex: 1; border: 0; border-radius: 9px; padding: 10px 12px; color: var(--muted); background: transparent; font-weight: 800; cursor: pointer; }
.view-switch button[aria-selected="true"] { color: white; background: var(--blue); box-shadow: 0 5px 14px rgba(0,47,108,.18); }
.view-switch button:disabled { opacity: .45; cursor: not-allowed; }

.results { margin-top: 24px; border-radius: 22px; overflow: hidden; }
.results-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding: 27px 30px 22px; border-bottom: 1px solid var(--line); }
.results-heading p { margin: 5px 0 0; color: var(--muted); }
.results-meta { color: var(--muted); text-align: right; font-size: .84rem; }
.results-meta strong { display: block; color: var(--ink); font-size: 1rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { padding: 12px 14px; background: var(--blue); color: white; font-size: .72rem; letter-spacing: .06em; text-align: right; text-transform: uppercase; white-space: nowrap; }
th:nth-child(2), td:nth-child(2) { text-align: left; }
td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: right; font-size: .91rem; white-space: nowrap; }
tbody tr:nth-child(even) { background: #f8fafd; }
tbody tr:hover { background: #eef5ff; }
.rank-cell { width: 70px; color: var(--blue); font-family: "Barlow Condensed", sans-serif; font-size: 1.2rem; font-weight: 800; }
.school-cell { min-width: 290px; white-space: normal; font-weight: 700; }
.class-tag { display: inline-block; min-width: 36px; padding: 3px 7px; border-radius: 6px; color: var(--blue); background: #e8f0fa; font-size: .76rem; font-weight: 800; text-align: center; }
.rating { color: var(--red-dark); font-weight: 800; }
.ranking-search { display: grid; grid-template-columns: auto minmax(220px, 360px) 1fr; align-items: center; gap: 10px 14px; padding: 16px 30px; border-bottom: 1px solid var(--line); background: var(--pale); }
.ranking-search label { color: var(--blue); font-weight: 800; }
.ranking-search input { width: 100%; min-height: 42px; border: 1px solid #9cabc0; border-radius: 9px; padding: 9px 12px; color: var(--ink); background: white; font: inherit; }
.ranking-search input:focus { border-color: var(--blue); outline: 3px solid rgba(11,79,156,.18); }
.ranking-search span { color: var(--muted); font-size: .82rem; }
.ranking-no-results { margin: 0; padding: 34px 30px; color: var(--muted); text-align: center; }
.rank-change { display: inline-block; min-width: 34px; font-size: .78rem; font-weight: 800; text-align: center; }
.rank-change.up { color: #18733c; }
.rank-change.down { color: var(--red-dark); }
.rank-change.new { padding: 2px 6px; border-radius: 999px; color: white; background: var(--blue-bright); font-size: .68rem; text-transform: uppercase; }
.rank-change.steady { color: var(--muted); }
.predictor-shell { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(320px, .95fr); gap: 26px; padding: 30px; background: linear-gradient(135deg, #f8fafd, #eef4fb); }
.predictor-form, .prediction-output { border: 1px solid var(--line); border-radius: 15px; background: white; box-shadow: 0 10px 28px rgba(0,47,108,.08); }
.predictor-form { display: grid; grid-template-columns: 1fr auto 1fr; gap: 18px; align-items: end; padding: 24px; }
.predictor-form label, .predictor-form legend { display: block; margin-bottom: 7px; color: var(--blue); font-size: .78rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.predictor-form input { width: 100%; min-height: 46px; border: 1px solid #9cabc0; border-radius: 9px; padding: 10px 12px; color: var(--ink); background: white; font: inherit; }
.predictor-form input:focus { border-color: var(--blue); outline: 3px solid rgba(11,79,156,.18); }
.matchup-action { display: grid; gap: 8px; justify-items: center; align-self: end; min-width: 132px; }
.matchup-action .versus { color: var(--red); font-family: "Barlow Condensed", sans-serif; font-size: 1.1rem; font-weight: 800; line-height: 1; }
.run-matchup { min-height: 46px; border: 0; border-radius: 999px; padding: 10px 17px; color: white; background: linear-gradient(135deg, var(--red), #9f001f); box-shadow: 0 8px 18px rgba(191,0,36,.24); font: inherit; font-weight: 800; cursor: pointer; transition: transform .16s ease, box-shadow .16s ease, filter .16s ease; }
.run-matchup:hover { filter: brightness(1.08); box-shadow: 0 10px 22px rgba(191,0,36,.31); transform: translateY(-1px); }
.run-matchup:active { transform: translateY(1px) scale(.98); }
.run-matchup:focus-visible { outline: 3px solid rgba(11,79,156,.24); outline-offset: 3px; }
.run-matchup:disabled { cursor: wait; filter: none; opacity: .88; transform: none; }
.run-matchup.is-running::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 7px; border: 2px solid rgba(255,255,255,.42); border-top-color: white; border-radius: 50%; vertical-align: -1px; animation: predictorSpin .6s linear infinite; }
.predictor-form fieldset { grid-column: 1 / -1; min-width: 0; margin: 4px 0 0; padding: 0; border: 0; }
.site-choice { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; padding: 4px; border-radius: 12px; background: var(--pale); }
.site-choice button { border: 0; border-radius: 9px; padding: 10px; color: var(--muted); background: transparent; font-weight: 800; cursor: pointer; }
.site-choice button[aria-pressed="true"] { color: white; background: var(--blue); }
.prediction-output { min-height: 260px; padding: 24px; }
.prediction-favorite { margin: 0 0 17px; color: var(--red-dark); font-family: "Barlow Condensed", sans-serif; font-size: 1.65rem; font-weight: 800; }
.projected-score { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 9px 18px; align-items: center; padding: 18px; border-radius: 12px; background: var(--pale); }
.projected-score span { font-weight: 700; overflow-wrap: anywhere; }
.projected-score strong { color: var(--blue); font-family: "Barlow Condensed", sans-serif; font-size: 2.25rem; }
.probability-row { display: flex; justify-content: space-between; gap: 20px; margin-top: 19px; color: var(--muted); }
.probability-row strong { color: var(--ink); }
.probability-meter { height: 10px; margin-top: 8px; overflow: hidden; border-radius: 999px; background: #dbe3ee; }
.probability-meter span { display: block; height: 100%; background: linear-gradient(90deg, var(--red), var(--blue)); }
.match-probabilities { display: grid; gap: 8px; }
.match-probabilities div { display: flex; justify-content: space-between; gap: 18px; padding: 11px 13px; border-radius: 9px; background: var(--pale); }
.prediction-detail, .prediction-warning { margin: 14px 0 0; color: var(--muted); font-size: .84rem; }
.prediction-warning { color: var(--red-dark); font-weight: 700; }
.prediction-empty { min-height: 210px; display: grid; align-content: center; justify-items: center; gap: 7px; color: var(--muted); text-align: center; }
.prediction-empty strong, .prediction-calculating strong { color: var(--blue); font-family: "Barlow Condensed", sans-serif; font-size: 1.35rem; }
.prediction-ready-mark { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 5px; border-radius: 50%; color: white; background: var(--blue); box-shadow: 0 0 0 7px rgba(0,47,108,.08); font-size: 1.25rem; }
.prediction-calculating { min-height: 210px; display: grid; align-content: center; justify-items: center; gap: 10px; color: var(--muted); text-align: center; }
.calculation-pulse { display: flex; gap: 7px; align-items: center; min-height: 30px; }
.calculation-pulse span { width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: predictorPulse .72s ease-in-out infinite alternate; }
.calculation-pulse span:nth-child(2) { animation-delay: .12s; background: var(--blue); }
.calculation-pulse span:nth-child(3) { animation-delay: .24s; }
.result-reveal { animation: predictorReveal .38s cubic-bezier(.2,.8,.2,1) both; }
@keyframes predictorSpin { to { transform: rotate(360deg); } }
@keyframes predictorPulse { from { transform: translateY(5px) scale(.8); opacity: .45; } to { transform: translateY(-5px) scale(1.15); opacity: 1; } }
@keyframes predictorReveal { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
.predictor-notes { display: flex; gap: 12px; padding: 17px 30px; border-top: 1px solid var(--line); color: var(--muted); background: white; font-size: .84rem; }
.predictor-notes strong { color: var(--blue); white-space: nowrap; }
.district-tools { padding: 18px 30px; border-bottom: 1px solid var(--line); background: var(--pale); }
.district-tools p { margin: 0 0 10px; color: var(--muted); font-size: .82rem; font-weight: 700; }
.district-list { display: flex; gap: 8px; flex-wrap: wrap; }
.all-districts { display: grid; gap: 28px; padding: 28px 30px 34px; }
.district-section { border: 1px solid var(--line); border-radius: 15px; overflow: hidden; }
.district-section h3 { margin: 0; padding: 13px 16px; color: var(--blue); background: #eaf1fa; font-size: 1.35rem; }
.district-section > .table-wrap:only-child { margin: -1px; }
.standings-table th:first-child, .standings-table td:first-child { text-align: left; }
.standings-table th:first-child { min-width: 300px; }
.standings-table td:first-child { white-space: normal; font-weight: 700; }
.standings-table { table-layout: fixed; }
.standings-table .team-group { width: 42%; }
.standings-table .gb-group { width: 8%; }
.standings-table th:not(:first-child), .standings-table td:not(:first-child) { text-align: center; }
.standings-table .overall-group, .standings-table .district-group, .standings-table .gb-group { text-align: center; }
.standings-table th:nth-child(5), .standings-table td:nth-child(5), .standings-table th:nth-child(8), .standings-table td:nth-child(8) { border-left: 1px solid rgba(255,255,255,.3); }
.standings-table tbody td:nth-child(5), .standings-table tbody td:nth-child(8) { border-left-color: var(--line); }
.standings-mobile { display: none; }
.team-link { color: var(--blue); font-weight: 800; text-decoration: none; }
.team-link:hover { color: var(--red-dark); text-decoration: none; }
.back-link { color: var(--blue); font-weight: 800; text-decoration: none; }
.schedule-table th:first-child, .schedule-table th:nth-child(2), .schedule-table td:first-child, .schedule-table td:nth-child(2) { text-align: left; }
.game-date span { display: block; color: var(--muted); font-size: .76rem; }
.result-win { color: #18733c; font-weight: 800; }
.result-loss { color: var(--red-dark); font-weight: 800; }
.empty-state { padding: 58px 30px; text-align: center; }
.empty-state .empty-mark { width: 52px; height: 52px; margin: 0 auto 15px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--blue); font-size: 1.3rem; }
.empty-state h3 { margin: 0; color: var(--blue); font-size: 1.75rem; }
.empty-state p { max-width: 580px; margin: 8px auto 0; color: var(--muted); }
.loading { padding: 50px 30px; color: var(--muted); text-align: center; }

footer { width: min(1180px, calc(100% - 40px)); margin: 0 auto 45px; display: flex; justify-content: space-between; gap: 30px; color: var(--muted); font-size: .8rem; }
footer strong, footer span { display: block; }
footer strong { color: var(--blue); font-size: 1rem; }
footer p { margin: 0; max-width: 560px; text-align: right; }

@media (max-width: 850px) {
  .header-note { display: none; }
  .sport-grid { grid-template-columns: repeat(2, 1fr); }
  .selector-row { grid-template-columns: 1fr; }
  .selector-row .selector-block + .selector-block { border-left: 0; border-top: 1px solid var(--line); }
  .results-heading { align-items: start; flex-direction: column; }
  .results-meta { text-align: left; }
  .predictor-shell { grid-template-columns: 1fr; }
  footer { flex-direction: column; }
  footer p { text-align: left; }
}

@media (max-width: 560px) {
  .header-inner, main, footer { width: min(100% - 24px, 1180px); }
  .header-inner { min-height: 76px; }
  .brand-mark { width: 40px; height: 40px; }
  .brand strong { font-size: 1.7rem; }
  .deck-heading, .selector-block, .results-heading { padding-left: 18px; padding-right: 18px; }
  .deck-heading { align-items: flex-start; }
  .source-badge { display: none; }
  .sport-grid { grid-template-columns: 1fr; }
  .sport-button { min-height: 54px; }
  .district-tools { padding: 16px 18px; }
  .ranking-search { grid-template-columns: 1fr; gap: 6px; padding: 15px 18px; }
  .predictor-shell { gap: 14px; padding: 14px 12px 18px; }
  .predictor-form { grid-template-columns: 1fr; gap: 12px; padding: 18px; }
  .matchup-action { width: 100%; padding: 2px 0; }
  .run-matchup { width: 100%; }
  .predictor-form fieldset { grid-column: auto; }
  .site-choice { grid-template-columns: 1fr; }
  .prediction-output { min-height: 0; padding: 18px; }
  .predictor-notes { display: grid; padding: 15px 18px; }
  .all-districts { padding: 18px 12px 24px; }
  th, td { padding: 11px 10px; }
  .school-cell { min-width: 230px; }
  .rankings-table th:nth-child(n+7), .rankings-table td:nth-child(n+7) { display: none; }
  .standings-desktop { display: none; }
  .standings-mobile { display: block; overflow-x: hidden; }
  .standings-mobile th { padding: 12px 9px; text-align: center; }
  .standings-mobile th:first-child, .standings-mobile td:first-child { width: 58%; text-align: left; white-space: normal; }
  .standings-mobile th:nth-child(2), .standings-mobile td:nth-child(2), .standings-mobile th:nth-child(3), .standings-mobile td:nth-child(3) { width: 21%; text-align: center; }
  .standings-mobile th:nth-child(2), .standings-mobile td:nth-child(2), .standings-mobile th:nth-child(3), .standings-mobile td:nth-child(3) { border-left: 1px solid var(--line); }
  .standings-mobile td { padding: 14px 9px; font-weight: 700; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
  .result-reveal, .calculation-pulse span, .run-matchup.is-running::before { animation: none !important; }
}
