/* Slapshot Math: dark arena look from the mockups. Global styles: the SVG art is injected as markup, so it can't
   use scoped component CSS. */

:root {
    --gold: #F5B400;
    --gold-light: #fff2b0;
    --ink: #0b1220;
    --panel: #141c2e;
    --panel-2: #1c2740;
    --line: #34405c;
    --muted: #9aa6bf;
    --soft: #b8c3da;
    --text: #dfe6f5;
    --red: #ff4d4d;
    --green: #3ddc84;
    --score: #ff5a3c;
    --font: "Segoe UI", "DejaVu Sans", "Liberation Sans", system-ui, sans-serif;
    --mono: "Cascadia Mono", "DejaVu Sans Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: #05080f;
    color: #fff;
    font-family: var(--font);
    overflow: hidden;
}

button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--gold-light); outline-offset: 2px; }

/* ---------- boot / app shell ---------- */

.boot {
    position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 12px; color: var(--muted); background: radial-gradient(ellipse at 50% 0%, #22304f 0%, var(--ink) 70%);
}
body:has(.slapshot) .boot { display: none; }

.slapshot {
    position: fixed; inset: 0; display: flex; flex-direction: column;
    background: radial-gradient(ellipse at 50% 0%, #22304f 0%, var(--ink) 70%);
}

.loading { flex: 1; display: grid; place-items: center; color: var(--muted); }

/* ---------- header / scoreboard ---------- */

.hdr {
    flex: 0 0 70px; display: flex; align-items: center; gap: 18px; padding: 0 22px;
    background: linear-gradient(#000, #121a2b); border-bottom: 3px solid var(--gold); z-index: 5;
}
.logo { font-weight: 900; font-size: 28px; letter-spacing: 1px; font-style: italic; white-space: nowrap; }
.logo span { color: var(--gold); }
.stat { background: #000; border: 2px solid #333; border-radius: 8px; padding: 4px 12px; text-align: center; min-width: 86px; }
.stat .k, .streak .k { font-size: 11px; color: var(--muted); letter-spacing: 2px; }
.stat .v { font-size: 24px; font-weight: 900; color: var(--score); font-family: var(--mono); }
.spacer { flex: 1; }
.streak { display: flex; gap: 8px; align-items: center; }
.streak .k { margin-right: 4px; }
.pk { width: 26px; height: 14px; border-radius: 50%; background: #2a3348; border: 2px solid #3b4661; transition: all .25s; }
.pk.on { background: #000; border-color: var(--gold); box-shadow: 0 0 10px var(--gold); }
.gear {
    width: 44px; height: 44px; border-radius: 50%; background: var(--panel-2); color: var(--text);
    display: flex; align-items: center; justify-content: center; border: 2px solid var(--line);
}
.gear:hover:not(:disabled) { border-color: var(--gold); }
.gear:disabled { opacity: .4; }

/* ---------- buttons, cards ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; border-radius: 14px; font-weight: 900;
    background: var(--panel-2); border: 3px solid var(--line); color: var(--text); padding: 0 18px; min-height: 46px;
    transition: transform .08s, background .15s;
}
.btn:hover:not(:disabled) { border-color: #5a6888; }
.btn:active:not(:disabled) { transform: scale(.96); }
.btn.sel { background: var(--gold); border-color: var(--gold-light); color: #000; box-shadow: 0 0 18px rgba(245, 180, 0, .55); }
.btn:disabled { opacity: .45; box-shadow: none; }
.btn.danger { background: #5a1a1a; border-color: #a33; color: #fff; }
.link { background: none; border: 0; padding: 0; color: var(--gold); font-weight: 700; text-decoration: underline; }

.card { background: rgba(20, 28, 46, .92); border: 2px solid #27324d; border-radius: 18px; padding: 18px 22px; margin-top: 14px; }
.h2 { font-size: 15px; letter-spacing: 3px; color: var(--muted); font-weight: 700; margin: 0 0 12px; }
.h2 .count { color: var(--soft); margin-left: 10px; }
.h2 .count.ok { color: var(--gold); }
.h2 .hint { color: var(--muted); margin-left: 10px; letter-spacing: 1px; font-weight: 400; }
.h2 .warn { color: var(--red); margin-left: 10px; letter-spacing: 1px; }
.muted { color: var(--soft); }
.gold { color: var(--gold); }

.num-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.num-grid .btn { height: 66px; font-size: 30px; }
.num-grid.compact { gap: 10px; }
.num-grid.compact .btn { height: 54px; font-size: 24px; }

.op-row { display: flex; gap: 14px; }
.op-row .btn { flex: 1; height: 88px; flex-direction: column; }
.op-row .sym { font-size: 44px; line-height: 44px; }
.op-row .word { font-size: 13px; letter-spacing: 2px; margin-top: 4px; }
.op-row.compact { gap: 10px; }
.op-row.compact .btn { height: 60px; }
.op-row.compact .sym { font-size: 36px; }

/* ---------- setup screen ---------- */

.setup { position: relative; flex: 1; overflow: auto; display: flex; gap: 20px; padding: 22px 40px; }
.setup-bg { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .16; pointer-events: none; }
.setup-main { position: relative; flex: 1; max-width: 820px; }
.setup-title { font-size: 44px; font-weight: 900; font-style: italic; margin: 0; }
.setup-title span { color: var(--gold); }
.setup-sub { color: var(--text); font-size: 18px; margin: 6px 0 6px; text-shadow: 0 2px 4px #000; }
.samples { margin-top: 14px; color: var(--soft); font-size: 15px; display: flex; gap: 8px; flex-wrap: wrap; }
.samples b { color: #fff; font-family: var(--mono); }
.faceoff-row { display: flex; align-items: center; gap: 20px; margin-top: 20px; flex-wrap: wrap; }
.faceoff { height: 76px; padding: 0 44px; font-size: 30px; font-style: italic; }
.faceoff-note { color: var(--soft); font-size: 16px; }
.setup-hero { position: relative; flex: 0 0 380px; height: auto; max-height: 100%; align-self: center; }
.hero-caption { font-size: 20px; font-weight: 900; fill: var(--gold); letter-spacing: 3px; }

/* ---------- SVG text ---------- */

.jersey-number, .crest-banner, .board-ad { font-family: "Arial Black", "DejaVu Sans", sans-serif; font-weight: 900; }
.crest-w { font-family: Georgia, "DejaVu Serif", serif; font-weight: 900; }
.timer-text { font-size: 28px; font-weight: 900; fill: #fff; font-family: var(--mono); }

/* ---------- game screen ---------- */

.game { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.scene { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.rink, .clip { position: absolute; inset: 0; width: 100%; height: 100%; }
.clip { object-fit: cover; background: #000; }

.goal-light { fill: #5a1a1a; }
.goal-light.on { fill: #ff3b3b; animation: blink .35s steps(2) infinite; }
.goal-glow { animation: glow .7s ease-in-out infinite alternate; }
@keyframes blink { 50% { fill: #5a1a1a; } }
@keyframes glow { from { opacity: .45; } to { opacity: 1; } }

.player-wrap, .goalie-wrap { transition: opacity .1s; }
.crowd { transition: filter .4s; }

.puck-flight {
    transform: translate(var(--x0), var(--y0));
    animation: puck-fly var(--dur) cubic-bezier(.25, .7, .4, 1) forwards;
}
@keyframes puck-fly {
    from { transform: translate(var(--x0), var(--y0)) scale(1); }
    to { transform: translate(var(--x1), var(--y1)) scale(var(--s1)); }
}

.crowd-meter, .windup-badge {
    position: absolute; top: 16px; background: rgba(0, 0, 0, .65); border-radius: 12px; padding: 8px 14px; z-index: 2;
}
.crowd-meter { left: 18px; border: 2px solid var(--line); display: flex; align-items: center; gap: 10px; }
.crowd-meter .k, .windup-badge .k { font-size: 11px; letter-spacing: 2px; color: var(--muted); }
.crowd-meter .bars { display: flex; gap: 4px; margin-top: 4px; align-items: flex-end; height: 20px; }
.crowd-meter .bar { width: 22px; border-radius: 3px; background: var(--line); transition: background .3s; }
.crowd-meter .bar.on { background: var(--gold); }
.crowd-meter .bar.hot { background: var(--score); }
.crowd-meter .label { font-weight: 900; font-size: 16px; margin-left: 4px; min-width: 80px; }
.windup-badge { right: 18px; border: 2px solid var(--gold); text-align: right; }
.windup-badge .v { font-weight: 900; font-size: 18px; color: var(--gold); }

.callout {
    position: absolute; right: 0; width: 34%; text-align: center; font-weight: 900; font-style: italic; z-index: 3;
    pointer-events: none;
}
.goal-text {
    top: 42%; font-size: clamp(56px, 8vw, 110px); color: var(--gold); letter-spacing: 6px;
    text-shadow: 0 0 30px rgba(255, 60, 60, .9), 6px 6px 0 #000; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1) both;
}
.saved-text, .wide-text {
    top: 44%; font-size: clamp(56px, 8vw, 104px); color: #cfd8ea; text-shadow: 5px 5px 0 #000;
    animation: pop .4s ease-out both;
}
.callout.sub { top: 66%; font-size: 24px; font-style: normal; color: #fff; text-shadow: 3px 3px 0 #000; }
.thunk {
    position: absolute; left: 10%; top: 26%; font-size: 24px; font-weight: 900; font-style: italic;
    -webkit-text-stroke: 1px #000; animation: pop .3s .45s ease-out both;
}
@keyframes pop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.confetti { position: absolute; inset: 0; pointer-events: none; z-index: 2; overflow: hidden; }
.confetti i {
    position: absolute; top: -20px; width: 8px; height: 14px; opacity: .9;
    animation-name: confetti-fall; animation-timing-function: linear; animation-iteration-count: infinite;
}
@keyframes confetti-fall {
    from { transform: translateY(0) rotate(0); }
    to { transform: translateY(110vh) rotate(var(--spin)); }
}

/* ---------- bottom panel ---------- */

.bottom {
    flex: 0 0 170px; display: flex; align-items: center; gap: 30px; padding: 0 34px; position: relative;
    background: linear-gradient(#0f1626, #070b14); border-top: 3px solid #222c44;
}
.problem { display: flex; align-items: center; gap: 30px; flex: 1; min-width: 0; }
.q { font-size: 76px; font-weight: 900; letter-spacing: 2px; font-family: var(--mono); white-space: nowrap; }
.q.small { font-size: 60px; }
.ans {
    width: 190px; height: 96px; border-radius: 14px; background: #fff; color: var(--ink); font-size: 64px; font-weight: 900;
    padding: 0 18px; border: 5px solid var(--gold); font-family: var(--mono); display: flex; align-items: center;
}
.ans:focus { outline: none; box-shadow: 0 0 0 4px rgba(245, 180, 0, .4); }
.ans:disabled { opacity: .6; }
.ans.wrong { width: 150px; font-size: 50px; border-color: var(--red); color: #999; text-decoration: line-through; }
.right-answer { font-size: 46px; font-weight: 900; color: var(--green); font-family: var(--mono); }
.shoot {
    background: var(--gold); color: #000; font-weight: 900; font-size: 22px; padding: 18px 24px; border-radius: 12px;
    letter-spacing: 1px; border: 0; white-space: nowrap;
}
.shoot:disabled { opacity: .5; }
.timer { margin-left: auto; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.timer .lbl { font-size: 12px; letter-spacing: 3px; color: var(--muted); }
.sequence-text { font-size: 30px; font-weight: 900; margin: 0 auto 0 0; }
.sequence-note { color: var(--soft); font-size: 20px; max-width: 420px; }
.sequence-note b { color: #fff; font-size: 28px; }

.numpad {
    position: absolute; right: 150px; bottom: 178px; display: grid; grid-template-columns: repeat(3, 72px); gap: 8px;
    background: rgba(7, 11, 20, .92); padding: 10px; border-radius: 16px; border: 2px solid var(--line); z-index: 4;
}
.numpad .btn { height: 60px; font-size: 26px; padding: 0; }
.numpad .btn:last-child { grid-column: span 3; }

/* ---------- settings ---------- */

.modal-backdrop {
    position: fixed; inset: 70px 0 0 0; background: rgba(3, 6, 12, .78); z-index: 20; overflow: auto; padding: 20px;
}
.settings { max-width: 1120px; margin: 0 auto; }
.settings-head { display: flex; align-items: center; gap: 12px; }
.settings-head h1 { font-size: 34px; margin: 0; }
.settings-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 18px; }
.choice-row { display: flex; gap: 10px; }
.choice-row .btn { flex: 1; height: 52px; font-size: 20px; padding: 0; }
.row { display: flex; align-items: center; gap: 16px; margin: 12px 0; }
.row .name { width: 170px; color: var(--text); font-size: 16px; }
.row input[type=range] { flex: 1; accent-color: var(--gold); height: 28px; }
.pct { width: 56px; text-align: right; }
.toggle {
    appearance: none; width: 60px; height: 32px; border-radius: 16px; background: var(--line); position: relative; cursor: pointer;
    margin: 0;
}
.toggle::after {
    content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: var(--muted);
    transition: left .15s;
}
.toggle:checked { background: var(--gold); }
.toggle:checked::after { left: 32px; background: #000; }
.player-card { display: flex; align-items: center; gap: 16px; }
.player-card .h2 { margin-bottom: 4px; }
.player-name { font-size: 18px; font-weight: 900; }
.btn.reset { margin-top: 14px; width: 100%; color: #ff8a7a; }
.confirm { border-color: #a33; }
.confirm-buttons { display: flex; gap: 10px; margin-top: 10px; }

/* ---------- smaller screens (tablets) ---------- */

@media (max-width: 1100px) {
    .setup-hero { display: none; }
    .settings-grid { grid-template-columns: 1fr; }
    .stat { min-width: 64px; padding: 4px 8px; }
    .logo { font-size: 22px; }
    .q { font-size: 56px; }
    .ans { width: 150px; height: 80px; font-size: 48px; }
    .shoot { font-size: 18px; padding: 14px 16px; }
    .bottom { gap: 18px; padding: 0 18px; }
}

@media (max-width: 760px) {
    .stat:nth-of-type(2) { display: none; }
    .num-grid { grid-template-columns: repeat(4, 1fr); }
    .op-row .btn { height: 72px; }
    .setup { padding: 16px; }
    .setup-title { font-size: 32px; }
}

@media (prefers-reduced-motion: reduce) {
    .confetti, .goal-glow { display: none; }
    .goal-light.on { animation: none; }
}

/* ---------- Blazor error bar ---------- */

#blazor-error-ui {
    background: #fffbe6; color: #3a2f00; bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, .2); display: none; left: 0;
    padding: .6rem 1.25rem .7rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
