:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f1f4f8;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #64748b;
  --line: #e5e9f0;
  --accent: #1d4ed8;
  --accent-soft: #eef3ff;
  --accent-line: #c7d6fe;
  --live: #d97706;
  --live-soft: #fff7e8;
  --rink-a: #4f46e5;
  --rink-b: #0d9488;
  --rink-x: #64748b;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f14;
    --surface: #141a22;
    --surface-2: #1b2330;
    --text: #eef2f7;
    --text-2: #c2ccd8;
    --muted: #8b98a8;
    --line: #232d3a;
    --accent: #6d9bff;
    --accent-soft: #16233d;
    --accent-line: #2a4274;
    --live: #f5a524;
    --live-soft: #2a2012;
    --rink-a: #8b86ff;
    --rink-b: #2dd4bf;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
button, select { font: inherit; color: inherit; }

/* ---------- App bar ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.appbar-inner {
  max-width: 680px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  width: 38px; height: 38px; flex: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #1e3a8a);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 800; font-size: 15px; letter-spacing: -.02em;
}
.brand h1 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
.brand .sub { margin: 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand > div:last-child { min-width: 0; }

.picker { display: flex; flex-direction: column; align-items: flex-end; min-width: 0; }
.picker-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.picker select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  border-radius: 10px;
  padding: 6px 30px 6px 12px;
  font-size: 15px;
  font-weight: 600;
  max-width: 44vw;
  text-overflow: ellipsis;
}

/* ---------- Layout ---------- */
main { max-width: 680px; margin: 0 auto; padding: 16px 16px 8px; }
.status { color: var(--muted); text-align: center; padding: 40px 0; }
.status.error { color: #dc2626; }

.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 28px 4px 10px;
}
.section-title h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.015em; }
.section-title span { font-size: 14px; color: var(--muted); }

/* ---------- Next-game hero ---------- */
.hero {
  background: linear-gradient(140deg, #1e40af 0%, #1d4ed8 55%, #3b82f6 100%);
  color: #fff;
  border-radius: 20px;
  padding: 18px 20px;
  box-shadow: 0 10px 30px rgba(29, 78, 216, .25);
}
.hero-top { display: flex; justify-content: space-between; align-items: center; }
.eyebrow { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; opacity: .85; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 700;
  padding: 4px 10px; border-radius: 999px;
}
.hero .pill { background: rgba(255, 255, 255, .18); color: #fff; }
.hero-date { font-size: 28px; font-weight: 800; letter-spacing: -.025em; margin: 8px 0 2px; line-height: 1.15; }
.hero-meta { font-size: 17px; opacity: .95; }
.hero-foot {
  display: flex; justify-content: space-between; gap: 12px;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, .2);
  font-size: 15px;
}
.hero-foot b { font-weight: 700; }
.hero a { color: #fff; }

#mine + #tonight { margin-top: 16px; }

/* ---------- Day cards ---------- */
.day {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  overflow: hidden;
}
.day-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.cal {
  width: 44px; flex: none; text-align: center;
  border-radius: 10px; background: var(--surface-2);
  padding: 4px 0 5px; line-height: 1.05;
}
.cal small { display: block; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.cal b { font-size: 19px; font-weight: 800; }
.day-name { font-weight: 700; font-size: 17px; }
.day-rel { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--muted); }

.day.live { border-color: var(--live); box-shadow: 0 0 0 3px color-mix(in srgb, var(--live) 18%, transparent), var(--shadow); }
.day.live .day-head { background: var(--live-soft); }
.day.live .cal { background: var(--live); }
.day.live .cal small, .day.live .cal b { color: #fff; }
.live-badge { margin-left: auto; background: var(--live); color: #fff; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- Game rows ---------- */
.game {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 4px 12px;
  padding: 14px 16px;
  position: relative;
}
.game + .game { border-top: 1px solid var(--line); }
.game.mine { background: var(--accent-soft); }
.game.mine::before {
  content: ""; position: absolute; left: 0; top: 10px; bottom: 10px;
  width: 4px; border-radius: 0 4px 4px 0; background: var(--accent);
}
.game.done { opacity: .5; }

.time { font-variant-numeric: tabular-nums; line-height: 1.1; padding-top: 2px; }
.time b { display: block; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.time small { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }

.rink { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rink-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--rink-x); flex: none; }
.rink-holiday .rink-dot { background: var(--rink-a); }
.rink-depew .rink-dot { background: var(--rink-b); }
.rink-name { font-weight: 700; font-size: 17px; flex: 1; min-width: 0; line-height: 1.25; }
.dir {
  flex: none; margin-left: auto;
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--accent);
  text-decoration: none;
}
.dir svg { width: 18px; height: 18px; }
.refs { grid-column: 2; display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.ref { display: flex; align-items: center; gap: 10px; font-size: 16px; color: var(--text-2); }
.avatar {
  width: 28px; height: 28px; flex: none; border-radius: 50%;
  background: var(--surface-2); color: var(--text-2);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
}
.ref.me { color: var(--text); font-weight: 700; }
.ref.me .avatar { background: var(--accent); color: #fff; }
.you { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--accent); color: #fff; text-transform: uppercase; letter-spacing: .04em; }
.tbd { color: var(--muted); font-style: italic; }

/* ---------- Empty tonight ---------- */
.quiet {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.quiet-icon {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  background: var(--surface-2); display: grid; place-items: center; font-size: 20px;
}
.quiet b { display: block; font-size: 16px; }
.quiet span { font-size: 14px; color: var(--muted); }

/* ---------- Segmented filter ---------- */
.segmented {
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--surface-2);
  border-radius: 12px; padding: 4px;
  margin: 24px 0 0;
}
.segmented button {
  border: 0; background: transparent;
  padding: 9px 0; border-radius: 9px;
  font-size: 15px; font-weight: 600; color: var(--muted);
  cursor: pointer;
}
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.empty { color: var(--muted); text-align: center; padding: 20px 0; }

/* ---------- Past ---------- */
details.past { margin-top: 20px; }
details.past summary {
  list-style: none; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  font-weight: 600; color: var(--text-2);
}
details.past summary::-webkit-details-marker { display: none; }
details.past summary::after { content: "Show"; font-size: 14px; color: var(--accent); }
details.past[open] summary::after { content: "Hide"; }
details.past[open] summary { margin-bottom: 12px; }

/* ---------- Footer ---------- */
.foot {
  max-width: 680px; margin: 0 auto;
  display: flex; justify-content: center; align-items: center; gap: 12px;
  color: var(--muted); font-size: 13px;
  padding: 20px 16px calc(28px + env(safe-area-inset-bottom));
}
.foot p { margin: 0; }
.foot .warn { color: var(--live); font-weight: 600; }
.foot button {
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.game.mine .dir, .game.mine .ref:not(.me) .avatar { background: var(--surface); }
