:root {
  color-scheme: dark;
  --purple: #4f2683;
  --purple-light: #7c4dba;
  --gold: #f5c451;
  --background: #092d1b;
  --surface: #18141f;
  --surface-raised: #211a2b;
  --border: #352b43;
  --text: #f7f4fb;
  --muted: #aca3b8;
  --success: #50c878;
  --warning: #f5c451;
  --danger: #ff7070;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background-color: var(--background);
  background-image: url("football-ball-rugby-field.jpg");
  background-position: center;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-attachment: fixed;
  line-height: 1.5;
}

body::before {
  position: fixed;
  z-index: 0;
  pointer-events: none;
  content: "";
}

body > header,
body > main,
body > footer {
  position: relative;
  z-index: 1;
}

body::before {
  inset: 0;
  background:
    radial-gradient(ellipse at center, rgb(0 0 0 / 16%) 20%, rgb(0 0 0 / 58%) 100%),
    linear-gradient(rgb(9 20 14 / 38%), rgb(9 20 14 / 62%));
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.25rem max(1.25rem, calc((100% - 1180px) / 2));
  border-bottom: 1px solid var(--border);
  background: rgb(13 11 18 / 88%);
  backdrop-filter: blur(14px);
}

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 3vw, 2rem);
  letter-spacing: -0.03em;
}

h1::before {
  display: inline-block;
  width: 0.35rem;
  height: 1.15em;
  margin-right: 0.65rem;
  border-radius: 999px;
  background: var(--gold);
  vertical-align: -0.15em;
  content: "";
}

h2 { margin-bottom: 0.15rem; font-size: 1.15rem; }

#meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
  color: var(--muted);
  font-size: 0.9rem;
}

#week { color: var(--gold); font-weight: 750; }
.dot { color: var(--purple-light); }

button {
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--purple-light);
  border-radius: 8px;
  color: var(--text);
  background: var(--purple);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease;
}

button:hover { background: var(--purple-light); }
button:active { transform: translateY(1px); }

button:focus-visible, summary:focus-visible {
  outline: 3px solid rgb(245 196 81 / 45%);
  outline-offset: 3px;
}

select {
  min-height: 2.4rem;
  padding: 0.45rem 2rem 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  font: inherit;
}

.section-heading,
.board-controls,
.picker,
.view-toggle {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.section-heading { justify-content: space-between; margin-bottom: 1rem; }
.section-heading .muted { margin-bottom: 0; }
.board-controls label { color: var(--muted); font-size: 0.82rem; font-weight: 700; }
.picker { gap: 0.45rem; }
.view-toggle { gap: 0; }
.view-toggle button { border-radius: 0; background: transparent; }
.view-toggle button:first-child { border-radius: 8px 0 0 8px; }
.view-toggle button:last-child { border-radius: 0 8px 8px 0; }
.view-toggle button.active { color: #fff; background: var(--purple); }

main {
  display: grid;
  gap: 1.25rem;
  width: min(1180px, calc(100% - 2.5rem));
  margin: 2rem auto;
}

.featured-card {
  border-color: rgb(245 196 81 / 55%);
  background:
    linear-gradient(120deg, rgb(79 38 131 / 94%), rgb(24 20 31 / 94%)),
    var(--surface);
  box-shadow: 0 18px 48px rgb(0 0 0 / 32%);
}

.featured-kicker {
  margin-bottom: 0.6rem;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.featured-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.featured-content h2 { font-size: clamp(1.5rem, 4vw, 2.35rem); }
.featured-matchup { margin-bottom: 0.2rem; color: #fff; font-size: 1.1rem; font-weight: 750; }
.featured-date { margin-bottom: 0; }

.featured-logos {
  display: flex;
  align-items: center;
  gap: clamp(0.65rem, 2vw, 1.25rem);
  margin: 0.6rem 0 0.8rem;
}

.featured-team {
  display: grid;
  grid-template-columns: 3.75rem auto;
  align-items: center;
  gap: 0.55rem;
  min-width: 6.5rem;
  font-size: 1rem;
  font-weight: 850;
}

.team-logo {
  width: 3.75rem;
  height: 3.75rem;
  object-fit: contain;
  filter: drop-shadow(0 5px 8px rgb(0 0 0 / 35%));
}

.versus { color: var(--gold); font-size: 0.8rem; font-weight: 850; text-transform: uppercase; }

.featured-player {
  min-width: min(100%, 16rem);
  padding: 0.9rem;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 10px;
  background: rgb(0 0 0 / 18%);
}

.featured-label {
  display: block;
  margin-bottom: 0.45rem;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 750;
}

.card {
  overflow: hidden;
  padding: 1.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(145deg, var(--surface-raised), var(--surface));
  box-shadow: 0 16px 40px rgb(0 0 0 / 20%);
}

.muted { margin-bottom: 1rem; color: var(--muted); font-size: 0.92rem; }
.hidden { display: none !important; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.square-list { display: flex; flex-wrap: wrap; gap: 0.35rem; color: var(--muted); }
.badge.square { color: var(--text); border-color: var(--purple-light); background: rgb(79 38 131 / 28%); }

.inline-result-row td {
  padding: 0.65rem 0.9rem 0.9rem;
  background: rgb(0 0 0 / 16%);
}

.inline-result {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1.25rem;
}

.result-period {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.badge.selected-win {
  color: #081c0e;
  border-color: var(--success);
  background: var(--success);
}

.board-wrap { overflow-x: auto; padding-bottom: 0.5rem; }

.board-grid {
  display: grid;
  grid-template-columns: minmax(5rem, 0.8fr) repeat(10, minmax(5.5rem, 1fr));
  min-width: 65rem;
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.board-cell {
  display: grid;
  place-items: center;
  min-height: 4.5rem;
  padding: 0.4rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
  text-align: center;
}

.board-header { min-height: 3rem; color: var(--gold); background: var(--purple); font-size: 1.1rem; font-weight: 800; }
.board-corner { color: var(--muted); background: var(--surface); font-size: 0.7rem; font-weight: 700; }
.board-square { background: rgb(255 255 255 / 2%); font-size: 0.78rem; font-weight: 650; }
.board-square:hover { background: rgb(124 77 186 / 22%); }
.board-square.open { color: var(--muted); font-weight: 400; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  white-space: nowrap;
}

th, td {
  padding: 0.8rem 0.9rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th {
  color: var(--muted);
  background: rgb(255 255 255 / 3%);
  font-size: 0.73rem;
  font-weight: 750;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 120ms ease; }
tbody tr:hover { background: rgb(255 255 255 / 4%); }
.center { text-align: center; }

.win-row { background: rgb(80 200 120 / 9%); box-shadow: inset 4px 0 var(--success); }
.pending-row { background: rgb(245 196 81 / 7%); box-shadow: inset 4px 0 var(--warning); }
.error-row { background: rgb(255 112 112 / 7%); box-shadow: inset 4px 0 var(--danger); }
.bye-row { background: rgb(124 77 186 / 13%); box-shadow: inset 4px 0 var(--gold); }

.badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.65rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: rgb(255 255 255 / 4%);
  font-size: 0.72rem;
  font-weight: 750;
}

.badge.final { color: #d9c9ef; border-color: var(--purple-light); background: rgb(79 38 131 / 32%); }
.badge.win { color: #c9f8d8; border-color: #297d45; background: rgb(80 200 120 / 16%); }
.badge.pending { color: #ffedb6; border-color: #8c6b18; background: rgb(245 196 81 / 13%); }
.badge.error { color: #ffd0d0; border-color: #9e3e3e; background: rgb(255 112 112 / 13%); }
.badge.bye { color: #ffedb6; border-color: var(--gold); background: rgb(79 38 131 / 45%); }

details { border-top: 1px solid var(--border); margin-top: 0.8rem; padding-top: 0.8rem; }

summary {
  width: fit-content;
  color: var(--gold);
  font-weight: 700;
  cursor: pointer;
}

pre {
  max-height: 32rem;
  overflow: auto;
  margin: 1rem 0 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: #ded7e8;
  background: #09070c;
  font-size: 0.8rem;
  line-height: 1.6;
}

footer { padding: 0 1.25rem 2rem; color: var(--muted); text-align: center; }

@media (max-width: 700px) {
  header { align-items: flex-start; flex-direction: column; gap: 0.75rem; }
  #meta { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  #meta button { margin-left: auto; }
  main { width: min(100% - 1.25rem, 1180px); margin-block: 0.75rem 1.5rem; gap: 0.75rem; }
  .card { padding: 1rem; border-radius: 10px; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .board-controls { align-items: stretch; flex-wrap: wrap; }
  .board-controls select { flex: 1; }
  th, td { padding: 0.7rem; }
}

@media (max-width: 520px) {
  body { background-attachment: scroll; }

  header { padding: 0.9rem; }
  #meta { gap: 0.45rem; font-size: 0.78rem; }
  #meta .dot { display: none; }
  #asof { flex-basis: calc(100% - 5.5rem); }
  #meta button { min-height: 2.5rem; }

  .featured-content { align-items: stretch; flex-direction: column; gap: 0.9rem; }
  .featured-player { width: 100%; }
  .featured-team { grid-template-columns: 3rem auto; min-width: 5rem; }
  .team-logo { width: 3rem; height: 3rem; }

  .board-controls { display: grid; grid-template-columns: 1fr; }
  .picker { display: grid; grid-template-columns: auto minmax(0, 1fr); }
  .view-toggle { width: 100%; }
  .view-toggle button { flex: 1; min-height: 2.65rem; }

  #numbers thead { display: none; }

  #numbers,
  #numbers tbody { display: block; white-space: normal; }

  #numbers tbody { padding: 0.5rem; }

  #numbers tbody tr {
    display: grid;
    margin-bottom: 0.65rem;
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: rgb(10 8 13 / 42%);
  }

  #numbers tbody tr:last-child { margin-bottom: 0; }

  #numbers td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-width: 0;
    padding: 0.55rem 0;
    text-align: right;
  }

  #numbers td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 0.68rem;
    font-weight: 750;
    letter-spacing: 0.04em;
    text-align: left;
    text-transform: uppercase;
  }

  #numbers td[colspan] { grid-column: auto; }
  #numbers .square-list { justify-content: flex-end; }
  #numbers tbody tr:not(.inline-result-row):not(.bye-row) {
    margin-bottom: 0;
    border-bottom: 0;
    border-radius: 9px 9px 0 0;
  }
  #numbers tbody .inline-result-row {
    border-radius: 0 0 9px 9px;
    background: rgb(0 0 0 / 28%);
  }
  #numbers .inline-result-row td { display: block; text-align: left; }
  #numbers .inline-result-row td::before { display: block; margin-bottom: 0.5rem; }
  .inline-result { display: grid; gap: 0.65rem; }
  .result-period { align-items: flex-start; flex-direction: column; }
  .badge { min-height: 1.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
