:root {
  --field-green: #1b5e3a;
  --field-green-dark: #123d26;
  --field-green-light: #2c7a4d;
  --end-zone-gold: #e8b93a;
  --bg: #f4f6f4;
  --surface: #ffffff;
  --surface-muted: #eef3ee;
  --text: #1a1f1c;
  --text-muted: #5b655e;
  --border: #dfe3df;
  --danger: #b3261e;
  --success: #1b7f4d;
  --warning: #6b4a00;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(20, 30, 22, 0.06);
  --shadow: 0 1px 3px rgba(20, 30, 22, 0.08), 0 1px 2px rgba(20, 30, 22, 0.06);
  --shadow-lg: 0 8px 24px rgba(20, 30, 22, 0.12), 0 2px 6px rgba(20, 30, 22, 0.08);

  --transition-fast: 0.15s ease;
  --focus-ring: 3px solid #2563eb;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--end-zone-gold);
  color: #000;
  padding: 8px 16px;
  z-index: 100;
}
.skip-link:focus {
  left: 8px;
  top: 8px;
}

a, button {
  font: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

/* -- Header / nav ---------------------------------------------------- */

.site-header {
  background: linear-gradient(135deg, var(--field-green), var(--field-green-dark));
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.brand {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  white-space: nowrap;
}

.main-nav {
  display: flex;
  gap: var(--space-1);
  overflow-x: auto;
  flex: 1 1 auto;
  scrollbar-width: thin;
  padding-bottom: 2px; /* room for focus outline */
}

.nav-link {
  background: transparent;
  border: none;
  color: #e9f5ee;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 500;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}
.nav-link:hover { background: rgba(255, 255, 255, 0.14); }
.nav-link.is-active {
  background: var(--end-zone-gold);
  color: #1a1f1c;
  font-weight: 700;
}

.header-meta { margin-left: auto; }

.pill {
  background: rgba(255, 255, 255, 0.15);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}
.pill.ok { background: rgba(52, 199, 129, 0.32); }
.pill.warn { background: rgba(220, 90, 70, 0.35); }

/* -- Layout ------------------------------------------------------------ */

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-6);
}

.view { display: none; }
.view.is-active { display: block; animation: fade-in 0.2s ease; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

h1 { font-size: 1.6rem; margin: 0 0 var(--space-4); letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; margin: 0 0 var(--space-2); }
h3 { font-size: 1rem; margin: var(--space-4) 0 var(--space-2); color: var(--text-muted); }

.section-subheading {
  font-size: 1.05rem;
  margin: var(--space-6) 0 var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}
.section-subheading:first-of-type { margin-top: 0; }

.muted { color: var(--text-muted); }

/* -- Badges (unified) ---------------------------------------------------
   One base .badge class + color modifiers, used everywhere a small status
   tag is needed (matchup status, betting notice, fraud rating). */

.badge {
  display: inline-flex;
  align-items: center;
  background: var(--end-zone-gold);
  color: #1a1f1c;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  vertical-align: middle;
  white-space: nowrap;
}
.badge-success { background: #e8f5ee; color: var(--success); border: 1px solid #bfe6cf; }
.badge-warning { background: #fff4e5; color: var(--warning); border: 1px solid #f0c987; }
.badge-danger { background: #fde8e6; color: var(--danger); border: 1px solid #f2b3ac; }
.badge-neutral { background: var(--surface-muted); color: var(--text-muted); border: 1px solid var(--border); }

/* -- Alerts / empty states ---------------------------------------------- */

/* `.alert` sets display:flex, which (per normal CSS cascade rules) overrides
   the browser's default `[hidden] { display: none }` rule -- without this,
   an alert with the `hidden` attribute set still renders as an empty flex
   box with just its icon showing. */
.alert[hidden] { display: none; }

.alert {
  background: #fff4e5;
  border: 1px solid #f0c987;
  color: var(--warning);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}
.alert::before { content: "ℹ️"; flex: 0 0 auto; }
.alert.error {
  background: #fde8e6;
  border-color: #f2b3ac;
  color: #7a1c14;
}
.alert.error::before { content: "⚠️"; }

/* -- Cards --------------------------------------------------------------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-4);
}
.span-full { grid-column: 1 / -1; }

/* Flexbox (not grid) so a leftover last row of cards centers itself instead
   of hugging the left edge with empty space to the right -- CSS Grid has no
   built-in way to center an incomplete final row. */
.matchup-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-4);
}
.matchup-grid > * {
  flex: 0 1 260px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast), transform var(--transition-fast);
}
.card h2 {
  font-size: 0.85rem;
  margin: 0 0 var(--space-2);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}
.card .big-stat {
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1.15;
}
.big-stat.superlative-team { font-size: 1.2rem; }

.trend-success { color: var(--success); font-weight: 600; margin: 0; }
.trend-danger { color: var(--danger); font-weight: 600; margin: 0; }

.sparkline { width: 100%; }
.sparkline svg { width: 100%; height: auto; display: block; }

.team-card {
  text-align: left;
  cursor: pointer;
  border: 1px solid var(--border);
  font: inherit;
  color: inherit;
}
.team-card:hover,
.team-card:focus-visible {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: var(--field-green-light);
}

/* -- Matchup cards --------------------------------------------------------
   Centered, stacked layout so long team names truncate gracefully instead
   of overflowing the card at any width. */

.matchup-card {
  text-align: center;
  padding: var(--space-4) var(--space-3);
}

.matchup-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.matchup-week {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.matchup-teams {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.matchup-team {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: var(--space-2) var(--space-1);
  border-radius: var(--radius-sm);
  min-width: 0; /* required for text-overflow to work inside a flex column */
}
.matchup-team.is-winner {
  background: rgba(27, 127, 77, 0.08);
}

.matchup-team-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  font-size: 0.92rem;
}
.matchup-team.is-winner .matchup-team-name { color: var(--success); }

.matchup-score {
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.matchup-team.is-winner .matchup-score { color: var(--success); }

.matchup-vs {
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  margin: 0.1rem 0;
}

.matchup-bye-name { margin: var(--space-3) 0 0; }

/* -- Tables --------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }

.table-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}
.table-toolbar label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}
.table-toolbar select {
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font: inherit;
  font-size: 0.9rem;
  min-width: 180px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

th, td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th { background: var(--surface-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }

tbody tr { transition: background-color var(--transition-fast); }
tbody tr:hover { background: var(--surface-muted); }
tbody tr:last-child td { border-bottom: none; }
tbody tr.is-highlighted { background: rgba(232, 185, 58, 0.14); }

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--field-green);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
}

.tooltip {
  border-bottom: 1px dotted var(--text-muted);
  cursor: help;
}

.formula-note {
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
  background: var(--surface-muted);
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  display: inline-block;
  margin-bottom: var(--space-4);
}

.team-detail {
  margin-top: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.fraud-legit { color: var(--success); font-weight: 600; }
.fraud-suspect { color: #a67c00; font-weight: 600; }
.fraud-watch { color: #b3691e; font-weight: 600; }
.fraud-certified { color: #c2410c; font-weight: 700; }
.fraud-federal { color: var(--danger); font-weight: 700; }

.site-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: var(--space-6) var(--space-4);
}

button.primary {
  background: var(--field-green);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.5rem 1.1rem;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}
button.primary:hover { background: var(--field-green-dark); }

/* -- Loading state -------------------------------------------------------- */

.loading-state {
  color: var(--text-muted);
  padding: var(--space-4);
  text-align: center;
}
.loading-state::after {
  content: "";
  display: inline-block;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* -- Mobile table stacking -------------------------------------------------- */

@media (max-width: 640px) {
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tbody tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: var(--space-3);
    padding: var(--space-2) var(--space-3);
    background: var(--surface);
  }
  td {
    border: none;
    padding: 0.3rem 0;
    white-space: normal;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
  }
  td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    flex: 0 0 auto;
  }

  .table-toolbar select { min-width: 0; flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
