:root {
  --bg:        #0a0a2e;
  --bg-alt:    #1a1a4e;
  --ice:       #d8e8f8;
  --ice-line:  #f83800;
  --ice-line2: #0078f8;
  --white:     #fcfcfc;
  --yellow:    #f8d800;
  --red:       #f83800;
  --red-dark:  #b80000;
  --blue:      #0078f8;
  --blue-dark: #0040a8;
  --green:     #00b800;
  --pink:      #f87858;
  --shadow:    #000;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background-color: var(--bg);
  color: var(--white);
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  line-height: 1.6;
  image-rendering: pixelated;
  min-height: 100vh;
}
/* Decorative scanline texture, kept off the contrast path (not an ancestor of text). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent 0 4px, rgba(255, 255, 255, 0.03) 4px 8px);
}
body { padding: 24px 16px 64px; max-width: 1100px; margin: 0 auto; }

/* Accessibility utilities */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--yellow);
  color: var(--shadow);
  padding: 10px 14px;
  text-decoration: none;
}
.skip-link:focus { left: 8px; top: 8px; }
a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--ice-line2);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .marquee-track { animation: none !important; transform: none !important; }
  .in-progress, .status-live, .puck-spin { animation: none !important; }
}

/* Pixel border using box-shadow */
.panel {
  background: var(--bg-alt);
  padding: 24px;
  margin: 24px 0;
  box-shadow:
    0 -4px 0 var(--white),
    0  4px 0 var(--white),
    -4px 0 0 var(--white),
     4px 0 0 var(--white),
     0  0 0 8px var(--bg),
     0  8px 0 var(--shadow);
  border: 4px solid transparent;
}
.panel-red    { background: var(--red-dark); }
.panel-blue   { background: var(--blue-dark); }
.panel-yellow { background: #806000; }

h1, h2, h3 { font-weight: normal; }
h1 {
  font-size: 28px;
  color: var(--yellow);
  text-align: center;
  text-shadow:
    4px 0 var(--red), -4px 0 var(--red),
    0 4px var(--red), 0 -4px var(--red),
    4px 4px var(--red), -4px -4px var(--red),
    4px -4px var(--red), -4px 4px var(--red),
    8px 8px var(--shadow);
  letter-spacing: 2px;
  line-height: 1.4;
}
h2 {
  font-size: 16px;
  color: var(--yellow);
  margin-bottom: 16px;
  text-shadow: 3px 3px var(--shadow);
}
h3 {
  font-size: 12px;
  color: var(--white);
  margin: 16px 0 8px;
  text-shadow: 2px 2px var(--shadow);
}
.subtitle {
  text-align: center;
  color: var(--ice);
  margin-top: 12px;
  font-size: 10px;
  text-shadow: 2px 2px var(--shadow);
}

/* Header with skaters */
.hero {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 32px;
  padding: 32px 0 16px;
  flex-wrap: wrap;
}
.hero-art { flex-shrink: 0; }
.hero-title { text-align: center; }

/* Pixel-art rink strip */
.rink {
  height: 24px;
  margin: 12px 0 24px;
  background:
    linear-gradient(90deg,
      var(--ice-line) 0 8%,
      var(--ice) 8% 30%,
      var(--ice-line2) 30% 31%,
      var(--ice) 31% 49%,
      var(--ice-line) 49% 51%,
      var(--ice) 51% 69%,
      var(--ice-line2) 69% 70%,
      var(--ice) 70% 92%,
      var(--ice-line) 92% 100%);
  box-shadow: 0 4px 0 var(--shadow);
}

/* Year selector / nav */
.yearbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 0 0 8px;
}
.year-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  color: var(--white);
  background: var(--bg);
  padding: 12px 14px;
  cursor: pointer;
  border: none;
  text-decoration: none;
  display: inline-block;
  box-shadow:
    -3px 0 0 var(--white), 3px 0 0 var(--white),
     0 -3px 0 var(--white), 0 3px 0 var(--white),
     0 6px 0 var(--shadow);
}
.year-btn:hover { color: var(--yellow); }
.year-btn[aria-current="true"] {
  background: var(--yellow);
  color: var(--shadow);
  text-shadow: none;
}

/* All-time leaderboard */
.leaderboard { font-size: 10px; }
.leaderboard th.player, .leaderboard td.player { text-align: left; }
.leaderboard td.rank-num {
  font-size: 14px; color: var(--yellow); text-shadow: 2px 2px var(--shadow);
}
.leaderboard td.player { display: flex; align-items: center; gap: 10px; }
.leaderboard .sprite svg { display: block; }
.leaderboard .pname { color: var(--white); }
.leaderboard .sub { color: var(--ice); font-size: 7px; margin-top: 4px; }
.leaderboard td.cups { font-size: 12px; letter-spacing: 2px; }
.leaderboard td.pts { color: var(--yellow); }
.leaderboard tr.rank-1 td { background: #1a1605; }
.leaderboard tr.rank-2 td { background: #161616; }
.leaderboard tr.rank-3 td { background: #1c1206; }
.leaderboard tr.rank-1 td:first-child { box-shadow: inset 6px 0 0 var(--yellow); }
.leaderboard tr.rank-2 td:first-child { box-shadow: inset 6px 0 0 #c8c8c8; }
.leaderboard tr.rank-3 td:first-child { box-shadow: inset 6px 0 0 #cd7f32; }
.board-note { color: var(--ice); font-size: 8px; margin-top: 12px; line-height: 1.8; }

/* Sortable headers */
.leaderboard .th-sort {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: var(--shadow);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  width: 100%;
  text-align: inherit;
}
.leaderboard .th-sort:hover { color: var(--red-dark); }
.leaderboard th[aria-sort] .th-sort { text-decoration: underline; }
.leaderboard .sort-ind { font-size: 8px; margin-left: 2px; }

/* Little hockey stick = "this column is sortable" */
.leaderboard .sort-stick {
  display: inline-block;
  vertical-align: middle;
  margin-left: 4px;
  line-height: 0;
  opacity: 0.35;
}
.leaderboard .sort-stick svg { display: block; fill: currentColor; }
.leaderboard .th-sort:hover .sort-stick { opacity: 1; }
.leaderboard th[aria-sort] .sort-stick { opacity: 1; }

/* Champions-by-season list */
.champions { list-style: none; }
.champions li {
  padding: 12px 14px; margin: 8px 0; background: var(--bg);
  box-shadow: 0 4px 0 var(--shadow); font-size: 10px;
}
.champions .cy-year { color: var(--yellow); margin-right: 10px; }
.champions b { color: var(--green); }
.champions .cy-team { color: var(--ice); font-size: 8px; }

/* Champion banner */
.champion-banner {
  text-align: center;
  padding: 18px;
  margin: 24px 0;
  background: var(--bg-alt);
  box-shadow:
    0 -4px 0 var(--yellow), 0 4px 0 var(--yellow),
    0 8px 0 var(--shadow);
}
.champion-banner .cup { font-size: 11px; color: var(--ice); }
.champion-banner .champ-team {
  font-size: 20px;
  color: var(--yellow);
  text-shadow: 3px 3px var(--shadow);
  margin: 8px 0;
}
.champion-banner .champ-winner { font-size: 11px; color: var(--white); }
.champion-banner .champ-winner b { color: var(--green); }
.status-live {
  color: var(--pink);
  animation: blink 1s steps(2) infinite;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 9px;
  margin-bottom: 8px;
}
th, td {
  padding: 10px 8px;
  text-align: center;
  border: 2px solid var(--bg-alt);
}
thead th {
  background: var(--yellow);
  color: var(--shadow);
  text-shadow: none;
  font-size: 9px;
}
tbody tr:nth-child(odd)  td { background: rgba(255,255,255,0.04); }
tbody tr:nth-child(even) td { background: rgba(255,255,255,0.10); }
.col-series { text-align: left; color: var(--ice); }
/* The series/points headers sit on the yellow header bar: keep dark text there. */
thead th.col-series { color: var(--shadow); }
.col-result { color: var(--yellow); }
.in-progress {
  color: var(--pink);
  animation: blink 1s steps(2) infinite;
}
/* Pulse via color, not opacity: opacity blending dropped contrast below 4.5:1. */
@keyframes blink { 50% { color: #ffd0c0; } }

/* Pick cells */
/* Outcome is signalled by typography too, not color alone: bonus is underlined,
   a wrong pick is struck through. Renders cleanly in the pixel font. */
.hit       { background: var(--yellow) !important; color: var(--shadow) !important; }
.hit-bonus { background: var(--green) !important; color: var(--shadow) !important; font-weight: bold; text-decoration: underline; }
.miss      { background: var(--red-dark) !important; color: var(--white) !important; text-decoration: line-through; }
.pending   { color: var(--ice); }

/* Scoring tables */
.score-table td.num, .score-table th.num { font-family: 'Press Start 2P', monospace; }
.score-table tfoot td {
  background: var(--blue-dark) !important;
  color: var(--yellow);
  font-weight: bold;
  border-top: 4px solid var(--yellow);
}

/* Standings: arcade-style leaderboard */
.standings {
  list-style: none;
  counter-reset: rank;
}
.standings li {
  display: grid;
  grid-template-columns: 60px 32px 1fr auto 100px;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  margin: 8px 0;
  background: var(--bg);
  box-shadow:
    -4px 0 0 var(--white), 4px 0 0 var(--white),
     0 -4px 0 var(--white), 0 4px 0 var(--white),
     0 8px 0 var(--shadow);
  font-size: 11px;
}
.standings li.rank-1 { background: #1a1605; box-shadow: inset 8px 0 0 var(--yellow), -4px 0 0 var(--white), 4px 0 0 var(--white), 0 -4px 0 var(--white), 0 4px 0 var(--white), 0 8px 0 var(--shadow); }
.standings li.rank-2 { background: #161616; box-shadow: inset 8px 0 0 #c8c8c8, -4px 0 0 var(--white), 4px 0 0 var(--white), 0 -4px 0 var(--white), 0 4px 0 var(--white), 0 8px 0 var(--shadow); }
.standings li.rank-3 { background: #1c1206; box-shadow: inset 8px 0 0 #cd7f32, -4px 0 0 var(--white), 4px 0 0 var(--white), 0 -4px 0 var(--white), 0 4px 0 var(--white), 0 8px 0 var(--shadow); }
.standings .rank-num {
  font-size: 18px;
  color: var(--yellow);
  text-shadow: 2px 2px var(--shadow);
}
.standings .name { color: var(--white); }
.standings .rounds {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  justify-content: flex-end;
}
.standings .rd { color: var(--ice); font-size: 9px; white-space: nowrap; }
.standings .total {
  text-align: right;
  color: var(--yellow);
  font-size: 16px;
  text-shadow: 2px 2px var(--shadow);
}
.standings .sprite { display: flex; justify-content: center; }

/* Footer legend */
.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 8px;
  padding: 16px;
  color: var(--ice);
}
.legend span { display: inline-block; padding: 6px 10px; }
.legend .hit       { color: var(--shadow); }
.legend .hit-bonus { color: var(--shadow); }

/* Footer marquee */
.marquee {
  overflow: hidden;
  margin-top: 32px;
  padding: 12px 0;
  border-top: 4px solid var(--yellow);
  border-bottom: 4px solid var(--yellow);
  background: var(--shadow);
}
.marquee-track {
  display: inline-block;
  white-space: nowrap;
  animation: scroll 24s linear infinite;
  color: var(--yellow);
  font-size: 10px;
}
@keyframes scroll {
  0%   { transform: translateX(100%); }
  100% { transform: translateX(-100%); }
}

/* Pixel-art SVG sprites get a glow */
.sprite svg { display: block; }
.puck-spin { animation: spin 2s linear infinite; transform-origin: center; }
@keyframes spin { 100% { transform: rotate(360deg); } }

.loading { text-align: center; padding: 48px; color: var(--ice); }

@media (max-width: 720px) {
  h1 { font-size: 18px; }
  body { padding: 16px 8px 48px; font-size: 9px; }
  table { font-size: 8px; }
  th, td { padding: 6px 4px; }
  .standings li {
    grid-template-columns: 40px 24px 1fr auto;
    grid-template-areas:
      "rank sprite name   total"
      "rank sprite rounds rounds";
    font-size: 9px;
  }
  .standings .rank-num { grid-area: rank; }
  .standings .sprite   { grid-area: sprite; }
  .standings .name     { grid-area: name; }
  .standings .total    { grid-area: total; }
  .standings .rounds   { grid-area: rounds; justify-content: flex-start; }
}
