:root {
  --ice: #f3f7fb;
  --ice-line: #dbe5ee;
  --blue: #1c5fb8;
  --red: #c8102e;
  --text: #0f1b2b;
  --muted: #5a6b7c;
  --card: #ffffff;
  --card-edge: #d7e0ea;
  --accent: #1c5fb8;
  --amber: #e0a100;
  --danger: #c8102e;
  --ok: #1e8a4c;
  --puck: #101418;
  --puck-text: #ffffff;
  --overlay: rgba(243, 247, 251, 0.94);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ice: #16212c; --ice-line: #233242; --blue: #4d8be0; --red: #e3384f;
    --text: #e8eef5; --muted: #9fb0c1; --card: #1f2c39; --card-edge: #324456;
    --accent: #6ea4f0; --amber: #ffc43d; --danger: #ff5c70; --ok: #4fcf84;
    --puck: #f3f7fb; --puck-text: #101418; --overlay: rgba(22, 33, 44, 0.94);
  }
}
:root[data-theme="dark"] {
  --ice: #16212c; --ice-line: #233242; --blue: #4d8be0; --red: #e3384f;
  --text: #e8eef5; --muted: #9fb0c1; --card: #1f2c39; --card-edge: #324456;
  --accent: #6ea4f0; --amber: #ffc43d; --danger: #ff5c70; --ok: #4fcf84;
  --puck: #f3f7fb; --puck-text: #101418; --overlay: rgba(22, 33, 44, 0.94);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; color: var(--text); background: var(--ice);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column; min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* The rink: blue lines at 35% / 65%, the red line and centre circle at 50%. */
.rink {
  flex: 1; position: relative; padding: 16px 16px 24px;
  background:
    radial-gradient(circle at 50% 50%, transparent 0 70px, var(--red) 70px 73px, transparent 73px),
    radial-gradient(circle at 50% 50%, var(--red) 0 4px, transparent 4px),
    linear-gradient(to bottom, transparent calc(50% - 2px), var(--red) calc(50% - 2px) calc(50% + 2px), transparent calc(50% + 2px)),
    linear-gradient(to bottom, transparent calc(35% - 4px), var(--blue) calc(35% - 4px) calc(35% + 4px), transparent calc(35% + 4px),
      transparent calc(65% - 4px), var(--blue) calc(65% - 4px) calc(65% + 4px), transparent calc(65% + 4px)),
    repeating-linear-gradient(90deg, transparent 0 39px, var(--ice-line) 39px 40px),
    var(--ice);
  background-attachment: scroll;
}
.rink::before { /* frost */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,.35), transparent 30%, transparent 70%, rgba(255,255,255,.25));
}
@media (prefers-color-scheme: dark) { .rink::before { background: none; } }
.screen { position: relative; max-width: 560px; margin: 0 auto; }
.rink { overflow-x: clip; }

/* Scoreboard */
.scoreboard {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  padding: 10px 16px; background: var(--puck); color: var(--puck-text);
  font-variant-numeric: tabular-nums;
}
.scoreboard .seat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.scoreboard .seat.right { text-align: right; }
.scoreboard .sname { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .55; }
.scoreboard .seat.on .sname { opacity: 1; }
.scoreboard .seat.on .sname::before { content: "● "; color: var(--ok); font-size: 10px; vertical-align: middle; }
.scoreboard .seat.right.on .sname::before { content: ""; }
.scoreboard .seat.right.on .sname::after { content: " ●"; color: var(--ok); font-size: 10px; vertical-align: middle; }
.scoreboard .slives { font-size: 12px; opacity: .8; letter-spacing: 2px; }
.scoreboard .center { text-align: center; }
.scoreboard .brand { display: block; font-weight: 800; letter-spacing: .5px; font-size: 13px; text-transform: uppercase; opacity: .8; }
.scoreboard .chain { display: block; font-weight: 800; font-size: 22px; line-height: 1; }

/* Home */
.title { font-size: 44px; font-weight: 900; letter-spacing: -1px; margin: 24px 0 6px; text-align: center; }
.title span { color: var(--red); }
.tag { text-align: center; color: var(--muted); margin: 0 0 20px; }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.setup .rules p { margin: 0; color: var(--muted); font-size: 13px; }
.mode {
  background: var(--card); border: 2px solid var(--card-edge); border-radius: 14px; padding: 14px 12px;
  text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 3px;
}
.mode strong { font-size: 18px; }
.mode small { color: var(--muted); }
.mode.on { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.setup { background: var(--card); border: 1px solid var(--card-edge); border-radius: 14px; padding: 14px; display: grid; gap: 12px; }
.setup label { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-bottom: 4px; }
.setup .row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.setup input[type=text], .setup select, .setup textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--card-edge); border-radius: 10px; background: var(--ice);
}
.setup textarea { resize: vertical; }
.seg { display: flex; gap: 4px; flex-wrap: wrap; }
.seg button { flex: 1; padding: 8px 6px; border: 1px solid var(--card-edge); border-radius: 10px; background: var(--ice); cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.go {
  padding: 14px; border: 0; border-radius: 12px; background: var(--red); color: #fff;
  font-weight: 800; font-size: 18px; cursor: pointer; width: 100%;
}
.go:disabled { opacity: .5; cursor: default; }
.board { text-align: center; color: var(--muted); font-size: 13px; margin: 14px 0 0; }
.board strong { color: var(--text); }
.foot { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-top: 16px; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 4px 6px; text-decoration: underline; }

/* Game */
.play { min-height: 190px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 8px 0; }
.name-card {
  background: var(--card); border: 1px solid var(--card-edge); border-radius: 16px; padding: 14px 22px;
  text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.12); max-width: 100%;
}
.name-card .nm { font-size: 30px; font-weight: 800; letter-spacing: -.5px; line-height: 1.1; }
.name-card .nm .hl { color: var(--red); font-size: 1.35em; font-weight: 900; }
.name-card .bio { color: var(--muted); font-size: 13px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.name-card.enter { animation: pass-in .5s cubic-bezier(.2,.9,.3,1.1) both; }
@keyframes pass-in { from { transform: translateX(-60vw) rotate(-4deg); opacity: 0; } to { transform: none; opacity: 1; } }

.thinking { display: flex; gap: 6px; }
.thinking span { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.thinking span:nth-child(2) { animation-delay: .2s; } .thinking span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.callout {
  /* Above the puck and the name card on every layout: fixed, centred, own backing. */
  position: fixed; left: 50%; top: 42vh; transform: translate(-50%, -50%); z-index: 6;
  padding: 10px 28px; border-radius: 18px; background: var(--overlay);
  box-shadow: 0 10px 40px rgba(0,0,0,.25); text-align: center; pointer-events: none; white-space: nowrap;
  font-size: 48px; font-weight: 900; letter-spacing: -1px; text-transform: uppercase; color: var(--red);
  animation: shout .9s ease-out both;
}
.callout.ok { color: var(--ok); }
.callout .why { display: block; font-size: 14px; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--text); }
@keyframes shout {
  0% { transform: translate(-50%, -50%) scale(.4); opacity: 0; }
  25% { transform: translate(-50%, -50%) scale(1.08); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
@media (max-width: 420px) { .callout { font-size: 36px; white-space: normal; max-width: 90vw; } }

.puck-row { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 6px 0 14px; }
.puck { position: relative; width: 132px; height: 132px; }
.puck svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.puck .ring-bg { fill: var(--puck); stroke: var(--card-edge); stroke-width: 6; }
.puck .ring { fill: none; stroke: var(--ok); stroke-width: 6; stroke-linecap: round;
  stroke-dasharray: 282.7; stroke-dashoffset: 0; transition: stroke .3s; }
.puck.warn .ring { stroke: var(--amber); } .puck.danger .ring { stroke: var(--danger); }
.puck .letter { position: absolute; inset: 0; display: grid; place-items: center; color: var(--puck-text);
  font-size: 56px; font-weight: 900; line-height: 1; padding-bottom: 10px; }
.puck .letter.free { font-size: 20px; letter-spacing: 1px; }
.puck .letter.pop { animation: pop .4s ease-out; }
@keyframes pop { 0% { transform: scale(.5); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }
.puck .secs { position: absolute; left: 0; right: 0; bottom: 24px; text-align: center; color: var(--puck-text);
  font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; opacity: .85; }
.hint { font-size: 13px; color: var(--muted); min-height: 18px; }

.answer { display: flex; gap: 8px; }
.answer input { flex: 1; padding: 14px; font-size: 18px; border: 2px solid var(--card-edge); border-radius: 12px; background: var(--card); }
.answer input:focus { outline: none; border-color: var(--accent); }
.answer button { padding: 0 20px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 800; cursor: pointer; }
.answer input:disabled, .answer button:disabled { opacity: .5; }
.answer.shake { animation: shake .4s; }
@keyframes shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }

.overlay { position: fixed; inset: 0; background: var(--overlay); display: grid; place-items: center; z-index: 5; }
.overlay .box { text-align: center; padding: 24px; max-width: 360px; width: 100%; display: grid; gap: 8px; }
.pass-to { color: var(--muted); text-transform: uppercase; letter-spacing: 1px; font-size: 13px; }
.pass-name { font-size: 40px; font-weight: 900; }
.pass-letter { color: var(--muted); margin-bottom: 8px; }
.pass-letter b { color: var(--red); font-size: 22px; }

/* Team mode: the two lineup cards (yours left, theirs right). */
.lineups { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin-bottom: 4px; }
.lineup { background: var(--card); border: 1px solid var(--card-edge); border-radius: 12px; padding: 6px; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.lineup .lhead { display: flex; justify-content: space-between; gap: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.lineup .lhead span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.lineup .lhead span:last-child { flex: 0 0 auto; }
.lineup .lrow { display: flex; gap: 4px; justify-content: center; }
.chip {
  flex: 1 1 0; min-width: 0; max-width: 34%; border: 1px dashed var(--card-edge); border-radius: 8px; padding: 3px 4px;
  text-align: center; line-height: 1.15; background: var(--ice);
}
.chip .cs { display: block; font-size: 9px; font-weight: 700; letter-spacing: .5px; color: var(--muted); }
.chip .cn { display: block; font-size: 11px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .co { display: block; font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.filled { border-style: solid; border-color: var(--accent); background: var(--card); }
/* A chip in its player's team colours (inline style): the slot and the
   rating take the text colour, a shade lighter. */
.chip.filled.team { border-width: 2px; }
.chip.filled.team .cs, .chip.filled.team .co { color: inherit; opacity: .78; }
.lineups.dim .chip.team { opacity: .55; }
.chip.empty .cn { color: var(--muted); font-weight: 400; }
.chip.callup { border-style: dotted; opacity: .7; }
.chip.bench { max-width: none; flex: 0 0 auto; padding: 3px 8px; border-style: dotted; }
.chip.lit { animation: chip-lit 1.1s ease-out; }
@keyframes chip-lit { 0% { background: var(--ok); color: #fff; transform: scale(1.06); } 100% { transform: none; } }
.lineups.final .lineup { padding: 8px; }
.name-card .slot-line { margin-top: 6px; font-size: 14px; font-weight: 700; color: var(--accent); }
.name-card .slot-line small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.team .play { min-height: 150px; }
.series { background: var(--card); border: 1px solid var(--card-edge); border-radius: 14px; padding: 10px 14px; margin: 10px 0 14px; font-variant-numeric: tabular-nums; }
.series h3 { margin: 0 0 6px; font-size: 18px; }
.series ul { margin: 0; padding: 0; list-style: none; }
.series li { padding: 3px 0; }
.series .muted { color: var(--muted); font-size: 13px; }
@media (max-width: 420px) { .mode { padding: 10px 8px; } .mode strong { font-size: 16px; } .mode small { font-size: 11px; } }

/* Team mode: the series playback */
.sboard { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; background: var(--puck); color: var(--puck-text);
  border-radius: 14px; padding: 10px 12px; margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.sside { display: flex; flex-direction: column; min-width: 0; }
.sside.s1 { text-align: right; }
.sside .sn { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sside .sscore { font-size: 40px; font-weight: 900; line-height: 1; }
.sside .sshots { font-size: 11px; opacity: .75; }
.sside.s0 .sn { border-bottom: 3px solid var(--blue); } .sside.s1 .sn { border-bottom: 3px solid var(--red); }
.sside .sn, .sside.s1 .sn { padding-bottom: 2px; margin-bottom: 2px; }
.sside.scored .sscore { animation: pop .5s ease-out; }
.smid { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.smid .sgame { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; opacity: .75; }
.smid .sclock { font-size: 26px; font-weight: 800; line-height: 1; min-height: 26px; }
.smid .speriod { font-size: 12px; font-weight: 700; }
.smid .sdots { font-size: 12px; letter-spacing: 3px; }
.sdots .d0 { color: var(--blue); } .sdots .d1 { color: var(--red); }
.lineups.dim .chip { opacity: .6; }
.lineups.dim .chip.lit { opacity: 1; }
/* The event line sits over centre ice, where the circle and the red line
   ran through the words (user, 2026-10-07): it gets its own sheet of plain
   ice — frosted, so the rink still shows at the edges — and a bigger,
   bolder, glowing line. */
.ice {
  min-height: 96px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 12px 14px; margin: 4px 0 8px; text-align: center;
  background: var(--overlay); border: 1px solid var(--card-edge); border-radius: 16px;
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.ice.shake { animation: shake .4s; }
.event-line {
  font-size: 24px; font-weight: 800; line-height: 1.2; letter-spacing: -.2px;
  text-shadow: 0 0 10px var(--ice), 0 0 18px var(--ice), 0 1px 0 var(--card);
}
.event-line b { font-weight: 900; text-shadow: 0 0 10px var(--ice), 0 0 2px currentColor; }
@media (max-width: 420px) { .event-line { font-size: 21px; } }
.event-line b.s0 { color: var(--blue); } .event-line b.s1 { color: var(--red); }
.event-line.enter { animation: pass-in .35s cubic-bezier(.2,.9,.3,1.1) both; }
.event-detail { font-size: 13px; color: var(--muted); min-height: 18px; }
#s-callout { top: 46vh; }
.callout.s0 { color: var(--blue); } .callout.s1 { color: var(--red); } .callout.neutral { color: var(--text); }
.ticker { list-style: none; margin: 0 0 10px; padding: 6px 10px; background: var(--card); border: 1px solid var(--card-edge); border-radius: 12px; min-height: 120px; font-size: 12.5px; }
.ticker li { padding: 2px 0; display: flex; gap: 8px; color: var(--muted); }
.ticker li:first-child { color: var(--text); }
.ticker .tc { flex: 0 0 auto; font-variant-numeric: tabular-nums; opacity: .7; min-width: 44px; }
.ticker li.big { font-weight: 700; }
.controls { display: flex; gap: 8px; }
.controls button { flex: 1; padding: 12px; border: 1px solid var(--card-edge); border-radius: 12px; background: var(--card); font-weight: 800; cursor: pointer; }
.controls button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.series .stars { margin: 8px 0 0; padding: 0; list-style: none; }
/* First star one star, second two, third three (user, 2026-10-07). */
.series .stars li::before { content: "★ "; color: var(--amber); }
.series .stars li:nth-child(2)::before { content: "★★ "; }
.series .stars li:nth-child(3)::before { content: "★★★ "; }

/* Post-game */
.result { font-size: 34px; font-weight: 900; text-align: center; margin: 24px 0 4px; }
.sub { text-align: center; color: var(--muted); margin: 0 0 16px; }
.chain-list { background: var(--card); border: 1px solid var(--card-edge); border-radius: 14px; padding: 8px 8px 8px 36px; margin: 0 0 14px; max-height: 50vh; overflow: auto; }
.chain-list li { padding: 6px 4px; border-bottom: 1px solid var(--card-edge); display: flex; justify-content: space-between; gap: 8px; font-variant-numeric: tabular-nums; }
.chain-list li:last-child { border-bottom: 0; }
.chain-list .who { color: var(--muted); font-size: 12px; }
.chain-list .t { color: var(--muted); font-size: 13px; white-space: nowrap; }
.chain-list li.fault { color: var(--danger); }
.actions { display: grid; gap: 8px; justify-items: center; }

@media (prefers-reduced-motion: reduce) {
  .name-card.enter, .callout, .puck .letter.pop, .answer.shake, .thinking span, .chip.lit,
  .event-line.enter, .ice.shake, .sside.scored .sscore { animation: none; }
}
