:root {
    --bg0: #0b0919;
    --bg1: #1a1240;
    --panel: #1d1745cc;
    --line: #ffffff22;
    --text: #f3eeff;
    --dim: #b6a9e6;
    --cyan: #38f9d7;
    --magenta: #ff4fd8;
    --gold: #ffd54a;
    --red: #ff4b6b;
    --light: #3c3470;
    --dark: #261f4d;
    --b: min(calc(100vw - 20px), calc(100svh - 330px), 600px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    min-height: 100%;
    background: radial-gradient(120% 80% at 50% 0%, var(--bg1) 0%, var(--bg0) 70%) fixed;
    color: var(--text);
    font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
    overflow-x: hidden;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }

/* ---------- boot / error ---------- */
.boot { height: 100svh; display: grid; place-content: center; gap: 18px; text-align: center; }
.boot-logo, .logo { font-weight: 900; letter-spacing: 2px; text-shadow: 0 0 18px #7a5cff; }
.boot-logo { font-size: 34px; }
.boot-logo span, .logo span { color: var(--magenta); margin-left: 4px; }
.boot-bar { width: 200px; height: 6px; border-radius: 6px; background: #ffffff1a; overflow: hidden; margin: 0 auto; }
.boot-bar i { display: block; height: 100%; width: 40%; background: linear-gradient(90deg, var(--cyan), var(--magenta)); animation: boot 1.1s infinite ease-in-out; }
@keyframes boot { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; padding: 10px; background: #5b1030; z-index: 1000; }

/* ---------- layout ---------- */
.app { max-width: 640px; margin: 0 auto; padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; align-items: center; min-height: 100svh; }

.topbar { width: calc(var(--b) + 12px); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.logo { font-size: 17px; white-space: nowrap; }
.controls { display: flex; gap: 5px; align-items: center; }
.sel, .icon-btn {
    background: #ffffff12; border: 1px solid var(--line); border-radius: 10px; padding: 6px 7px; font-size: 12px; font-weight: 800;
}
.icon-btn.muted { opacity: .45; text-decoration: line-through; }
.sel option { color: #000; }
.icon-btn { min-width: 30px; }
.icon-btn.wide { background: linear-gradient(180deg, #5b3bd6, #3b22a0); }

.player { width: calc(var(--b) + 12px); display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 12px; background: #ffffff0a; border: 1px solid transparent; transition: border-color .25s, box-shadow .25s, background .25s; }
.player.active { border-color: #38f9d788; background: #38f9d714; box-shadow: 0 0 14px #38f9d733; }
.avatar { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff9; flex: none; }
.avatar.w { background: radial-gradient(circle at 35% 30%, #fff, #8cc4ff); }
.avatar.b { background: radial-gradient(circle at 35% 30%, #9366f0, #25104f); border-color: var(--magenta); }
.pname { font-weight: 800; font-size: 14px; }
.chips { margin-left: auto; display: flex; gap: 5px; }
.chip { display: inline-flex; align-items: center; gap: 3px; padding: 2px 6px; border-radius: 999px; background: #ffffff14; font-size: 12px; font-weight: 800; }
.chip svg { width: 14px; height: 14px; }
.chip.zero { opacity: .35; }

/* ---------- board ---------- */
.board-frame { padding: 6px; border-radius: 16px; background: linear-gradient(145deg, #5b3bd6, #ff4fd8 60%, #38f9d7); box-shadow: 0 10px 40px #000a, 0 0 30px #7a5cff55; }
.board { width: var(--b); height: var(--b); max-width: calc(100vw - 32px); max-height: calc(100vw - 32px); position: relative; display: grid; grid-template-columns: repeat(var(--cols, 8), 1fr); grid-template-rows: repeat(var(--cols, 8), 1fr); border-radius: 10px; overflow: hidden; touch-action: manipulation; }
.board.shaking { animation: shake .38s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake { 10%, 90% { transform: translate3d(-1px, 0, 0); } 20%, 80% { transform: translate3d(3px, 1px, 0); } 30%, 50%, 70% { transform: translate3d(-5px, -1px, 0); } 40%, 60% { transform: translate3d(5px, 1px, 0); } }

.sq { position: relative; display: grid; place-items: center; }
.sq.light { background: var(--light); }
.sq.dark { background: var(--dark); }
.sq.last::after { content: ""; position: absolute; inset: 0; background: #38f9d71f; box-shadow: inset 0 0 0 2px #38f9d755; }
.sq.selected { box-shadow: inset 0 0 0 3px var(--cyan), inset 0 0 18px #38f9d788; z-index: 1; }
.sq.check { background: radial-gradient(circle, #ff4b6bcc 0%, #ff4b6b00 75%), var(--dark); animation: pulse-red .9s infinite; }
@keyframes pulse-red { 50% { filter: brightness(1.5); } }
.coord { position: absolute; font-style: normal; font-size: 9px; font-weight: 800; color: #ffffff55; pointer-events: none; }
.coord.rank { top: 2px; left: 3px; }
.coord.file { bottom: 1px; right: 3px; }

.sq.target::before { content: ""; position: absolute; inset: 0; margin: auto; width: 28%; height: 28%; border-radius: 50%; background: #38f9d7; box-shadow: 0 0 12px #38f9d7; animation: dot 1s infinite ease-in-out; z-index: 3; }
.sq.target.cap::before { width: 82%; height: 82%; background: transparent; border: 3px solid var(--red); box-shadow: 0 0 14px var(--red), inset 0 0 12px #ff4b6b88; animation: ringpulse .8s infinite ease-in-out; }
.sq.aim::before { content: ""; position: absolute; inset: 0; margin: auto; width: 86%; height: 86%; border-radius: 12px; border: 3px dashed var(--gold); box-shadow: 0 0 14px var(--gold); animation: ringpulse .8s infinite ease-in-out; z-index: 3; }
@keyframes dot { 50% { transform: scale(1.25); } }
@keyframes ringpulse { 50% { transform: scale(.92); opacity: .75; } }

/* Powerup squares: flat, full-tile, glowing. Boulders are the raised grey blocks, so raised means blocked, glowing means go. */
.sq.powerup { --pu-edge: #ffd54a; --pu-glyph: #fff1b8; background-image: linear-gradient(135deg, var(--pu-a), var(--pu-b)); }
.sq.powerup.pu-hidden { --pu-edge: #d9b8ff; --pu-glyph: #fff3c4; --pu-a: #6a45e6dd; --pu-b: #d4a017aa; }
.sq.powerup.pu-buff { --pu-edge: #ffd54a; --pu-glyph: #fff1b8; --pu-a: #ffd54acc; --pu-b: #ff9f1c88; }
.sq.powerup.pu-perk { --pu-edge: #38f9d7; --pu-glyph: #c6fff5; --pu-a: #38f9d7cc; --pu-b: #12b8a088; }
.pu-edge { position: absolute; inset: 0; border: 2px solid var(--pu-edge); border-radius: 0; box-shadow: inset 0 0 12px var(--pu-edge); pointer-events: none; animation: puglow 1.8s ease-in-out infinite; }
@keyframes puglow { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
.pu-glyph { position: relative; z-index: 1; width: 56%; height: 56%; display: grid; place-items: center; color: var(--pu-glyph); font-weight: 900; font-size: calc(var(--b) / 11); line-height: 1; animation: pupulse 1.8s ease-in-out infinite; pointer-events: none; }
.pu-glyph svg { width: 100%; height: 100%; }
@keyframes pupulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-3deg); filter: brightness(1); } 50% { transform: translateY(-4%) rotate(3deg); filter: brightness(1.2); } }
.boulder { position: absolute; inset: 10%; color: #8d86a8; filter: drop-shadow(0 3px 0 #0006); display: grid; }
.boulder svg { width: 100%; height: 100%; }
.sq.rock { background: repeating-linear-gradient(45deg, #1b1638, #1b1638 6px, #231c47 6px, #231c47 12px); }

/* ---------- pieces ---------- */
.layer { position: absolute; inset: 0; pointer-events: none; }
.piece {
    position: absolute; width: 12.5%; height: 12.5%; z-index: 5;
    transition: left .34s cubic-bezier(.34, 1.45, .55, 1), top .34s cubic-bezier(.34, 1.45, .55, 1);
    will-change: left, top;
}
.piece-body { width: 100%; height: 100%; padding: 6%; transform-origin: 50% 90%; filter: drop-shadow(0 3px 2px #0007); }
.piece.lifted .piece-body { transform: translateY(-8%) scale(1.08); filter: drop-shadow(0 8px 6px #000a) drop-shadow(0 0 8px #38f9d7); transition: transform .12s; }
.piece-body.land-0 { animation: land0 .42s .26s both; }
.piece-body.land-1 { animation: land1 .42s .26s both; }
@keyframes land0 { 0% { transform: scale(1.22, .78); } 55% { transform: scale(.94, 1.1); } 100% { transform: none; } }
@keyframes land1 { 0% { transform: scale(1.22, .78); } 55% { transform: scale(.94, 1.1); } 100% { transform: none; } }
.piece.dying { z-index: 8; animation: die .6s ease-out forwards; }
@keyframes die { 0% { transform: scale(1); filter: brightness(2.2); } 100% { transform: scale(1.7) rotate(22deg); opacity: 0; filter: blur(5px) brightness(2); } }

.piece-svg { width: 100%; height: 100%; overflow: visible; }
.piece-svg .shadow { fill: #0006; }
.piece-svg .body { stroke-width: 4; stroke-linejoin: round; }
.piece-svg.w .body { fill: url(#gW); stroke: #3b2a8f; }
.piece-svg.b .body { fill: url(#gB); stroke: var(--magenta); }
.piece-svg .shine { fill: #ffffff66; }
.piece-svg.b .shine { fill: #ffffff2e; }
.piece-svg .line { fill: none; stroke: #3b2a8f; stroke-width: 4; stroke-linecap: round; }
.piece-svg.b .line { stroke: var(--magenta); }
.piece-svg .eye { fill: #1b0f4d; }
.piece-svg.b .eye { fill: var(--cyan); }

.piece.armored .piece-body { filter: drop-shadow(0 3px 2px #0007) drop-shadow(0 0 7px var(--cyan)); }
.piece.poisoned .piece-body { filter: drop-shadow(0 3px 2px #0007) drop-shadow(0 0 6px #7dff4f); }
.piece.stunned .piece-body { filter: grayscale(.85) brightness(.8) drop-shadow(0 3px 2px #0007); animation: stunwobble .7s infinite ease-in-out; }
@keyframes stunwobble { 50% { transform: rotate(-5deg) scale(.96); } }

.armor-ring { position: absolute; inset: -3%; display: grid; pointer-events: none; }
.armor-ring .spikes { grid-area: 1 / 1; width: 100%; height: 100%; overflow: visible; animation: spin 9s linear infinite; filter: drop-shadow(0 0 4px var(--cyan)); }
.armor-ring .spikes circle { fill: none; stroke: var(--cyan); stroke-width: 3; }
.armor-ring .spikes polygon { fill: #38f9d7; stroke: #0a4a41; stroke-width: 1; stroke-linejoin: round; }
.armor-ring b { position: absolute; right: -4%; top: -4%; font-size: 10px; background: var(--cyan); color: #00332a; border-radius: 999px; min-width: 15px; height: 15px; display: grid; place-items: center; box-shadow: 0 0 6px var(--cyan); }
@keyframes spin { to { transform: rotate(360deg); } }
.stun-tag { position: absolute; left: 2%; top: 0; display: flex; align-items: center; gap: 1px; color: var(--gold); font-size: 10px; font-weight: 900; text-shadow: 0 1px 0 #000; }
.stun-tag svg { width: 14px; height: 14px; animation: spin 2s linear infinite; }

.badges { position: absolute; right: 2%; bottom: 2%; display: flex; gap: 1px; }
.badge { width: 38%; min-width: 14px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid #000a; padding: 2px; }
.badge svg { width: 100%; height: 100%; }
.badge.dm { background: var(--gold); color: #3a2a00; }
.badge.ps { background: #7dff4f; color: #123a00; }
.badge.bm { background: #ff8a3d; color: #3a1500; }
.badge.bb { background: var(--red); color: #fff; animation: bob 1s infinite; }

/* ---------- effects ---------- */
.fx-burst, .fx-ring, .fx-flash, .fx-ping, .fx-stars { position: absolute; transform: translate(-50%, -50%); pointer-events: none; z-index: 9; }
.fx-burst i { position: absolute; left: 0; top: 0; width: 7px; height: 7px; margin: -3px; border-radius: 50%; background: var(--c, #ffd54a); box-shadow: 0 0 8px var(--c, #ffd54a); animation: spark .7s ease-out forwards; }
@keyframes spark { 0% { transform: rotate(var(--a)) translateX(0) scale(1.3); opacity: 1; } 100% { transform: rotate(var(--a)) translateX(var(--d)) scale(.2); opacity: 0; } }
.fx-burst.boom { --c: #ff9f1c; }
.fx-burst.steal { --c: #ff4fd8; }
.fx-burst.fire { --c: #ff5a1f; }
.fx-burst.poison { --c: #7dff4f; }
.fx-burst.rock { --c: #a39cc4; }
.fx-ring { width: var(--s); height: var(--s); border-radius: 50%; border: 4px solid var(--c, #ffd54a); box-shadow: 0 0 20px var(--c, #ffd54a), inset 0 0 20px var(--c, #ffd54a); animation: ring .75s ease-out forwards; }
@keyframes ring { 0% { transform: translate(-50%, -50%) scale(.1); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1.05); opacity: 0; } }
.fx-ring.boom { --c: #ff8a3d; }
.fx-ring.steal { --c: #ff4fd8; }
.fx-ring.gold { --c: #ffd54a; }
.fx-flash { width: var(--s); height: var(--s); border-radius: 50%; background: radial-gradient(circle, #fff 0%, #ffb347 35%, #ff4b2b00 70%); animation: flash .5s ease-out forwards; }
@keyframes flash { 0% { transform: translate(-50%, -50%) scale(.3); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1.2); opacity: 0; } }
.fx-ping { width: 12.5%; height: 12.5%; border-radius: 50%; border: 3px solid var(--gold); animation: ping .9s ease-out forwards; }
.fx-ping.steal { border-color: var(--cyan); }
@keyframes ping { 0% { transform: translate(-50%, -50%) scale(.3); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; } }
.fx-stars i { position: absolute; width: 18px; height: 18px; color: var(--gold); animation: rise 1s ease-out forwards; }
.fx-stars i:nth-child(1) { left: -22px; } .fx-stars i:nth-child(2) { left: -2px; animation-delay: .1s; } .fx-stars i:nth-child(3) { left: 18px; animation-delay: .2s; }
@keyframes rise { 0% { transform: translateY(0) scale(.4) rotate(0); opacity: 1; } 100% { transform: translateY(-34px) scale(1.2) rotate(180deg); opacity: 0; } }
.fx-beam { position: absolute; height: 10px; margin-top: -5px; z-index: 9; transform-origin: 0 50%; border-radius: 10px; background: linear-gradient(90deg, #fff, #ffb347 30%, #ff4b2b); box-shadow: 0 0 18px #ff7a2b, 0 0 36px #ff4b2b; animation: beam .7s ease-out forwards; }
.fx-beam.steal { background: linear-gradient(90deg, #fff, #ff4fd8); box-shadow: 0 0 18px #ff4fd8; }
@keyframes beam { 0% { transform: rotate(var(--r)) scaleX(0); opacity: 1; } 35% { transform: rotate(var(--r)) scaleX(1); opacity: 1; } 100% { transform: rotate(var(--r)) scaleX(1); opacity: 0; } }

.toasts { position: absolute; left: 0; right: 0; top: 6px; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 20; }
.toast { display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 8px; border-radius: 999px; background: linear-gradient(180deg, #2b1f66ee, #130c36ee); border: 2px solid var(--gold); box-shadow: 0 0 22px #ffd54a66; animation: toast 2.2s ease-out forwards; max-width: 94%; }
.toast .ticon { width: 28px; height: 28px; flex: none; color: var(--gold); }
.toast .ticon svg { width: 100%; height: 100%; }
.toast .ttext { display: flex; flex-direction: column; line-height: 1.1; }
.toast b { font-size: 15px; letter-spacing: 1px; text-transform: uppercase; }
.toast small { font-size: 11px; color: var(--dim); }
.toast.fire { border-color: #ff7a2b; box-shadow: 0 0 22px #ff7a2b88; } .toast.fire .ticon { color: #ff7a2b; }
.toast.boom { border-color: #ff8a3d; box-shadow: 0 0 22px #ff8a3d88; } .toast.boom .ticon { color: #ff8a3d; }
.toast.steal { border-color: var(--magenta); box-shadow: 0 0 22px #ff4fd888; } .toast.steal .ticon { color: var(--magenta); }
.toast.poison { border-color: #7dff4f; box-shadow: 0 0 22px #7dff4f88; } .toast.poison .ticon { color: #7dff4f; }
.toast.stun { border-color: var(--cyan); box-shadow: 0 0 22px #38f9d788; } .toast.stun .ticon { color: var(--cyan); }
@keyframes toast { 0% { transform: translateY(-14px) scale(.8); opacity: 0; } 12% { transform: none; opacity: 1; } 80% { opacity: 1; } 100% { transform: translateY(-6px); opacity: 0; } }

/* ---------- action bar ---------- */
.actions { width: calc(var(--b) + 12px); display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; min-height: 52px; }
.perk { display: flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 12px; border: 1px solid var(--line); background: linear-gradient(180deg, #3a2c80, #22185a); font-weight: 800; font-size: 13px; transition: transform .1s, box-shadow .2s, opacity .2s; }
.perk:not(:disabled):active { transform: scale(.95); }
.perk:disabled { opacity: .35; }
.perk:not(:disabled) { box-shadow: 0 0 12px #7a5cff77; }
.perk.on { background: linear-gradient(180deg, #ffd54a, #ff9f1c); color: #3a2a00; box-shadow: 0 0 18px #ffd54a; }
.perk .pi { width: 20px; height: 20px; display: grid; }
.perk .pi svg { width: 100%; height: 100%; }
.perk .pc { background: #0006; border-radius: 999px; padding: 0 7px; font-size: 12px; }
.perk.boom-btn { background: linear-gradient(180deg, #ff8a3d, #d9421e); animation: glow 1s infinite ease-in-out; }
@keyframes glow { 0%, 100% { box-shadow: 0 0 8px #ff8a3d88; } 50% { box-shadow: 0 0 24px #ff8a3d; } }
.perk.ghost { background: transparent; }

.status { min-height: 22px; font-weight: 800; font-size: 14px; color: var(--dim); text-align: center; letter-spacing: .3px; }
.status.warn { color: var(--red); text-shadow: 0 0 10px var(--red); }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; background: #07041299; backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.card { width: min(380px, 100%); background: linear-gradient(180deg, #2a1f66, #150e3c); border: 2px solid #7a5cffaa; border-radius: 20px; padding: 18px; text-align: center; box-shadow: 0 0 40px #7a5cff66; max-height: 92svh; overflow: auto; }
.card.pop { animation: pop .35s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
.kicker { font-size: 12px; letter-spacing: 3px; text-transform: uppercase; color: var(--gold); font-weight: 900; }
.card h1 { margin: 6px 0; font-size: 40px; letter-spacing: 3px; text-shadow: 0 0 20px currentColor; }
.card h2 { margin: 4px 0; font-size: 26px; letter-spacing: 1px; }
.card p { color: var(--dim); font-size: 14px; line-height: 1.35; margin: 6px 0 14px; }
.card p.fine { font-size: 12px; }
.big-icon { width: 84px; height: 84px; margin: 12px auto 4px; border-radius: 24px; padding: 16px; display: grid; animation: bob 1.5s infinite ease-in-out; }
.big-icon svg { width: 100%; height: 100%; }
.big-icon.buff, .gi.buff { background: linear-gradient(145deg, #fff0a0, var(--gold) 55%, #ff9f1c); color: #3a2a00; box-shadow: 0 0 30px #ffd54a99; }
.big-icon.perk, .gi.perk { background: linear-gradient(145deg, #a4fff0, var(--cyan) 55%, #12b8a0); color: #003a31; box-shadow: 0 0 30px #38f9d799; }
.row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.btn { padding: 11px 20px; border-radius: 14px; border: 1px solid var(--line); background: #ffffff14; font-weight: 900; font-size: 15px; }
.btn.primary { background: linear-gradient(180deg, #ff6fe1, #c42ba3); box-shadow: 0 0 20px #ff4fd88a; }
.btn.ghost { background: transparent; margin-top: 10px; }
.promo-btn { width: 70px; height: 70px; padding: 6px; }
.result.win h1 { color: var(--gold); }
.result.lose h1 { color: var(--red); }
.result.draw h1 { color: var(--dim); }
.help { text-align: left; }
.help .kicker, .help p { text-align: center; }
.guide { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; }
.guide li { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--dim); line-height: 1.25; }
.guide b { color: var(--text); }
.gi { width: 34px; height: 34px; flex: none; border-radius: 10px; padding: 6px; display: grid; }
.gi svg { width: 100%; height: 100%; }
.help .btn { display: block; margin: 8px auto 0; }

@media (max-height: 640px) { :root { --b: min(calc(100vw - 20px), calc(100svh - 270px), 600px); } }

/* ---------- fireball aim preview + piece inspect card ---------- */
.sq.doomed::before { content: ""; position: absolute; inset: 14%; border-radius: 10px; border: 3px dashed var(--red); box-shadow: 0 0 12px var(--red); animation: ringpulse .8s infinite ease-in-out; z-index: 3; }

.inspect { width: calc(var(--b) + 12px); background: linear-gradient(180deg, #2a1f66ee, #150e3cee); border: 2px solid #7a5cffaa; border-radius: 14px; padding: 8px 10px; animation: pop .25s cubic-bezier(.34, 1.56, .64, 1); display: grid; gap: 6px; }
.inspect-head { display: flex; justify-content: space-between; align-items: center; font-size: 14px; letter-spacing: .5px; }
.inspect-head .x { background: #ffffff14; border: 1px solid var(--line); border-radius: 8px; width: 26px; height: 26px; line-height: 1; font-weight: 900; }
.inspect-row { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--dim); line-height: 1.25; }
.inspect-row b { color: var(--text); display: block; }
.inspect-row .gi { width: 30px; height: 30px; padding: 5px; }

/* ---------- fireball badge, rewind, move review ---------- */
.badge.fb { background: #ff7a2b; color: #3a1200; }
.perk.fire-btn { background: linear-gradient(180deg, #ff9a3d, #e0481e); animation: glow 1s infinite ease-in-out; }

.review { width: calc(var(--b) + 12px); display: grid; gap: 8px; background: linear-gradient(180deg, #2a1f66ee, #150e3cee); border: 2px solid var(--cyan); border-radius: 14px; padding: 8px 10px; box-shadow: 0 0 18px #38f9d744; }
.review-label { display: grid; gap: 2px; text-align: center; font-size: 13px; color: var(--dim); }
.review-label .rp { color: var(--cyan); font-weight: 900; letter-spacing: 1px; text-transform: uppercase; font-size: 12px; }
.review-btns { display: flex; gap: 6px; align-items: center; justify-content: center; flex-wrap: wrap; }
.rbtn { width: 44px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: #ffffff14; padding: 9px; display: grid; place-items: center; }
.rbtn svg { width: 100%; height: 100%; }
.rbtn:disabled { opacity: .3; }
.review-exit { padding: 9px 14px; font-size: 14px; }

/* ---------- bomb preview ---------- */
.sq.blast { box-shadow: inset 0 0 0 1px #ff8a3d66; background-image: linear-gradient(#ff8a3d26, #ff8a3d26); }
.sq.spared::before { content: ""; position: absolute; inset: 12%; border-radius: 50%; border: 3px solid var(--cyan); box-shadow: 0 0 10px var(--cyan); z-index: 3; }
.sq.rock.doomed::before { inset: 8%; }

/* ---------- powerup tutorials ---------- */
.tutorial { position: fixed; left: 0; right: 0; bottom: 0; z-index: 90; max-width: 640px; margin: 0 auto; display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(180deg, #2a1f66f5, #120a33fa); border-top: 2px solid var(--gold); border-radius: 16px 16px 0 0; box-shadow: 0 -12px 34px #000b; animation: slideup .3s cubic-bezier(.34, 1.3, .64, 1); }
@keyframes slideup { from { transform: translateY(40px); opacity: 0; } }
.demo-wrap { --demo: min(168px, 30svh); width: var(--demo); flex: none; margin: 0 auto; }
.board.demo-board { --b: var(--demo); width: var(--demo); height: var(--demo); max-width: none; max-height: none; border-radius: 10px; box-shadow: 0 0 0 3px #7a5cff88; }
.demo-board .sq.aim::before { width: 70%; height: 70%; border-width: 2px; }
.demo-caption { margin-top: 6px; min-height: 2.7em; font-size: 11.5px; line-height: 1.25; text-align: center; color: var(--gold); font-weight: 800; }
.tut-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.tut-title { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.tut-title .gi { width: 30px; height: 30px; padding: 5px; }
.tut-text p { margin: 0; font-size: 12.5px; line-height: 1.3; color: var(--dim); }
.chk { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--dim); cursor: pointer; }
.chk input { width: 18px; height: 18px; accent-color: var(--magenta); flex: none; }
.tut-ok { padding: 9px 16px; font-size: 14px; align-self: flex-start; }
.card .demo-wrap { margin: 4px auto 10px; }
.card .chk { justify-content: center; margin-bottom: 10px; }
.demo-btn { margin-left: auto; flex: none; background: #ffffff14; border: 1px solid var(--line); border-radius: 8px; padding: 4px 9px; font-size: 11px; font-weight: 800; color: var(--cyan); }
.help-row { margin: 6px 0; }

/* ---------- New game sheet ---------- */
.newgame { text-align: left; display: grid; gap: 10px; }
.newgame .kicker { text-align: center; }
.opt-label { font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--dim); font-weight: 800; margin-top: 2px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg.four { grid-template-columns: repeat(4, 1fr); }
.seg-btn { background: #ffffff10; border: 2px solid var(--line); border-radius: 12px; padding: 10px 8px; display: grid; gap: 3px; text-align: center; font-weight: 800; font-size: 13px; }
.seg-btn small { font-size: 10.5px; line-height: 1.2; color: var(--dim); font-weight: 600; }
.seg-btn.on { border-color: var(--cyan); background: #38f9d714; box-shadow: 0 0 14px #38f9d744; }
.newgame-row { margin-top: 6px; }
.sqinfo { border-color: var(--gold); }

/* ---------- fireball projectile ---------- */
.fx-fireball { position: absolute; height: 0; z-index: 9; transform-origin: 0 50%; transform: rotate(var(--r)); pointer-events: none; }
.fx-fireball .ball {
    position: absolute; left: 0; top: 50%; width: var(--bw); aspect-ratio: 1; margin-top: calc(var(--bw) / -2); border-radius: 50%;
    background: radial-gradient(circle at 38% 38%, #fff 0 14%, #ffe27a 30%, #ff8a2b 62%, #d9300f 100%);
    box-shadow: 0 0 10px 3px #ff8a2b, 0 0 24px 8px #ff4b2b88;
    opacity: 0;
    animation: fly var(--dur) cubic-bezier(.35, .1, .75, 1) forwards, fireflick .09s steps(2) infinite alternate;
}
.fx-fireball .ball::before { content: ""; position: absolute; right: 42%; top: 16%; height: 68%; width: 340%; border-radius: 50%; background: linear-gradient(270deg, #ffb347d9, #ff5a1faa 35%, #ff4b2b00 100%); filter: blur(1.5px); z-index: -1; }
.fx-fireball .ball i { position: absolute; right: 55%; width: 16%; aspect-ratio: 1; border-radius: 50%; background: #ffd27a; box-shadow: 0 0 6px #ff8a2b; animation: ember .32s linear infinite; }
.fx-fireball .ball i:nth-child(1) { top: 8%; }
.fx-fireball .ball i:nth-child(2) { top: 44%; animation-delay: .11s; }
.fx-fireball .ball i:nth-child(3) { top: 76%; animation-delay: .22s; }
@keyframes fly { 0% { left: 0; opacity: 0; transform: scale(.5); } 8% { opacity: 1; transform: scale(1); } 90% { opacity: 1; } 100% { left: calc(100% - var(--bw)); opacity: 0; transform: scale(1.35); } }
@keyframes fireflick { from { filter: brightness(1) hue-rotate(0deg); } to { filter: brightness(1.3) hue-rotate(-14deg); } }
@keyframes ember { from { transform: translateX(0) scale(1); opacity: 1; } to { transform: translateX(-280%) scale(.2); opacity: 0; } }

/* a piece hit by a fireball burns up */
.piece.dying.burning { animation: none; }
.piece.dying.burning .piece-body { animation: burn .7s ease-out forwards; }
.piece.burning::after { content: ""; position: absolute; left: 12%; right: 12%; top: -8%; bottom: 22%; border-radius: 50% 50% 40% 40%; background: radial-gradient(ellipse at 50% 90%, #fff3b0 0 18%, #ffb347 40%, #ff4b2b 62%, transparent 72%); mix-blend-mode: screen; animation: flame .22s ease-in-out infinite alternate; pointer-events: none; }
@keyframes flame { from { transform: scaleY(.85); opacity: .85; } to { transform: scaleY(1.2) translateY(-6%); opacity: 1; } }
@keyframes burn { 0% { filter: brightness(1.5) sepia(1) saturate(4) hue-rotate(-30deg); } 100% { transform: scale(.7) translateY(-14%); opacity: 0; filter: brightness(.35) sepia(1) saturate(5) hue-rotate(-30deg) blur(2px); } }

/* ---------- Milestone 2g: ghost, teleporters ---------- */
.badge.gh { background: #c9d4ff; color: #1a1f4a; }
.piece.ghosted .piece-body { opacity: .62; filter: drop-shadow(0 0 9px #b7c4ff) drop-shadow(0 0 3px #fff); animation: ghostfloat 1.6s infinite ease-in-out; }
.piece.ghosted.lifted .piece-body { opacity: .85; }
@keyframes ghostfloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5%); } }
.piece.warping .piece-body { animation: warp .7s ease-in-out; }
@keyframes warp { 0% { opacity: 0; transform: scale(.2) rotate(-200deg); filter: hue-rotate(0deg); } 60% { opacity: 1; transform: scale(1.2) rotate(15deg); } 100% { transform: none; } }
.sq.powerup.pu-portal { --pu-edge: #b36bff; --pu-glyph: #f3e4ff; --pu-a: #7a2ff0cc; --pu-b: #2fb7ff88; }
.sq.pu-portal .pu-glyph { animation: portalspin 3.2s linear infinite; }
@keyframes portalspin { to { transform: rotate(360deg); } }
.fx-ring.portal { --c: #b36bff; }
.fx-ping.portal { border-color: #b36bff; }
.toast.portal { border-color: #b36bff; box-shadow: 0 0 22px #b36bff88; } .toast.portal .ticon { color: #b36bff; }

/* ---------- strike drama ---------- */
.board.shaking.sk2 { animation: shake2 .5s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake2 { 10%, 90% { transform: translate3d(-2px, 0, 0); } 20%, 80% { transform: translate3d(7px, 2px, 0); } 30%, 50%, 70% { transform: translate3d(-11px, -3px, 0); } 40%, 60% { transform: translate3d(11px, 3px, 0); } }
.board.freeze .piece-body, .board.freeze .fx-burst i, .board.freeze .fx-ring, .board.freeze .fx-flash, .board.freeze .pu-edge, .board.freeze .pu-glyph, .board.freeze .fx-ping { animation-play-state: paused; }
.board.freeze { filter: contrast(1.25) saturate(1.2); }
.board.punch { animation: punch .55s ease-out; }
@keyframes punch { 0% { transform: scale(1); } 22% { transform: scale(1.045); } 100% { transform: scale(1); } }
.fx-slash { position: absolute; height: 0; z-index: 12; pointer-events: none; transform: translate(-50%, -50%) rotate(-38deg); }
.fx-slash.b { transform: translate(-50%, -50%) rotate(38deg); }
.fx-slash i { position: absolute; left: 0; right: 0; top: -2px; height: 4px; border-radius: 4px; background: linear-gradient(90deg, #fff0, #fff 22%, #fff 78%, #fff0); box-shadow: 0 0 10px #fff, 0 0 22px #ff4b6b; transform-origin: 0 50%; animation: slash .34s ease-out forwards; }
.fx-slash i + i { top: 3px; height: 2px; background: linear-gradient(90deg, #ff4b6b00, #ff4b6b 25%, #ff4b6b 75%, #ff4b6b00); animation-delay: .04s; }
@keyframes slash { 0% { transform: scaleX(0); opacity: 1; } 28% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(1.06); opacity: 0; } }
.fx-streak { position: absolute; height: 8px; margin-top: -4px; z-index: 6; transform-origin: 0 50%; pointer-events: none; border-radius: 8px; background: linear-gradient(90deg, #fff0, #ffffffcc 70%, #fff); filter: blur(1px); animation: streak .42s ease-out forwards; }
@keyframes streak { 0% { transform: rotate(var(--r)) scaleX(.1); opacity: .9; } 40% { transform: rotate(var(--r)) scaleX(1); opacity: .9; } 100% { transform: rotate(var(--r)) scaleX(1); opacity: 0; } }
.fx-callout { position: absolute; left: 0; right: 0; top: 38%; z-index: 15; text-align: center; pointer-events: none; animation: callout 1s ease-out forwards; }
.fx-callout span { display: inline-block; font-size: calc(var(--b) / 8); font-weight: 900; font-style: italic; letter-spacing: 3px; color: #fff; padding: 0 .35em; transform: skewX(-9deg); text-shadow: 3px 3px 0 #ff2e63, -2px -2px 0 #1b0b3a, 0 0 22px #ff2e63; border-bottom: 5px solid #ff2e63; background: linear-gradient(90deg, #0000, #14083a99 18%, #14083a99 82%, #0000); }
.fx-callout.heavy span { font-size: calc(var(--b) / 6.2); text-shadow: 3px 3px 0 #ff7a2b, -2px -2px 0 #1b0b3a, 0 0 26px #ff4b2b; border-bottom-color: #ff7a2b; }
.fx-callout.check span { color: #ffe27a; font-size: calc(var(--b) / 9); border-bottom-color: #ffd54a; text-shadow: 2px 2px 0 #b3361e, 0 0 18px #ffd54a; }
.fx-callout.mate { top: 34%; animation-duration: 1.5s; }
@keyframes callout { 0% { transform: scale(2.4); opacity: 0; } 12% { transform: scale(1); opacity: 1; } 75% { transform: scale(1.04); opacity: 1; } 100% { transform: scale(1.1) translateY(-8px); opacity: 0; } }

/* ---------- debug tools ---------- */
.debug { width: calc(var(--b) + 12px); border: 1px dashed #ff4b6b; border-radius: 12px; padding: 8px; background: #1a0b2acc; display: flex; flex-direction: column; gap: 6px; }
.debug-head { display: flex; align-items: center; gap: 8px; }
.debug-head b { color: #ff4b6b; letter-spacing: 2px; }
.debug-head small { flex: 1; color: var(--dim); font-size: 11px; }
.debug-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.debug-row > span { font-size: 10px; font-weight: 800; color: var(--dim); text-transform: uppercase; width: 100%; }
.dbtn { padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); background: #2a1f5c; font-size: 11px; font-weight: 800; }
.dbtn.on { background: var(--cyan); color: #04251f; }
.dbtn.warn { border-color: #ff4b6b; }

/* ---------- progression ---------- */
.icon-btn.lvl { width: auto; padding: 0 10px; font-size: 12px; }
.icon-btn.lvl b { color: var(--gold); margin-left: 3px; }
.reward { margin: 8px 0 10px; text-align: left; display: flex; flex-direction: column; gap: 6px; }
.xp-line { display: flex; flex-direction: column; gap: 1px; }
.xp-line b { font-size: 20px; color: var(--gold); }
.xp-line small, .lv-line { font-size: 11px; color: var(--dim); }
.xpbar { height: 10px; border-radius: 6px; background: #ffffff18; overflow: hidden; }
.xpbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--magenta)); transition: width .8s ease-out; }
.levelup { font-weight: 900; letter-spacing: 1px; color: #fff; text-shadow: 0 0 14px var(--magenta); animation: glow 1s infinite ease-in-out; }
.unlocks { font-size: 12px; color: var(--cyan); }
.trophy-new { display: grid; grid-template-columns: 24px 1fr; column-gap: 8px; align-items: center; padding: 6px 8px; border-radius: 10px; border: 1px solid var(--gold); background: #ffd54a14; }
.trophy-new span { grid-row: span 2; color: var(--gold); width: 22px; height: 22px; }
.trophy-new b { font-size: 13px; }
.trophy-new small { grid-column: 2; font-size: 11px; color: var(--dim); }
.stats { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 0; margin: 8px 0; }
.stats li { background: #ffffff0f; border-radius: 10px; padding: 6px 4px; text-align: center; }
.stats b { display: block; font-size: 18px; }
.stats small { font-size: 10px; color: var(--dim); text-transform: uppercase; }
.trophies { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.trophy { display: grid; grid-template-columns: 22px 1fr; column-gap: 6px; padding: 6px 8px; border-radius: 10px; background: #ffffff0f; text-align: left; }
.trophy .ti { grid-row: span 2; width: 20px; height: 20px; color: var(--dim); }
.trophy.got { border: 1px solid var(--gold); background: #ffd54a14; }
.trophy.got .ti { color: var(--gold); }
.trophy b { font-size: 12px; }
.trophy small { grid-column: 2; font-size: 10px; color: var(--dim); }
.trophy.locked b { color: var(--dim); }
.guide li.locked { opacity: .5; }
.lockline { color: var(--gold); font-style: normal; font-weight: 700; }

/* ---------- daily challenge ---------- */
.icon-btn.daily { width: auto; padding: 0 9px; font-size: 12px; position: relative; }
.icon-btn .dot { position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--magenta); box-shadow: 0 0 8px var(--magenta); }
.puzzle-hud { width: calc(var(--b) + 12px); display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--gold); background: #ffd54a14; }
.ph-main { flex: 1; display: flex; flex-direction: column; gap: 1px; text-align: left; }
.ph-main b { color: var(--gold); letter-spacing: 1px; }
.ph-goal { font-size: 12px; font-weight: 800; }
.ph-main small { font-size: 11px; color: var(--dim); }
.ph-btns { display: flex; flex-direction: column; gap: 4px; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.streak-big { display: flex; align-items: center; gap: 8px; justify-content: center; margin: 6px 0; }
.streak-big .flame { width: 30px; height: 30px; color: #ff7a2b; filter: drop-shadow(0 0 8px #ff7a2b); }
.streak-big b { font-size: 34px; color: var(--gold); }
.streak-big small { font-size: 11px; color: var(--dim); text-align: left; max-width: 90px; }
.daily-title { margin: 4px 0; font-size: 20px; }
.solved-today { color: var(--cyan); font-weight: 800; }
.streak-line { font-size: 13px; }
.streak-line b { color: var(--gold); font-size: 18px; }
.icon-btn.lvl, .icon-btn.daily { white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 36px; padding: 0 9px; }
.icon-btn.daily .dot { position: static; flex: none; }
@media (max-width: 430px) {
  .topbar .logo { font-size: 14px; letter-spacing: 1px; }
  .topbar .controls { gap: 4px; }
  .topbar .icon-btn { min-width: 26px; font-size: 11px; padding: 0 7px; }
  .icon-btn.lvl, .icon-btn.daily { padding: 0 7px; gap: 3px; height: 32px; }
}
@media (max-width: 430px) { .topbar .icon-btn { height: 32px; display: inline-flex; align-items: center; justify-content: center; } }
.ghost-tag { position: absolute; left: 2%; top: 2%; display: flex; align-items: center; gap: 1px; padding: 1px 4px 1px 2px; border-radius: 999px; background: #1a1f4acc; border: 1px solid #b7c4ff; color: #dfe6ff; font-size: calc(var(--b) / 34); line-height: 1; pointer-events: none; z-index: 2; }
.ghost-tag svg { width: calc(var(--b) / 28); height: calc(var(--b) / 28); }
.ghost-tag b { font-weight: 900; }
.seg.six { grid-template-columns: repeat(3, 1fr); }

/* custom powerup rules */
.opt-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.05); color: inherit; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; display: inline-flex; flex-direction: column; align-items: center; line-height: 1.15; }
.chip-btn.on { border-color: var(--accent, #6cf); background: rgba(100,200,255,.18); }
.chip-btn.locked { opacity: .45; }
.chip-btn small { font-size: 10px; opacity: .8; }
.preset-blurb { font-size: 12px; opacity: .85; margin: 6px 0 2px; }
.preset-blurb em { color: #fc6; font-style: normal; }
.rules-badge { margin-left: 8px; font-size: 10px; padding: 2px 7px; border-radius: 999px; background: rgba(255,200,80,.2); color: #fc6; text-transform: uppercase; letter-spacing: .04em; }
.custom-sheet { max-height: 80vh; overflow-y: auto; }
.custom-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 14px; }
.custom-row .chip-btn { min-width: 76px; }
.opt-chips { justify-content: flex-start; } .chip-btn { margin: 0; }

.opt-chips { align-items: center; }
.chip-btn { min-height: 40px; justify-content: center; }
.chip-btn small { line-height: 1; }
.chip-btn { height: 44px; min-height: 0; padding-top: 0; padding-bottom: 0; }

.sq.last::after { background: #ffd24a33; box-shadow: inset 0 0 0 3px #ffd24acc; }

/* replay clip */
.clip-sheet { display: grid; gap: 10px; justify-items: center; }
.clip-canvas { width: min(100%, 250px); aspect-ratio: 9 / 16; border-radius: 14px; background: #07041a; border: 2px solid #7a5cffaa; }
.clip-len { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.clip-len small { opacity: .7; }
.clip-msg { font-size: 12px; color: var(--gold); min-height: 16px; text-align: center; }
.clip-sheet .newgame-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

/* level-up previews */
.unlock-strip { margin: 8px 0; padding: 8px; border: 1px solid #7a5cff66; border-radius: 14px; background: #ffffff0a; display: grid; gap: 6px; text-align: center; }
.us-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--gold); }
.us-head small { color: var(--dim); }
.us-card { display: grid; gap: 4px; justify-items: center; }
.us-name { font-weight: 900; font-size: 16px; }
.us-name em { font-style: normal; font-size: 11px; color: var(--dim); margin-left: 6px; }
.us-text { font-size: 12px; color: var(--dim); line-height: 1.3; }
.us-badge { width: 54px; height: 54px; display: grid; place-items: center; color: var(--gold); }
.us-badge svg { width: 36px; height: 36px; }
.us-nav { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.us-dots { display: flex; gap: 5px; }
.us-dots i { width: 7px; height: 7px; border-radius: 50%; background: #ffffff33; }
.us-dots i.on { background: var(--cyan); }
.new-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #ff4fd8; margin-left: 5px; box-shadow: 0 0 8px #ff4fd8; vertical-align: middle; }

.us-card .demo-wrap { margin: 0 auto; }
.us-card .demo-board { margin-left: auto; margin-right: auto; }

/* hints */
.sq.hint::after { content: ""; position: absolute; inset: 0; border-radius: 6px; box-shadow: inset 0 0 0 3px #7dff9a, 0 0 18px #7dff9a99; background: #7dff9a22; animation: hintpulse 1s ease-in-out infinite; pointer-events: none; z-index: 3; }
@keyframes hintpulse { 50% { box-shadow: inset 0 0 0 5px #7dff9a, 0 0 28px #7dff9acc; } }
.hint-line { text-align: center; font-weight: 800; font-size: 14px; color: #7dff9a; margin: 2px 0 4px; text-shadow: 0 0 10px #7dff9a66; }
.perk.hint-btn { border-color: #7dff9a88; }
.perk.hint-btn .pn { margin-left: 6px; background: #7dff9a; color: #0d1a10; border-radius: 999px; min-width: 18px; padding: 0 5px; font-size: 12px; font-weight: 900; }
.perk.hint-btn[disabled] { opacity: .5; }
