:root {
  --bg: #f7e9a8; --bg2: #f1dd86; --card: #fffbe6; --ink: #3b2a1a; --soft: #8a7352;
  --coral: #ff6b57; --green: #34b36f; --blue: #4a90d9; --gold: #ffc93c;
  --r: 18px; --shadow: 0 5px 0 var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'Fredoka', system-ui, sans-serif; color: var(--ink); font-size: 18px;
  background: var(--bg);
  background-image: radial-gradient(var(--bg2) 2px, transparent 2px); background-size: 28px 28px;
}
header { display: flex; justify-content: space-between; align-items: center; padding: 14px 24px; max-width: 1000px; margin: 0 auto; }
.logo { font-size: 28px; font-weight: 700; letter-spacing: -.5px; }
.logo span { color: var(--coral); }
.who { display: flex; gap: 12px; align-items: center; }
main { max-width: 1000px; margin: 0 auto; padding: 12px 20px 48px; display: flex; flex-direction: column; align-items: center; }
h1 { font-size: 40px; margin: 8px 0 4px; text-align: center; }
h2 { margin: 0 0 14px; font-size: 26px; }
.sub { color: var(--soft); margin: 0 0 24px; text-align: center; }

.card { background: var(--card); border: 3px solid var(--ink); border-radius: var(--r); box-shadow: var(--shadow); padding: 24px; width: 100%; max-width: 480px; }
.card.wide { max-width: 640px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }

.btn {
  font: inherit; font-weight: 600; color: var(--ink); background: var(--gold); cursor: pointer;
  border: 3px solid var(--ink); border-radius: 14px; padding: 12px 22px; box-shadow: 0 4px 0 var(--ink);
  transition: transform .08s, box-shadow .08s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--ink); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.coral { background: var(--coral); color: #fff; }
.btn.green { background: var(--green); color: #fff; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.small { padding: 5px 12px; font-size: 15px; border-width: 2px; box-shadow: 0 3px 0 var(--ink); }
.btn.big { font-size: 22px; padding: 16px 28px; }
.btn:disabled { opacity: .5; cursor: default; pointer-events: none; }

input[type=text], input[type=password] {
  font: inherit; width: 100%; padding: 12px 14px; border: 3px solid var(--ink); border-radius: 12px; background: #fff; color: var(--ink);
}
input:focus { outline: 3px solid var(--gold); }
label.l { font-weight: 600; font-size: 15px; color: var(--soft); text-transform: uppercase; letter-spacing: .06em; }
.err { color: var(--coral); font-weight: 600; min-height: 1.3em; margin: 0; }
.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tabs .btn { flex: 1; box-shadow: none; background: transparent; }
.tabs .btn.on { background: var(--gold); box-shadow: 0 4px 0 var(--ink); }

/* mode cards */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; width: 100%; max-width: 640px; }
@media (max-width: 560px) { .modes { grid-template-columns: 1fr; } }
.mode { text-align: center; cursor: pointer; transition: transform .1s; padding: 32px 20px; }
.mode:hover { transform: translateY(-6px) rotate(-1deg); }
.mode .ico { font-size: 56px; line-height: 1; }
.mode h2 { margin: 12px 0 4px; }
.mode p { margin: 0; color: var(--soft); }

/* segmented chips */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font: inherit; font-weight: 600; cursor: pointer; padding: 8px 16px; border: 3px solid var(--ink); border-radius: 999px; background: #fff; color: var(--ink); }
.chip.on { background: var(--ink); color: var(--gold); }
.chip:disabled { cursor: default; }
.chip:disabled:not(.on) { opacity: .45; }

/* lobbies */
.lobby { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border: 3px solid var(--ink); border-radius: 14px; background: #fff; }
.lobby small { color: var(--soft); display: block; }
.empty { text-align: center; color: var(--soft); padding: 18px; }
.code { font-size: 44px; font-weight: 700; letter-spacing: .12em; text-align: center; background: var(--gold); border: 3px dashed var(--ink); border-radius: 14px; padding: 4px; }
.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.plist li { display: flex; justify-content: space-between; padding: 10px 14px; border: 3px solid var(--ink); border-radius: 12px; background: #fff; font-weight: 600; }
.plist li.me { background: #fff2b8; }
.badge { background: var(--coral); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 99px; margin-left: 8px; vertical-align: middle; }

/* game */
.game { display: flex; gap: 24px; align-items: flex-start; justify-content: center; flex-wrap: wrap; width: 100%; }
.play { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.hud { display: flex; gap: 14px; width: 100%; align-items: stretch; }
.stat { flex: 1; background: var(--card); border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 4px 0 var(--ink); padding: 6px 14px; text-align: center; position: relative; }
.stat small { display: block; font-size: 12px; color: var(--soft); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.stat b { font-size: 30px; line-height: 1.1; display: inline-block; }
.stat.low b { color: var(--coral); animation: pulse .5s infinite alternate; }
.bump { animation: bump .4s; }
.drop { animation: shake .4s; color: var(--coral); }
.float { position: absolute; right: 10px; top: 0; font-weight: 700; animation: floatup .9s forwards; pointer-events: none; }
.bar { width: 100%; height: 16px; border: 3px solid var(--ink); border-radius: 99px; background: #fff; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--green); transition: width .25s linear, background .3s; }
.bar i.low { background: var(--coral); }

.board { --n: 9; display: grid; grid-template-columns: repeat(var(--n), 1fr); grid-template-rows: repeat(var(--n), 1fr); border: 4px solid var(--ink); border-radius: 12px; overflow: hidden; background: var(--ink); gap: 1px; width: min(92vw, 520px); aspect-ratio: 1; box-shadow: var(--shadow); }
.board.n4 { width: min(86vw, 400px); }
.cell { min-width: 0; min-height: 0; background: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: clamp(18px, 5vw, 30px); cursor: pointer; user-select: none; transition: background .12s; }
.board.n4 .cell { font-size: clamp(26px, 8vw, 44px); }
.cell.given { background: #f5ecc2; font-weight: 700; cursor: default; }
.cell.filled { color: var(--blue); }
.cell.rel { background: #fff4c4; }
.cell.same { background: #ffe38a; }
.cell.sel { background: var(--gold); outline: 3px solid var(--ink); outline-offset: -3px; z-index: 1; }
.cell.edge-r { margin-right: 2px; } .cell.edge-b { margin-bottom: 2px; }
.cell.pop { animation: pop .35s; }
.cell.bad { animation: shake .4s; background: #ffb4aa !important; }
.board.win { animation: win .6s; }

.pad { display: grid; gap: 8px; width: min(92vw, 520px); }
.pad button { font: inherit; font-weight: 700; font-size: 24px; padding: 8px 0; cursor: pointer; background: var(--card); color: var(--ink); border: 3px solid var(--ink); border-radius: 12px; box-shadow: 0 4px 0 var(--ink); }
.pad button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.side { width: 240px; }
.side .card { padding: 16px; }
.side h3 { margin: 0 0 10px; }

.podium { font-size: 64px; text-align: center; }
.big-score { font-size: 64px; font-weight: 700; text-align: center; color: var(--coral); line-height: 1; }

#toast { position: fixed; left: 50%; top: 24px; transform: translate(-50%, -150%); opacity: 0; background: var(--ink); color: var(--gold); padding: 12px 22px; border-radius: 99px; font-weight: 600; transition: transform .3s; z-index: 9; }
#toast.show { transform: translate(-50%, 0); opacity: 1; }
#toast.good { background: var(--green); color: #fff; }

@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.35); color: var(--green); } 100% { transform: scale(1); } }
@keyframes pulse { to { transform: scale(1.12); } }
@keyframes floatup { to { transform: translateY(-28px); opacity: 0; } }
@keyframes win { 0% { transform: scale(1); } 40% { transform: scale(1.04) rotate(.6deg); } 100% { transform: scale(1); } }

.icon { display: inline-flex; vertical-align: middle; }
.icon svg { width: 1em; height: 1em; }
.mode .ico { width: 84px; height: 84px; margin: 0 auto; border: 3px solid var(--ink); border-radius: 50%; background: var(--gold); display: flex; align-items: center; justify-content: center; font-size: 46px; box-shadow: 0 4px 0 var(--ink); }
.mode:nth-child(2) .ico { background: var(--coral); color: #fff; }
.podium { color: var(--coral); }
.icon.inl { font-size: .9em; margin-left: 2px; color: var(--green); }
.rank { display: inline-flex; width: 26px; height: 26px; align-items: center; justify-content: center; border-radius: 50%; background: var(--ink); color: var(--gold); font-size: 14px; margin-right: 8px; }

.sticker { position: fixed; left: 0; top: 0; z-index: 5; pointer-events: none; user-select: none; filter: drop-shadow(0 6px 0 rgba(59,42,26,.25)); will-change: transform, opacity; }

/* settings */
#settingsBtn { display: inline-flex; align-items: center; font-size: 20px; padding: 4px 9px; }
.overlay { position: fixed; inset: 0; background: rgba(59, 42, 26, .45); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.modal { max-width: 460px; max-height: 90vh; overflow: auto; }
.opt { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 10px 14px; border: 3px solid var(--ink); border-radius: 14px; background: #fff; }
.opt.col { flex-direction: column; align-items: flex-start; }
.opt small { display: block; color: var(--soft); font-size: 14px; line-height: 1.25; margin-top: 2px; }
.switch { flex: none; width: 56px; height: 32px; padding: 0; border: 3px solid var(--ink); border-radius: 99px; background: #e6dcb4; cursor: pointer; position: relative; transition: background .15s; }
.switch i { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); transition: transform .15s; }
.switch.on { background: var(--green); }
.switch.on i { transform: translateX(24px); background: #fff; }
.switch:focus-visible, .chip:focus-visible { outline: 3px solid var(--coral); outline-offset: 2px; }

/* combo bar + power-ups */
.boardwrap { position: relative; }
.bwin { position: relative; }
.combo { position: absolute; right: calc(100% + 16px); top: 0; bottom: 0; width: 56px; display: flex; flex-direction: column; align-items: center; gap: 10px; --p: 0; --c: var(--green); }
.combo > small { font-size: 12px; font-weight: 600; color: var(--soft); text-transform: uppercase; letter-spacing: .08em; }
.combo .lvl { min-width: 56px; text-align: center; font-size: 26px; font-weight: 700; line-height: 1; padding: 6px 8px; background: var(--card); border: 3px solid var(--ink); border-radius: 12px; box-shadow: 0 3px 0 var(--ink); }
.combo[data-l="1"] { --c: var(--green); } .combo[data-l="2"] { --c: var(--gold); } .combo[data-l="3"] { --c: #ff9f43; } .combo[data-l="4"] { --c: var(--coral); } .combo[data-l="5"] { --c: #e0457b; } .combo[data-l="6"] { --c: #c13fb5; } .combo[data-l="7"] { --c: #8e4fd8; } .combo[data-l="8"] { --c: #5b62e8; } .combo[data-l="9"] { --c: #2aa5d8; } .combo[data-l="10"] { --c: linear-gradient(to top, #ffc93c, #ff6b57, #e0457b, #8e4fd8); }
.track { flex: 1; width: 28px; min-height: 60px; border: 3px solid var(--ink); border-radius: 99px; background: #fff; position: relative; overflow: hidden; box-shadow: 0 3px 0 var(--ink); }
.track i { position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--p) * 100%); background: var(--c); transition: height .2s linear, background .3s; }
.track::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(to top, transparent 0 calc(11.111% - 2px), rgba(59, 42, 26, .35) calc(11.111% - 2px) 11.111%); }
.slots { display: flex; flex-direction: column; gap: 8px; }
.slot { width: 52px; height: 52px; padding: 0; border-radius: 50%; border: 3px dashed rgba(59, 42, 26, .3); display: flex; align-items: center; justify-content: center; font-size: 26px; }
button.slot.full { border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); color: #fff; cursor: pointer; animation: pulse .7s infinite alternate; }
.slot.bomb { background: var(--coral); } .slot.freeze { background: var(--blue); } .slot.smoke { background: #8a7352; }
.flyer { position: fixed; left: 0; top: 0; z-index: 30; width: 52px; height: 52px; border: 3px solid var(--ink); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 26px; color: #fff; pointer-events: none; }
.flyer.bomb { background: var(--coral); } .flyer.freeze { background: var(--blue); } .flyer.smoke { background: #8a7352; }
.ice { position: absolute; inset: 0; z-index: 4; border-radius: 12px; pointer-events: none; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #1d4e89; font-weight: 700; font-size: 34px; border: 4px solid #cfe9ff;
  background: radial-gradient(circle at 25% 20%, rgba(255, 255, 255, .8), transparent 35%), radial-gradient(circle at 80% 75%, rgba(255, 255, 255, .6), transparent 30%), rgba(150, 205, 255, .72); backdrop-filter: blur(3px); animation: icein .25s; }
.ice b { font-size: 56px; line-height: 1; }
.board.boom { animation: boom .6s; }
@keyframes icein { from { opacity: 0; transform: scale(1.06); } }
@keyframes puff { from { transform: translate(-3%, 2%) scale(1); } to { transform: translate(3%, -2%) scale(1.06); } }
@keyframes boom { 0%, 100% { transform: none; box-shadow: var(--shadow); } 10% { transform: translate(-9px, 3px) rotate(-1.2deg); box-shadow: 0 0 0 8px var(--coral); } 30% { transform: translate(8px, -3px) rotate(1deg); } 50% { transform: translate(-6px, 2px); } 70% { transform: translate(4px, -1px); } }
@media (max-width: 960px) {
  .combo { position: static; flex-direction: row; width: 100%; height: auto; margin-bottom: 12px; align-items: center; }
  .combo > small { display: none; }
  .combo .lvl { min-width: 0; }
  .track { height: 26px; width: auto; min-height: 0; flex: 1; }
  .track i { top: 0; right: auto; height: auto; width: calc(var(--p) * 100%); transition-property: width, background; }
  .track::after { background: repeating-linear-gradient(to right, transparent 0 calc(11.111% - 2px), rgba(59, 42, 26, .35) calc(11.111% - 2px) 11.111%); }
  .slots { flex-direction: row; flex: none; }
  .slot { width: 44px; height: 44px; font-size: 22px; flex: none; }
  .boardwrap { display: flex; flex-direction: column; }
}

/* cartoon smoke cloud */
.cloud { position: absolute; z-index: 4; pointer-events: none; transition: opacity .9s; filter: drop-shadow(0 6px 0 rgba(59, 42, 26, .25)); }
.cloud.fade { opacity: 0; }
.cloud .sl { position: absolute; inset: 0; }
.cloud .p, .cloud .fr, .cloud .w { position: absolute; }
.cloud .p, .cloud .w { border-radius: 50%; }
.cloud .p { animation: pop .45s cubic-bezier(.3, 1.6, .5, 1) var(--pd) backwards, billow var(--bd) ease-in-out calc(var(--pd) + .45s) infinite alternate; }
.cloud .w { animation: rise 2.4s ease-out infinite backwards; }
.cloud .ink .p, .cloud .ink .fr, .cloud .ink .w { background: var(--ink); }
.cloud .fill .p, .cloud .fill .fr, .cloud .fill .w { background: radial-gradient(circle at 35% 30%, #fff 0, #ece8e1 55%, #cdc8bf 100%); }
@keyframes pop { from { transform: scale(0); } }
@keyframes billow { from { transform: translate(-2px, 2px) scale(.94); } to { transform: translate(2px, -3px) scale(1.07); } }
@keyframes rise { 0% { transform: translateY(0) scale(.4); opacity: 0; } 20% { opacity: 1; } 100% { transform: translateY(-80px) scale(1.1); opacity: 0; } }

/* "Board animations" off: no motion, but wrong entries still flash red (colour, not movement) */
.still .cell.pop, .still .cell.bad, .still .board.win, .still .board.boom, .still .bump, .still .drop { animation: none; }

html, body { overflow-x: hidden; }   /* smoke cloud overhangs the board; never let it cause sideways scroll */

.stat.primary { background: #fff0a8; border-color: var(--ink); outline: 3px solid var(--gold); outline-offset: 2px; }

/* guided tutorial */
#tut { position: fixed; inset: 0; z-index: 40; cursor: pointer; }
.tut-skip { position: absolute; top: 14px; right: 16px; }
.tut-box { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); width: min(780px, calc(100vw - 24px)); display: flex; align-items: flex-end; gap: 16px;
  transition: bottom .6s cubic-bezier(.3, 1.2, .5, 1), transform .6s cubic-bezier(.3, 1.2, .5, 1); }
#tut.intro .tut-box { bottom: 50%; transform: translate(-50%, 50%) scale(1.1); }
.tut-char { width: clamp(100px, 22vw, 170px); flex: none; filter: drop-shadow(0 6px 0 rgba(59, 42, 26, .25)); transform-origin: 50% 100%; animation: bob 2.2s ease-in-out infinite; }
.tut-char.swap { animation: swappop .45s cubic-bezier(.3, 1.6, .5, 1), bob 2.2s ease-in-out .45s infinite; }
.tut-char.hit { animation: shake .5s; }
.tut-bubble { position: relative; flex: 1; background: var(--card); border: 3px solid var(--ink); border-radius: 20px; box-shadow: var(--shadow); padding: 18px 44px 16px 20px; min-height: 100px; margin-bottom: 8px; }
.tut-bubble::before { content: ''; position: absolute; left: -13px; bottom: 28px; width: 22px; height: 22px; background: var(--card); border-left: 3px solid var(--ink); border-bottom: 3px solid var(--ink); transform: rotate(45deg); }
.tut-name { position: absolute; top: -16px; left: 18px; background: var(--coral); color: #fff; border: 3px solid var(--ink); border-radius: 99px; padding: 0 12px; font-size: 14px; font-weight: 700; letter-spacing: .04em; }
.tut-text { margin: 4px 0 0; font-size: clamp(18px, 2.4vw, 24px); font-weight: 500; line-height: 1.3; min-height: 2.6em; }
.tut-next { position: absolute; right: 14px; bottom: 8px; font-size: 24px; opacity: 0; animation: nudge .7s ease-in-out infinite alternate; }
.tut-next.on { opacity: 1; }
.spot { outline: 4px solid var(--coral); outline-offset: 5px; border-radius: 14px; animation: spotpulse .9s ease-in-out infinite alternate; }
.game.tut-enter { animation: icein .5s; }
.timeup { position: absolute; inset: 0; z-index: 4; display: flex; align-items: center; justify-content: center; border-radius: 12px; pointer-events: none; font-size: 46px; font-weight: 700; color: #fff; text-shadow: 0 4px 0 var(--ink); background: rgba(59, 42, 26, .55); animation: icein .35s; }
.plist li.winner { background: var(--gold); }
.still .tut-char, .still .tut-next, .still .spot { animation: none; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-8px) rotate(2deg); } }
@keyframes swappop { 0% { transform: scale(.6) rotate(-12deg); } 60% { transform: scale(1.15) rotate(3deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes nudge { to { transform: translateY(5px); } }
@keyframes spotpulse { to { outline-offset: 9px; } }

/* cartoon ice sheet (overrides the plain frosted box above) */
.ice { display: block; overflow: hidden; border: 4px solid var(--ink); background: radial-gradient(circle at 25% 20%, rgba(255, 255, 255, .75), transparent 38%), radial-gradient(circle at 80% 78%, rgba(255, 255, 255, .55), transparent 32%), repeating-linear-gradient(115deg, rgba(255, 255, 255, .13) 0 10px, transparent 10px 24px), rgba(140, 200, 255, .74); backdrop-filter: blur(3px); }
.ice > * { position: absolute; pointer-events: none; }
.ice .glint { inset: 0; background: linear-gradient(115deg, transparent 42%, rgba(255, 255, 255, .7) 50%, transparent 58%) 0 0 / 260% 100%; animation: glint 2.6s ease-in-out infinite; }
.ice .teeth { left: 0; right: 0; height: 38px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 40' preserveAspectRatio='none'%3E%3Cpath d='M0 0H48L41 18 34 8 26 38 18 10 10 22Z' fill='%23eaf7ff' stroke='%233b2a1a' stroke-width='3' stroke-linejoin='round'/%3E%3C/svg%3E") repeat-x 0 0 / 48px 38px; animation: drip 3s ease-in-out infinite alternate; }
.ice .teeth.top { top: -3px; }
.ice .teeth.bot { bottom: -3px; transform: scaleY(-1); animation: none; }
.ice .crys { aspect-ratio: 1; transform: rotate(var(--r)); animation: pop .5s cubic-bezier(.3, 1.6, .5, 1) var(--d) backwards, wob 2.6s ease-in-out calc(var(--d) + .5s) infinite alternate; filter: drop-shadow(0 4px 0 rgba(59, 42, 26, .25)); }
.ice .crys svg, .ice .spark svg { display: block; width: 100%; height: 100%; }
.ice .spark { aspect-ratio: 1; animation: twinkle 1.8s ease-in-out infinite; }
.ice .flake { top: -12%; color: #fff; filter: drop-shadow(0 2px 0 rgba(59, 42, 26, .3)); animation: snow 5s linear infinite; }
.ice .ice-text { inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-shadow: 0 3px 0 rgba(255, 255, 255, .8); }
.ice.thaw { animation: thaw .7s ease-in forwards; }
.still .ice, .still .ice > *, .still .ice .crys { animation: none; }
@keyframes glint { from { background-position: 130% 0; } to { background-position: -30% 0; } }
@keyframes drip { from { transform: translateY(-2px); } to { transform: translateY(3px); } }
@keyframes wob { from { transform: rotate(calc(var(--r) - 3deg)); } to { transform: rotate(calc(var(--r) + 3deg)); } }
@keyframes twinkle { 0%, 100% { transform: scale(.2) rotate(0); opacity: .2; } 50% { transform: scale(1) rotate(45deg); opacity: 1; } }
@keyframes snow { from { transform: translateY(0) rotate(0); } to { transform: translateY(125vh) rotate(200deg); } }
@keyframes thaw { 0% { transform: none; } 15% { transform: translate(-4px, 1px); } 30% { transform: translate(4px, -1px); filter: brightness(1.15); } 45% { transform: translate(-3px, 0); } 100% { transform: translateY(8px); opacity: 0; filter: brightness(1.3) blur(2px); } }

/* tutorial: less clutter. The overlay blocks the header buttons anyway, so hide them; on narrow screens the scoreboard sits behind the dialog, so hide it and fade the bottom. */
.tutoring #logout, .tutoring #settingsBtn { display: none; }
@media (max-width: 960px) {
  .tutoring .side { display: none; }
  #tut:not(.intro)::before { content: ''; position: fixed; left: 0; right: 0; bottom: 0; height: min(300px, 38vh); pointer-events: none; background: linear-gradient(to top, var(--bg) 60%, rgba(247, 233, 168, 0)); }
}

/* cartoon bomb blast */
.blast { position: fixed; z-index: 35; width: 0; height: 0; pointer-events: none; }
.blast .burst { position: absolute; left: calc(var(--s) * -.3); top: calc(var(--s) * -.3); width: calc(var(--s) * .6); height: calc(var(--s) * .6); filter: drop-shadow(0 6px 0 rgba(59, 42, 26, .25)); animation: burst .65s cubic-bezier(.2, 1.4, .4, 1) forwards; }
.blast .burst svg { display: block; width: 100%; height: 100%; }
.blast .spark { position: absolute; left: calc(var(--s) * -.03); top: calc(var(--s) * -.03); width: calc(var(--s) * .06); height: calc(var(--s) * .06); border-radius: 50%; background: var(--gold); border: 3px solid var(--ink); animation: sparkfly .7s ease-out forwards; }
.fall { position: fixed; z-index: 34; display: flex; align-items: center; justify-content: center; font-weight: 600; color: var(--blue); pointer-events: none; animation: fall .95s cubic-bezier(.5, 0, .9, .6) forwards; }
body.rumble header, body.rumble main { animation: rumble .45s; }
.board.boom { animation: boomflash .6s; }   /* the page rumble does the shaking now; the board just flashes */
.still .blast, .still .fall { display: none; }
@keyframes burst { 0% { transform: scale(.1) rotate(-20deg); opacity: 1; } 28% { transform: scale(1.05) rotate(4deg); opacity: 1; } 62% { transform: scale(1.12) rotate(6deg); opacity: 1; } 100% { transform: scale(1.3) rotate(10deg); opacity: 0; } }
@keyframes sparkfly { from { transform: translate(0, 0) scale(1); opacity: 1; } to { transform: translate(var(--x), var(--y)) scale(.4); opacity: 0; } }
@keyframes fall { 0% { transform: translate(0, 0) rotate(0); } 15% { transform: translate(calc(var(--dx) * .3), -14px) rotate(calc(var(--rot) * .2)); } 100% { transform: translate(var(--dx), 170px) rotate(var(--rot)); opacity: 0; } }
@keyframes rumble { 0%, 100% { transform: none; } 15% { transform: translate(-6px, 3px); } 30% { transform: translate(6px, -3px); } 45% { transform: translate(-4px, 2px); } 60% { transform: translate(3px, -1px); } }
@keyframes boomflash { 0%, 100% { box-shadow: var(--shadow); } 15% { box-shadow: 0 0 0 8px var(--coral); } }

/* leaderboard */
.modes .lbbtn { grid-column: 1 / -1; max-width: none; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 10px 18px; box-shadow: 0 4px 0 var(--ink); }
.modes .lbbtn:hover { transform: translateY(-3px); }
.lbbtn .icon { font-size: 26px; color: var(--coral); }
.lbbtn b { font-size: 20px; }
.lbbtn span:last-child { color: var(--soft); font-size: 15px; }
.lbrow { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 3px solid var(--ink); border-radius: 14px; background: #fff; }
.lbrow.me { background: #fff2b8; }
.lbrank { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--ink); background: var(--ink); color: var(--gold); display: flex; align-items: center; justify-content: center; font-weight: 700; }
.lbrank.r1 { background: var(--gold); color: var(--ink); } .lbrank.r2 { background: #dfe3e8; color: var(--ink); } .lbrank.r3 { background: #e7a96b; color: var(--ink); }
.lbmid { flex: 1; min-width: 0; }
.lbmid b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lbtags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.lbtag { font-size: 13px; font-weight: 600; padding: 0 9px; border: 2px solid var(--ink); border-radius: 99px; background: var(--bg); }
.lbscore { flex: none; font-size: 26px; font-weight: 700; color: var(--coral); }

/* a number you just typed, not yet confirmed by the server */
.cell.pending { color: var(--soft); }

/* get-ready countdown: every device generates the round's boards from the seed while this shows */
.countdown { position: absolute; inset: 0; z-index: 5; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(247, 233, 168, .85); backdrop-filter: blur(4px); border: 4px solid var(--ink); pointer-events: none; }
.countdown b { font-size: min(30vw, 150px); line-height: 1; color: var(--coral); text-shadow: 0 6px 0 var(--ink); animation: cdpop 1s ease-out infinite; }
.countdown span { font-weight: 600; font-size: 20px; color: var(--soft); }
@keyframes cdpop { 0% { transform: scale(1.35); opacity: .3; } 35% { transform: scale(1); opacity: 1; } 100% { transform: scale(.95); } }
.still .countdown b { animation: none; }
.countdown.tally b { font-size: min(14vw, 64px); }

/* handicap box in the lobby */
.hc { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.hc input { width: 70px; font: inherit; padding: 2px 6px; border: 2px solid var(--ink); border-radius: 8px; text-align: right; background: #fff; color: var(--ink); }

/* "Time's up!" / "Finished!" banner: one pop when it appears, then a very slow breath until the results arrive (no per-second pulsing) */
.countdown.tally b { animation: tallypop .6s cubic-bezier(.2, 1.3, .4, 1) 1, breathe 5s ease-in-out .6s infinite alternate; }
@keyframes tallypop { 0% { transform: scale(1.35); opacity: .2; } 60% { transform: scale(.98); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
@keyframes breathe { from { transform: scale(1); } to { transform: scale(1.035); } }
.still .countdown.tally b { animation: none; }

/* starting a game: skeleton of the game screen under a blurred glass layer with a loading bar */
.game.skel .play { position: relative; }
.game.skel .cell { animation: skelpulse 1.6s ease-in-out infinite; }
.game.skel .pad button, .game.skel .cell { pointer-events: none; }
.glass { position: absolute; inset: -14px; z-index: 6; display: flex; align-items: center; justify-content: center; border-radius: 26px; background: rgba(255, 251, 230, .42); backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px); animation: icein .2s; }
.glass-box { min-width: 230px; padding: 18px 26px 22px; text-align: center; background: var(--card); border: 3px solid var(--ink); border-radius: 18px; box-shadow: var(--shadow); }
.glass-box b { display: block; margin-bottom: 12px; font-size: 24px; }
.bar.load i { width: 40%; background: var(--coral); animation: loadslide 1.1s ease-in-out infinite alternate; }
.still .game.skel .cell, .still .bar.load i, .still .glass { animation: none; }
@keyframes skelpulse { 0%, 100% { background: #fff; } 50% { background: #fff4c4; } }
@keyframes loadslide { from { transform: translateX(0); } to { transform: translateX(150%); } }
