/* The app's look. Colours and sizes are set once here as "tokens" and
   reused everywhere, so changing --blue changes every blue thing. */

@font-face {
  font-family: 'Score';
  src: url('/fonts/barlow-condensed-latin-700-normal.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Score';
  src: url('/fonts/barlow-condensed-latin-600-normal.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}

:root {
  --navy: #0b1f3a;
  --navy-2: #16305a;
  --blue: #1e6fd9;
  --blue-soft: #e8f1fd;
  --bg: #eef1f5;
  --card: #ffffff;
  --text: #14202e;
  --muted: #5b6b7d;
  --faint: #8a98a8;
  --line: #e3e8ee;
  --live: #e0262e;
  --win: #1a7f37;
  --notice-bg: #fff4c2;
  --notice-line: #e9c200;
  --home-row: #eef5ff;
  --radius: 14px;
  --score-font: 'Score', 'Arial Narrow', 'Helvetica Neue Condensed', sans-serif;
  --tabbar-h: 62px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--blue); text-decoration: none; }
button { font: inherit; color: inherit; }
h2, h3 { margin: 0; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--navy); color: #fff;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  display: flex; align-items: center; gap: 8px; min-height: 54px;
}
.topbar h1 { margin: 0; font-size: 19px; font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .back {
  border: 0; background: none; color: #fff; padding: 6px 8px 6px 0; margin-left: -4px;
  display: flex; align-items: center; cursor: pointer; min-height: 44px;
}
.topbar .back[hidden] { display: none; }
.topbar .bell { position: relative; color: #fff; display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; margin-right: -8px; }
.topbar .bell[hidden] { display: none; }
.topbar .badge { position: absolute; top: 4px; right: 3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--live); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.topbar .badge[hidden] { display: none; }
.alert-item { display: block; padding: 14px 16px; border-top: 1px solid var(--line); color: inherit; }
.alert-item:first-child { border-top: 0; }
.alert-item.unread { background: var(--home-row); }
.alert-item strong { display: block; }
.alert-item .when { font-size: 12px; color: var(--muted); margin-top: 4px; }
.code-input { font-family: var(--score-font); font-size: 32px; letter-spacing: .3em; text-align: center; }
.devnote { background: var(--notice-bg); border: 1px solid var(--notice-line); border-radius: 10px; padding: 10px 12px; font-size: 14px; color: #4a3a00; }
.topbar .updated { font-size: 12px; color: #a9bad3; white-space: nowrap; }

/* ---------- Page ---------- */
main { max-width: 600px; margin: 0 auto; padding: 12px 12px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(15, 30, 50, .06); margin-bottom: 12px; overflow: hidden; }
.card-pad { padding: 14px 16px; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 4px 8px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 14px; }
.tiny { font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 28px 16px; }
.loading { text-align: center; color: var(--muted); padding: 40px 16px; }
.error { color: #b42318; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; font-weight: 600; cursor: pointer; text-decoration: none; color: var(--text);
}
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-block { width: 100%; }
.btn-ghost { background: none; border-color: transparent; color: var(--blue); }
.btn:disabled { opacity: .5; cursor: default; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Bottom tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: #fff; border-top: 1px solid var(--line);
  display: flex; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; max-width: 150px; height: var(--tabbar-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--faint); font-size: 11px; font-weight: 600;
}
.tabbar a.on { color: var(--blue); }
.tabbar svg { width: 24px; height: 24px; }
body.no-tabbar .tabbar { display: none; }
body.no-tabbar main { padding-bottom: 24px; }

/* ---------- Chips and segmented tabs ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -12px; padding-left: 12px; padding-right: 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; color: var(--text);
}
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
/* Home's "All" tab stays pinned at the left edge while the team tabs scroll under it. */
.chips .chip[data-tab="all"] { position: sticky; left: 0; z-index: 1; box-shadow: -14px 0 0 2px var(--bg), 10px 0 8px -4px var(--bg); }
.tabs { display: flex; border-bottom: 1px solid var(--line); background: #fff; }
.tabs button {
  flex: 1; min-height: 46px; border: 0; background: none; font-weight: 600; font-size: 15px; color: var(--muted);
  border-bottom: 3px solid transparent; cursor: pointer;
}
.tabs button.on { color: var(--blue); border-bottom-color: var(--blue); }

/* ---------- Date navigator ---------- */
.datenav { display: flex; align-items: center; justify-content: space-between; margin: 2px 0 10px; }
.datenav button {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: #fff;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.datenav button:disabled { opacity: .35; cursor: default; }
.datenav .label { text-align: center; }
.datenav .label strong { display: block; font-size: 17px; }
.datenav .label span { font-size: 13px; color: var(--muted); }

/* ---------- Team crest ---------- */
.crest {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; color: #fff; font-weight: 700; font-family: var(--score-font);
  letter-spacing: .02em; overflow: hidden; background: var(--navy-2);
}
.crest img { width: 100%; height: 100%; object-fit: contain; background: #fff; }

/* ---------- Score card ---------- */
.scorecard { display: flex; align-items: stretch; padding: 12px 14px; color: inherit; border-top: 1px solid var(--line); }
.scorecard:first-child { border-top: 0; }
.scorecard .teams { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.scorecard .team { display: flex; align-items: center; gap: 10px; min-width: 0; }
.scorecard .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 16px; }
.scorecard .team.mine .name { font-weight: 700; }
.scorecard .team.lost .name { color: var(--muted); }
.scorecard .score { font-family: var(--score-font); font-weight: 700; font-size: 26px; line-height: 1; min-width: 26px; text-align: right; }
.scorecard .team.lost .score { color: var(--faint); }
.scorecard .status {
  width: 86px; flex: none; margin-left: 12px; padding-left: 12px; border-left: 1px solid var(--line);
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 2px; font-size: 13px;
}
.scorecard .status strong { font-size: 14px; }
.scorecard .status .rink { color: var(--muted); font-size: 12px; line-height: 1.25; }
.live-dot { display: inline-flex; align-items: center; gap: 6px; color: var(--live); font-weight: 700; font-size: 13px; }
.live-dot::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--live);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .live-dot::before { animation: none; } }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 5px; background: var(--bg); color: var(--muted); }
.tag-warn { background: var(--notice-bg); color: #6b5300; }

/* ---------- Notice banner ---------- */
.notice {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--notice-bg); border: 1px solid var(--notice-line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 12px; color: #4a3a00; font-size: 15px;
}
.notice strong { display: block; }
.notice svg { flex: none; margin-top: 2px; }

/* ---------- Team summary card (Home, single team) ---------- */
.teamcard { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.teamcard .info { flex: 1; min-width: 0; }
.teamcard .info strong { display: block; font-size: 17px; }

/* ---------- Game page header ---------- */
.gamehead { text-align: center; padding: 16px 12px 14px; background: var(--navy); color: #fff; }
.gamehead .when { font-size: 13px; color: #b7c6dc; }
.gamehead .matchup { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin: 14px 0 6px; }
.gamehead .side { display: flex; flex-direction: column; align-items: center; gap: 8px; color: #fff; font-weight: 600; font-size: 14px; line-height: 1.2; }
.gamehead .side small { color: #9fb2cd; font-weight: 500; font-size: 12px; }
.gamehead .bigscore { font-family: var(--score-font); font-weight: 700; font-size: 54px; line-height: 1; letter-spacing: .02em; }
.gamehead .bigscore.time { font-size: 30px; }
.gamehead .state { margin-top: 6px; font-size: 14px; font-weight: 600; color: #d4deec; }
.gamehead .live-dot { color: #ff6b6b; font-size: 14px; }
.gamehead .live-dot::before { background: #ff6b6b; }

/* ---------- Tables ---------- */
table.stats { width: 100%; border-collapse: collapse; font-size: 15px; }
table.stats th { font-size: 12px; color: var(--muted); font-weight: 600; text-align: right; padding: 8px 8px; border-bottom: 1px solid var(--line); }
table.stats td { padding: 10px 8px; text-align: right; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.stats tr:last-child td { border-bottom: 0; }
table.stats .l { text-align: left; }
table.stats td.l { max-width: 0; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.stats tr.home td { background: var(--home-row); }
table.stats tr.home td.l { font-weight: 700; }
table.stats .num { font-family: var(--score-font); font-weight: 700; font-size: 18px; }
table.stats .strong { font-weight: 700; }
.table-scroll { overflow-x: auto; }

/* ---------- Lists (rows) ---------- */
.rows > * { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); color: inherit; min-height: 52px; }
.rows > *:first-child { border-top: 0; }
.rows .grow { flex: 1; min-width: 0; }
.rows .jersey { width: 34px; flex: none; font-family: var(--score-font); font-weight: 700; font-size: 20px; color: var(--muted); text-align: center; }
.chev { color: var(--faint); flex: none; }

/* ---------- Scoring summary / timeline ---------- */
.period-head { padding: 10px 16px; font-size: 13px; font-weight: 700; color: var(--muted); background: #f7f9fb; border-top: 1px solid var(--line); }
.period-head:first-child { border-top: 0; }
.event { display: flex; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); align-items: flex-start; }
.event .time { width: 48px; flex: none; font-family: var(--score-font); font-weight: 600; font-size: 18px; color: var(--muted); }
.event .what { flex: 1; min-width: 0; }
.event .what .assists { font-size: 14px; color: var(--muted); }
.event .runscore { font-family: var(--score-font); font-weight: 700; font-size: 20px; flex: none; }
.event.penalty .what { color: var(--muted); }
.event.away { flex-direction: row; }
.ev-icon { width: 22px; height: 22px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; margin-top: 1px; }
.ev-goal { background: var(--blue); color: #fff; }
.ev-pen { background: var(--bg); color: var(--muted); }

/* ---------- Stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; }
.tiles > div { padding: 14px 4px; border-left: 1px solid var(--line); }
.tiles > div:first-child { border-left: 0; }
.tiles strong { display: block; font-family: var(--score-font); font-size: 30px; line-height: 1.1; }
.tiles span { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---------- Leaderboards ---------- */
.board h3 { font-size: 15px; padding: 12px 16px 4px; }

/* ---------- Forms: checks, switches, search ---------- */
.check {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line);
  cursor: pointer; min-height: 52px;
}
.check:first-child { border-top: 0; }
.check input { width: 22px; height: 22px; accent-color: var(--blue); flex: none; }
.check .grow { flex: 1; min-width: 0; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: #cfd6df; transition: background .15s; pointer-events: none; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked + span { background: var(--blue); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }
.search { width: 100%; min-height: 46px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; font: inherit; font-size: 16px; background: #fff; }
.alert-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 0 16px 14px; }
.alert-grid label { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- Welcome / setup ---------- */
.welcome { min-height: calc(100vh - 120px); display: flex; flex-direction: column; }
.welcome .hero { text-align: center; padding: 40px 12px 24px; }
.welcome .hero .logo { width: 84px; height: 84px; margin: 0 auto 18px; border-radius: 22px; background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: center; }
.welcome .hero h2 { font-size: 26px; margin-bottom: 8px; }
.welcome .steps { display: flex; gap: 6px; justify-content: center; margin: 6px 0 16px; }
.welcome .steps i { width: 26px; height: 5px; border-radius: 3px; background: #cfd6df; }
.welcome .steps i.on { background: var(--blue); }
.welcome .step-title { font-size: 22px; margin: 0 4px 4px; }
.welcome .step-sub { margin: 0 4px 14px; color: var(--muted); }
.welcome .footer { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); display: flex; gap: 10px; margin-top: auto; }
.welcome .footer .btn { flex: 1; }

@media (min-width: 640px) {
  main { padding-left: 16px; padding-right: 16px; }
}

/* Box score on the game page */
table.boxscore .bs-num { display: inline-block; width: 28px; color: var(--muted); font-family: var(--score-font); font-weight: 700; }
table.boxscore tr.quiet td.l { color: var(--muted); }
.bs-team { display: flex; align-items: center; gap: 10px; padding: 12px 12px 4px; }
