/* Shared styles for every page */
:root {
  --ice: #EEF3F6; --surface: #FFFFFF; --ink: #1B2733; --muted: #5B6B79; --rule: #D5DEE5;
  --red: #C8102E; --blue: #0B5CAD; --crease: #D6EAF7; --fav: #FFF6D6;
  --display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --body: "Barlow", "Segoe UI", system-ui, sans-serif;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ice: #0E1620; --surface: #15202B; --ink: #E5ECF1; --muted: #93A4B3; --rule: #263441;
    --red: #FF5263; --blue: #5AA9F0; --crease: #1A3550; --fav: #3A3320;
  }
}
*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body { margin: 0; background: var(--ice); color: var(--ink); font: 16px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px 64px; }

header { padding: 32px 0 20px; display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px 24px; }
h1 { font: 700 clamp(2.4rem, 7vw, 3.75rem)/0.9 var(--display); margin: 0; letter-spacing: -0.01em; }
.updated { color: var(--muted); font-size: 0.9rem; margin: 6px 0 0; }
label.fav-pick { display: grid; gap: 4px; font-size: 0.85rem; color: var(--muted); }
select { font: 500 1rem var(--body); color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 8px 10px; min-width: 240px; max-width: 100%; }

/* Favorite team panel: styled like a center-ice faceoff spot */
.fav { background: var(--surface); border-left: 6px solid var(--red); border-radius: 4px 12px 12px 4px; padding: 18px 20px; margin: 0 0 24px;
       display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; align-items: center; }
.fav[hidden] { display: none; }
.fav .logo.big { width: 64px; height: 64px; grid-row: span 2; }
.fav .logo.big .abbr { font-size: 1.25rem; border-width: 2.5px; }
.fav h2 { font: 700 1.9rem/1 var(--display); margin: 0; }
.fav .line { color: var(--muted); }
.fav .stats { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px 24px; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--rule); }
.fav .stat.wide { grid-column: span 2; }
.fav .stat b { display: block; font: 700 1.6rem/1.1 var(--display); font-variant-numeric: tabular-nums; }
.fav .stat > span { font-size: 0.85rem; color: var(--muted); }

nav.pages ul { display: flex; gap: 4px; background: var(--surface); padding: 4px; border-radius: 10px; width: fit-content; max-width: 100%; overflow-x: auto; margin: 0 0 18px; list-style: none; }
nav.pages a { display: block; font: 600 1.05rem var(--display); color: var(--muted); text-decoration: none; padding: 8px 16px; border-radius: 7px; white-space: nowrap; }
nav.pages a:hover { color: var(--ink); }
nav.pages a[aria-current="page"] { background: var(--ink); color: var(--surface); }
nav.pages a:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
button:focus-visible, select:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

section.group { margin-bottom: 28px; }
section.group h3 { font: 600 1.5rem/1.1 var(--display); margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; }
section.group h3 small { font: 400 0.85rem var(--body); color: var(--muted); }
.scroll { overflow-x: auto; background: var(--surface); border-radius: 10px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; font-size: 0.95rem; }
th { font: 600 0.8rem var(--body); color: var(--muted); text-align: right; padding: 10px 8px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
td { padding: 8px; text-align: right; border-bottom: 1px solid var(--rule); white-space: nowrap; }
th.team, td.team { text-align: left; }
th.rank, td.rank { text-align: center; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td.team { font-weight: 600; min-width: 170px; white-space: normal; line-height: 1.25; }
th, td { padding-left: 6px; padding-right: 6px; }
td.team .tn { display: flex; align-items: center; gap: 10px; }
.logo { position: relative; width: 28px; height: 28px; flex: none; display: inline-block; }
.logo .abbr { position: absolute; inset: 0; display: grid; place-items: center; border: 1.5px solid var(--muted); border-radius: 50%;
              font: 700 0.62rem/1 var(--display); letter-spacing: 0.02em; color: var(--ink); background: var(--crease); }
.logo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
td.team .div-tag { font-weight: 400; color: var(--muted); font-size: 0.8rem; }
td.pts { font-weight: 600; }
tr.is-fav td { background: var(--fav); }
.W { color: #1D8A4C; } .L { color: var(--red); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .W, :root:not([data-theme="light"]) .up { color: #4FCB84; } }
:root[data-theme="dark"] .W, :root[data-theme="dark"] .up { color: #4FCB84; }

/* Rink lines: blue line under the last bye spot, red line under the last playoff spot */
tr.blue-line td { border-bottom: 3px solid var(--blue); }
tr.red-line td { border-bottom: 4px solid var(--red); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 0.85rem; color: var(--muted); margin: -6px 0 18px; }
.legend > span::before { content: ""; display: inline-block; width: 22px; height: 0; vertical-align: middle; margin-right: 6px; }
.legend .b::before { border-top: 3px solid var(--blue); }
.legend .r::before { border-top: 4px solid var(--red); }
.legend .arrows::before { display: none; }
.legend .arrows .up, .legend .arrows .down { margin-right: 2px; }

/* Weekly movement arrows */
th.mv, td.mv { text-align: left; padding-left: 0; padding-right: 4px; font-size: 0.82rem; font-weight: 600; }
.up { color: #1D8A4C; } .down { color: var(--red); } .mv-none { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Team name opens a dropdown with last week's details */
button.expand { all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center; gap: 10px; border-radius: 6px; }
button.expand:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
button.expand:hover .full, button.expand:hover .short { text-decoration: underline; text-underline-offset: 3px; }
.chev { color: var(--muted); font-size: 0.8rem; transition: transform .15s; }
button.expand[aria-expanded="true"] .chev { transform: rotate(180deg); }
tr.open td { border-bottom-color: transparent; }
tr.detail td { text-align: left; white-space: normal; background: var(--ice); padding: 14px 16px 16px; }
.wk { max-width: 640px; }
.wk p { margin: 0 0 8px; }
.wk-head { font-weight: 500; }
.wk-games { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; }
.wk-games .when { color: var(--muted); font-size: 0.85rem; }
.wk-games .W, .wk-games .L { font-weight: 700; }
.wk-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px 20px; }
.wk-grid b { font: 700 1.35rem/1.1 var(--display); }
.wk-grid span:last-child { display: block; font-size: 0.82rem; color: var(--muted); }
.wk-grid .up, .wk-grid .down, .wk-grid .mv-none { font-size: 0.9rem; font-weight: 600; margin-left: 4px; }
.wk-none { color: var(--muted); font-size: 0.9rem; }
.fav-mv { font-size: 1rem; }
.wk .wk-next { margin-top: 12px; }
.wk-next .when { color: var(--muted); font-size: 0.85rem; }
a.more { color: var(--blue); font-weight: 600; text-decoration: none; }
a.more:hover { text-decoration: underline; text-underline-offset: 3px; }
.fav a.more { grid-column: 1 / -1; margin-top: 4px; }

/* Team page: results and remaining schedule */
table.games th.date, table.games td.date, table.games th.opp, table.games td.opp, table.games .res { text-align: left; }
table.games td.opp a { display: inline-flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; font-weight: 600; }
table.games td.opp a:hover span { text-decoration: underline; text-underline-offset: 3px; }
table.games td.res { font-weight: 700; }
table.games th.time, table.games td.time { text-align: left; }
button.expand.game { display: inline-flex; gap: 6px; }
.gchev { color: var(--muted); font-size: 0.8rem; transition: transform .15s; }
button.expand.game[aria-expanded="true"] .gchev { transform: rotate(180deg); }
.gs { position: sticky; left: 16px; max-width: min(560px, calc(100vw - 64px)); }
.gs p { margin: 8px 0 0; }
ul.goals { list-style: none; margin: 0; padding: 0; }
ul.goals li { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
ul.goals li.gper { font: 600 1rem var(--display); color: var(--muted); padding-top: 10px; }
ul.goals li.gper:first-child { padding-top: 0; }
.gtime { width: 3.2em; flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }
.gast { color: var(--muted); }
.gtag { display: inline-block; font-size: 0.72rem; font-weight: 700; color: var(--blue); border: 1px solid var(--blue); border-radius: 999px; padding: 0 6px; margin-left: 6px; }
.gscore { margin-left: auto; padding-left: 12px; white-space: nowrap; font-weight: 600; font-variant-numeric: tabular-nums; }

.odds { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; min-width: 96px; }
.bar { width: 48px; height: 6px; background: var(--crease); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--blue); }
.odds.hi .bar i { background: #1D8A4C; } .odds.lo .bar i { background: var(--red); }


/* Trends chart */
.trend-controls { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-bottom: 14px; }
.trend-controls label { display: grid; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.trend-controls select { min-width: 200px; }
.chart-wrap { position: relative; background: var(--surface); border-radius: 10px; padding: 8px 4px 0; touch-action: pan-y; }
.chart { display: block; font-family: var(--body); user-select: none; -webkit-user-select: none; }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .ytick { fill: var(--muted); font-size: 12px; text-anchor: end; dominant-baseline: middle; font-variant-numeric: tabular-nums; }
.chart .xtick { fill: var(--muted); font-size: 12px; text-anchor: middle; }
.chart .xtitle { fill: var(--muted); font-size: 12px; text-anchor: middle; }
.chart .cut-blue { stroke: var(--blue); stroke-width: 2; stroke-dasharray: 6 5; }
.chart .cut-red { stroke: var(--red); stroke-width: 2.5; stroke-dasharray: 6 5; }
.chart .half { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 3 4; }
.chart .changelog { background: var(--surface); border-radius: 10px; padding: 4px 20px 16px; max-width: 75ch; }
.changelog h2 { font: 600 1.5rem/1.2 var(--display); margin: 20px 0 6px; }
.changelog ul { margin: 0; padding-left: 20px; }
.changelog li { margin: 4px 0; }
.changelog code { font-size: 0.9em; background: var(--ice); padding: 1px 4px; border-radius: 4px; }
.chart .guide { stroke: var(--ink); stroke-width: 1; opacity: 0.35; }
.chart .series .hit { stroke: transparent; stroke-width: 14; fill: none; cursor: pointer; }
.chart .label { cursor: pointer; }
.chart .label text { font-size: 13px; font-weight: 600; dominant-baseline: middle; }
.chart .label text.strong { font-weight: 800; font-size: 14px; }
.chart.small .label text { font-size: 11.5px; } .chart.small .label text.strong { font-size: 12.5px; }
.chart.small .ytick, .chart.small .xtick { font-size: 11px; }
.chart .dim { opacity: 0.15; }
@media (prefers-reduced-motion: no-preference) { .chart .series, .chart .label { transition: opacity .2s; } }
.tip { position: absolute; z-index: 2; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 8px 10px; font-size: 0.82rem;
       box-shadow: 0 6px 20px rgba(20, 30, 40, 0.18); pointer-events: none; min-width: 150px; }
.tip.below { position: static; box-shadow: none; border: 0; border-top: 1px solid var(--rule); border-radius: 0 0 10px 10px; margin: 0 4px; padding: 10px 8px 12px; }
.tip.below ul { columns: 2; column-gap: 18px; }
.tip p { margin: 0 0 4px; color: var(--muted); }
.tip p b { color: var(--ink); }
.tip ul { list-style: none; margin: 0; padding: 0; }
.tip li { display: flex; align-items: center; gap: 6px; line-height: 1.55; }
.tip li i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tip li span { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }
.tip li.strong { font-weight: 700; }
.chart-note { color: var(--muted); font-size: 0.85rem; margin: 10px 0 24px; max-width: 70ch; }

.note { color: var(--muted); font-size: 0.9rem; max-width: 70ch; }
.note a { color: var(--blue); }
.colguide { background: var(--surface); border-radius: 10px; margin: 8px 0 0; }
.colguide summary { cursor: pointer; padding: 14px 16px; font: 600 1.1rem var(--display); }
.colguide summary:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 10px; }
.colguide-body { padding: 0 16px 16px; font-size: 0.92rem; max-width: 75ch; }
.colguide-body p { margin: 0 0 12px; }
.colguide dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 12px; }
.colguide dt { font-weight: 700; font-variant-numeric: tabular-nums; }
.colguide dd { margin: 0; color: var(--muted); }
.colguide .tag { display: inline-block; font-size: 0.75rem; font-weight: 600; color: var(--blue); border: 1px solid var(--blue); border-radius: 999px; padding: 0 7px; margin-left: 4px; }
footer.site { color: var(--muted); font-size: 0.9rem; margin-top: 32px; }
footer.site a { color: var(--blue); }
.note h4 { font: 600 1.15rem var(--display); color: var(--ink); margin: 32px 0 4px; }
.msg { background: var(--surface); padding: 24px; border-radius: 10px; }
.msg.error { border-left: 6px solid var(--red); }
@media (prefers-reduced-motion: no-preference) { .bar i { transition: width .5s ease-out; } }

/* Scrollable tables: rank, movement arrow and team stay pinned on the left
   while the stats scroll sideways. */
th.rank, td.rank, th.mv, td.mv, th.team, td.team { position: sticky; z-index: 1; background: var(--surface); }
th.rank, td.rank { left: 0; width: 34px; min-width: 34px; max-width: 34px; }
th.mv, td.mv { left: 34px; width: 34px; min-width: 34px; max-width: 34px; }
th.team, td.team { left: 68px; }
th.rank, th.mv, th.team { z-index: 2; }
tr.is-fav td.rank, tr.is-fav td.mv, tr.is-fav td.team { background: var(--fav); }
.scroll.scrolled td.team, .scroll.scrolled th.team { box-shadow: 8px 0 8px -6px rgba(20, 30, 40, 0.28); }
tr.detail td .wk { position: sticky; left: 16px; max-width: min(640px, calc(100vw - 64px)); }
.narrow-only { display: none; }

@media (max-width: 820px) {
  .chev, .bar { display: none; }
  .wide-only { display: none; } .narrow-only { display: inline; }
  .odds { min-width: 0; }
  table { font-size: 0.88rem; }
  th, td { padding: 8px 5px; }
  th.mv, td.mv { font-size: 0.75rem; }
  td.team { min-width: 0; }
  td.team .full { display: none; }
  td.team .logo { width: 24px; height: 24px; } td.team .logo .abbr { font-size: 0.55rem; }
  td.team .tn { gap: 6px; }
  .wrap { padding: 0 10px 48px; }
}
@media (min-width: 821px) { td.team .short { display: none; } }
