/* ── CANDY ACCENTS ──────────────────────────────────────────────────────── */
:root {
  --candy-pink:   #f06d96;
  --candy-yellow: #f5c947;
  --candy-orange: #ee9355;
  --candy-mint:   #4cd1b0;
  --candy-blue:   #5aa8e8;
  --candy-purple: #9b78e0;
  --candy-red:    #e8606e;

  /* ── DARK-ONLY TOKENS — charcoal / near-black, intentionally NOT the purple Plinko look ── */
  --cream:     #1b1c20;
  --paper:     #232529;
  --paper-2:   #2b2d33;
  --ink:       #ffffff;
  --ink-soft:  #b3b7c1;
  --outline-c: #3a3d45;
  --drop-c:    #050507;

  --bg-1: #1d1e23;
  --bg-2: #16171b;
  --bg-3: #191a1f;
  --bg-4: #0e0f12;
  --bg-5: #060608;

  --board-bg-1: #161719;
  --board-bg-2: #0a0a0c;
  --board-edge: #34373e;
  --cell-bg:    rgba(255,255,255,0.04);
  --cell-edge:  rgba(255,255,255,0.06);

  --tab-active: #f0b94a;

  --r:    16px;
  --r-lg: 22px;
  --r-xl: 28px;

  --outline: 3px solid var(--outline-c);
  --drop:    0 4px 0 var(--drop-c);
  --drop-sm: 0 3px 0 var(--drop-c);
}

/* ── RESET ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; background: #0e0a1e; }
body {
  background:
    radial-gradient(ellipse at 20% 0%,  var(--bg-1) 0%, transparent 55%),
    radial-gradient(ellipse at 100% 30%, var(--bg-2) 0%, transparent 60%),
    radial-gradient(ellipse at 40% 100%, var(--bg-3) 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-4) 0%, var(--bg-5) 100%);
  color: var(--ink);
  font-family: 'Fredoka', system-ui, sans-serif;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.3;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
img, svg, canvas { -webkit-user-drag: none; user-drag: none; }
/* universal text stroking for the chunky dark-mode look */
.hud-value, .upg-val, .stats-val, .tab-btn, .board-pill, .upg-name, .upg-next, .hud-label, .stats-label {
  paint-order: stroke fill;
}

/* ── LOADER ─────────────────────────────────────────────────────────────── */
#loader {
  position: fixed; inset: 0; z-index: 9999;
  background:
    radial-gradient(ellipse at 30% 30%, var(--bg-1) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 70%, var(--bg-2) 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-4) 0%, var(--bg-5) 100%);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.5s;
}
.loader-inner { text-align: center; }
.loader-logo {
  margin-bottom: 26px;
  animation: loader-logo-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.loader-logo svg {
  width: min(300px, 72vw); height: auto; display: block;
  filter: drop-shadow(0 6px 0 var(--drop-c)) drop-shadow(0 10px 16px rgba(0,0,0,0.55));
}
@keyframes loader-logo-pop {
  0%   { transform: scale(0.6) translateY(10px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
.loader-bar-wrap {
  width: 240px; height: 14px;
  background: var(--paper);
  border: var(--outline);
  border-radius: 999px;
  overflow: hidden;
  margin: 0 auto;
  box-shadow: var(--drop);
}
.loader-bar-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--candy-pink), var(--candy-yellow), var(--candy-mint));
  transition: width 0.6s ease;
}

/* ── ROOT LAYOUT ────────────────────────────────────────────────────────── */
#root {
  display: flex; flex-direction: column;
  height: 100dvh; overflow: hidden;
  /* respect the device safe area (notch / rounded corners / home bar) */
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  gap: 10px;
}

/* ── HUD ────────────────────────────────────────────────────────────────── */
.hud {
  flex-shrink: 0;
  height: 76px;
  background:
    linear-gradient(180deg, color-mix(in srgb, #fff 4%, var(--paper)) 0%, var(--paper) 55%, color-mix(in srgb, #000 6%, var(--paper)) 100%);
  border: var(--outline);
  border-radius: var(--r-lg);
  box-shadow: var(--drop), inset 0 1px 0 rgba(255,255,255,0.10), inset 0 -2px 0 rgba(0,0,0,0.25);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
}
.hud-left  { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hud-right { display: flex; align-items: center; gap: 10px; min-width: 0; flex-shrink: 0; }
.hud-block {
  display: flex; align-items: center; gap: 10px;
  background: var(--cream);
  border: 2.5px solid var(--outline-c);
  border-radius: 999px;
  padding: 5px 16px 5px 5px;
  box-shadow: var(--drop-sm);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.hud-block-icon {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 3px solid var(--outline-c);
  flex-shrink: 0;
  font-size: 18px;
}
.hud-block-icon svg { width: 76%; height: 76%; display: block; filter: drop-shadow(0 1.5px 0 rgba(0,0,0,0.35)); }

/* shimmer applied to the prominent "Score" pill */
.hud-feature::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  width: 60%;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.22) 50%, transparent 100%);
  transform: translateX(-200%);
  animation: coin-shine 5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes coin-shine {
  0%, 75%   { transform: translateX(-200%); }
  90%, 100% { transform: translateX(280%); }
}

/* score pill (sum of tile values) — teal sigma + bob + cyan shine */
.hud-score {
  background: linear-gradient(180deg, color-mix(in srgb, #2bb8e8 18%, var(--cream)) 0%, var(--cream) 100%);
  border-color: color-mix(in srgb, #2bb8e8 55%, var(--outline-c));
  box-shadow: var(--drop-sm);
}
.hud-score .hud-block-icon {
  background: radial-gradient(circle at 30% 30%, #b8f0ff 0%, #4cd1ee 35%, #1a7ec0 100%);
  animation: score-bob 2.4s ease-in-out infinite;
  box-shadow:
    inset 0 -3px 0 rgba(0,0,0,0.28),
    inset 0 2px 0 rgba(255,255,255,0.55);
}
@keyframes score-bob {
  0%, 100% { transform: rotate(-3deg) translateY(0); }
  50%      { transform: rotate(3deg) translateY(-2px); }
}
.hud-score .hud-value { font-size: 26px; letter-spacing: 1.5px; color: #8be7ff; -webkit-text-stroke: 1.6px var(--drop-c); }
.hud-score .hud-label { font-size: 10px; letter-spacing: 2px; }
.hud-feature::before {
  background: linear-gradient(90deg, transparent 0%, rgba(140,230,255,0.30) 50%, transparent 100%);
}

/* best-tile pill — pink trophy */
.hud-best {
  background: linear-gradient(180deg, color-mix(in srgb, #ff5d8f 16%, var(--cream)) 0%, var(--cream) 100%);
  border-color: color-mix(in srgb, #ff5d8f 55%, var(--outline-c));
  box-shadow: var(--drop-sm);
}
.hud-best .hud-block-icon {
  background: radial-gradient(circle at 30% 30%, #ffd0e0 0%, #ff5d8f 45%, #b53875 100%);
  box-shadow:
    inset 0 -3px 0 rgba(0,0,0,0.28),
    inset 0 2px 0 rgba(255,255,255,0.55);
}
.hud-best .hud-value { color: #ffb6cd; -webkit-text-stroke: 1.5px var(--drop-c); }

/* coins pill — premium gold */
.hud-coins {
  background: linear-gradient(180deg, color-mix(in srgb, #ffa844 16%, var(--cream)) 0%, var(--cream) 100%);
  border-color: color-mix(in srgb, #ffa844 55%, var(--outline-c));
  box-shadow: var(--drop-sm);
}
.hud-coins .hud-block-icon {
  background: radial-gradient(circle at 30% 30%, #fff5d8 0%, #ffd970 35%, #ff9920 100%);
  box-shadow:
    inset 0 -3px 0 rgba(0,0,0,0.28),
    inset 0 2px 0 rgba(255,255,255,0.65);
}
.hud-coins .hud-value { color: #ffd970; -webkit-text-stroke: 1.5px var(--drop-c); }

/* gems pill — premium purple */
.hud-gems {
  background: linear-gradient(180deg, color-mix(in srgb, #9b5fff 18%, var(--cream)) 0%, var(--cream) 100%);
  border-color: color-mix(in srgb, #9b5fff 55%, var(--outline-c));
  box-shadow: var(--drop-sm);
}
.hud-gems .hud-block-icon {
  background: radial-gradient(circle at 30% 30%, #e8d6ff 0%, #b78dff 45%, #6f3bd8 100%);
  box-shadow:
    inset 0 -3px 0 rgba(0,0,0,0.28),
    inset 0 2px 0 rgba(255,255,255,0.50);
}
.hud-gems .hud-value { color: #c8a4ff; -webkit-text-stroke: 1.5px var(--drop-c); }

.hud-score.bump .hud-value,
.hud-best.bump  .hud-value,
.hud-coins.bump .hud-value,
.hud-gems.bump  .hud-value {
  animation: hud-bump 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes hud-bump {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.24); color: #ffe27a; }
  100% { transform: scale(1); }
}
.hud-block-text { display: flex; flex-direction: column; line-height: 1; }
.hud-label {
  font-family: 'Fredoka', sans-serif;
  font-size: 9px; letter-spacing: 1.5px;
  color: var(--ink-soft);
  text-transform: uppercase;
  font-weight: 700;
}
.hud-value {
  font-family: 'Luckiest Guy', cursive;
  font-size: 21px; letter-spacing: 1px;
  color: var(--ink);
  margin-top: 2px;
  -webkit-text-stroke: 1.4px var(--drop-c);
  display: inline-block;
  transform-origin: center;
}

.hud-title {
  display: flex; align-items: center;
  flex-shrink: 0;
  padding: 0 2px;
}
.hud-title svg {
  height: 46px; width: auto; display: block;
  filter: drop-shadow(0 3px 0 var(--drop-c)) drop-shadow(0 5px 8px rgba(0,0,0,0.5));
}

.hud-mute, .hud-reset, .hud-settings {
  background: var(--paper);
  border: 2.5px solid var(--outline-c);
  color: var(--ink);
  border-radius: 50%;
  width: 42px; height: 42px;
  cursor: pointer;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.1s;
  box-shadow: var(--drop-sm);
  padding: 0;
}
.hud-mute svg, .hud-reset svg, .hud-settings svg { width: 50%; height: 50%; }
.hud-settings:hover { filter: brightness(1.06); }
.hud-settings:active { transform: translateY(2px) rotate(35deg); box-shadow: 0 1px 0 var(--drop-c); }
.hud-mute:active, .hud-reset:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--drop-c); }
.hud-mute.muted { background: color-mix(in srgb, var(--candy-red) 30%, var(--paper)); }

/* ── GAME AREA ──────────────────────────────────────────────────────────── */
.game-area {
  flex: 1; display: flex; overflow: hidden; min-height: 0; gap: 10px;
}

/* ── BOARD PANEL (left) ─────────────────────────────────────────────────── */
.board-panel {
  flex: 0 0 auto;
  width: calc((100dvh - 198px) + 20px);
  max-width: calc(100dvw - 360px);   /* always leave a readable upgrade panel beside it */
  display: flex; flex-direction: column; align-items: center;
  justify-content: flex-start;
  padding: 10px;
  gap: 8px;
  background:
    linear-gradient(180deg, color-mix(in srgb, #fff 3%, var(--paper)) 0%, var(--paper) 65%, color-mix(in srgb, #000 5%, var(--paper)) 100%);
  border: var(--outline);
  border-radius: var(--r-lg);
  box-shadow: var(--drop), inset 0 1px 0 rgba(255,255,255,0.08);
  overflow: hidden;
}

.score-bar {
  width: 100%;
  height: 26px;
  position: relative;
  background: var(--cream);
  border: 2.5px solid var(--outline-c);
  border-radius: 999px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: var(--drop-sm), inset 0 2px 0 rgba(0,0,0,0.35);
}
.score-bar-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 0;
  background: linear-gradient(180deg, #ffd06b 0%, #ff8e3c 55%, #d65a17 100%);
  box-shadow:
    inset 0 -3px 0 rgba(0,0,0,0.28),
    inset 0 2px 0 rgba(255,255,255,0.40),
    0 0 14px rgba(255,140,60,0.5);
  transition: width 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.score-bar-label {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Luckiest Guy', cursive;
  font-size: 12px; letter-spacing: 1.5px;
  color: #fff;
  -webkit-text-stroke: 1.5px var(--drop-c);
  paint-order: stroke fill;
  pointer-events: none;
  z-index: 1;
}

/* When the Undo / Auto bars are present they add height to the column; shrink the
   board width budget by that amount so the square field never gets squished
   (which used to push tiles past the bottom edge). */
.board-panel.has-undo { width: calc((100dvh - 246px) + 20px); }
.board-panel.has-auto { width: calc((100dvh - 244px) + 20px); }
.board-panel.has-undo.has-auto { width: calc((100dvh - 292px) + 20px); }
/* the bottom banner shortens the play column — shrink the square-field budget to match,
   so the field + Reset/Undo/Auto bars never get cropped behind the banner */
body.has-banner .board-panel { width: calc((100dvh - 198px - var(--banner-h)) + 20px); }
body.has-banner .board-panel.has-undo { width: calc((100dvh - 246px - var(--banner-h)) + 20px); }
body.has-banner .board-panel.has-auto { width: calc((100dvh - 244px - var(--banner-h)) + 20px); }
body.has-banner .board-panel.has-undo.has-auto { width: calc((100dvh - 292px - var(--banner-h)) + 20px); }

/* full-width wrappers so the buttons match the Reset button length */
#undo-slot, #auto-slot { width: 100%; }

/* ── BOARD FRAME ────────────────────────────────────────────────────────── */
.board-frame {
  position: relative;
  width: 100%;
  flex-shrink: 0;          /* never compress — keeps the field perfectly square */
  aspect-ratio: 1 / 1;
  touch-action: none;      /* swipes drive the game only — never scroll/bounce the page */
  border: 3px solid var(--drop-c);
  border-radius: var(--r);
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 25%, rgba(155,95,255,0.14) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(76,209,238,0.10) 0%, transparent 55%),
    linear-gradient(180deg, var(--board-bg-1) 0%, var(--board-bg-2) 100%);
  box-shadow:
    inset 0 0 0 2px rgba(255,255,255,0.06),
    inset 0 10px 24px rgba(0,0,0,0.55),
    inset 0 -10px 24px rgba(0,0,0,0.55),
    0 0 14px rgba(120,90,200,0.12);
  container-type: inline-size;
  container-name: field;
}

.board {
  position: absolute;
  inset: 0;
}
.cell {
  position: absolute;
  width: var(--tile-size);
  height: var(--tile-size);
  left: var(--tx);
  top: var(--ty);
  background: var(--cell-bg);
  border: 1.5px solid var(--cell-edge);
  border-radius: 2.5cqw;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.35);
}

.tiles-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.tile {
  position: absolute;
  width: var(--tile-size);
  height: var(--tile-size);
  border-radius: 2.5cqw;
  overflow: hidden;   /* clip skin highlight/sheen pseudo-elements to the tile shape */
  display: flex; align-items: center; justify-content: center;
  font-family: 'Luckiest Guy', cursive;
  letter-spacing: 0.5px;
  border: clamp(2.5px, 0.7cqw, 4px) solid var(--drop-c);
  box-shadow:
    inset 0 -5px 0 rgba(0,0,0,0.28),
    inset 0 3px 0 rgba(255,255,255,0.5),
    0 4px 0 rgba(0,0,0,0.45),
    0 0 0 1px rgba(255,255,255,0.05);
  color: #fff;
  -webkit-text-stroke: clamp(1.2px, 0.4cqw, 2.2px) var(--drop-c);
  paint-order: stroke fill;
  text-shadow: 0 2px 0 rgba(0,0,0,0.35);
  /* Position via GPU-composited transform (NOT left/top): animating left/top forces
     a full layout on every frame of the move for every tile — the main cause of
     mobile move-animation jank. translate() animates on the compositor, no layout.
     The scale keyframes below re-state translate(--tx,--ty) so they don't clobber it. */
  left: 0;
  top: 0;
  transform: translate(var(--tx), var(--ty));
  will-change: transform;
  transition: transform 0.16s cubic-bezier(0.22, 0.7, 0.3, 1);
}
.tile.spawning { animation: tile-spawn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1); }
.tile.merged   { z-index: 3; animation: tile-pop 0.26s cubic-bezier(0.34, 1.56, 0.64, 1); }
.tile.merging  { z-index: 2; }
.tile.dying    { z-index: 1; opacity: 0; transition: transform 0.16s cubic-bezier(0.22, 0.7, 0.3, 1),
                                                     opacity 0.10s ease-in 0.10s; }

@keyframes tile-spawn {
  0%   { transform: translate(var(--tx), var(--ty)) scale(0.0); opacity: 0; }
  60%  { transform: translate(var(--tx), var(--ty)) scale(1.10); opacity: 1; }
  100% { transform: translate(var(--tx), var(--ty)) scale(1.0);  opacity: 1; }
}
@keyframes tile-pop {
  0%   { transform: translate(var(--tx), var(--ty)) scale(1); }
  35%  { transform: translate(var(--tx), var(--ty)) scale(1.22); filter: brightness(1.45); }
  100% { transform: translate(var(--tx), var(--ty)) scale(1);    filter: brightness(1); }
}

/* tile palette (dark-mode friendly, more glow per tier) */
.tile.t1   { background: linear-gradient(180deg, #ffe6a1, #f4b81e);
             box-shadow: inset 0 -5px 0 rgba(0,0,0,0.25), inset 0 3px 0 rgba(255,255,255,0.65), 0 4px 0 rgba(0,0,0,0.45), 0 0 14px rgba(244,184,30,0.35); }
.tile.t2   { background: linear-gradient(180deg, #ffc878, #ec8924);
             box-shadow: inset 0 -5px 0 rgba(0,0,0,0.28), inset 0 3px 0 rgba(255,255,255,0.55), 0 4px 0 rgba(0,0,0,0.45), 0 0 14px rgba(236,137,36,0.38); }
.tile.t3   { background: linear-gradient(180deg, #ff9c63, #d9501c);
             box-shadow: inset 0 -5px 0 rgba(0,0,0,0.28), inset 0 3px 0 rgba(255,255,255,0.55), 0 4px 0 rgba(0,0,0,0.45), 0 0 16px rgba(217,80,28,0.42); }
.tile.t4   { background: linear-gradient(180deg, #ff8ea0, #e84676);
             box-shadow: inset 0 -5px 0 rgba(0,0,0,0.28), inset 0 3px 0 rgba(255,255,255,0.55), 0 4px 0 rgba(0,0,0,0.45), 0 0 18px rgba(232,70,118,0.45); }
.tile.t5   { background: linear-gradient(180deg, #ff7077, #c63040);
             box-shadow: inset 0 -5px 0 rgba(0,0,0,0.28), inset 0 3px 0 rgba(255,255,255,0.55), 0 4px 0 rgba(0,0,0,0.45), 0 0 20px rgba(198,48,64,0.5); }
.tile.t6   { background: linear-gradient(180deg, #c8a4ff, #8d54e8);
             box-shadow: inset 0 -5px 0 rgba(0,0,0,0.28), inset 0 3px 0 rgba(255,255,255,0.5), 0 4px 0 rgba(0,0,0,0.45), 0 0 18px rgba(155,95,255,0.45); }
.tile.t7   { background: linear-gradient(180deg, #a386ff, #6332d2);
             box-shadow: inset 0 -5px 0 rgba(0,0,0,0.28), inset 0 3px 0 rgba(255,255,255,0.5), 0 4px 0 rgba(0,0,0,0.45), 0 0 22px rgba(115,55,222,0.55); }
.tile.t8   { background: linear-gradient(180deg, #79c3ff, #2f8ed8);
             box-shadow: inset 0 -5px 0 rgba(0,0,0,0.28), inset 0 3px 0 rgba(255,255,255,0.5), 0 4px 0 rgba(0,0,0,0.45), 0 0 22px rgba(58,168,232,0.55); }
.tile.t9   { background: linear-gradient(180deg, #4ed8ff, #008fc6);
             box-shadow: inset 0 -5px 0 rgba(0,0,0,0.28), inset 0 3px 0 rgba(255,255,255,0.5), 0 4px 0 rgba(0,0,0,0.45), 0 0 26px rgba(46,189,232,0.65); }
.tile.t10  { background: linear-gradient(180deg, #6ff0c8, #14a47a);
             box-shadow: inset 0 -5px 0 rgba(0,0,0,0.28), inset 0 3px 0 rgba(255,255,255,0.5), 0 4px 0 rgba(0,0,0,0.45), 0 0 26px rgba(76,209,176,0.7); }
.tile.t11  { background: linear-gradient(180deg, #b6f273, #45a82c);
             box-shadow: inset 0 -5px 0 rgba(0,0,0,0.28), inset 0 3px 0 rgba(255,255,255,0.55), 0 4px 0 rgba(0,0,0,0.45), 0 0 28px rgba(160,230,90,0.7); }
.tile.t12  { background: linear-gradient(180deg, #ffe27a, #f4b81e);
             box-shadow: inset 0 -5px 0 rgba(0,0,0,0.28), inset 0 3px 0 rgba(255,255,255,0.6), 0 4px 0 rgba(0,0,0,0.45), 0 0 32px rgba(255,220,90,0.85); }
.tile.t13, .tile.tx {
  background: linear-gradient(45deg, #ff6d96, #ffd23f, #6ff0c8, #5aa8e8, #9b78e0);
  background-size: 300% 300%;
  animation: tile-rainbow 4s linear infinite;
  box-shadow: inset 0 -5px 0 rgba(0,0,0,0.28), inset 0 3px 0 rgba(255,255,255,0.5), 0 4px 0 rgba(0,0,0,0.45), 0 0 36px rgba(255,200,120,0.85);
}
@keyframes tile-rainbow {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* tile font scales with cell size */
.tile { font-size: calc(var(--tile-size) * 0.42); }
.tile.f4 { font-size: calc(var(--tile-size) * 0.34); }
.tile.f5 { font-size: calc(var(--tile-size) * 0.28); }

/* ── MERGE POPUP ────────────────────────────────────────────────────────── */
.merge-pop {
  position: absolute;
  left: var(--tx); top: var(--ty);
  width: var(--tile-size); height: var(--tile-size);
  display: flex; align-items: center; justify-content: center;
  gap: clamp(2px, 0.5cqw, 4px);
  font-family: 'Luckiest Guy', cursive;
  font-size: calc(var(--tile-size) * 0.24);
  letter-spacing: 1px;
  color: #ffe27a;
  -webkit-text-stroke: clamp(1.2px, 0.35cqw, 2px) var(--drop-c);
  paint-order: stroke fill;
  text-shadow: 0 2px 0 var(--drop-c);
  pointer-events: none;
  z-index: 4;
  will-change: transform, opacity;
  animation: merge-pop-rise 0.85s cubic-bezier(0.22, 0.7, 0.3, 1) forwards;
}
.merge-pop .mp-coin {
  display: inline-flex;
  width: calc(var(--tile-size) * 0.22);
  height: calc(var(--tile-size) * 0.22);
  filter: drop-shadow(0 2px 0 var(--drop-c));
}
.merge-pop .mp-coin svg { width: 100%; height: 100%; display: block; }
@keyframes merge-pop-rise {
  0%   { transform: translateY(0)    scale(0.55); opacity: 0; }
  18%  { transform: translateY(-6%)  scale(1.18); opacity: 1; }
  60%  { transform: translateY(-40%) scale(1);    opacity: 1; }
  100% { transform: translateY(-85%) scale(0.9);  opacity: 0; }
}

/* ── OVERLAY PILLS (top-left/right of board frame) ──────────────────────── */
.board-pill {
  background: var(--cream);
  border: clamp(2px, 0.45cqw, 2.5px) solid var(--outline-c);
  border-radius: 999px;
  padding: clamp(2px, 0.55cqw, 3px) clamp(7px, 1.9cqw, 11px) clamp(2px, 0.55cqw, 3px) clamp(2px, 0.55cqw, 3px);
  display: flex;
  align-items: center;
  gap: clamp(4px, 1cqw, 6px);
  box-shadow: var(--drop-sm);
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(10px, 2.4cqw, 14px);
  letter-spacing: 1px;
  color: var(--ink);
  -webkit-text-stroke: 1.2px var(--drop-c);
  paint-order: stroke fill;
}
.board-pill-icon {
  width: clamp(14px, 3.8cqw, 22px);
  height: clamp(14px, 3.8cqw, 22px);
  border-radius: 50%;
  border: clamp(1.5px, 0.35cqw, 2px) solid var(--outline-c);
  box-shadow:
    inset 0 -2px 0 rgba(0,0,0,0.28),
    inset 0 1.5px 0 rgba(255,255,255,0.5);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.pill-stack {
  position: absolute;
  top: clamp(4px, 1.3cqw, 8px);
  left: clamp(4px, 1.3cqw, 8px);
  z-index: 5;
  display: flex; flex-direction: column;
  gap: clamp(2px, 0.7cqw, 4px);
  pointer-events: none;
}
.pill-stack.right {
  left: auto;
  right: clamp(4px, 1.3cqw, 8px);
  align-items: flex-end;
}
.pill-score .board-pill-icon { background: radial-gradient(circle at 30% 30%, #ffe17a 0%, #ffb620 60%, #d68800 100%); }
.pill-best  .board-pill-icon { background: radial-gradient(circle at 30% 30%, #ffd0d0 0%, #ff5d8f 60%, #b53875 100%); }
.pill-moves .board-pill-icon { background: radial-gradient(circle at 30% 30%, #d9d0ff 0%, #9b78e0 60%, #6938b5 100%); }

/* ── GAME-OVER OVERLAY ──────────────────────────────────────────────────── */
.gameover {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgba(10,8,22,0.75);
  backdrop-filter: blur(6px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(8px, 3cqw, 16px);
  padding: clamp(8px, 4cqw, 22px);
  text-align: center;
  animation: gameover-fade 0.45s ease-out;
}
@keyframes gameover-fade { from { opacity: 0; } to { opacity: 1; } }
.gameover-title {
  font-family: 'Bungee', system-ui, sans-serif;
  /* scale with the board container (#board-frame is container-type: inline-size)
     so the title never overflows a small board — mirrors how .tile sizes text. */
  font-size: clamp(22px, 13cqw, 50px); letter-spacing: clamp(1px, 1.2cqw, 5px);
  background: linear-gradient(180deg, #ffd23f 0%, #ff5d8f 70%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  -webkit-text-stroke: clamp(1.5px, 0.8cqw, 3px) var(--drop-c);
  filter: drop-shadow(0 5px 0 var(--drop-c));
  transform: rotate(-3deg);
}
.gameover-sub {
  font-family: 'Fredoka', sans-serif;
  font-size: clamp(10px, 3.6cqw, 15px); font-weight: 700;
  color: var(--ink);
  text-shadow: 0 2px 0 var(--drop-c);
  letter-spacing: clamp(0.4px, 0.25cqw, 1px);
  max-width: 92%;
}
/* PLAY AGAIN button also scales with the board (horizontal padding set here
   instead of inline so it shrinks too). */
.gameover .new-btn {
  height: clamp(30px, 10cqw, 48px);
  font-size: clamp(13px, 4.5cqw, 22px);
  padding-left: clamp(12px, 5cqw, 24px);
  padding-right: clamp(12px, 5cqw, 24px);
}

/* ── AUTO-SLIDE BAR + PAUSE (Plinko-style; only once Auto Slide is owned) ─── */
.auto-bar-row {
  width: 100%; display: flex; align-items: stretch; gap: 6px;
}
.auto-pause-btn {
  flex: 0 0 auto; width: 40px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #ffd29a 0%, #ff8e3c 100%);
  border: 2.5px solid var(--drop-c); border-radius: var(--r);
  color: #5a2a08; cursor: pointer; padding: 0;
  box-shadow: var(--drop-sm), inset 0 -2px 0 rgba(0,0,0,0.25), inset 0 1.5px 0 rgba(255,255,255,0.45);
  transition: transform 0.08s, filter 0.1s;
}
.auto-pause-btn svg { width: 20px; height: 20px; display: block; }
.auto-pause-btn:hover { filter: brightness(1.08); }
.auto-pause-btn:active { transform: translateY(2px); }
.auto-pause-btn.paused { background: linear-gradient(180deg, #9fe6b4 0%, #34c46f 100%); color: #0c3d22; }

.auto-bar {
  flex: 1 1 0; height: 34px; position: relative; overflow: hidden;
  background: var(--cream);
  border: 2.5px solid var(--outline-c); border-radius: var(--r);
  box-shadow: var(--drop-sm), inset 0 2px 0 rgba(0,0,0,0.3);
}
.auto-bar-fill {
  position: absolute; inset: 0; width: 0;
  background: linear-gradient(180deg, #ffd06b 0%, #ff8e3c 60%, #d65a17 100%);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.25), inset 0 2px 0 rgba(255,255,255,0.35);
}
.auto-bar.paused .auto-bar-fill { background: linear-gradient(180deg, #7a7290, #4a4060); }
.auto-bar-label {
  position: absolute; inset: 0; z-index: 1;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-family: 'Luckiest Guy', cursive; font-size: 12px; letter-spacing: 1.5px;
  color: #fff; -webkit-text-stroke: 1.4px var(--drop-c); paint-order: stroke fill;
  pointer-events: none;
}
.auto-bar-ico { display: inline-flex; width: 16px; height: 16px; }
.auto-bar-ico svg { width: 100%; height: 100%; }
.auto-bar.paused .auto-bar-label::after { content: ' (paused)'; opacity: 0.85; }

/* ── UNDO BUTTON (above RESET; only appears once Undo Slots is bought) ─── */
.undo-btn {
  width: 100%;
  height: 40px;
  background: linear-gradient(180deg, #c8a4ff 0%, #7e54d6 100%);
  border: var(--outline);
  border-color: var(--drop-c);
  border-radius: var(--r);
  color: #fff;
  font-family: 'Luckiest Guy', cursive;
  font-size: 16px; letter-spacing: 2px;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow:
    var(--drop-sm),
    inset 0 -3px 0 rgba(0,0,0,0.28),
    inset 0 2px 0 rgba(255,255,255,0.5);
  text-shadow: 0 2px 0 rgba(0,0,0,0.45);
  -webkit-text-stroke: 1.3px var(--drop-c);
  paint-order: stroke fill;
  transition: transform 0.08s, box-shadow 0.08s, filter 0.08s;
}
.undo-btn:hover  { filter: brightness(1.1); }
.undo-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--drop-c), inset 0 -2px 0 rgba(0,0,0,0.28), inset 0 2px 0 rgba(255,255,255,0.4);
}
.undo-btn:disabled {
  background: color-mix(in srgb, var(--ink-soft) 25%, var(--paper-2));
  color: color-mix(in srgb, var(--ink) 50%, transparent);
  text-shadow: none;
  cursor: not-allowed;
  filter: none;
  box-shadow: var(--drop-sm), inset 0 -2px 0 rgba(0,0,0,0.2);
}

/* ── RESET BUTTON ───────────────────────────────────────────────────────── */
.new-btn {
  width: 100%;
  height: 48px;
  background: linear-gradient(180deg, #ff8eb6 0%, var(--candy-pink) 100%);
  border: var(--outline);
  border-color: var(--drop-c);
  border-radius: var(--r);
  color: #fff;
  font-family: 'Luckiest Guy', cursive;
  font-size: 22px; letter-spacing: 3px;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s, filter 0.08s;
  flex-shrink: 0;
  box-shadow:
    var(--drop),
    inset 0 -4px 0 rgba(0,0,0,0.28),
    inset 0 3px 0 rgba(255,255,255,0.5),
    0 0 22px rgba(240,109,150,0.50);
  text-shadow: 0 2px 0 rgba(46,24,84,0.6);
  -webkit-text-stroke: 1.5px var(--drop-c);
  paint-order: stroke fill;
  position: relative;
  overflow: hidden;
}
.new-btn::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0; width: 40%;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.35) 50%, transparent 100%);
  transform: translateX(-220%);
  animation: btn-shine 4.5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes btn-shine {
  0%, 72%   { transform: translateX(-220%); }
  88%, 100% { transform: translateX(300%); }
}
.new-btn:hover  { filter: brightness(1.08); }
.new-btn:active {
  transform: translateY(4px);
  box-shadow:
    0 0 0 var(--drop-c),
    inset 0 -2px 0 rgba(0,0,0,0.28),
    inset 0 2px 0 rgba(255,255,255,0.4),
    0 0 16px rgba(240,109,150,0.40);
}

/* ── SMALL VIEWPORT ─────────────────────────────────────────────────────── */
@media (max-height: 620px), (max-width: 900px) {
  #root { padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left)); gap: 6px; }
  .hud { height: 58px; padding: 0 10px; gap: 8px; }
  .hud-title { flex-shrink: 1; min-width: 0; }
  .hud-title svg { height: 36px; }
  .hud-block { padding: 3px 12px 3px 3px; gap: 7px; }
  .hud-block-icon { width: 36px; height: 36px; font-size: 16px; }
  .hud-score .hud-value { font-size: 22px; letter-spacing: 1px; }
  .hud-score .hud-label { font-size: 9px; letter-spacing: 1.5px; }
  .hud-label { font-size: 8px; letter-spacing: 1px; }
  .hud-value { font-size: 17px; }
  .hud-mute, .hud-reset { width: 38px; height: 38px; font-size: 15px; border-width: 2px; flex-shrink: 0; }
  .hud-left, .hud-right { gap: 6px; }

  .board-panel {
    padding: 6px; gap: 5px;
    width: calc((100dvh - 138px) + 12px);
    max-width: calc(100dvw - 300px);
  }
  .board-panel.has-undo { width: calc((100dvh - 184px) + 12px); }
  .board-panel.has-auto { width: calc((100dvh - 182px) + 12px); }
  .board-panel.has-undo.has-auto { width: calc((100dvh - 226px) + 12px); }
  body.has-banner .board-panel { width: calc((100dvh - 138px - var(--banner-h)) + 12px); }
  body.has-banner .board-panel.has-undo { width: calc((100dvh - 184px - var(--banner-h)) + 12px); }
  body.has-banner .board-panel.has-auto { width: calc((100dvh - 182px - var(--banner-h)) + 12px); }
  body.has-banner .board-panel.has-undo.has-auto { width: calc((100dvh - 226px - var(--banner-h)) + 12px); }
  .score-bar { height: 18px; }
  .new-btn { height: 36px; font-size: 16px; letter-spacing: 2px; }

}

@media (max-width: 700px) {
  .hud-title { display: none; }
  .hud-best .hud-label, .hud-coins .hud-label, .hud-gems .hud-label { display: none; }
}
@media (max-width: 560px) {
  .hud-best { display: none; }
}
@media (max-width: 460px) {
  .hud-gems { display: none; }
  /* narrowest phones can't fit Score + Coins/SP/AP + buttons — drop Score (it's
     the tile-sum, visible from the board and shown in the Stats tab) */
  .hud-score { display: none; }
}
/* compact the HUD so the score + all 3 currencies (Coins / SP / AP) + buttons fit
   on phones — without this the wide right group crushes the left score to nothing */
@media (max-width: 560px) {
  .hud { padding: 0 8px; gap: 4px; }
  .hud-left, .hud-right { gap: 4px; }
  .hud-block { gap: 4px; padding: 3px 8px 3px 3px; border-width: 2px; }
  .hud-block-icon { width: 26px; height: 26px; border-width: 2px; font-size: 13px; }
  .hud-value { font-size: 15px; margin-top: 0; -webkit-text-stroke: 1px var(--drop-c); }
  .hud-score .hud-value { font-size: 18px; }
  .hud-mute, .hud-reset, .hud-theme { width: 32px; height: 32px; border-width: 2px; }
}

/* ── UI PANEL (right) ───────────────────────────────────────────────────── */
.ui-panel {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; min-width: 0;
  background:
    linear-gradient(180deg, color-mix(in srgb, #fff 3%, var(--paper)) 0%, var(--paper) 65%, color-mix(in srgb, #000 5%, var(--paper)) 100%);
  border: var(--outline);
  border-radius: var(--r-lg);
  box-shadow: var(--drop), inset 0 1px 0 rgba(255,255,255,0.08);
  container-type: inline-size;
  container-name: ui;
}

/* ── TABS — Plinko-style: horizontal scroll of pill buttons, each with a
   per-tab COLORED rounded-square icon badge (chunky dark border + inset glints)
   beside a label. The badge colour is the tab's identity. ─────────────────── */
.tab-bar {
  flex-shrink: 0;
  display: flex; gap: 6px;
  padding: 8px 8px 10px;   /* bottom gap so the bar + button shadows clear the content below */
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tab-btn {
  flex: 0 0 auto;
  scroll-snap-align: start;
  display: inline-flex; align-items: center; gap: 7px;
  height: 40px; padding: 0 14px 0 6px;
  background: linear-gradient(180deg, color-mix(in srgb, #fff 6%, var(--cream)) 0%, var(--cream) 100%);
  border: 2.5px solid var(--tab-c, var(--outline-c));
  border-radius: 999px;
  cursor: pointer; white-space: nowrap;
  transition: transform 0.08s, box-shadow 0.08s, filter 0.12s, border-color 0.12s, background 0.12s;
  box-shadow: var(--drop-sm), inset 0 1px 0 rgba(255,255,255,0.10);
}
/* the colored badge — every tab icon shares this exact treatment */
.tab-btn-icon {
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--drop-c);
  background: var(--tab-c, var(--candy-mint));
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.28), inset 0 2px 0 rgba(255,255,255,0.45), 0 1px 0 rgba(0,0,0,0.3);
  color: #fff;
}
.tab-btn-icon svg { width: 84%; height: 84%; display: block; filter: drop-shadow(0 1px 0 rgba(0,0,0,0.35)); }
.tab-btn-label {
  font-family: 'Luckiest Guy', cursive;
  font-size: 13px; letter-spacing: 0.5px;
  color: var(--ink-soft);
  -webkit-text-stroke: 1px var(--drop-c); paint-order: stroke fill;
  transition: color 0.12s;
}
.tab-btn:hover { filter: brightness(1.06); }
.tab-btn.active {
  background: linear-gradient(180deg, color-mix(in srgb, var(--tab-c, var(--tab-active)) 26%, var(--cream)) 0%, var(--cream) 100%);
  border-color: var(--tab-c, var(--tab-active));
  box-shadow: var(--drop-sm), 0 0 13px color-mix(in srgb, var(--tab-c, var(--tab-active)) 50%, transparent);
}
.tab-btn.active .tab-btn-label { color: var(--ink); }
.tab-btn.active .tab-btn-icon { box-shadow: inset 0 -2px 0 rgba(0,0,0,0.28), inset 0 2px 0 rgba(255,255,255,0.5), 0 0 10px color-mix(in srgb, var(--tab-c, var(--tab-active)) 60%, transparent); }
@media (max-height: 620px), (max-width: 900px) {
  .tab-bar { padding: 6px 6px 9px; gap: 5px; }
  .tab-btn { height: 36px; padding: 0 11px 0 5px; gap: 6px; }
  .tab-btn-icon { width: 24px; height: 24px; border-radius: 7px; }
  .tab-btn-label { font-size: 12px; }
}
@container ui (max-width: 340px) {
  .tab-btn { height: 34px; padding: 0 9px 0 4px; gap: 5px; }
  .tab-btn-icon { width: 22px; height: 22px; border-radius: 6px; }
  .tab-btn-label { font-size: 11px; }
}

.tab-content {
  flex: 1; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.tab-content > * { flex-shrink: 0; }
.tab-content::-webkit-scrollbar { width: 8px; }
.tab-content::-webkit-scrollbar-track { background: var(--cream); border-radius: 4px; }
.tab-content::-webkit-scrollbar-thumb {
  background: var(--candy-pink);
  border-radius: 4px;
  border: 1.5px solid var(--outline-c);
}

/* ── UPGRADE CARDS ──────────────────────────────────────────────────────── */
.upgrade-card {
  background:
    linear-gradient(180deg, color-mix(in srgb, #fff 5%, var(--cream)) 0%, var(--cream) 60%, color-mix(in srgb, #000 4%, var(--cream)) 100%);
  border: var(--outline);
  border-radius: var(--r);
  padding: 12px;
  display: flex; align-items: center; gap: 12px;
  box-shadow:
    var(--drop-sm),
    inset 0 1px 0 rgba(255,255,255,0.08),
    inset 0 -2px 0 rgba(0,0,0,0.15);
  position: relative;
  overflow: hidden;
}
.upgrade-card::after {
  /* faint glossy highlight sweeping across the card */
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.04) 0%, transparent 100%);
  pointer-events: none;
}
.upg-icon {
  flex-shrink: 0;
  width: 48px; height: 48px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  border: 2.5px solid var(--drop-c);
  box-shadow:
    inset 0 -4px 0 rgba(0,0,0,0.28),
    inset 0 3px 0 rgba(255,255,255,0.5),
    0 2px 0 rgba(0,0,0,0.35);
  font-size: 22px;
  color: #fff;
  text-shadow: 0 2px 0 rgba(46,24,84,0.55);
}
.upg-icon svg { width: 70%; height: 70%; display: block; filter: drop-shadow(0 1.5px 0 rgba(0,0,0,0.4)); }
.upg-info { flex: 1; min-width: 0; }
.upg-name {
  font-family: 'Fredoka', sans-serif;
  font-size: 11px; letter-spacing: 1px; font-weight: 700;
  color: var(--ink-soft); text-transform: uppercase;
}
.upg-val {
  font-family: 'Luckiest Guy', cursive;
  font-size: 20px; letter-spacing: 1px;
  line-height: 1.1;
  color: var(--ink);
  margin-top: 1px;
  -webkit-text-stroke: 1.2px var(--drop-c);
}
/* (×N) chips showing a boost a LATER upgrade applies to this one */
.upg-addon { font-size: 0.62em; -webkit-text-stroke: 0.6px var(--drop-c); paint-order: stroke fill; }
.upg-addon.shop    { color: #b89bff; }
.upg-addon.inv     { color: #ffd23f; }
.upg-addon.ascend  { color: #7ec0ff; }
.upg-addon.supreme { color: #ffae6b; }
.upg-next {
  font-family: 'Fredoka', sans-serif;
  font-size: 12px; font-weight: 600;
  color: var(--ink-soft);
  margin-top: 1px;
}
.upg-right { flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.lv-pips { display: flex; gap: 4px; align-items: center; }
.lv-pip {
  width: 10px; height: 10px; border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 2px solid var(--outline-c);
  transition: background 0.2s;
}
.lv-pip.on { background: linear-gradient(180deg, #c8a4ff, #8a4fee); border-color: var(--drop-c); }
.lv-pips.compact { gap: 2px; }
.lv-pips.compact .lv-pip { width: 7px; height: 7px; border-width: 1.5px; }
.lv-pips.tiny    { gap: 1.5px; }
.lv-pips.tiny .lv-pip { width: 5px; height: 5px; border-width: 1px; }

.upg-btn {
  height: 38px; padding: 0 14px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--btn-c) 80%, white) 0%, var(--btn-c) 100%);
  border: 2.5px solid var(--drop-c);
  color: #fff;
  border-radius: 12px;
  font-family: 'Luckiest Guy', cursive;
  font-size: 14px; letter-spacing: 1px;
  cursor: pointer; white-space: nowrap;
  transition: transform 0.08s, box-shadow 0.08s, filter 0.08s;
  box-shadow:
    var(--drop-sm),
    inset 0 -3px 0 rgba(0,0,0,0.28),
    inset 0 2px 0 rgba(255,255,255,0.5);
  text-shadow: 0 2px 0 rgba(46,24,84,0.55);
  -webkit-text-stroke: 1.2px var(--drop-c);
  paint-order: stroke fill;
  display: inline-flex; align-items: center; gap: 5px;
}
.upg-btn svg { width: 16px; height: 16px; }
.upg-btn:hover { filter: brightness(1.08); }
.upg-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--drop-c), inset 0 -2px 0 rgba(0,0,0,0.28); }
.upg-btn.glow { animation: btn-bounce 1.6s ease-in-out infinite; }
@keyframes btn-bounce {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.18); }
}
.upg-btn:disabled {
  background: color-mix(in srgb, var(--ink-soft) 25%, var(--paper-2));
  color: color-mix(in srgb, var(--ink) 50%, transparent);
  text-shadow: none;
  cursor: not-allowed;
  animation: none;
  transform: none;
  box-shadow:
    var(--drop-sm),
    inset 0 -2px 0 rgba(0,0,0,0.18),
    inset 0 1px 0 rgba(255,255,255,0.04);
  filter: none;
}
.upg-maxed {
  font-family: 'Luckiest Guy', cursive;
  font-size: 13px; letter-spacing: 2px;
  color: #fff;
  padding: 6px 12px;
  border: 2.5px solid var(--drop-c);
  border-radius: 999px;
  background: linear-gradient(180deg, #ffd55a, var(--candy-yellow));
  box-shadow: var(--drop-sm), inset 0 -2px 0 rgba(0,0,0,0.28), inset 0 2px 0 rgba(255,255,255,0.5);
  text-shadow: 0 2px 0 rgba(46,24,84,0.55);
  -webkit-text-stroke: 1.2px var(--drop-c);
  paint-order: stroke fill;
  transform: rotate(-3deg);
}

.upgrade-card.gem {
  background: linear-gradient(180deg, color-mix(in srgb, #9b5fff 18%, var(--cream)) 0%, var(--cream) 100%);
  border-color: color-mix(in srgb, #9b5fff 60%, var(--outline-c));
  box-shadow: var(--drop-sm), inset 0 1px 0 rgba(255,255,255,0.08), inset 0 -2px 0 rgba(0,0,0,0.15);
}

/* ── RESET CINEMATICS — full-screen palette-tinted reveal animations.
   Ported from Mining Simulator's ResetCinematics (Phase 7 / v17). Each
   reset/transition tier gets ~2s of spectacle so it reads as a *moment*,
   not a button click. Ascend = tectonic shift, Prestige = singularity. */
.reset-cinematic { background: #000; }
@keyframes cinematicFadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes cinematicFadeOut { to   { opacity: 0; } }
@keyframes cinematicCrack {
  0%   { stroke-dashoffset: 1000; }
  100% { stroke-dashoffset: 0; }
}
@keyframes cinematicBloom {
  0%   { width: 40px;   height: 40px;   opacity: 1; }
  100% { width: 1400px; height: 1400px; opacity: 0; }
}
@keyframes cinematicBloomCore {
  0%   { width: 80px;   height: 80px;   opacity: 0; filter: blur(0); }
  30%  { width: 240px;  height: 240px;  opacity: 1; filter: blur(0); }
  100% { width: 1600px; height: 1600px; opacity: 0; filter: blur(60px); }
}
@keyframes cinematicPull {
  0%   { transform: translate(var(--tx), var(--ty)) scale(1); opacity: 1; }
  100% { transform: translate(0, 0) scale(0.2); opacity: 0; }
}
@keyframes cinematicSingularity {
  0%   { width: 160px; height: 160px; opacity: 0; }
  40%  { width: 280px; height: 280px; opacity: 1; }
  80%  { width: 40px;  height: 40px;  opacity: 1; }
  100% { width: 4px;   height: 4px;   opacity: 0; }
}
@keyframes cinematicTitle {
  0%   { opacity: 0; transform: scale(.6);  letter-spacing: 24px; filter: blur(20px); }
  40%  { opacity: 1; transform: scale(1.05); letter-spacing: 6px;  filter: blur(0); }
  100% { opacity: 1; transform: scale(1);   letter-spacing: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .reset-cinematic, .reset-cinematic * { animation: none !important; }
}

/* ── PRESTIGE / ASCEND ACTION PANEL ─────────────────────────────────────── */
.reset-action {
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap; row-gap: 10px;   /* button drops to a full-width row when too narrow */
  padding: 14px;
  border-radius: var(--r-lg);
  border: 3px solid var(--drop-c);
  box-shadow: var(--drop), inset 0 1px 0 rgba(255,255,255,0.10), inset 0 -2px 0 rgba(0,0,0,0.2);
  position: relative;
  overflow: hidden;
}
.reset-action.prestige {
  background:
    linear-gradient(180deg, color-mix(in srgb, #4cd1ee 26%, var(--cream)) 0%, var(--cream) 70%, color-mix(in srgb, #000 4%, var(--cream)) 100%);
  box-shadow: var(--drop), inset 0 1px 0 rgba(255,255,255,0.12), inset 0 -2px 0 rgba(0,0,0,0.2), 0 0 28px rgba(76,209,238,0.30);
}
.reset-action.ascend {
  background:
    linear-gradient(180deg, color-mix(in srgb, #c8a4ff 26%, var(--cream)) 0%, var(--cream) 70%, color-mix(in srgb, #000 4%, var(--cream)) 100%);
  box-shadow: var(--drop), inset 0 1px 0 rgba(255,255,255,0.12), inset 0 -2px 0 rgba(0,0,0,0.2), 0 0 14px rgba(155,95,255,0.18);
}
.reset-action::before {
  /* shimmering top-light */
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, transparent 100%);
  pointer-events: none;
}
.reset-action-icon {
  flex-shrink: 0;
  width: 60px; height: 60px;
  border-radius: 18px;
  border: 3px solid var(--drop-c);
  display: flex; align-items: center; justify-content: center;
  box-shadow:
    inset 0 -4px 0 rgba(0,0,0,0.32),
    inset 0 3px 0 rgba(255,255,255,0.5),
    0 3px 0 rgba(0,0,0,0.35);
  color: #fff;
}
.reset-action.prestige .reset-action-icon {
  background: radial-gradient(circle at 30% 30%, #b8f0ff 0%, #4cd1ee 50%, #1a7ec0 100%);
  box-shadow:
    inset 0 -4px 0 rgba(0,0,0,0.32),
    inset 0 3px 0 rgba(255,255,255,0.55),
    0 3px 0 rgba(0,0,0,0.35);
}
.reset-action.ascend .reset-action-icon {
  background: radial-gradient(circle at 30% 30%, #e8d6ff 0%, #b78dff 50%, #6f3bd8 100%);
  box-shadow:
    inset 0 -4px 0 rgba(0,0,0,0.32),
    inset 0 3px 0 rgba(255,255,255,0.5),
    0 3px 0 rgba(0,0,0,0.35);
}
.reset-action-icon svg { width: 60%; height: 60%; display: block; filter: drop-shadow(0 1.5px 0 rgba(0,0,0,0.45)); }

.reset-action-body { flex: 1 1 150px; min-width: 150px; display: flex; flex-direction: column; gap: 4px; }
.reset-action-title {
  font-family: 'Bungee', system-ui, sans-serif;
  font-size: 22px;
  letter-spacing: 3px;
  color: #fff;
  -webkit-text-stroke: 2px var(--drop-c);
  paint-order: stroke fill;
  line-height: 1;
}
.reset-action.prestige .reset-action-title { color: #8be7ff; }
.reset-action.ascend   .reset-action-title { color: #c8a4ff; }

.reset-action-stat-row {
  display: flex; gap: 14px; flex-wrap: wrap;
  margin-top: 2px;
}
.ra-stat { display: flex; flex-direction: column; line-height: 1; gap: 2px; }
.ra-label {
  font-family: 'Fredoka', sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--ink-soft);
  text-transform: uppercase;
}
.ra-val {
  font-family: 'Luckiest Guy', cursive;
  font-size: 18px;
  letter-spacing: 1px;
  color: var(--ink);
  -webkit-text-stroke: 1.3px var(--drop-c);
  paint-order: stroke fill;
}
.ra-pop { color: #ffd970; -webkit-text-stroke: 1.4px var(--drop-c); }
.reset-action-hint {
  font-family: 'Fredoka', sans-serif;
  font-size: 11px; font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: 0.5px;
}
.reset-action-btn {
  flex: 1 1 auto;
  height: 64px;
  padding: 0 18px;
  min-width: 140px;
  border: 3px solid var(--drop-c);
  border-radius: 14px;
  color: #fff;
  font-family: 'Luckiest Guy', cursive;
  font-size: 18px; letter-spacing: 2px;
  cursor: pointer;
  -webkit-text-stroke: 1.4px var(--drop-c);
  paint-order: stroke fill;
  text-shadow: 0 2px 0 rgba(0,0,0,0.45);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.08s;
  box-shadow:
    var(--drop),
    inset 0 -4px 0 rgba(0,0,0,0.32),
    inset 0 3px 0 rgba(255,255,255,0.55);
}
.reset-action.prestige .reset-action-btn {
  background: linear-gradient(180deg, #6fe4ff 0%, #2bb8e8 100%);
}
.reset-action.ascend   .reset-action-btn {
  background: linear-gradient(180deg, #c8a4ff 0%, #8a4fee 100%);
}
.reset-action-btn:hover  { filter: brightness(1.08); }
.reset-action-btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--drop-c), inset 0 -2px 0 rgba(0,0,0,0.28), inset 0 2px 0 rgba(255,255,255,0.4); }
.reset-action-btn.glow {
  animation: action-btn-pulse 1.6s ease-in-out infinite;
}
.reset-action.prestige .reset-action-btn.glow { box-shadow: var(--drop), inset 0 -4px 0 rgba(0,0,0,0.32), inset 0 3px 0 rgba(255,255,255,0.55), 0 0 16px rgba(76,209,238,0.45); }
.reset-action.ascend   .reset-action-btn.glow { box-shadow: var(--drop), inset 0 -4px 0 rgba(0,0,0,0.32), inset 0 3px 0 rgba(255,255,255,0.55), 0 0 16px rgba(155,95,255,0.45); }
.reset-action-btn:disabled {
  background: color-mix(in srgb, var(--ink-soft) 22%, var(--paper-2));
  color: color-mix(in srgb, var(--ink) 50%, transparent);
  text-shadow: none;
  cursor: not-allowed;
  animation: none;
  transform: none;
  box-shadow: var(--drop-sm), inset 0 -2px 0 rgba(0,0,0,0.2);
  filter: none;
}
@keyframes action-btn-pulse {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.18); }
}

/* ── "COMING SOON" BANNER (top of prestige/ascend) ──────────────────────── */
.soon-banner {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--candy-yellow) 22%, var(--cream)) 0%, var(--cream) 100%);
  border: var(--outline);
  border-color: color-mix(in srgb, var(--candy-yellow) 60%, var(--outline-c));
  border-radius: var(--r);
  padding: 10px 14px;
  text-align: center;
  font-family: 'Luckiest Guy', cursive;
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--ink);
  -webkit-text-stroke: 1.2px var(--drop-c);
  paint-order: stroke fill;
  box-shadow: var(--drop-sm), inset 0 1px 0 rgba(255,255,255,0.08);
}

/* ── PRESTIGE TAB — app-store grid ──────────────────────────────────────── */
.prestige-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.prestige-card {
  background:
    linear-gradient(180deg, color-mix(in srgb, #fff 5%, var(--cream)) 0%, var(--cream) 60%, color-mix(in srgb, #000 4%, var(--cream)) 100%);
  border: var(--outline);
  border-radius: var(--r);
  padding: 14px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  box-shadow: var(--drop-sm), inset 0 1px 0 rgba(255,255,255,0.08), inset 0 -2px 0 rgba(0,0,0,0.18);
  position: relative;
  text-align: center;
  overflow: hidden;
}
.prestige-card.locked { filter: saturate(0.55); }
.prestige-card.locked .pc-icon { opacity: 0.85; }
.pc-icon {
  width: 56px; height: 56px;
  border-radius: 16px;
  border: 3px solid var(--drop-c);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Luckiest Guy', cursive;
  font-size: 32px;
  color: #fff;
  -webkit-text-stroke: 1.5px var(--drop-c);
  paint-order: stroke fill;
  text-shadow: 0 2px 0 rgba(0,0,0,0.4);
  box-shadow:
    inset 0 -4px 0 rgba(0,0,0,0.32),
    inset 0 3px 0 rgba(255,255,255,0.5),
    0 2px 0 rgba(0,0,0,0.35);
}
.pc-name {
  font-family: 'Luckiest Guy', cursive;
  font-size: 14px; letter-spacing: 1.2px;
  color: var(--ink);
  -webkit-text-stroke: 1.2px var(--drop-c);
  paint-order: stroke fill;
}
.pc-sub {
  font-family: 'Fredoka', sans-serif;
  font-size: 11px; font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: 0.5px;
}
.pc-badge {
  margin-top: 4px;
  padding: 3px 10px;
  background: linear-gradient(180deg, color-mix(in srgb, #8a7aa8 60%, var(--cream)) 0%, var(--cream) 100%);
  border: 2px solid var(--outline-c);
  border-radius: 999px;
  font-family: 'Luckiest Guy', cursive;
  font-size: 10px; letter-spacing: 1.5px;
  color: var(--ink-soft);
  -webkit-text-stroke: 0.6px var(--drop-c);
  paint-order: stroke fill;
  white-space: nowrap;
}

/* ── ASCEND TAB — Plinko-style hero card + RPG stat rows ─────────────────── */
.ascend-hero {
  background: linear-gradient(180deg, color-mix(in srgb, #9b5fff 22%, var(--cream)) 0%, var(--cream) 100%);
  border: 3px solid color-mix(in srgb, #9b5fff 65%, var(--outline-c));
  border-radius: var(--r-lg);
  padding: 14px; margin-bottom: 10px;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--drop), 0 0 20px rgba(155,95,255,0.22);
}
.ascend-hero.gated {
  background: linear-gradient(180deg, color-mix(in srgb, #6b4d8a 12%, var(--cream)) 0%, var(--cream) 100%);
  border-color: color-mix(in srgb, #6b4d8a 50%, var(--outline-c));
  box-shadow: var(--drop); filter: saturate(0.85);
}
.ascend-hero-title {
  font-family: 'Bungee', system-ui, sans-serif;
  font-size: 24px; letter-spacing: 3px; text-align: center;
  color: #c8a4ff; -webkit-text-stroke: 2px var(--drop-c); paint-order: stroke fill;
  text-shadow: 0 3px 0 var(--drop-c);
}
.ascend-hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ascend-stat {
  background: rgba(155,95,255,0.10);
  border: 2px solid color-mix(in srgb, #9b5fff 35%, var(--outline-c));
  border-radius: var(--r); padding: 6px 9px;
  display: flex; flex-direction: column; gap: 1px;
}
.ascend-stat-label {
  font-family: 'Fredoka', sans-serif; font-size: 9px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--ink-soft);
}
.ascend-stat-val {
  font-family: 'Luckiest Guy', cursive; font-size: 18px; letter-spacing: 1px;
  color: var(--ink); -webkit-text-stroke: 1px var(--drop-c); paint-order: stroke fill;
}
.ascend-stat-val.glow { color: #ffd970; text-shadow: 0 0 10px rgba(255,210,80,0.6); }
.ascend-hero-btn {
  height: 48px; border: 3px solid var(--drop-c); border-radius: var(--r);
  background: linear-gradient(180deg, #c8a4ff 0%, #8a4fee 100%); color: #fff;
  font-family: 'Bungee', system-ui, sans-serif; font-size: 16px; letter-spacing: 1.5px;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  -webkit-text-stroke: 1.2px var(--drop-c); paint-order: stroke fill; text-shadow: 0 2px 0 rgba(0,0,0,0.4);
  box-shadow: var(--drop-sm), inset 0 -3px 0 rgba(0,0,0,0.28), inset 0 2px 0 rgba(255,255,255,0.5);
  transition: transform 0.08s, filter 0.08s;
}
.ascend-hero-btn-ico { display: inline-flex; width: 22px; height: 22px; }
.ascend-hero-btn-ico svg { width: 100%; height: 100%; }
.ascend-hero-btn.glow { animation: action-btn-pulse 1.6s ease-in-out infinite; }
.ascend-hero-btn.locked, .ascend-hero-btn:disabled {
  background: linear-gradient(180deg, #4a4663, #36324d); color: var(--ink-soft);
  cursor: not-allowed; filter: saturate(0.55);
}
.ascend-hero-btn:active:not(:disabled) { transform: translateY(2px); }
.ascend-hero-sub, .ascend-hero-locked {
  font-family: 'Fredoka', sans-serif; font-weight: 600; color: var(--ink-soft); text-align: center;
}
.ascend-hero-sub { font-size: 10.5px; }
.ascend-hero-locked { font-size: 12.5px; font-weight: 700; }

.ascend-rows { display: flex; flex-direction: column; gap: 10px; }
.ascend-row {
  position: relative; overflow: hidden;
  background: linear-gradient(180deg, color-mix(in srgb, #fff 5%, var(--cream)) 0%, var(--cream) 100%);
  border: 2.5px solid color-mix(in srgb, var(--c, #9b5fff) 40%, var(--outline-c));
  border-radius: var(--r); padding: 10px 12px 10px 14px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center;
  box-shadow: var(--drop-sm), inset 0 1px 0 rgba(255,255,255,0.08);
}
.ascend-row::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
  background: var(--c, #9b5fff); box-shadow: 0 0 10px var(--c, #9b5fff);
}
.ascend-row.maxed { background: color-mix(in srgb, var(--c, #9b5fff) 12%, var(--cream)); }
.ascend-row-left { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.ascend-row-icon {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 12px;
  border: 2.5px solid var(--drop-c); display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.25), inset 0 2px 0 rgba(255,255,255,0.45), var(--drop-sm);
}
.ascend-row-icon svg { width: 68%; height: 68%; display: block; filter: drop-shadow(0 1.5px 0 rgba(0,0,0,0.4)); }
.ascend-row-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ascend-row-namewrap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ascend-row-name {
  font-family: 'Luckiest Guy', cursive; font-size: 15px; letter-spacing: 0.8px; line-height: 1;
  color: var(--ink); -webkit-text-stroke: 1px var(--drop-c); paint-order: stroke fill;
}
.ascend-row-lv {
  font-family: 'Luckiest Guy', cursive; font-size: 10.5px; letter-spacing: 1px;
  border: 2px solid; border-radius: 999px; padding: 2px 8px; line-height: 1;
}
.ascend-row-desc {
  font-family: 'Fredoka', sans-serif; font-size: 11px; font-weight: 500; line-height: 1.3; color: var(--ink-soft);
}
.ascend-row-right { display: flex; flex-direction: column; align-items: stretch; gap: 6px; width: 168px; flex-shrink: 0; }
.ascend-pipbar { display: flex; gap: 4px; height: 18px; }
.ascend-pip {
  flex: 1; border-radius: 3px; transform: skewX(-14deg);
  background: color-mix(in srgb, var(--outline-c) 22%, var(--paper));
  border: 2px solid var(--outline-c); transition: background 0.2s, box-shadow 0.2s;
}
.ascend-pip.next { animation: pip-pulse 1.4s ease-in-out infinite; }
@keyframes pip-pulse { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.4); } }
.ascend-row-vals { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 0 2px; }
.ascend-row-cur {
  font-family: 'Luckiest Guy', cursive; font-size: 14px; letter-spacing: 0.5px;
  -webkit-text-stroke: 0.6px var(--drop-c); paint-order: stroke fill;
}
.ascend-row-next { font-family: 'Fredoka', sans-serif; font-size: 10.5px; font-weight: 600; color: var(--ink-soft); }
.ascend-row-next.maxed { color: #ffd23f; text-shadow: 0 0 6px rgba(255,210,63,0.55); }
.ascend-row-buy {
  font-family: 'Luckiest Guy', cursive; font-size: 13px; letter-spacing: 1px;
  padding: 7px 10px; border: 2.5px solid var(--drop-c); border-radius: var(--r); color: #fff;
  text-shadow: 0 2px 0 rgba(0,0,0,0.32); cursor: pointer;
  box-shadow: var(--drop-sm), inset 0 -2px 0 rgba(0,0,0,0.22), inset 0 1.5px 0 rgba(255,255,255,0.5);
  -webkit-text-stroke: 0.8px var(--drop-c); paint-order: stroke fill;
}
.ascend-row-buy.glow { animation: btn-bounce 1.6s ease-in-out infinite; }
.ascend-row-buy:active:not(:disabled):not(.maxed) { transform: translateY(2px); }
.ascend-row-buy:disabled {
  background: color-mix(in srgb, var(--ink-soft) 30%, var(--paper-2)); color: color-mix(in srgb, var(--ink) 50%, transparent);
  text-shadow: none; cursor: not-allowed; box-shadow: var(--drop-sm);
}
.ascend-row-buy.maxed {
  background: linear-gradient(180deg, #ffd55a, var(--candy-yellow)); color: #5a3a05;
  text-shadow: none; border-color: #9a6206; cursor: default;
}

@container ui (max-width: 360px) {
  .ascend-row { grid-template-columns: 1fr; }
  .ascend-row-right { width: auto; }
  .prestige-grid { grid-template-columns: 1fr; }
  .prestige-card { padding: 10px 8px; }
  .pc-icon { width: 46px; height: 46px; font-size: 26px; border-radius: 12px; }
  .pc-name { font-size: 12px; letter-spacing: 0.8px; }
  .pc-sub  { font-size: 10px; }
}

/* ── STATS TAB ──────────────────────────────────────────────────────────── */
.stats-card {
  background: linear-gradient(180deg, color-mix(in srgb, #fff 5%, var(--cream)) 0%, var(--cream) 100%);
  border: var(--outline);
  border-radius: var(--r);
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px;
  box-shadow: var(--drop-sm), inset 0 1px 0 rgba(255,255,255,0.08);
}
.stats-row { display: flex; justify-content: space-between; align-items: center; }
.stats-label {
  font-family: 'Fredoka', sans-serif;
  font-size: 12px; font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.stats-val {
  font-family: 'Luckiest Guy', cursive;
  font-size: 18px; letter-spacing: 1px;
  color: var(--ink);
  -webkit-text-stroke: 1.2px var(--drop-c);
}

@container ui (max-width: 360px) {
  .tab-content { padding: 8px; gap: 7px; }
  .upgrade-card { padding: 8px; gap: 8px; }
  .upg-icon { width: 38px; height: 38px; font-size: 18px; border-radius: 11px; }
  .upg-name { font-size: 10px; letter-spacing: 0.5px; }
  .upg-val { font-size: 17px; }
  .upg-next { font-size: 10px; }
  .upg-btn { height: 32px; padding: 0 10px; font-size: 12px; letter-spacing: 0.5px; }
  .upg-maxed { font-size: 11px; padding: 4px 8px; letter-spacing: 1px; }
  .lv-pip { width: 7px; height: 7px; border-width: 1.5px; }
  .lv-pips { gap: 2px; }
}
@container ui (max-width: 260px) {
  .tab-content { padding: 6px; gap: 5px; }
  .upgrade-card { padding: 6px; gap: 6px; }
  .upg-icon { width: 30px; height: 30px; font-size: 14px; border-radius: 9px; }
  .upg-val { font-size: 14px; }
  .upg-btn { height: 28px; padding: 0 8px; font-size: 11px; }
  .lv-pips { display: none; }
  .upg-right { gap: 2px; }
}

/* ════════════════════════════════════════════════════════════════════════════
   EXTENDED SYSTEMS — gems HUD, powers dock, quests/daily, awards, codex,
   events, toasts, tab badges. Appended; later rules win where they overlap.
   ════════════════════════════════════════════════════════════════════════════ */

/* NOTE: classes below (pdock, cal-*, event-*, wide-btn) are unused v5 leftovers
   kept harmless (no matching DOM in v6). panel-card/panel-sub/info-banner ARE used. */

/* ── POWER DOCK (unused v5) ── */
.power-dock {
  width: 100%; flex-shrink: 0;
  display: flex; gap: 6px;
}
.pdock {
  flex: 1 1 0; height: 50px;
  background: linear-gradient(180deg, color-mix(in srgb, #fff 5%, var(--cream)) 0%, var(--cream) 100%);
  border: 2.5px solid var(--outline-c);
  border-radius: var(--r);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative; cursor: pointer;
  box-shadow: var(--drop-sm), inset 0 1px 0 rgba(255,255,255,0.10), inset 0 -2px 0 rgba(0,0,0,0.2);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.1s;
}
.pdock:active { transform: translateY(2px); }
.pdock-ic { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; }
.pdock-ic svg { width: 100%; height: 100%; filter: drop-shadow(0 1.5px 0 rgba(0,0,0,0.4)); }
.pdock-n {
  position: absolute; bottom: -6px; right: -4px;
  min-width: 19px; height: 19px; padding: 0 4px;
  background: linear-gradient(180deg, #79ccff, var(--candy-blue));
  border: 2px solid var(--drop-c); border-radius: 999px;
  font-family: 'Luckiest Guy', cursive; font-size: 11px; line-height: 15px; color: #fff;
  display: flex; align-items: center; justify-content: center;
  -webkit-text-stroke: 0.6px var(--drop-c);
  box-shadow: 0 2px 0 var(--drop-c);
}
.pdock.empty { filter: grayscale(0.7) brightness(0.7); }
.pdock.empty .pdock-n { background: linear-gradient(180deg, #8a8398, #5a5470); }
.pdock.armed {
  border-color: var(--tab-active);
  box-shadow: var(--drop-sm), 0 0 0 2px var(--tab-active), 0 0 16px rgba(240,185,74,0.6);
  animation: action-btn-pulse 1.2s ease-in-out infinite;
}

/* ── GENERIC PANEL CARD / BANNERS ── */
.panel-card {
  background: linear-gradient(180deg, color-mix(in srgb, #fff 5%, var(--cream)) 0%, var(--cream) 100%);
  border: var(--outline); border-radius: var(--r); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
  box-shadow: var(--drop-sm), inset 0 1px 0 rgba(255,255,255,0.08);
}
.panel-title {
  font-family: 'Luckiest Guy', cursive; font-size: 16px; letter-spacing: 1.5px;
  color: var(--ink); -webkit-text-stroke: 1.2px var(--drop-c); paint-order: stroke fill;
}
.panel-sub { font-family: 'Fredoka', sans-serif; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.info-banner {
  background: linear-gradient(180deg, color-mix(in srgb, var(--candy-blue) 18%, var(--cream)) 0%, var(--cream) 100%);
  border: 2.5px solid color-mix(in srgb, var(--candy-blue) 50%, var(--outline-c));
  border-radius: var(--r); padding: 10px 12px;
  font-family: 'Fredoka', sans-serif; font-size: 12px; font-weight: 600; color: var(--ink-soft);
  line-height: 1.4; box-shadow: var(--drop-sm);
}

/* ── EVENT BANNER ── */
.event-banner {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--candy-yellow) 26%, var(--cream)) 0%, var(--cream) 100%);
  border: 3px solid color-mix(in srgb, var(--candy-yellow) 60%, var(--drop-c));
  border-radius: var(--r);
  box-shadow: var(--drop-sm), 0 0 18px rgba(245,201,71,0.4);
  animation: action-btn-pulse 1.8s ease-in-out infinite;
}
.event-ic { width: 34px; height: 34px; flex-shrink: 0; }
.event-ic svg { width: 100%; height: 100%; filter: drop-shadow(0 1.5px 0 rgba(0,0,0,0.4)); }
.event-name { font-family: 'Luckiest Guy', cursive; font-size: 15px; letter-spacing: 1px; color: var(--ink); -webkit-text-stroke: 1px var(--drop-c); paint-order: stroke fill; }
.event-desc { font-family: 'Fredoka', sans-serif; font-size: 11px; font-weight: 600; color: var(--ink-soft); }

/* ── DAILY CALENDAR ── */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-day {
  aspect-ratio: 1/1; border-radius: 12px;
  background: var(--cream); border: 2.5px solid var(--outline-c);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  position: relative; padding: 2px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), inset 0 -2px 0 rgba(0,0,0,0.18);
}
.cal-n { font-family: 'Fredoka', sans-serif; font-size: 8px; font-weight: 700; color: var(--ink-soft); letter-spacing: 0.5px; }
.cal-ic { width: 20px; height: 20px; }
.cal-ic svg { width: 100%; height: 100%; }
.cal-r { font-family: 'Luckiest Guy', cursive; font-size: 9px; color: var(--ink); -webkit-text-stroke: 0.6px var(--drop-c); }
.cal-day.claimed { filter: grayscale(0.7) brightness(0.6); }
.cal-day.claimed::after {
  content: '✓'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: var(--candy-mint); font-family: 'Luckiest Guy', cursive; -webkit-text-stroke: 1.5px var(--drop-c);
}
.cal-day.today { border-color: var(--tab-active); box-shadow: 0 0 0 2px var(--tab-active), 0 0 14px rgba(240,185,74,0.5); animation: ascend-ready-pulse 1.6s ease-in-out infinite; }

.wide-btn {
  width: 100%; height: 44px;
  background: linear-gradient(180deg, #6ce8a0, #34c46f);
  border: 3px solid var(--drop-c); border-radius: var(--r); color: #fff;
  font-family: 'Luckiest Guy', cursive; font-size: 16px; letter-spacing: 2px; cursor: pointer;
  -webkit-text-stroke: 1.2px var(--drop-c); paint-order: stroke fill;
  box-shadow: var(--drop-sm), inset 0 -3px 0 rgba(0,0,0,0.28), inset 0 2px 0 rgba(255,255,255,0.5);
  transition: transform 0.08s, filter 0.08s;
}
.wide-btn:active { transform: translateY(2px); }
.wide-btn.glow { animation: action-btn-pulse 1.6s ease-in-out infinite; }
.wide-btn:disabled { background: color-mix(in srgb, var(--ink-soft) 22%, var(--paper-2)); color: color-mix(in srgb, var(--ink) 50%, transparent); cursor: not-allowed; box-shadow: var(--drop-sm); }

/* ── QUEST CARDS ── */
.quest-card {
  background: linear-gradient(180deg, color-mix(in srgb, #fff 5%, var(--cream)) 0%, var(--cream) 100%);
  border: var(--outline); border-radius: var(--r); padding: 10px 12px;
  display: flex; flex-direction: column; gap: 7px;
  box-shadow: var(--drop-sm), inset 0 1px 0 rgba(255,255,255,0.08);
}
.quest-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.quest-text { font-family: 'Fredoka', sans-serif; font-size: 13px; font-weight: 700; color: var(--ink); }
.quest-rew { display: inline-flex; align-items: center; gap: 4px; font-family: 'Luckiest Guy', cursive; font-size: 13px; color: #8df0e8; -webkit-text-stroke: 0.8px var(--drop-c); white-space: nowrap; }
.quest-rew svg { width: 16px; height: 16px; }
.qbar { height: 9px; border-radius: 999px; background: rgba(0,0,0,0.3); overflow: hidden; border: 1.5px solid var(--outline-c); }
.qbar-fill { height: 100%; background: linear-gradient(90deg, var(--candy-mint), #9cffc0); border-radius: 999px; transition: width 0.3s; }
.quest-bot { display: flex; justify-content: space-between; align-items: center; }
.quest-prog { font-family: 'Fredoka', sans-serif; font-size: 11px; font-weight: 700; color: var(--ink-soft); }
.quest-done { font-family: 'Luckiest Guy', cursive; font-size: 12px; letter-spacing: 1px; color: var(--candy-mint); -webkit-text-stroke: 0.8px var(--drop-c); }
.mini-btn {
  height: 30px; padding: 0 14px;
  background: linear-gradient(180deg, #6ce8a0, #34c46f);
  border: 2.5px solid var(--drop-c); border-radius: 10px; color: #fff;
  font-family: 'Luckiest Guy', cursive; font-size: 12px; letter-spacing: 1px; cursor: pointer;
  -webkit-text-stroke: 0.8px var(--drop-c); paint-order: stroke fill;
  box-shadow: var(--drop-sm), inset 0 -2px 0 rgba(0,0,0,0.28), inset 0 2px 0 rgba(255,255,255,0.5);
}
.mini-btn.glow { animation: action-btn-pulse 1.4s ease-in-out infinite; }
.mini-btn:disabled { background: color-mix(in srgb, var(--ink-soft) 22%, var(--paper-2)); color: color-mix(in srgb, var(--ink) 50%, transparent); cursor: not-allowed; }

/* ── AWARDS GRID ── */
.award-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.award {
  background: var(--cream); border: 2.5px solid var(--outline-c); border-radius: 14px;
  padding: 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center;
  filter: grayscale(0.85) brightness(0.7); box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
.award.done { filter: none; border-color: color-mix(in srgb, var(--candy-yellow) 55%, var(--outline-c)); box-shadow: 0 0 14px rgba(245,201,71,0.35); }
.award-ic { width: 34px; height: 34px; }
.award-ic svg { width: 100%; height: 100%; filter: drop-shadow(0 1.5px 0 rgba(0,0,0,0.4)); }
.award-n { font-family: 'Fredoka', sans-serif; font-size: 9.5px; font-weight: 700; color: var(--ink-soft); line-height: 1.1; }
.award-g { display: inline-flex; align-items: center; gap: 3px; font-family: 'Luckiest Guy', cursive; font-size: 11px; color: #8df0e8; -webkit-text-stroke: 0.6px var(--drop-c); }
.award-g svg { width: 13px; height: 13px; }

/* ── CODEX GRID ── */
.codex-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.codex-cell {
  aspect-ratio: 1/1; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Luckiest Guy', cursive; font-size: 17px;
  border: 2.5px solid var(--drop-c); color: #fff;
  -webkit-text-stroke: 1.2px var(--drop-c); paint-order: stroke fill;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,0.28), inset 0 3px 0 rgba(255,255,255,0.4), 0 2px 0 rgba(0,0,0,0.35);
}
.codex-cell.locked {
  background: var(--cream); color: var(--ink-soft); border-color: var(--outline-c);
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.35); -webkit-text-stroke: 0; font-size: 22px;
}
.codex-cell.t1 { background: linear-gradient(180deg, #ffe6a1, #f4b81e); }
.codex-cell.t2 { background: linear-gradient(180deg, #ffc878, #ec8924); }
.codex-cell.t3 { background: linear-gradient(180deg, #ff9c63, #d9501c); }
.codex-cell.t4 { background: linear-gradient(180deg, #ff8ea0, #e84676); }
.codex-cell.t5 { background: linear-gradient(180deg, #ff7077, #c63040); }
.codex-cell.t6 { background: linear-gradient(180deg, #c8a4ff, #8d54e8); }
.codex-cell.t7 { background: linear-gradient(180deg, #a386ff, #6332d2); }
.codex-cell.t8 { background: linear-gradient(180deg, #79c3ff, #2f8ed8); }
.codex-cell.t9 { background: linear-gradient(180deg, #4ed8ff, #008fc6); font-size: 14px; }
.codex-cell.t10 { background: linear-gradient(180deg, #6ff0c8, #14a47a); font-size: 14px; }
.codex-cell.t11 { background: linear-gradient(180deg, #b6f273, #45a82c); font-size: 14px; }
.codex-cell.t12 { background: linear-gradient(180deg, #ffe27a, #f4b81e); font-size: 13px; }
.codex-cell.t13 { background: linear-gradient(45deg, #ff6d96, #ffd23f, #6ff0c8, #5aa8e8, #9b78e0); background-size: 300% 300%; animation: tile-rainbow 4s linear infinite; font-size: 12px; }

/* ── TOASTS ── */
#toast-wrap {
  position: fixed; left: 0; right: 0; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 1550;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none; padding: 0 12px;
}
.toast {
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(180deg, var(--paper-2), var(--paper));
  border: 2.5px solid var(--outline-c); border-radius: 999px;
  padding: 8px 16px; max-width: 92%;
  font-family: 'Fredoka', sans-serif; font-size: 13px; font-weight: 700; color: var(--ink);
  box-shadow: var(--drop), 0 0 18px rgba(0,0,0,0.4);
  animation: toast-in 0.3s cubic-bezier(0.34,1.56,0.64,1), toast-out 0.4s ease 2s forwards;
}
.toast-ic { width: 20px; height: 20px; flex-shrink: 0; }
.toast-ic svg { width: 100%; height: 100%; }
@keyframes toast-in  { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes toast-out { to { transform: translateY(-10px); opacity: 0; } }

/* ════════════════════════════════════════════════════════════════════════════
   PHASE 4 — LIGHT THEME, THEME TOGGLE, CONFETTI SPARKS
   ════════════════════════════════════════════════════════════════════════════ */

/* Light theme: override the dark-only structural tokens. Candy accents stay. */
:root[data-theme="light"] {
  /* surfaces — bright warm cards over a cream base */
  --cream:     #faf1d9;
  --paper:     #fffefb;
  --paper-2:   #efe0c2;
  --ink:       #4a3418;
  --ink-soft:  #8a7150;
  --outline-c: #ccb481;
  --drop-c:    #2c1d0c;     /* deep espresso → crisp chunky outlines + hard offset shadows */

  /* cheerful candy backdrop (more visible behind the panels) */
  --bg-1: #ffd79a;
  --bg-2: #ffc0d6;
  --bg-3: #ccbcff;
  --bg-4: #fff1de;
  --bg-5: #ffdcb8;

  /* board — clearly readable empty cells */
  --board-bg-1: #f0dcae;
  --board-bg-2: #e3c890;
  --board-edge: #c2a266;
  --cell-bg:    rgba(74,48,14,0.20);
  --cell-edge:  rgba(74,48,14,0.30);
}

/* ── LIGHT MODE polish: elevation + contrast ──────────────────────────────── */
/* float panels & cards with a soft warm shadow — light themes read flat without
   an elevation cue beyond the flat chunky outline */
:root[data-theme="light"] .hud,
:root[data-theme="light"] .upgrade-card,
:root[data-theme="light"] .panel-card,
:root[data-theme="light"] .inv-hero,
:root[data-theme="light"] .inv-card,
:root[data-theme="light"] .skin-card,
:root[data-theme="light"] .reset-action,
:root[data-theme="light"] .ascend-row,
:root[data-theme="light"] .board-frame,
:root[data-theme="light"] .soon-banner {
  box-shadow: var(--drop), 0 6px 15px rgba(150,98,28,0.13);
}
/* washed-out pastel readouts → saturated versions that pop on cream */
:root[data-theme="light"] .hud-score .hud-value,
:root[data-theme="light"] .hud-sp .hud-value,
:root[data-theme="light"] .reset-action.prestige .reset-action-title,
:root[data-theme="light"] .reset-action.cashout .reset-action-title,
:root[data-theme="light"] .cashout-prog-txt    { color: #1488b8; }
:root[data-theme="light"] .hud-best .hud-value  { color: #d24e7b; }
:root[data-theme="light"] .hud-ap .hud-value    { color: #1d72cf; }
:root[data-theme="light"] .hud-coins .hud-value,
:root[data-theme="light"] .ra-pop,
:root[data-theme="light"] .ascend-stat-val.glow { color: #cc8b0c; }
:root[data-theme="light"] .hud-gems .hud-value,
:root[data-theme="light"] .reset-action.ascend .reset-action-title,
:root[data-theme="light"] .ascend-hero-title { color: #8a5fe0; }
/* chunky value/number text AND headers/names: a dark --ink fill ringed by a dark
   --drop-c outline reads as a heavy black blob on a light card. Flip the OUTLINE to
   cream so the dark text reads as a clean embossed sticker instead. */
:root[data-theme="light"] .upg-val,
:root[data-theme="light"] .stats-val,
:root[data-theme="light"] .board-pill,
:root[data-theme="light"] .hud-value,
:root[data-theme="light"] .ascend-row-cur,
:root[data-theme="light"] .ra-stat .ra-val,
:root[data-theme="light"] .ascend-stat-val,
:root[data-theme="light"] .panel-title,
:root[data-theme="light"] .soon-banner,
:root[data-theme="light"] .inv-hero-title,
:root[data-theme="light"] .fac-section-title,
:root[data-theme="light"] .ascend-row-name,
:root[data-theme="light"] .inv-name,
:root[data-theme="light"] .skin-name,
:root[data-theme="light"] .event-name,
:root[data-theme="light"] .cal-r {
  -webkit-text-stroke-color: #fff8ec;
}
/* big hero titles also carry a hard dark drop-shadow; soften it to a warm tan so the
   header doesn't get a heavy black slab under it in light mode */
:root[data-theme="light"] .inv-hero-title { text-shadow: 0 3px 0 #d8c39a; }
/* THE VOID title is a panel-title too, but the Void panel stays dark in both themes —
   keep its black glitch outline so white text on dark still pops. */
:root[data-theme="light"] .void-glitch { -webkit-text-stroke-color: #000; }
/* tab names: washed light-brown fill + dark outline reads muddy. Give the inactive
   labels a richer brown and a cream outline so they read clean (active = darkest). */
:root[data-theme="light"] .tab-btn-label {
  color: #8a6630;
  -webkit-text-stroke-color: #fff8ec;
}
:root[data-theme="light"] .tab-btn.active .tab-btn-label { color: var(--ink); }

/* can't-afford / disabled buttons: a clean muted tan instead of a muddy ink mix,
   with solid muted text and no heavy dark outline ghosting through */
:root[data-theme="light"] .upg-btn:disabled,
:root[data-theme="light"] .mini-btn:disabled,
:root[data-theme="light"] .wide-btn:disabled,
:root[data-theme="light"] .reset-action-btn:disabled,
:root[data-theme="light"] .ascend-row-buy:disabled,
:root[data-theme="light"] .inv-btn:disabled:not(.owned) {
  background: linear-gradient(180deg, #ecdfc1 0%, #dbc9a4 100%);
  color: #9c875d;
  border-color: #ccb887;
  text-shadow: none;
  -webkit-text-stroke-width: 0;
}

/* theme toggle button — matches the round mute/reset chips */
.hud-theme {
  background: var(--paper);
  border: 2.5px solid var(--outline-c);
  color: var(--ink);
  border-radius: 50%;
  width: 42px; height: 42px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.1s, filter 0.1s;
  box-shadow: var(--drop-sm);
  padding: 0;
}
.hud-theme svg { width: 54%; height: 54%; }
.hud-theme:hover  { filter: brightness(1.08); }
.hud-theme:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--drop-c); }
@media (max-height: 620px), (max-width: 900px) {
  .hud-theme { width: 38px; height: 38px; border-width: 2px; }
}
@media (max-width: 420px) { .hud-theme { display: none; } }

/* confetti sparks (big merges + ascend) — emit from board-frame center, self-clean */
.spark {
  position: absolute;
  left: 50%; top: 50%;
  width: 9px; height: 9px;
  border-radius: 2px;
  border: 1.5px solid var(--drop-c);
  z-index: 6;
  pointer-events: none;
  animation: spark-fly 0.74s cubic-bezier(0.22, 0.7, 0.3, 1) forwards;
}
@keyframes spark-fly {
  0%   { transform: translate(-50%, -50%) scale(0.4) rotate(0deg); opacity: 0; }
  15%  { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1) rotate(220deg); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .spark { display: none; } }

/* ════════════════════════════════════════════════════════════════════════════
   FIELD-RESET EXPLOSION — tiles pop out & fall off-screen (NO dark/blur bg)
   ════════════════════════════════════════════════════════════════════════════ */
#explode-layer {
  position: fixed; inset: 0; z-index: 700;
  pointer-events: none; overflow: visible;
}
/* clones reuse .tile styling; this just drives the fling. The .tile base sets
   transition on left/top — override so our transform animation is clean. */
.tile.exploding {
  transition: none;
  border-radius: 14%;   /* cqw doesn't resolve outside the board container; keep a sane round */
  animation: tile-explode 0.95s cubic-bezier(0.32, 0.12, 0.5, 1) forwards;
  will-change: transform, opacity;
  z-index: 701;
}
@keyframes tile-explode {
  0%   { transform: translate(0,0) scale(1) rotate(0deg); opacity: 1; }
  16%  { transform: translate(0,-14%) scale(1.18) rotate(calc(var(--er) * 0.12)); opacity: 1; }
  100% { transform: translate(var(--ex), var(--ey)) scale(0.7) rotate(var(--er)); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  #explode-layer { display: none; }
}

/* ════════════════════════════════════════════════════════════════════════════
   CASHOUT CELEBRATION — full-screen reward burst on cashout
   ════════════════════════════════════════════════════════════════════════════ */
.cashout-cele {
  position: fixed; inset: 0; z-index: 800;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; overflow: hidden;
  animation: cc-fade 1.85s ease-out forwards;
}
@keyframes cc-fade { 0%,82% { opacity: 1; } 100% { opacity: 0; } }

/* darkened + blurred backdrop behind the whole celebration */
.cc-backdrop {
  position: absolute; inset: -9vmax;   /* oversized so screen-shake never reveals an edge gap */
  background: rgba(6, 4, 14, 0.88);    /* dark enough that the game UI never reads through */
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  animation: cc-backdrop 1.85s ease-out forwards;
}
@keyframes cc-backdrop {
  0%   { opacity: 0; }
  14%  { opacity: 1; }
  74%  { opacity: 1; }
  100% { opacity: 0; }
}

/* soft radial flash behind everything */
.cc-flash {
  position: absolute; width: 60vmin; height: 60vmin; border-radius: 50%;
  background: radial-gradient(circle, rgba(127,227,255,0.55) 0%, rgba(76,209,238,0.18) 40%, transparent 70%);
  animation: cc-flash 0.9s ease-out forwards;
}
@keyframes cc-flash {
  0%   { transform: scale(0.2); opacity: 0; }
  25%  { opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* expanding cyan shockwave ring */
.cc-shock {
  position: absolute; width: 20vmin; height: 20vmin; border-radius: 50%;
  border: 0.9vmin solid #7fe3ff;
  box-shadow: 0 0 24px rgba(127,227,255,0.7), inset 0 0 18px rgba(127,227,255,0.5);
  animation: cc-shock 0.85s cubic-bezier(0.2,0.7,0.3,1) forwards;
}
@keyframes cc-shock {
  0%   { transform: scale(0.3); opacity: 0; }
  20%  { opacity: 1; }
  100% { transform: scale(3.4); opacity: 0; }
}

/* hero SP star: zoom in, overshoot, settle, then pop out */
.cc-star {
  position: absolute; width: 34vmin; height: 34vmin; max-width: 220px; max-height: 220px;
  filter: drop-shadow(0 6px 0 var(--drop-c)) drop-shadow(0 0 28px rgba(127,227,255,0.85));
  animation: cc-star 1.85s cubic-bezier(0.3,1.4,0.5,1) forwards;
}
.cc-star svg { width: 100%; height: 100%; display: block; }
@keyframes cc-star {
  0%   { transform: scale(0) rotate(-40deg); opacity: 0; }
  22%  { transform: scale(1.18) rotate(6deg); opacity: 1; }
  34%  { transform: scale(1) rotate(0deg); }
  78%  { transform: scale(1) rotate(0deg); opacity: 1; }
  100% { transform: scale(1.5) rotate(0deg); opacity: 0; }
}

/* "+N SP" amount, sits below the star */
.cc-amt {
  position: absolute; transform: translateY(20vmin);
  font-family: 'Bungee', system-ui, sans-serif;
  font-size: clamp(30px, 9vmin, 64px); letter-spacing: 2px;
  color: #8be7ff;
  -webkit-text-stroke: 2.4px var(--drop-c); paint-order: stroke fill;
  text-shadow: 0 4px 0 var(--drop-c);
  animation: cc-amt 1.85s ease-out forwards;
}
.cc-amt-tag { font-size: 0.5em; margin-left: 0.25em; color: #d6f7ff; }
@keyframes cc-amt {
  0%   { transform: translateY(20vmin) scale(0.4); opacity: 0; }
  30%  { transform: translateY(20vmin) scale(1.1); opacity: 1; }
  42%  { transform: translateY(20vmin) scale(1); }
  80%  { opacity: 1; }
  100% { transform: translateY(15vmin) scale(1); opacity: 0; }
}

/* coins fly from screen edges toward center, then vanish into the star */
.cc-coin {
  position: absolute; width: 6vmin; height: 6vmin; max-width: 44px; max-height: 44px;
  transform: translate(var(--sx), var(--sy)) scale(0.6);
  filter: drop-shadow(0 2px 0 var(--drop-c));
  animation: cc-coin 0.95s cubic-bezier(0.5,0,0.6,1) forwards;
}
.cc-coin svg { width: 100%; height: 100%; display: block; }
@keyframes cc-coin {
  0%   { transform: translate(var(--sx), var(--sy)) scale(0.5); opacity: 0; }
  15%  { opacity: 1; }
  100% { transform: translate(0, 0) scale(0.25); opacity: 0; }
}

/* sparkle ring that pops at the star on coin impact */
.cc-spark {
  position: absolute; width: 1.6vmin; height: 1.6vmin; max-width: 12px; max-height: 12px;
  border-radius: 2px; background: #ffe27a;
  border: 1.5px solid var(--drop-c);
  animation: cc-spark 0.8s ease-out 0.5s forwards;
  opacity: 0;
}
@keyframes cc-spark {
  0%   { transform: translate(0,0) scale(0.2); opacity: 0; }
  20%  { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1) rotate(180deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .cc-coin, .cc-spark, .cc-shock { display: none; }
  .cc-star { animation: cc-flash 0.9s ease-out forwards; }
}

/* ── ASCEND CELEBRATION (blue lift-off) ── */
.ascend-cele {
  position: fixed; inset: 0; z-index: 800;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; overflow: hidden;
  animation: cc-fade 2s ease-out forwards;
}
.ascend-cele .cc-backdrop { animation: cc-backdrop 2s ease-out forwards; }
.ac-flash { background: radial-gradient(circle, rgba(120,185,255,0.6) 0%, rgba(58,169,255,0.2) 40%, transparent 70%); }
.ac-shock { border-color: #7fc0ff; box-shadow: 0 0 24px rgba(127,180,255,0.75), inset 0 0 18px rgba(127,180,255,0.55); }
/* vertical light shaft rising from the bottom */
.ac-beam {
  position: absolute; bottom: 0; width: 42vmin;
  background: linear-gradient(0deg, rgba(58,169,255,0.55) 0%, rgba(127,200,255,0.22) 55%, transparent 100%);
  filter: blur(6px);
  animation: ac-beam 1.6s cubic-bezier(0.2,0.7,0.3,1) forwards;
}
@keyframes ac-beam { 0% { height: 0; opacity: 0; } 25% { opacity: 1; } 100% { height: 100dvh; opacity: 0; } }
/* chevrons streaming skyward */
.ac-chev {
  position: absolute; bottom: -10vh; width: 7vmin; height: 7vmin; color: #8bc4ff;
  filter: drop-shadow(0 0 8px rgba(127,180,255,0.85));
  animation-name: ac-chev-rise; animation-timing-function: linear; animation-fill-mode: forwards;
}
.ac-chev svg { width: 100%; height: 100%; display: block; }
@keyframes ac-chev-rise {
  0%   { transform: translateY(0) scale(0.6); opacity: 0; }
  15%  { opacity: 1; }
  100% { transform: translateY(calc(-1 * var(--rise) - 20vh)) scale(1.1); opacity: 0; }
}
/* central rank emblem: zoom up, settle, pop out */
.ac-emblem {
  position: absolute; width: 30vmin; height: 30vmin; max-width: 200px; max-height: 200px; color: #d6ecff;
  filter: drop-shadow(0 6px 0 var(--drop-c)) drop-shadow(0 0 28px rgba(127,180,255,0.9));
  animation: ac-emblem 2s cubic-bezier(0.3,1.4,0.5,1) forwards;
}
.ac-emblem svg { width: 100%; height: 100%; display: block; }
@keyframes ac-emblem {
  0%   { transform: scale(0) translateY(30vh); opacity: 0; }
  24%  { transform: scale(1.18) translateY(0); opacity: 1; }
  36%  { transform: scale(1) translateY(0); }
  80%  { transform: scale(1) translateY(0); opacity: 1; }
  100% { transform: scale(1.5) translateY(-10vh); opacity: 0; }
}
.ac-label {
  position: absolute; text-align: center;
  font-family: 'Luckiest Guy', cursive; font-size: clamp(28px,8vmin,56px); letter-spacing: 2px;
  color: #8bc4ff; -webkit-text-stroke: 2.2px var(--drop-c); paint-order: stroke fill;
  text-shadow: 0 4px 0 var(--drop-c);
  display: flex; flex-direction: column; gap: 6px; align-items: center;
  animation: cc-amt 2s ease-out forwards;
}
.ac-rank { font-family: 'Fredoka', sans-serif; font-weight: 800; font-size: 0.32em; color: #d6ecff; -webkit-text-stroke: 0; text-shadow: none; letter-spacing: 1px; }
.ac-spark {
  position: absolute; width: 1.6vmin; height: 1.6vmin; max-width: 12px; max-height: 12px;
  border-radius: 2px; background: #bfe0ff; border: 1.5px solid var(--drop-c);
  animation: cc-spark 0.85s ease-out 0.45s forwards; opacity: 0;
}
@media (prefers-reduced-motion: reduce) {
  .ac-chev, .ac-spark, .ac-shock, .ac-beam { display: none; }
  .ac-emblem { animation: cc-flash 0.9s ease-out forwards; }
}

/* ════════════════════════════════════════════════════════════════════════════
   INVESTMENT CELEBRATION — merge-cascade build-up to the invested cube
   ════════════════════════════════════════════════════════════════════════════ */
.inv-cele {
  position: fixed; inset: 0; z-index: 820;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; overflow: hidden;
}
/* hold the darkened/blurred backdrop for the whole cascade (cashout's fades out too early) */
/* invest has lots of open space around the growing cube, so make its backdrop
   near-opaque — no game text bleeds through behind the cube. */
.inv-cele .cc-backdrop { background: rgba(7, 5, 17, 0.97); animation: iv-bd 0.25s ease-out forwards; }
@keyframes iv-bd { from { opacity: 0; } to { opacity: 1; } }
.inv-cele.iv-fadeout { animation: iv-celeout 0.4s ease-out forwards; }
@keyframes iv-celeout { to { opacity: 0; } }
.inv-cele.iv-shake { animation: iv-shake 0.22s ease-out; }
@keyframes iv-shake {
  0%,100% { transform: translate(0,0); }
  20% { transform: translate(calc(var(--shk,4px) * -1), var(--shk,4px)); }
  45% { transform: translate(var(--shk,4px), calc(var(--shk,4px) * -0.6)); }
  70% { transform: translate(calc(var(--shk,4px) * -0.6), var(--shk,4px)); }
}
.iv-stage { position: relative; display: flex; align-items: center; justify-content: center; }
.iv-cube {
  width: 34vmin; height: 34vmin; max-width: 200px; max-height: 200px;
  border-radius: 16px; display: flex; align-items: center; justify-content: center;
  font-family: 'Luckiest Guy', cursive; color: #fff; letter-spacing: 0.5px;
  border: 4px solid var(--drop-c);
  -webkit-text-stroke: 2.2px var(--drop-c); paint-order: stroke fill; text-shadow: 0 3px 0 rgba(0,0,0,0.4);
  box-shadow: inset 0 -6px 0 rgba(0,0,0,0.28), inset 0 4px 0 rgba(255,255,255,0.5), 0 6px 0 rgba(0,0,0,0.45), 0 0 28px rgba(255,255,255,0.25);
}
.iv-main { position: relative; z-index: 2; }
.iv-faller { position: absolute; z-index: 3; animation: iv-fall var(--fall, 280ms) cubic-bezier(0.5,0.02,0.7,0.9) forwards; }
@keyframes iv-fall {
  0%   { transform: translateY(-115vmin) scale(0.92); opacity: 0; }
  12%  { opacity: 1; }
  88%  { transform: translateY(0) scale(1); }
  100% { transform: translateY(0) scaleY(0.86) scaleX(1.08); }
}
.iv-pop { animation: iv-pop 0.26s cubic-bezier(0.34,1.56,0.64,1); }
@keyframes iv-pop {
  0%   { transform: scale(0.86); filter: brightness(1.6); }
  55%  { transform: scale(1.18); filter: brightness(1.3); }
  100% { transform: scale(1); filter: brightness(1); }
}
.iv-rainbow {
  background: linear-gradient(45deg, #ff6d96, #ffd23f, #6ff0c8, #5aa8e8, #9b78e0) !important;
  background-size: 300% 300%; animation: tile-rainbow 4s linear infinite;
}
.iv-win { animation: iv-win 1.4s ease-out forwards; }
@keyframes iv-win {
  0%   { transform: scale(1); }
  18%  { transform: scale(1.28); filter: brightness(1.7) drop-shadow(0 0 40px rgba(255,255,255,0.9)); }
  60%  { transform: scale(1.12); }
  100% { transform: scale(1.12); filter: brightness(1.1); }
}
.iv-ring {
  position: absolute; width: 30vmin; height: 30vmin; max-width: 180px; max-height: 180px;
  border-radius: 50%; border: 0.7vmin solid rgba(255,255,255,0.85);
  box-shadow: 0 0 22px rgba(255,255,255,0.6); pointer-events: none;
  animation: iv-ring 0.6s cubic-bezier(0.2,0.7,0.3,1) forwards;
}
@keyframes iv-ring {
  0%   { transform: scale(0.5); opacity: 0; }
  25%  { opacity: 0.9; }
  100% { transform: scale(2.1); opacity: 0; }
}
.iv-spark {
  position: absolute; width: 1.5vmin; height: 1.5vmin; max-width: 12px; max-height: 12px;
  border-radius: 2px; background: #fff4c2; border: 1.5px solid var(--drop-c);
  animation: iv-spark 0.6s ease-out forwards;
}
@keyframes iv-spark {
  0%   { transform: translate(0,0) scale(0.3); opacity: 0; }
  20%  { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1) rotate(160deg); opacity: 0; }
}
.iv-win-label {
  position: absolute; z-index: 5; text-align: center;   /* above the cube — never hidden behind it */
  font-family: 'Bungee', system-ui, sans-serif; font-size: clamp(24px, 7vmin, 50px); letter-spacing: 2px;
  color: #fff4c2; -webkit-text-stroke: 2.4px var(--drop-c); paint-order: stroke fill; text-shadow: 0 4px 0 var(--drop-c);
  animation: iv-win-label-in 1.6s ease-out forwards;
}
.iv-win-label span { display: block; font-size: 0.42em; letter-spacing: 6px; color: #fff; margin-top: 2px; }
/* sits clearly BELOW the cube the whole time (the old cc-amt pulled it up onto the cube) */
@keyframes iv-win-label-in {
  0%   { transform: translateY(30vmin) scale(0.4); opacity: 0; }
  28%  { transform: translateY(30vmin) scale(1.12); opacity: 1; }
  44%  { transform: translateY(30vmin) scale(1); opacity: 1; }
  100% { transform: translateY(30vmin) scale(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .iv-faller, .iv-ring, .iv-spark, .cc-shock { display: none; }
}

/* ════════════════════════════════════════════════════════════════════════════
   v6 PLINKO-ALIGN — SP pill, Cashout action, Invest ladder, Skins
   ════════════════════════════════════════════════════════════════════════════ */
.hud-sp {
  background: linear-gradient(180deg, color-mix(in srgb, #4cd1ee 18%, var(--cream)) 0%, var(--cream) 100%);
  border-color: color-mix(in srgb, #4cd1ee 55%, var(--outline-c));
  box-shadow: var(--drop-sm);
}
.hud-sp .hud-block-icon {
  background: radial-gradient(circle at 30% 30%, #d6f7ff 0%, #4cd1ee 45%, #1a7ec0 100%);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.28), inset 0 2px 0 rgba(255,255,255,0.55);
}
.hud-sp .hud-value { color: #8be7ff; -webkit-text-stroke: 1.5px var(--drop-c); }
.hud-sp.bump .hud-value { animation: hud-bump 0.45s cubic-bezier(0.34,1.56,0.64,1); }
@media (max-width: 560px) { .hud-sp .hud-label { display: none; } }

/* AP — Ascend Points (blue, matches the Ascend layer) */
.hud-ap {
  background: linear-gradient(180deg, color-mix(in srgb, #3aa9ff 18%, var(--cream)) 0%, var(--cream) 100%);
  border-color: color-mix(in srgb, #3aa9ff 55%, var(--outline-c));
  box-shadow: var(--drop-sm);
}
.hud-ap .hud-block-icon {
  background: radial-gradient(circle at 30% 30%, #d6ecff 0%, #3aa9ff 45%, #1668c0 100%);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.28), inset 0 2px 0 rgba(255,255,255,0.55);
  color: #fff;   /* the tab_ascend glyph is currentColor → keep it white on the blue badge in both themes */
}
.hud-ap .hud-value { color: #9cd0ff; -webkit-text-stroke: 1.5px var(--drop-c); }
.hud-ap.bump .hud-value { animation: hud-bump 0.45s cubic-bezier(0.34,1.56,0.64,1); }
@media (max-width: 560px) { .hud-ap .hud-label { display: none; } }

.reset-action.cashout {
  background: linear-gradient(180deg, color-mix(in srgb, #4cd1ee 26%, var(--cream)) 0%, var(--cream) 70%, color-mix(in srgb, #000 4%, var(--cream)) 100%);
  box-shadow: var(--drop), inset 0 1px 0 rgba(255,255,255,0.12), inset 0 -2px 0 rgba(0,0,0,0.2), 0 0 14px rgba(76,209,238,0.18);
}
.reset-action.cashout .reset-action-icon { background: radial-gradient(circle at 30% 30%, #b8f0ff 0%, #4cd1ee 50%, #1a7ec0 100%); }
.reset-action.cashout .reset-action-title { color: #8be7ff; }
.reset-action.cashout .reset-action-btn { background: linear-gradient(180deg, #6fe4ff 0%, #2bb8e8 100%); }

/* progress toward the next Shop Point */
.cashout-prog { margin-top: 6px; }
.cashout-prog-bar {
  height: 8px; border-radius: 999px;
  background: rgba(0,0,0,0.3);
  border: 1.5px solid var(--outline-c);
  overflow: hidden;
}
.cashout-prog-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #2bb8e8, #8be7ff);
  transition: width 0.3s ease;
}
.cashout-prog-txt {
  margin-top: 3px;
  font-family: 'Fredoka', sans-serif; font-size: 10.5px; font-weight: 700;
  color: var(--ink-soft); letter-spacing: 0.3px;
}

/* ════════ INVEST TAB — premium milestone roadmap ════════ */
.inv-hero {
  position: relative; overflow: hidden;
  background: linear-gradient(160deg, color-mix(in srgb, #6cc8ff 18%, var(--cream)) 0%, var(--cream) 70%);
  border: 3px solid color-mix(in srgb, #5aa8e8 55%, var(--outline-c));
  border-radius: var(--r-lg); padding: 14px; margin-bottom: 14px;
  box-shadow: var(--drop), 0 0 22px rgba(90,168,232,0.20);
}
.inv-hero-glow {
  position: absolute; top: -40%; right: -10%; width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle, rgba(120,200,255,0.45), transparent 70%); pointer-events: none;
}
.inv-hero-row { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.inv-hero-titles { min-width: 0; }
.inv-hero-title {
  font-family: 'Luckiest Guy', cursive; font-size: 22px; letter-spacing: 1.5px; line-height: 1;
  color: var(--ink); -webkit-text-stroke: 1.6px var(--drop-c); paint-order: stroke fill;
  text-shadow: 0 3px 0 var(--drop-c);
}
.inv-hero-sub { font-family: 'Fredoka', sans-serif; font-size: 11px; font-weight: 600; color: var(--ink-soft); margin-top: 5px; }
.inv-hero-badge {
  flex-shrink: 0; text-align: center; min-width: 62px;
  background: linear-gradient(180deg, #8fd0ff, #2b8fd6); color: #fff;
  border: 3px solid var(--drop-c); border-radius: 14px; padding: 6px 8px;
  box-shadow: var(--drop-sm), inset 0 -3px 0 rgba(0,0,0,0.25), inset 0 2px 0 rgba(255,255,255,0.5);
}
.inv-hero-count { font-family: 'Luckiest Guy', cursive; font-size: 22px; line-height: 1; -webkit-text-stroke: 1.2px var(--drop-c); paint-order: stroke fill; }
.inv-hero-count-lbl { font-family: 'Fredoka', sans-serif; font-size: 8.5px; font-weight: 700; letter-spacing: 1.5px; margin-top: 2px; opacity: 0.92; }
.inv-hero-bar {
  position: relative; height: 12px; margin-top: 12px; border-radius: 999px;
  background: color-mix(in srgb, var(--outline-c) 24%, var(--paper));
  border: 2px solid var(--outline-c); overflow: hidden;
}
.inv-hero-fill {
  height: 100%; border-radius: 999px; transition: width 0.5s cubic-bezier(.2,.9,.3,1);
  background: linear-gradient(90deg, #6ce8a0, #4cd1ee, #8fd0ff);
  box-shadow: 0 0 10px rgba(120,200,255,0.7), inset 0 1px 0 rgba(255,255,255,0.5);
}

.inv-road { position: relative; display: flex; flex-direction: column; }
.inv-node { position: relative; display: flex; align-items: stretch; gap: 12px; padding: 7px 0; }
/* connector track */
.inv-track { position: relative; flex-shrink: 0; width: 44px; display: flex; align-items: center; justify-content: center; }
.inv-track::before {
  content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 5px; transform: translateX(-50%);
  background: color-mix(in srgb, var(--outline-c) 38%, var(--paper)); border-radius: 3px;
}
.inv-node:first-child .inv-track::before { top: 50%; }
.inv-node:last-child  .inv-track::before { bottom: 50%; }
.inv-node.owned .inv-track::before { background: linear-gradient(180deg, #6ce8a0, #34c46f); box-shadow: 0 0 9px rgba(52,196,111,0.6); }
.inv-orb {
  position: relative; z-index: 1; width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Luckiest Guy', cursive; font-size: 17px; color: #fff;
  border: 3px solid var(--drop-c); -webkit-text-stroke: 1px var(--drop-c); paint-order: stroke fill;
  background: radial-gradient(circle at 32% 28%, color-mix(in srgb, var(--outline-c) 18%, var(--paper)), color-mix(in srgb, var(--outline-c) 50%, var(--paper-2)));
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.25), inset 0 2px 0 rgba(255,255,255,0.4), var(--drop-sm);
}
.inv-node.owned .inv-orb { background: radial-gradient(circle at 32% 28%, #9cffc0, #34c46f); }
.inv-node.next  .inv-orb { background: radial-gradient(circle at 32% 28%, var(--cl), var(--c)); animation: inv-orb-pulse 1.6s ease-in-out infinite; }
@keyframes inv-orb-pulse { 0%,100% { box-shadow: inset 0 -3px 0 rgba(0,0,0,0.25), inset 0 2px 0 rgba(255,255,255,0.4), 0 0 0 rgba(0,0,0,0); } 50% { box-shadow: inset 0 -3px 0 rgba(0,0,0,0.25), inset 0 2px 0 rgba(255,255,255,0.4), 0 0 16px var(--c); } }

.inv-card {
  flex: 1; min-width: 0; position: relative; overflow: hidden;
  background: linear-gradient(180deg, color-mix(in srgb, #fff 6%, var(--cream)) 0%, var(--cream) 100%);
  border: 2.5px solid color-mix(in srgb, var(--c) 42%, var(--outline-c));
  border-radius: var(--r); padding: 11px 12px;
  box-shadow: var(--drop-sm), inset 0 1px 0 rgba(255,255,255,0.1);
}
.inv-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
  background: var(--c); box-shadow: 0 0 10px var(--c);
}
.inv-node.next .inv-card { border-color: var(--c); box-shadow: var(--drop-sm), 0 0 16px color-mix(in srgb, var(--c) 45%, transparent); }
.inv-node.locked { filter: saturate(0.5); opacity: 0.72; }
.inv-card-head { display: flex; align-items: center; gap: 11px; }
.inv-icon {
  flex-shrink: 0; width: 42px; height: 42px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, var(--cl), var(--c));
  border: 2.5px solid var(--drop-c);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.25), inset 0 2px 0 rgba(255,255,255,0.45), var(--drop-sm);
}
.inv-icon svg { width: 66%; height: 66%; display: block; filter: drop-shadow(0 1.5px 0 rgba(0,0,0,0.4)); }
.inv-headtext { flex: 1; min-width: 0; }
.inv-name {
  font-family: 'Luckiest Guy', cursive; font-size: 16px; letter-spacing: 0.6px; line-height: 1;
  color: var(--ink); -webkit-text-stroke: 1px var(--drop-c); paint-order: stroke fill;
}
.inv-reward {
  display: inline-block; margin-top: 6px; font-family: 'Fredoka', sans-serif; font-size: 11px; font-weight: 700;
  color: color-mix(in srgb, var(--c) 70%, var(--ink)); background: color-mix(in srgb, var(--c) 14%, transparent);
  border: 1.5px solid color-mix(in srgb, var(--c) 40%, var(--outline-c)); border-radius: 999px; padding: 2px 9px;
}
.inv-gate { margin-top: 10px; }
.inv-gate-bar {
  height: 9px; border-radius: 999px; overflow: hidden;
  background: color-mix(in srgb, var(--outline-c) 22%, var(--paper)); border: 1.5px solid var(--outline-c);
}
.inv-gate-fill {
  height: 100%; border-radius: 999px; transition: width 0.4s ease;
  background: linear-gradient(90deg, color-mix(in srgb, var(--c) 50%, var(--cl)), var(--c));
}
.inv-gate-fill.done { background: linear-gradient(90deg, #6ce8a0, #34c46f); box-shadow: 0 0 8px rgba(52,196,111,0.6); }
.inv-gate-lbl { font-family: 'Fredoka', sans-serif; font-size: 10px; font-weight: 600; color: var(--ink-soft); margin-top: 4px; }
.inv-gate-lbl.done { color: var(--candy-mint); font-weight: 700; }
.inv-btn {
  width: 100%; margin-top: 11px; height: 38px;
  font-family: 'Luckiest Guy', cursive; font-size: 16px; letter-spacing: 1px; color: #fff; cursor: pointer;
  background: linear-gradient(180deg, var(--cl), var(--c));
  border: 2.5px solid var(--drop-c); border-radius: 10px;
  -webkit-text-stroke: 1.4px var(--drop-c); paint-order: stroke fill; text-shadow: 0 2px 0 rgba(0,0,0,0.3);
  box-shadow: var(--drop-sm), inset 0 -2px 0 rgba(0,0,0,0.28), inset 0 2px 0 rgba(255,255,255,0.5);
  transition: transform 0.08s, filter 0.08s;
}
.inv-btn.glow { animation: action-btn-pulse 1.4s ease-in-out infinite; }
.inv-btn:active:not(:disabled) { transform: translateY(2px); }
.inv-btn.owned { background: linear-gradient(180deg, #9cffc0, #34c46f); cursor: default; }
.inv-btn:disabled:not(.owned) {
  background: color-mix(in srgb, var(--ink-soft) 26%, var(--paper-2));
  color: color-mix(in srgb, var(--ink) 50%, transparent); text-shadow: none;
  -webkit-text-stroke: 0; cursor: not-allowed; box-shadow: var(--drop-sm);
}

.skin-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.skin-card {
  background: linear-gradient(180deg, color-mix(in srgb, #fff 5%, var(--cream)) 0%, var(--cream) 100%);
  border: var(--outline); border-radius: var(--r); padding: 10px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  box-shadow: var(--drop-sm), inset 0 1px 0 rgba(255,255,255,0.08);
}
.skin-card.active {
  border-color: var(--tab-active);
  box-shadow: var(--drop-sm), inset 0 1px 0 rgba(255,255,255,0.08), 0 0 0 2px color-mix(in srgb, var(--tab-active) 55%, transparent), 0 0 14px color-mix(in srgb, var(--tab-active) 45%, transparent);
}
.skin-name { font-family: 'Luckiest Guy', cursive; font-size: 13px; letter-spacing: 1px; color: var(--ink); -webkit-text-stroke: 0.8px var(--drop-c); paint-order: stroke fill; }
.skin-desc { font-family: 'Fredoka', sans-serif; font-size: 10.5px; font-weight: 600; color: var(--ink-soft); text-align: center; margin-top: -3px; }
/* recessed "well" so the live cubes pop off the card */
.skin-swatch {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: 100%;
  padding: 7px; border-radius: 11px;
  background: color-mix(in srgb, #000 16%, var(--cream));
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.32), inset 0 -1px 0 rgba(255,255,255,0.06);
}
/* SP star chip inside the buy button */
.skin-card .mini-btn .skin-buy-ico { display: inline-flex; width: 14px; height: 14px; margin-right: 4px; vertical-align: -2px; }
.skin-card .mini-btn .skin-buy-ico svg { width: 100%; height: 100%; display: block; }
.sw-tile {
  aspect-ratio: 1/1; display: flex; align-items: center; justify-content: center;
  font-family: 'Luckiest Guy', cursive; font-size: 13px; color: #fff;
  border: 2.5px solid var(--drop-c); border-radius: 8px;
  -webkit-text-stroke: 0.8px var(--drop-c); paint-order: stroke fill;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.25), inset 0 2px 0 rgba(255,255,255,0.4);
}
.sw-tile.t4  { background: linear-gradient(180deg, #ff8ea0, #e84676); }
.sw-tile.t6  { background: linear-gradient(180deg, #c8a4ff, #8d54e8); }
.sw-tile.t8  { background: linear-gradient(180deg, #79c3ff, #2f8ed8); }
.sw-tile.t11 { background: linear-gradient(180deg, #b6f273, #45a82c); font-size: 12px; }
.skin-tag.active {
  font-family: 'Luckiest Guy', cursive; font-size: 12px; letter-spacing: 1px; color: var(--candy-yellow);
  padding: 6px 14px; border: 2.5px solid var(--drop-c); border-radius: 12px;
  -webkit-text-stroke: 0.6px var(--drop-c); box-shadow: 0 0 12px rgba(245,201,71,0.4);
}

/* ════════════════════════════════════════════════════════════════════════════
   TILE SKINS — same cube SHAPE, re-themed MATERIAL. Each theme recolours the
   tier gradient (a tuned filter, keeping light→dark per-tier variation) and adds
   a material texture on ::before/::after. Rules target BOTH the live board
   (.tiles-layer[data-skin=X] .tile) and the picker preview (.skin-swatch .sw-tile).
   ════════════════════════════════════════════════════════════════════════════ */

/* WOOD — stained wooden blocks: brown recolour + grain streaks + warm sheen */
.tiles-layer[data-skin="wood"] .tile,
.skin-swatch[data-skin="wood"] .sw-tile { filter: sepia(0.72) saturate(1.3) brightness(0.92) hue-rotate(-8deg); }
.tiles-layer[data-skin="wood"] .tile::after,
.skin-swatch[data-skin="wood"] .sw-tile::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background:
    repeating-linear-gradient(91deg, rgba(48,24,4,0.22) 0 1.5px, rgba(48,24,4,0) 1.5px 6px),
    repeating-linear-gradient(91deg, rgba(255,225,180,0.10) 0 1px, rgba(255,225,180,0) 1px 11px);
  mix-blend-mode: multiply; opacity: 0.55;
}
.tiles-layer[data-skin="wood"] .tile::before,
.skin-swatch[data-skin="wood"] .sw-tile::before {
  content: ''; position: absolute; left: 14%; top: 9%; width: 56%; height: 24%; border-radius: 50%;
  background: rgba(255,240,210,0.30); filter: blur(1.5px); pointer-events: none;
}

/* STONE — carved granite: desaturate + chiselled edge + speckle */
.tiles-layer[data-skin="stone"] .tile,
.skin-swatch[data-skin="stone"] .sw-tile { filter: grayscale(0.72) brightness(0.97) contrast(1.05); }
.tiles-layer[data-skin="stone"] .tile::after,
.skin-swatch[data-skin="stone"] .sw-tile::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background:
    radial-gradient(rgba(0,0,0,0.20) 1px, transparent 1.6px) 0 0 / 12% 12%,
    radial-gradient(rgba(255,255,255,0.16) 1px, transparent 1.6px) 6% 7% / 16% 16%;
  mix-blend-mode: overlay; opacity: 0.7;
}
.tiles-layer[data-skin="stone"] .tile::before,
.skin-swatch[data-skin="stone"] .sw-tile::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 3px 2px rgba(255,255,255,0.32), inset 0 -4px 3px rgba(0,0,0,0.32);
}

/* GEMS — faceted jewels: vivid + angular facet highlights + sparkle glints */
.tiles-layer[data-skin="gems"] .tile,
.skin-swatch[data-skin="gems"] .sw-tile { filter: saturate(1.55) brightness(1.06) contrast(1.08); }
.tiles-layer[data-skin="gems"] .tile::before,
.skin-swatch[data-skin="gems"] .sw-tile::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.55) 0 18%, rgba(255,255,255,0) 40%),
    linear-gradient(305deg, rgba(255,255,255,0.26) 0 14%, rgba(255,255,255,0) 34%);
  mix-blend-mode: screen;
}
.tiles-layer[data-skin="gems"] .tile::after,
.skin-swatch[data-skin="gems"] .sw-tile::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background:
    radial-gradient(circle at 73% 24%, rgba(255,255,255,0.95) 0 1px, transparent 3px),
    radial-gradient(circle at 28% 70%, rgba(255,255,255,0.7) 0 1px, transparent 2.5px);
}

/* COMIC — superhero halftone: punchy ink + Ben-Day dots + gloss streak */
.tiles-layer[data-skin="comic"] .tile,
.skin-swatch[data-skin="comic"] .sw-tile { filter: saturate(1.7) contrast(1.18) brightness(1.05); }
.tiles-layer[data-skin="comic"] .tile::after,
.skin-swatch[data-skin="comic"] .sw-tile::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(rgba(0,0,0,0.18) 1.3px, transparent 1.7px) 0 0 / 15% 15%;
  opacity: 0.45;
}
.tiles-layer[data-skin="comic"] .tile::before,
.skin-swatch[data-skin="comic"] .sw-tile::before {
  content: ''; position: absolute; left: 12%; top: 8%; width: 52%; height: 22%; border-radius: 50%;
  background: rgba(255,255,255,0.5); filter: blur(0.5px); pointer-events: none;
}

/* METAL — brushed chrome: desaturate + bright + brushed grain, specular & rivets */
.tiles-layer[data-skin="metal"] .tile,
.skin-swatch[data-skin="metal"] .sw-tile { filter: grayscale(0.82) brightness(1.18) contrast(1.12); }
.tiles-layer[data-skin="metal"] .tile::after,
.skin-swatch[data-skin="metal"] .sw-tile::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,0.10) 0 1px, rgba(0,0,0,0.07) 1px 2px),
    linear-gradient(122deg, rgba(255,255,255,0) 32%, rgba(255,255,255,0.5) 49%, rgba(255,255,255,0) 62%);
  mix-blend-mode: screen; opacity: 0.85;
}
.tiles-layer[data-skin="metal"] .tile::before,
.skin-swatch[data-skin="metal"] .sw-tile::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background:
    radial-gradient(circle at 13% 13%, rgba(255,255,255,0.75) 0 1.4px, rgba(0,0,0,0.4) 2px 3px, transparent 3.6px),
    radial-gradient(circle at 87% 13%, rgba(255,255,255,0.75) 0 1.4px, rgba(0,0,0,0.4) 2px 3px, transparent 3.6px),
    radial-gradient(circle at 13% 87%, rgba(255,255,255,0.75) 0 1.4px, rgba(0,0,0,0.4) 2px 3px, transparent 3.6px),
    radial-gradient(circle at 87% 87%, rgba(255,255,255,0.75) 0 1.4px, rgba(0,0,0,0.4) 2px 3px, transparent 3.6px);
}

/* GALAXY — premium full deep-space recolour: dark cosmic base + animated nebula
   swirl + starfield. The whole board takes the galaxy palette (read by number). */
.tiles-layer[data-skin="galaxy"] .tile,
.skin-swatch[data-skin="galaxy"] .sw-tile {
  background: radial-gradient(circle at 50% 32%, #34206e 0%, #170c3a 58%, #0a0520 100%);
  filter: none;
}
.tiles-layer[data-skin="galaxy"] .tile::before,
.skin-swatch[data-skin="galaxy"] .sw-tile::before {
  content: ''; position: absolute; inset: -32%; pointer-events: none;
  background: conic-gradient(from 0deg, rgba(150,90,255,0.55), rgba(80,160,255,0.4), rgba(255,110,205,0.45), rgba(120,80,255,0.5), rgba(150,90,255,0.55));
  mix-blend-mode: screen; opacity: 0.55; animation: galaxy-spin 16s linear infinite;
}
.tiles-layer[data-skin="galaxy"] .tile::after,
.skin-swatch[data-skin="galaxy"] .sw-tile::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0.9;
  background:
    radial-gradient(circle at 22% 30%, #fff 0 0.6px, transparent 1.4px),
    radial-gradient(circle at 68% 18%, #fff 0 0.6px, transparent 1.2px),
    radial-gradient(circle at 81% 63%, #fff 0 0.7px, transparent 1.5px),
    radial-gradient(circle at 40% 78%, #fff 0 0.5px, transparent 1.2px),
    radial-gradient(circle at 56% 46%, rgba(255,255,255,0.85) 0 0.5px, transparent 1.2px);
}
@keyframes galaxy-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .tiles-layer[data-skin="galaxy"] .tile::before, .skin-swatch[data-skin="galaxy"] .sw-tile::before { animation: none; }
}

/* both ::before and ::after need a positioned host */
.sw-tile { position: relative; overflow: hidden; }

/* ═══════════════════════════════════════════════════════════════════════════
   THE CHALLENGE + FACTORIES
   ═══════════════════════════════════════════════════════════════════════════ */
/* Challenge tab (data-tab keeps its internal id "supreme") — red border comes from
   the shared --tab-c rule; no animated aura. */

.chal-panel { border-color: color-mix(in srgb, #ff2e2e 40%, var(--outline-c)); }
.chal-progress {
  font-family: 'Luckiest Guy', cursive; font-size: 13px; letter-spacing: 1px;
  color: #ff8a8a; -webkit-text-stroke: 1px var(--drop-c); paint-order: stroke fill;
}

/* enter button */
.chal-enter {
  margin-top: 10px; border-radius: var(--r); padding: 14px 16px; text-align: center;
  display: flex; flex-direction: column; gap: 4px; box-shadow: var(--drop-sm);
  border: 3px solid color-mix(in srgb, #ff2e2e 55%, var(--outline-c));
  background: linear-gradient(180deg, color-mix(in srgb, #ff2e2e 26%, var(--cream)) 0%, var(--cream) 100%);
}
button.chal-enter { width: 100%; cursor: pointer; transition: transform 0.08s, filter 0.12s, box-shadow 0.12s; }
button.chal-enter:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
button.chal-enter:active:not(:disabled) { transform: translateY(1px); }
button.chal-enter:not(:disabled) { box-shadow: var(--drop-sm), 0 0 16px rgba(255,46,46,0.5); animation: chal-btn-pulse 1.8s ease-in-out infinite; }
@keyframes chal-btn-pulse {
  0%, 100% { box-shadow: var(--drop-sm), 0 0 12px rgba(255,46,46,0.4); }
  50%      { box-shadow: var(--drop-sm), 0 0 24px rgba(255,46,46,0.8); }
}
.chal-enter.cooldown, .chal-enter.locked { opacity: 0.85; filter: saturate(0.5); cursor: not-allowed; animation: none; }
.chal-enter.locked  { border-color: var(--outline-c); background: var(--cream); }
.chal-enter.cleared { border-color: color-mix(in srgb, var(--candy-yellow) 55%, var(--outline-c)); background: linear-gradient(180deg, color-mix(in srgb, var(--candy-yellow) 22%, var(--cream)) 0%, var(--cream) 100%); }
.chal-enter-title {
  font-family: 'Luckiest Guy', cursive; font-size: 18px; letter-spacing: 1.5px;
  color: #fff; -webkit-text-stroke: 1.4px var(--drop-c); paint-order: stroke fill;
}
.chal-enter-sub { font-family: 'Fredoka', sans-serif; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.chal-warn {
  margin-top: 8px; padding: 9px 12px;
  font-family: 'Fredoka', sans-serif; font-size: 11.5px; font-weight: 600; line-height: 1.45;
  color: color-mix(in srgb, var(--candy-red) 60%, var(--ink));
  background: color-mix(in srgb, var(--candy-red) 12%, var(--cream));
  border: 2px solid color-mix(in srgb, var(--candy-red) 45%, var(--outline-c));
  border-radius: var(--radius-md, 10px);
}
.chal-warn strong { color: var(--candy-red); font-weight: 700; letter-spacing: 0.3px; }
@media (prefers-reduced-motion: reduce) { button.chal-enter { animation: none; } }

/* factory section */
.fac-section-title {
  margin: 16px 0 8px; font-family: 'Luckiest Guy', cursive; font-size: 14px; letter-spacing: 1.5px;
  color: var(--ink); -webkit-text-stroke: 1px var(--drop-c); paint-order: stroke fill;
}
.fac-wrap { display: flex; flex-direction: column; gap: 12px; }
.factory {
  border: var(--outline); border-radius: var(--r); overflow: hidden;
  box-shadow: var(--drop-sm), inset 0 1px 0 rgba(255,255,255,0.06);
  background: linear-gradient(180deg, var(--paper-2) 0%, var(--cream) 100%);
}
.factory.locked { opacity: 0.6; filter: saturate(0.4); }
/* roof bar with little smokestacks — reads as a building */
.factory-roof {
  position: relative; height: 30px; display: flex; align-items: center;
  padding: 0 12px;
  background: repeating-linear-gradient(45deg, #b23030 0 10px, #9a2727 10px 20px);
  border-bottom: 3px solid var(--drop-c);
}
.factory-stack {
  position: absolute; top: -10px; width: 8px; height: 12px;
  background: #7d7f93; border: 2px solid var(--drop-c); border-bottom: none; border-radius: 2px 2px 0 0;
}
.factory-stack { left: 14px; }
.factory-stack.tall { left: 28px; height: 16px; top: -14px; }
.factory-name {
  margin-left: auto; font-family: 'Luckiest Guy', cursive; font-size: 13px; letter-spacing: 1px;
  color: #fff; -webkit-text-stroke: 1px var(--drop-c); paint-order: stroke fill;
}
.factory-body { display: flex; gap: 12px; padding: 12px; align-items: center; }
.factory-body.locked-body { justify-content: flex-start; }
.factory-display { display: flex; flex-direction: column; align-items: center; gap: 7px; flex-shrink: 0; }
.fac-cube {
  position: relative; width: 58px; height: 58px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Luckiest Guy', cursive; font-size: 22px; color: #fff;
  -webkit-text-stroke: 1.4px var(--drop-c); paint-order: stroke fill;
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  transition: transform 0.1s;
}
.fac-cube.f4 { font-size: 17px; } .fac-cube.f5 { font-size: 14px; }
.fac-cube:active { cursor: grabbing; transform: scale(1.08); }
.fac-meter { width: 58px; height: 8px; border-radius: 999px; overflow: hidden; background: rgba(0,0,0,0.4); border: 1.5px solid var(--drop-c); }
.fac-meter-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #ffd23f, #ff2e2e); transition: width 0.5s linear; }
.factory-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.fac-timer { font-family: 'Luckiest Guy', cursive; font-size: 13px; letter-spacing: 0.5px; color: #ffd23f; -webkit-text-stroke: 0.8px var(--drop-c); paint-order: stroke fill; }
.fac-rate  { font-family: 'Fredoka', sans-serif; font-size: 11px; font-weight: 700; color: var(--ink-soft); }
.fac-help  { font-family: 'Fredoka', sans-serif; font-size: 11px; font-weight: 600; color: var(--ink-soft); line-height: 1.35; }
.fac-lock  { width: 58px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.fac-lock svg { width: 38px; height: 38px; filter: drop-shadow(0 2px 0 rgba(0,0,0,0.25)); }

/* board cell drop highlight while dragging a factory cube */
.cell.drop-ok  { box-shadow: inset 0 0 0 3px #3bd16b, inset 0 2px 6px rgba(0,0,0,0.35); }
.cell.drop-bad { box-shadow: inset 0 0 0 3px #e8606e, inset 0 2px 6px rgba(0,0,0,0.35); }
.fac-ghost {
  position: fixed; z-index: 1000; pointer-events: none;
  width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Luckiest Guy', cursive; font-size: 20px; color: #fff;
  -webkit-text-stroke: 1.4px var(--drop-c); paint-order: stroke fill;
  opacity: 0.92; transform: scale(1.05);
}

/* ── SINGULARITY wildcard orb (lives in the board corner once Void power 5 is owned) ── */
#void-wild {
  position: absolute; top: 5px; right: 5px; z-index: 6;
  width: clamp(32px, 11cqw, 46px); height: clamp(32px, 11cqw, 46px);
  border-radius: 50%; cursor: default; opacity: 0.7;
  background:
    radial-gradient(circle at 50% 50%, #190433 0 53%, transparent 54%),
    conic-gradient(#b46bff var(--charge, 0%), rgba(255,255,255,0.12) 0);
  border: 2.5px solid #2a0a44;
  box-shadow: 0 3px 0 #120420, inset 0 0 8px rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.2s, transform 0.1s;
}
.void-wild-core {
  width: 46%; height: 46%; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ecd4ff, #9b4dff 55%, #4a148c);
  box-shadow: 0 0 6px rgba(180,107,255,0.6);
}
#void-wild.ready {
  opacity: 1; cursor: grab;
  box-shadow: 0 3px 0 #120420, 0 0 16px rgba(180,107,255,0.75), inset 0 0 8px rgba(0,0,0,0.5);
  animation: void-wild-pulse 1.4s ease-in-out infinite;
}
#void-wild.ready:active { cursor: grabbing; transform: scale(0.92); }
#void-wild.ready .void-wild-core { box-shadow: 0 0 12px rgba(210,170,255,0.95); }
@keyframes void-wild-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.09); } }
.void-ghost {
  position: fixed; z-index: 1000; pointer-events: none;
  width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ecd4ff, #9b4dff 55%, #4a148c);
  border: 2.5px solid #2a0a44; box-shadow: 0 0 18px rgba(180,107,255,0.9);
  opacity: 0.92; transform: scale(1.05);
}
@media (prefers-reduced-motion: reduce) { #void-wild.ready { animation: none; } }

/* ── challenge overlay (full-screen red 2048) ── */
#challenge-overlay {
  position: fixed; inset: 0; z-index: 900;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  padding: 20px;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(255,40,40,0.28) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(140,0,0,0.4) 0%, transparent 60%),
    linear-gradient(180deg, #2a0707 0%, #160303 100%);
  animation: chal-bg-pulse 3s ease-in-out infinite;
}
@keyframes chal-bg-pulse { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.12); } }
.chal-head { text-align: center; display: flex; flex-direction: column; gap: 4px; }
.chal-goal {
  font-family: 'Luckiest Guy', cursive; font-size: 30px; letter-spacing: 2px;
  color: #ff5d5d; -webkit-text-stroke: 2px #2a0707; paint-order: stroke fill;
  text-shadow: 0 0 18px rgba(255,40,40,0.8);
}
.chal-sub { font-family: 'Fredoka', sans-serif; font-size: 14px; font-weight: 700; color: #ffb3b3; }
.chal-sub span { color: #fff; }
.chal-frame {
  width: min(86vw, 64vh); max-width: 440px;
  border-color: #ff3b3b;
  background:
    radial-gradient(ellipse at 50% 25%, rgba(255,60,60,0.18) 0%, transparent 60%),
    linear-gradient(180deg, #3a0c0c 0%, #1c0404 100%);
  box-shadow: inset 0 0 0 2px rgba(255,120,120,0.15), inset 0 10px 24px rgba(0,0,0,0.6), 0 0 30px rgba(255,40,40,0.5);
}
.chal-frame .cell { background: rgba(255,90,90,0.08); border-color: rgba(255,90,90,0.22); }
.chal-quit {
  font-family: 'Luckiest Guy', cursive; font-size: 14px; letter-spacing: 1px; color: #fff;
  padding: 9px 22px; border-radius: 999px; cursor: pointer;
  border: 2.5px solid #2a0707; background: linear-gradient(180deg, #ff6b6b, #c62d2d);
  -webkit-text-stroke: 1px #2a0707; paint-order: stroke fill; box-shadow: 0 4px 0 #2a0707;
}
.chal-quit:hover { filter: brightness(1.08); }
.chal-quit:active { transform: translateY(2px); box-shadow: 0 2px 0 #2a0707; }

/* give-up confirm — modal inside the challenge overlay */
.chal-confirm {
  position: absolute; inset: 0; z-index: 8;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(10,3,3,0.6); backdrop-filter: blur(3px);
  animation: chal-confirm-in 0.18s ease-out;
}
@keyframes chal-confirm-in { from { opacity: 0; } to { opacity: 1; } }
.chal-confirm-box {
  width: min(320px, 90%); padding: 20px 18px 16px; text-align: center;
  background: linear-gradient(180deg, #3a1414, #240b0b);
  border: 3px solid #2a0707; border-radius: 18px;
  box-shadow: 0 10px 0 #1a0404, 0 0 30px rgba(255,40,40,0.4);
  animation: chal-confirm-pop 0.26s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes chal-confirm-pop { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.chal-confirm-title {
  font-family: 'Luckiest Guy', cursive; font-size: 24px; letter-spacing: 1px; color: #ff6b6b;
  -webkit-text-stroke: 1.4px #160303; paint-order: stroke fill;
}
.chal-confirm-sub { font-family: 'Fredoka', sans-serif; font-size: 13px; font-weight: 600; color: #f3c2c2; margin: 6px 0 16px; line-height: 1.4; }
.chal-confirm-row { display: flex; gap: 10px; }
.chal-confirm-btn {
  flex: 1; font-family: 'Luckiest Guy', cursive; font-size: 13px; letter-spacing: 0.5px; color: #fff;
  padding: 11px 8px; border-radius: 12px; cursor: pointer;
  -webkit-text-stroke: 0.9px #160303; paint-order: stroke fill;
  transition: transform 0.08s, filter 0.1s;
}
.chal-confirm-btn:active { transform: translateY(2px); }
.chal-confirm-btn.keep { border: 2.5px solid #0c3d2b; background: linear-gradient(180deg, #3bd16b, #1f9a4d); box-shadow: 0 4px 0 #0c3d2b; }
.chal-confirm-btn.quit { border: 2.5px solid #2a0707; background: linear-gradient(180deg, #ff6b6b, #c62d2d); box-shadow: 0 4px 0 #2a0707; }
.chal-confirm-btn:hover { filter: brightness(1.08); }
.chal-flash {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center; text-align: center; white-space: pre-line;
  font-family: 'Luckiest Guy', cursive; font-size: 44px; letter-spacing: 2px; line-height: 1.1;
  -webkit-text-stroke: 2.5px #160303; paint-order: stroke fill;
  background: rgba(10,3,3,0.55); backdrop-filter: blur(3px);
  animation: chal-flash-in 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes chal-flash-in { 0% { transform: scale(0.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* ═══════════════════════════════════════════════════════════════════════════
   THE VOID — distorted black & white
   ═══════════════════════════════════════════════════════════════════════════ */
.tab-btn[data-tab="void"] {
  filter: grayscale(1) contrast(1.15);
}
.tab-btn[data-tab="void"] .tab-btn-icon { background: #d7dadf; color: #111; }

.void-panel {
  filter: grayscale(1) contrast(1.1);
  border-color: #6b6f78;
  background: linear-gradient(180deg, #1c1c1f 0%, #0c0c0e 100%);
  position: relative; overflow: hidden;
}
.void-panel::after {     /* faint scanlines */
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0.5;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.04) 0 1px, transparent 1px 3px);
}
.void-panel .panel-sub { color: #b8b8bd; }
.void-status {
  font-family: 'Luckiest Guy', cursive; font-size: 12px; letter-spacing: 1px;
  color: #e6e6ea; -webkit-text-stroke: 1px #000; paint-order: stroke fill;
}
/* glitchy title — duplicated offset layers via ::before/::after */
.void-glitch { position: relative; color: #f2f2f4; -webkit-text-stroke: 1.2px #000; paint-order: stroke fill; }
.void-glitch::before, .void-glitch::after {
  content: attr(data-text); position: absolute; left: 0; top: 0; width: 100%;
  -webkit-text-stroke: 0; clip-path: inset(0 0 0 0);
}
.void-glitch::before { color: #ffffff; animation: void-glitch-a 2.6s infinite steps(1); }
.void-glitch::after  { color: #7a7a7e; animation: void-glitch-b 3.1s infinite steps(1); }
@keyframes void-glitch-a {
  0%, 90%, 100% { transform: translate(0,0); opacity: 0; }
  91% { transform: translate(2px,-1px); opacity: 0.9; clip-path: inset(0 0 55% 0); }
  94% { transform: translate(-2px,1px); opacity: 0.9; clip-path: inset(40% 0 0 0); }
}
@keyframes void-glitch-b {
  0%, 85%, 100% { transform: translate(0,0); opacity: 0; }
  86% { transform: translate(-2px,0); opacity: 0.8; clip-path: inset(60% 0 0 0); }
  89% { transform: translate(2px,1px); opacity: 0.8; clip-path: inset(0 0 60% 0); }
}
@media (prefers-reduced-motion: reduce) { .void-glitch::before, .void-glitch::after { animation: none; opacity: 0; } }

.void-wrap { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.void-card {
  display: flex; flex-direction: column; gap: 10px; padding: 10px 12px;
  border-radius: var(--r); border: 2.5px solid #5a5d64;
  background: linear-gradient(180deg, #232327 0%, #141416 100%);
  filter: grayscale(1) contrast(1.08);
  box-shadow: var(--drop-sm), inset 0 1px 0 rgba(255,255,255,0.05);
}
.void-top { display: flex; align-items: center; gap: 12px; }
.void-card.done   { opacity: 0.55; }
.void-card.locked { opacity: 0.45; }
.void-card.active { border-color: #c9ccd2; box-shadow: var(--drop-sm), 0 0 14px rgba(220,220,228,0.28); }
/* the void orb — a collapsing black-and-white well */
.void-orb {
  flex-shrink: 0; width: 46px; height: 46px; border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #000 0%, #000 26%, #c9ccd2 30%, #2a2a2e 55%, #e8e8ec 72%, #1a1a1d 100%);
  border: 2px solid #000; position: relative; overflow: hidden;
  animation: void-spin 6s linear infinite;
}
.void-orb-core {
  position: absolute; inset: 36%; border-radius: 50%; background: #000;
  box-shadow: 0 0 8px 2px rgba(255,255,255,0.35);
}
@keyframes void-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .void-orb { animation: none; } }
.void-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.void-name { font-family: 'Luckiest Guy', cursive; font-size: 13px; letter-spacing: 1px; color: #fff; -webkit-text-stroke: 1px #000; paint-order: stroke fill; }
.void-req  { font-family: 'Fredoka', sans-serif; font-size: 12px; font-weight: 700; color: #e2e2e6; }
.void-fx   { font-family: 'Fredoka', sans-serif; font-size: 11px; font-weight: 600; color: #a8a8ad; }
.void-btn {
  width: 100%; font-family: 'Luckiest Guy', cursive; font-size: 13px; letter-spacing: 1px;
  color: #111; padding: 9px 14px; border-radius: 999px; cursor: pointer;
  border: 2.5px solid #000; background: linear-gradient(180deg, #f4f4f6, #c2c4c9);
  box-shadow: 0 3px 0 #000;
}
.void-btn:disabled { opacity: 0.4; cursor: not-allowed; filter: grayscale(1); }
.void-btn.glow { animation: void-btn-pulse 1.6s ease-in-out infinite; }
@keyframes void-btn-pulse { 0%,100% { box-shadow: 0 3px 0 #000, 0 0 8px rgba(255,255,255,0.4); } 50% { box-shadow: 0 3px 0 #000, 0 0 18px rgba(255,255,255,0.85); } }
.void-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #000; }
.void-tag {
  text-align: center; font-family: 'Luckiest Guy', cursive; font-size: 11px; letter-spacing: 1px;
  padding: 6px 12px; border-radius: 999px; border: 2px solid #000;
}
.void-tag.done   { color: #cfcfd3; background: #2a2a2e; }
.void-tag.locked { color: #8a8a8f; background: #1a1a1d; }
@media (prefers-reduced-motion: reduce) { .void-btn.glow { animation: none; } }

/* ════════════════════════════════════════════════════════════════════════════
   UPGRADED CELEBRATIONS — shared FX (rays / confetti / particles) + new outros
   ════════════════════════════════════════════════════════════════════════════ */
/* rotating light rays behind a celebration; tint via `color` */
.fx-rays {
  position: absolute; left: 50%; top: 46%; width: 220vmax; height: 220vmax;
  transform: translate(-50%, -50%); pointer-events: none; opacity: 0; color: #ffd970;
  background: repeating-conic-gradient(from 0deg, currentColor 0deg 5deg, transparent 5deg 17deg);
  -webkit-mask-image: radial-gradient(circle, #000 0%, #000 16%, transparent 58%);
  mask-image: radial-gradient(circle, #000 0%, #000 16%, transparent 58%);
  mix-blend-mode: screen;
  animation: fx-rays-in 0.5s ease-out forwards, fx-rays-spin 16s linear infinite;
}
@keyframes fx-rays-in { from { opacity: 0; } to { opacity: 0.28; } }
@keyframes fx-rays-spin { to { transform: translate(-50%,-50%) rotate(360deg); } }
/* confetti raining from the top with drift + spin */
.fx-confetti {
  position: absolute; top: -6vh; pointer-events: none; box-shadow: 0 1px 0 rgba(0,0,0,0.3);
  animation-name: fx-confetti-fall; animation-timing-function: cubic-bezier(0.4,0,0.7,1); animation-fill-mode: forwards;
}
@keyframes fx-confetti-fall {
  0%   { transform: translate(0,0) rotate(0deg); opacity: 0; }
  10%  { opacity: 1; }
  100% { transform: translate(var(--drift,0), 112vh) rotate(var(--spin,360deg)); opacity: 0.85; }
}
/* radial particle burst from centre */
.fx-particle {
  position: absolute; left: 50%; top: 46%; border-radius: 2px; pointer-events: none; box-shadow: 0 0 8px currentColor;
  animation: fx-particle 0.9s cubic-bezier(0.2,0.7,0.3,1) forwards;
}
@keyframes fx-particle {
  0%   { transform: translate(-50%,-50%) scale(0.3); opacity: 0; }
  18%  { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1) rotate(180deg); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .fx-rays, .fx-confetti, .fx-particle { display: none; } }
/* peak-moment flashes (shared by celebrations) */
.fx-bigflash {
  position: absolute; inset: -12%; pointer-events: none; mix-blend-mode: screen;
  background: radial-gradient(circle at 50% 46%, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0) 56%);
  opacity: 0; animation: fx-bigflash 0.5s ease-out forwards;
}
@keyframes fx-bigflash { 0% { opacity: 0; transform: scale(0.5); } 22% { opacity: 1; } 100% { opacity: 0; transform: scale(1.25); } }
.fx-rainbow-flash {
  position: absolute; inset: -12%; pointer-events: none; mix-blend-mode: screen;
  background: conic-gradient(from 0deg, #ff6d96, #ffd970, #7dffa6, #5aa8e8, #c8a4ff, #ff6d96);
  -webkit-mask-image: radial-gradient(circle, #000 0%, #000 30%, transparent 62%);
  mask-image: radial-gradient(circle, #000 0%, #000 30%, transparent 62%);
  opacity: 0; animation: fx-rainbow-flash 0.65s ease-out forwards;
}
@keyframes fx-rainbow-flash { 0% { opacity: 0; transform: scale(0.4) rotate(0deg); } 28% { opacity: 0.6; } 100% { opacity: 0; transform: scale(1.35) rotate(45deg); } }
@media (prefers-reduced-motion: reduce) { .fx-bigflash, .fx-rainbow-flash { display: none; } }

/* cashout additions */
.cc-rays { color: #7fe3ff; }
.cc-shock2 { animation-duration: 1.25s; animation-delay: 0.12s; border-color: #bfefff; }
.cc-halo {
  position: absolute; width: 50vmin; height: 50vmin; max-width: 320px; max-height: 320px; border-radius: 50%;
  background: radial-gradient(circle, rgba(127,227,255,0.5) 0%, transparent 65%);
  animation: cc-halo 1.9s ease-out forwards;
}
@keyframes cc-halo { 0% { transform: scale(0.4); opacity: 0; } 30% { opacity: 1; } 100% { transform: scale(1.35); opacity: 0; } }

/* ── Tutorial / contextual-tip spotlight overlay ───────────────────────────── */
.tut-overlay { position: fixed; inset: 0; z-index: 1200; pointer-events: auto; }
/* The dim is produced by the spotlight's huge outer shadow so the highlighted
   element stays bright. When no target, .tut-overlay gets .tut-dim for a flat veil. */
.tut-overlay.tut-dim { background: rgba(10, 8, 22, 0.72); backdrop-filter: blur(3px); }
.tut-spotlight {
  position: absolute; border-radius: 16px; pointer-events: none;
  border: 3px solid var(--candy-mint, #4cd1b0);
  box-shadow: 0 0 0 9999px rgba(10, 8, 22, 0.72), 0 0 22px 4px rgba(76, 209, 176, 0.55);
  transition: top .18s ease, left .18s ease, width .18s ease, height .18s ease;
}
.tut-textbox {
  position: absolute; max-width: min(440px, calc(100vw - 24px));
  background: linear-gradient(180deg, color-mix(in srgb, #fff 8%, var(--paper)) 0%, var(--paper) 100%);
  border: 3.5px solid var(--outline-c);
  border-radius: 20px; padding: 20px 18px 16px;
  box-shadow: 0 7px 0 var(--drop-c), 0 0 22px 2px rgba(76,209,176,0.38), inset 0 2px 0 rgba(255,255,255,0.14);
  display: flex; flex-direction: column; gap: 12px; z-index: 1201; overflow: visible;
}
/* bouncing mascot badge peeking from the top-left corner */
.tut-mascot {
  position: absolute; top: -20px; left: -12px; width: 44px; height: 44px;
  border-radius: 13px; border: 3px solid var(--drop-c);
  background: linear-gradient(180deg, #6ff0d0, #2bbd99);
  display: flex; align-items: center; justify-content: center; z-index: 2;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.25), inset 0 2px 0 rgba(255,255,255,0.5), 0 4px 0 var(--drop-c);
  animation: tut-mascot-bob 1.8s ease-in-out infinite;
}
.tut-mascot svg { width: 66%; height: 66%; display: block; filter: drop-shadow(0 1px 0 rgba(0,0,0,0.3)); }
@keyframes tut-mascot-bob {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50%      { transform: translateY(-4px) rotate(5deg); }
}
.tut-text { font-size: 15px; line-height: 1.5; color: var(--ink); font-weight: 600; animation: tut-text-in 0.3s ease; }
.tut-text strong { color: var(--candy-mint, #4cd1b0); }
@keyframes tut-text-in { 0% { opacity: 0; transform: translateY(6px); } 100% { opacity: 1; transform: none; } }
.tut-btn {
  align-self: flex-end; font-family: 'Luckiest Guy', cursive; letter-spacing: 1px;
  font-size: 16px; color: #fff;
  background: linear-gradient(180deg, #6ce8c0, #2bbd99);
  border: 3px solid var(--drop-c); border-radius: 13px; padding: 9px 22px;
  -webkit-text-stroke: 0.8px var(--drop-c); paint-order: stroke fill;
  box-shadow: 0 4px 0 var(--drop-c), inset 0 2px 0 rgba(255,255,255,0.5), inset 0 -3px 0 rgba(0,0,0,0.2);
  cursor: pointer; transition: filter 0.1s;
}
.tut-btn:hover { filter: brightness(1.07); }
.tut-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--drop-c), inset 0 2px 0 rgba(255,255,255,0.5); }
@media (prefers-reduced-motion: reduce) { .tut-mascot { animation: none; } .tut-text { animation: none; } }
.tut-skip-btn {
  position: fixed; top: 14px; right: 14px; z-index: 1202;
  font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 12px;
  color: var(--ink-soft); background: var(--paper);
  border: 2px solid var(--outline-c); border-radius: 10px; padding: 6px 12px;
  box-shadow: 0 3px 0 var(--drop-c); cursor: pointer;
}
.tut-skip-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--drop-c); }

/* ════════════════════════════════════════════════════════════════════════════
   8c. SPLASH INTRO + GUIDED-ONBOARDING JUICE
   Branded first-load splash, a glowing/pulsing spotlight, an animated swipe
   hand, and the first-merge fireworks. All reduced-motion-safe.
   ════════════════════════════════════════════════════════════════════════════ */
/* ── branded splash (first-load only) ── */
.splash {
  position: fixed; inset: 0; z-index: 10000; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 27% 24%, rgba(255,156,189,0.40) 0%, transparent 52%),
    radial-gradient(ellipse at 75% 28%, rgba(134,194,251,0.40) 0%, transparent 52%),
    radial-gradient(ellipse at 50% 84%, rgba(255,221,126,0.38) 0%, transparent 55%),
    linear-gradient(180deg, #2a1c4e 0%, #181030 100%);
  transition: opacity 0.45s ease, transform 0.45s ease;
}
.splash.splash-out { opacity: 0; transform: scale(1.08); pointer-events: none; }
.splash-stage { display: flex; gap: 10px; position: relative; z-index: 2; }
.splash-cube {
  position: relative;
  width: clamp(54px, 16vw, 70px); aspect-ratio: 1/1; border-radius: 15px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Luckiest Guy', cursive; font-size: clamp(28px, 8vw, 36px); color: #fff;
  border: 3.5px solid var(--drop-c);
  box-shadow: inset 0 -5px 0 rgba(0,0,0,0.28), inset 0 3px 0 rgba(255,255,255,0.5), 0 5px 0 rgba(0,0,0,0.42);
  -webkit-text-stroke: 1.6px var(--drop-c); paint-order: stroke fill; text-shadow: 0 2px 0 rgba(0,0,0,0.35);
  opacity: 0; animation: splash-cube-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes splash-cube-in {
  0%   { transform: translate(var(--fx,0), var(--fy,0)) scale(0.4) rotate(var(--fr,0deg)); opacity: 0; }
  65%  { opacity: 1; }
  100% { transform: translate(0,0) scale(1) rotate(0deg); opacity: 1; }
}
.splash-tagline {
  margin-top: 22px; font-family: 'Luckiest Guy', cursive; font-size: clamp(15px, 4.4vw, 19px);
  letter-spacing: 2px; color: #fff; z-index: 2;
  -webkit-text-stroke: 1.4px var(--drop-c); paint-order: stroke fill; text-shadow: 0 3px 0 rgba(0,0,0,0.3);
  opacity: 0; animation: splash-tag-in 0.5s ease-out 0.95s forwards;
}
@keyframes splash-tag-in { from { opacity: 0; transform: translateY(12px) scale(0.9); } to { opacity: 1; transform: none; } }
.splash-hint {
  position: absolute; bottom: 7vh; font-family: 'Fredoka', sans-serif; font-weight: 700;
  font-size: 13px; letter-spacing: 1px; color: rgba(255,255,255,0.85); z-index: 2;
  opacity: 0; animation: splash-hint-in 0.6s ease 1.5s forwards;
}
@keyframes splash-hint-in { from { opacity: 0; } to { opacity: 0.85; } }
.splash-flash {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 44%, rgba(255,255,255,0.9), transparent 60%);
  animation: splash-flash 0.7s ease-out 0.55s;
}
@keyframes splash-flash { 0% { opacity: 0; } 30% { opacity: 0.8; } 100% { opacity: 0; } }
.splash-rays { color: #ffe6a0; }

/* ── juiced spotlight: pulsing glow ring (doesn't touch the dim outer shadow) ── */
.tut-spotlight::after {
  content: ''; position: absolute; inset: -3px; border-radius: inherit; pointer-events: none;
  animation: tut-glow 1.3s ease-in-out infinite;
}
@keyframes tut-glow {
  0%, 100% { box-shadow: 0 0 12px 2px rgba(76,209,176,0.45); }
  50%      { box-shadow: 0 0 26px 7px rgba(76,209,176,0.85); }
}

/* ── animated swipe hand pointer ── */
.tut-hand {
  position: fixed; z-index: 1203; width: 48px; height: 48px; pointer-events: none;
  filter: drop-shadow(0 3px 0 rgba(0,0,0,0.4));
  animation: tut-hand-swipe 1.5s ease-in-out infinite;
}
.tut-hand svg { width: 100%; height: 100%; display: block; }
@keyframes tut-hand-swipe {
  0%, 100% { transform: translateX(-18px) rotate(10deg); }
  50%      { transform: translateX(18px)  rotate(-6deg); }
}

/* ── desktop arrow-key indicator: full 4-key cluster, LEFT/RIGHT lit ── */
.tut-keys {
  position: fixed; z-index: 1203; pointer-events: none;
  transform: translate(-50%, -50%);
  display: grid; grid-template-columns: repeat(3, auto); gap: 5px;
  justify-items: center; align-items: center;
}
.tut-key { width: 40px; height: 40px; filter: drop-shadow(0 3px 0 rgba(0,0,0,0.4)); }
.tut-key svg { width: 100%; height: 100%; display: block; }
.tut-key-up   { grid-column: 2; grid-row: 1; }
.tut-key-l    { grid-column: 1; grid-row: 2; }
.tut-key-down { grid-column: 2; grid-row: 2; }
.tut-key-r    { grid-column: 3; grid-row: 2; }
.tut-key.dim    { opacity: 0.35; filter: drop-shadow(0 3px 0 rgba(0,0,0,0.4)) grayscale(0.5); }
.tut-key.active { animation: tut-key-press 1.3s ease-in-out infinite; }
.tut-key-r.active { animation-delay: 0.65s; }
@keyframes tut-key-press {
  0%, 38%, 100% { transform: translateY(0); filter: brightness(1) drop-shadow(0 0 0 transparent); }
  16%           { transform: translateY(5px) scale(0.95); filter: brightness(1.3) drop-shadow(0 0 8px rgba(127,227,255,0.8)); }
}
@media (prefers-reduced-motion: reduce) { .tut-key.active { animation: none; } }

/* ── first-merge fireworks ── */
.fmf-host { position: fixed; inset: 0; z-index: 60; pointer-events: none; overflow: hidden; }
.fmf-origin { position: absolute; width: 0; height: 0; }
.fmf-ring {
  position: absolute; left: 0; top: 0; border-radius: 50%; border: 5px solid #ffe27a;
  width: 60px; height: 60px; pointer-events: none;
  transform: translate(-50%, -50%) scale(0.2); opacity: 0;
  animation: fmf-ring 0.85s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
@keyframes fmf-ring {
  0%   { opacity: 0; transform: translate(-50%,-50%) scale(0.2); }
  20%  { opacity: 0.9; }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(2.0); }
}

@media (prefers-reduced-motion: reduce) {
  .splash-cube { animation: none; opacity: 1; transform: none; }
  .splash-tagline, .splash-hint { animation: none; opacity: 0.9; }
  .splash-flash, .tut-spotlight::after, .tut-hand, .fmf-ring { animation: none; }
  .tut-hand { display: none; }
}

/* invest additions */
.iv-rays { color: #ffd970; }
.iv-tint { position: absolute; inset: 0; pointer-events: none; transition: background 0.18s linear; }
.iv-counter {
  position: absolute; transform: translateY(-27vmin); text-align: center; z-index: 4;
  font-family: 'Bungee', system-ui, sans-serif; font-size: clamp(22px,6vmin,46px); letter-spacing: 1px;
  color: #fff; -webkit-text-stroke: 2px var(--drop-c); paint-order: stroke fill; text-shadow: 0 3px 0 var(--drop-c);
}
.iv-counter-pop { animation: iv-counter-pop 0.18s ease-out; }
@keyframes iv-counter-pop { 0% { transform: translateY(-27vmin) scale(1); } 50% { transform: translateY(-27vmin) scale(1.32); color: #fff4c2; } 100% { transform: translateY(-27vmin) scale(1); } }
.iv-counter-win { animation: iv-counter-win 1s ease-out forwards; }
@keyframes iv-counter-win { 0% { transform: translateY(-27vmin) scale(1); } 30% { transform: translateY(-29vmin) scale(1.45); color: #fff4c2; } 100% { transform: translateY(-29vmin) scale(1.2); } }
.inv-cele.iv-finale .iv-tint { animation: iv-finale-tint 1.5s ease-out forwards; }
@keyframes iv-finale-tint { 0% { filter: brightness(1); } 12% { filter: brightness(2.4); } 100% { filter: brightness(1); } }

/* ascend additions */
.ac-rays { color: #7fc0ff; }
.ac-shock2 { animation-duration: 1.3s; animation-delay: 0.14s; }

/* ── CHALLENGE OUTRO (win / fail) ── */
.chal-end { position: absolute; inset: 0; z-index: 6; pointer-events: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; }
.chal-rays { color: #7dffa6; }
.chal-end-flash { position: absolute; inset: 0; }
.chal-end.win  .chal-end-flash { background: radial-gradient(circle at 50% 45%, rgba(125,255,166,0.55), rgba(255,215,112,0.18) 45%, transparent 70%); animation: cc-flash 1s ease-out forwards; }
.chal-end.fail .chal-end-flash { background: radial-gradient(circle at 50% 45%, rgba(190,0,0,0.5), transparent 65%); animation: chal-fail-flash 1.4s ease-out forwards; }
@keyframes chal-fail-flash { 0% { opacity: 0; } 15% { opacity: 1; } 100% { opacity: 0.5; } }
.chal-end-burst { position: absolute; width: 24vmin; height: 24vmin; border-radius: 50%; }
.chal-end.win .chal-end-burst { border: 0.8vmin solid #ffe27a; box-shadow: 0 0 30px #7dffa6; animation: cc-shock 0.95s cubic-bezier(0.2,0.7,0.3,1) forwards; }
.chal-end-title {
  position: relative; font-family: 'Luckiest Guy', cursive; font-size: clamp(30px,9vmin,64px); line-height: 1; letter-spacing: 2px;
  -webkit-text-stroke: 2.4px #160303; paint-order: stroke fill;
}
.chal-end-title span { display: block; font-size: 1.15em; margin-top: 4px; }
.chal-end.win  .chal-end-title { color: #fff; text-shadow: 0 0 24px rgba(125,255,166,0.9); animation: chal-title-win 0.6s cubic-bezier(0.34,1.56,0.64,1) both; }
.chal-end.win  .chal-end-title span { color: #ffe27a; }
.chal-end.fail .chal-end-title { color: #ff5d5d; text-shadow: 0 0 18px rgba(255,40,40,0.8); animation: chal-title-fail 0.5s steps(2,end) both, chal-title-settle 0.4s ease-out 0.5s both; }
@keyframes chal-title-win { 0% { transform: scale(0.3) rotate(-8deg); opacity: 0; } 60% { transform: scale(1.18) rotate(2deg); opacity: 1; } 100% { transform: scale(1) rotate(0); } }
@keyframes chal-title-fail { 0% { transform: translate(0,0) skewX(0); opacity: 0; } 20% { transform: translate(-7px,2px) skewX(8deg); opacity: 1; } 40% { transform: translate(7px,-2px) skewX(-6deg); } 60% { transform: translate(-4px,0) skewX(4deg); } 100% { transform: translate(0,0) skewX(0); } }
@keyframes chal-title-settle { from { filter: brightness(1.6); } to { filter: brightness(1); } }
.chal-end-sub { position: relative; font-family: 'Fredoka', sans-serif; font-weight: 800; font-size: clamp(13px,3.6vmin,20px); letter-spacing: 2px; animation: chal-sub-in 0.5s ease-out 0.35s both; }
.chal-end.win  .chal-end-sub { color: #7dffa6; }
.chal-end.fail .chal-end-sub { color: #ffb3b3; }
@keyframes chal-sub-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.chal-tile-win  { animation: chal-tile-win 0.7s cubic-bezier(0.4,0,0.6,1) forwards; }
@keyframes chal-tile-win { 0% { transform: scale(1); filter: saturate(1); } 30% { transform: scale(1.15); filter: hue-rotate(75deg) saturate(1.6) brightness(1.4); } 100% { transform: scale(0) translateY(-40px) rotate(180deg); opacity: 0; filter: hue-rotate(75deg); } }
.chal-tile-fail { animation: chal-tile-fail 0.85s cubic-bezier(0.5,0,0.8,1) forwards; }
@keyframes chal-tile-fail { 0% { transform: translateY(0) rotate(0); filter: grayscale(0); opacity: 1; } 25% { filter: grayscale(1) brightness(0.7); transform: translateY(-6px); } 100% { transform: translateY(60vh) rotate(40deg); filter: grayscale(1) brightness(0.4); opacity: 0; } }
.chal-failed { animation: chal-fail-shake 0.5s ease-out; }
@keyframes chal-fail-shake { 0%,100% { transform: translate(0,0); } 20% { transform: translate(-8px,4px); } 40% { transform: translate(8px,-4px); } 60% { transform: translate(-6px,2px); } 80% { transform: translate(4px,-2px); } }
@media (prefers-reduced-motion: reduce) { .chal-tile-win, .chal-tile-fail, .chal-failed { animation: none; } }

/* ── THE VOID CELEBRATION (black & white singularity) ── */
.void-cele { position: fixed; inset: 0; z-index: 850; pointer-events: none; overflow: hidden; display: flex; align-items: center; justify-content: center; animation: cc-fade 2.3s ease-out forwards; }
.vc-desat { position: absolute; inset: 0; background: rgba(0,0,0,0.45); -webkit-backdrop-filter: grayscale(1) blur(3px) contrast(1.2); backdrop-filter: grayscale(1) blur(3px) contrast(1.2); animation: vc-desat 2.3s ease-out forwards; }
@keyframes vc-desat { 0% { opacity: 0; } 12% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }
.vc-warp { position: absolute; inset: 0; background: radial-gradient(circle at 50% 50%, transparent 28%, rgba(0,0,0,0.88) 100%); animation: vc-warp 2.3s ease-out forwards; }
@keyframes vc-warp { 0% { opacity: 0; transform: scale(1.4); } 30% { opacity: 1; transform: scale(1); } 70% { opacity: 1; } 100% { opacity: 0; } }
.vc-swirl {
  position: absolute; width: 92vmin; height: 92vmin; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent, rgba(255,255,255,0.55), transparent, rgba(255,255,255,0.28), transparent);
  -webkit-mask-image: radial-gradient(circle, transparent 8%, #000 22%, transparent 55%);
  mask-image: radial-gradient(circle, transparent 8%, #000 22%, transparent 55%);
  animation: vc-swirl-in 1.7s ease-out forwards, vc-swirl-spin 1.1s linear infinite;
}
@keyframes vc-swirl-in { 0% { opacity: 0; transform: scale(0.2); } 25% { opacity: 1; } 60% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(0.5); } }
@keyframes vc-swirl-spin { to { transform: rotate(360deg); } }
.vc-hole {
  position: absolute; width: 12vmin; height: 12vmin; border-radius: 50%; background: #000;
  box-shadow: 0 0 0 2vmin #000, 0 0 60px 10px rgba(255,255,255,0.5), inset 0 0 20px rgba(255,255,255,0.3);
  animation: vc-hole 2.3s cubic-bezier(0.6,0,0.8,1) forwards;
}
@keyframes vc-hole {
  0%   { transform: scale(0); opacity: 0; }
  20%  { transform: scale(1); opacity: 1; }
  55%  { transform: scale(1.25); opacity: 1; }
  64%  { transform: scale(0.05); opacity: 1; }
  67%  { transform: scale(0.05); opacity: 0; }
  100% { transform: scale(0.05); opacity: 0; }
}
.vc-debris { position: absolute; left: 50%; top: 50%; border: 1.5px solid #000; animation: vc-debris 1.5s cubic-bezier(0.6,0,0.9,1) forwards; }
@keyframes vc-debris {
  0%   { transform: translate(calc(-50% + var(--sx)), calc(-50% + var(--sy))) rotate(0deg) scale(1); opacity: 0; }
  15%  { opacity: 1; }
  100% { transform: translate(-50%,-50%) rotate(var(--sr,360deg)) scale(0.1); opacity: 0; }
}
.vc-flash { position: absolute; width: 50vmax; height: 50vmax; border-radius: 50%; background: radial-gradient(circle, #fff 0%, rgba(255,255,255,0.5) 30%, transparent 65%); opacity: 0; animation: vc-flash 0.6s ease-out 0.95s forwards; }
@keyframes vc-flash { 0% { transform: scale(0.05); opacity: 0; } 35% { opacity: 1; } 100% { transform: scale(1.2); opacity: 0; } }
.vc-shock { position: absolute; width: 16vmin; height: 16vmin; border-radius: 50%; border: 1vmin solid #fff; box-shadow: 0 0 30px #fff, inset 0 0 20px rgba(255,255,255,0.6); opacity: 0; animation: vc-shock 1s cubic-bezier(0.2,0.7,0.3,1) 1.05s forwards; }
@keyframes vc-shock { 0% { transform: scale(0.2); opacity: 0; } 25% { opacity: 1; } 100% { transform: scale(5); opacity: 0; } }
.vc-label {
  position: absolute; text-align: center; z-index: 3;
  font-family: 'Luckiest Guy', cursive; font-size: clamp(26px,8vmin,56px); letter-spacing: 3px; line-height: 1.1;
  color: #fff; -webkit-text-stroke: 2.4px #000; paint-order: stroke fill; text-shadow: 0 0 24px rgba(255,255,255,0.6);
  animation: vc-label 1.4s ease-out 1.0s both;
}
.vc-label span { display: block; font-size: 0.42em; letter-spacing: 5px; color: #cfcfd3; margin-top: 8px; }
@keyframes vc-label { 0% { opacity: 0; transform: scale(0.6); } 25% { opacity: 1; transform: scale(1.1); } 40% { transform: scale(1); } 85% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .vc-swirl, .vc-debris, .vc-warp { display: none; }
  .void-cele { animation: cc-fade 0.9s ease-out forwards; }
}

/* ── PHONE ONLY (very small screens): stack board over panel and let the whole
   page scroll, so the board AND the tabs/upgrades are all reachable. Placed last
   so it wins over the earlier side-by-side board-width rules. ───────────────── */
@media (max-width: 520px) {
  html, body { overflow: auto; height: auto; }
  #root { height: auto; min-height: 100dvh; overflow: visible; }
  .game-area { flex-direction: column; overflow: visible; min-height: 0; }
  .board-panel,
  .board-panel.has-undo,
  .board-panel.has-auto,
  .board-panel.has-undo.has-auto,
  body.has-banner .board-panel,
  body.has-banner .board-panel.has-undo,
  body.has-banner .board-panel.has-auto,
  body.has-banner .board-panel.has-undo.has-auto {
    width: min(100%, 70dvh); max-width: 100%; align-self: center; flex-shrink: 0;
  }
  .ui-panel { flex: 0 0 auto; overflow: visible; }
  .tab-content { overflow: visible; }   /* scroll the page, not an inner box */
}

/* ════════════════════════════════════════════════════════════════════════════
   CRAZYGAMES ADS — single persistent banner bar (dedicated, never over the board)
   + rewarded-ad button accents. The bar is hidden until an ad is actually served.
   ════════════════════════════════════════════════════════════════════════════ */
/* Banner unit: 320×50 on mobile (reviewer flagged 320×100 as too tall), 728×90 on
   desktop. Container sized so requestResponsiveBanner picks that unit. Bottom padding
   respects the device safe area (home-bar / rounded corners). */
#cg-banner {
  display: none;   /* Ads.banner.mount() switches this to flex; setCovered() hides it under popups */
  position: fixed; left: 0; right: 0; top: 0; z-index: 1500;   /* pinned to the TOP (CrazyGames review) */
  align-items: center; justify-content: center;
  min-height: 58px; padding: 4px;
  padding-top: max(4px, env(safe-area-inset-top));
  background: #0b0b11; border-bottom: 2px solid rgba(255,255,255,0.12);
  box-shadow: 0 4px 16px rgba(0,0,0,0.45);
}
.cg-banner-tag {
  position: absolute; left: 9px; top: max(5px, env(safe-area-inset-top));
  font: 700 9px/1 'Fredoka', system-ui, sans-serif; letter-spacing: 0.6px;
  color: rgba(255,255,255,0.42); text-transform: uppercase; pointer-events: none;
}
/* fixed 320x50 (CrazyGames review) — constrain the slot so the SDK serves a 320x50 banner everywhere */
#cg-banner-slot { display: flex; align-items: center; justify-content: center; width: 320px; max-width: calc(100vw - 16px); height: 50px; min-height: 50px; }
/* centre anchor in the top bar; the banner docks here (between Best & Coins) when it fits */
.hud-ad { flex: 1 1 auto; min-width: 0; height: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; }
/* inline mode — banner is overlaid onto the top-bar centre anchor (top/left/size set by JS).
   Kept top-level (not reparented) so a HUD rebuild can't destroy the CG banner. */
#cg-banner.inline { position: fixed; right: auto; z-index: 1490; min-height: 0; padding: 0; background: transparent; border: none; box-shadow: none; overflow: hidden; pointer-events: none; }
#cg-banner.inline .cg-banner-tag { left: 1px; top: 1px; }
/* only the 320 slot catches taps — the transparent overlay never blocks the HUD blocks behind it */
#cg-banner.inline #cg-banner-slot { width: 100%; max-width: 320px; height: 50px; min-height: 50px; pointer-events: auto; }
/* reserve space at the TOP so the banner never overlaps gameplay/UI.
   --banner-h drives the board height budget + where the floating ad UI (offers / boosts) sits. */
body.has-banner { --banner-h: calc(58px + env(safe-area-inset-top, 0px)); }
body.has-banner #root { margin-top: var(--banner-h); height: calc(100dvh - var(--banner-h) - 4px); }

/* PHONE-ONLY bottom banner: when the top bar can't fit a 320×50 slot (see placeBanner), the
   banner is pinned to the very bottom. It reserves bottom space so it never covers the board. */
#cg-banner.bottom {
  position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 1500;
  align-items: center; justify-content: center;
  min-height: 58px; padding: 4px; padding-bottom: max(4px, env(safe-area-inset-bottom));
  background: #0b0b11; border-top: 2px solid rgba(255,255,255,0.12); border-bottom: none;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.45);
}
#cg-banner.bottom .cg-banner-tag { left: 9px; top: 4px; }
#cg-banner.bottom #cg-banner-slot { width: 320px; max-width: calc(100vw - 16px); height: 50px; min-height: 50px; }
body.has-bottom-banner { --bbanner-h: calc(58px + env(safe-area-inset-bottom, 0px)); }
/* fixed-height phone layout (521–768px): shrink #root + the board-height budget by the banner */
body.has-bottom-banner #root { height: calc(100dvh - var(--bbanner-h)); }
@media (max-height: 620px), (max-width: 900px) {
  body.has-bottom-banner .board-panel { width: calc((100dvh - 138px - var(--bbanner-h)) + 12px); }
  body.has-bottom-banner .board-panel.has-undo { width: calc((100dvh - 184px - var(--bbanner-h)) + 12px); }
  body.has-bottom-banner .board-panel.has-auto { width: calc((100dvh - 182px - var(--bbanner-h)) + 12px); }
  body.has-bottom-banner .board-panel.has-undo.has-auto { width: calc((100dvh - 226px - var(--bbanner-h)) + 12px); }
}
/* scrolling phone layout (≤520px): page scrolls, so reserve via body padding instead of height */
@media (max-width: 520px) {
  body.has-bottom-banner { padding-bottom: var(--bbanner-h); }
  body.has-bottom-banner #root { height: auto; min-height: calc(100dvh - var(--bbanner-h)); }
}

/* rewarded-ad buttons — clearly optional, video icon, distinct from the non-ad path */
.ra-btns { display: flex; flex-direction: column; gap: 6px; flex: 1 1 150px; min-width: 140px; }
.ra-btns .reset-action-btn { width: 100%; flex: 0 0 auto; }
.reset-action-btn.ad-btn { background: linear-gradient(180deg, #b46bff, #7a37d6); border-color: #4a1e86; }
.reset-action-btn.ad-btn:hover { filter: brightness(1.08); }
.new-btn.revive-btn { background: linear-gradient(180deg, #3bd16b, #1f9a4d); border-color: #0c3d2b; }
.ad-ico { display: inline-flex; width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; }
.ad-ico svg { width: 100%; height: 100%; }

/* rewarded-offer side pop-up (slides in from the left, above the banner) */
.ad-offer {
  position: fixed; left: -360px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); z-index: 1400;
  width: min(290px, 86vw);
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px 10px 14px;
  background: linear-gradient(180deg, color-mix(in srgb, #b46bff 10%, var(--paper)) 0%, var(--paper) 70%);
  border: 2.5px solid #9b5fff; border-left: 5px solid #c8a4ff; border-radius: 14px;
  box-shadow: var(--drop), 0 6px 22px rgba(0,0,0,0.36), 0 0 18px 2px rgba(180,107,255,0.5);
  transition: left 0.36s cubic-bezier(0.34,1.4,0.5,1), opacity 0.3s;
}
.ad-offer.in  { left: 12px; animation: ad-offer-glow 2s ease-in-out infinite; }
@keyframes ad-offer-glow {
  0%,100% { box-shadow: var(--drop), 0 6px 22px rgba(0,0,0,0.36), 0 0 16px 1px rgba(180,107,255,0.4); }
  50%     { box-shadow: var(--drop), 0 6px 22px rgba(0,0,0,0.36), 0 0 30px 5px rgba(180,107,255,0.8); }
}
@media (prefers-reduced-motion: reduce) { .ad-offer.in { animation: none; } }
.ad-offer.out { left: -360px; opacity: 0; }
.ad-offer-ico { width: 42px; height: 42px; flex-shrink: 0; filter: drop-shadow(0 2px 0 rgba(0,0,0,0.22)); }
.ad-offer-ico svg { width: 100%; height: 100%; }
.ad-offer-txt { flex: 1; min-width: 0; }
.ad-offer-name { font-family: 'Luckiest Guy', cursive; font-size: 13px; letter-spacing: 0.5px; color: var(--ink); }
.ad-offer-desc { font-family: 'Fredoka', sans-serif; font-size: 11px; font-weight: 600; color: var(--ink-soft); }
.ad-offer-go {
  flex-shrink: 0; font-family: 'Luckiest Guy', cursive; font-size: 12px; letter-spacing: 0.5px; color: #fff;
  padding: 8px 11px; border-radius: 10px; cursor: pointer;
  border: 2.5px solid var(--drop-c); background: linear-gradient(180deg, #46e07e, #1f9a4d);
  box-shadow: 0 3px 0 var(--drop-c), 0 0 12px rgba(60,209,107,0.45);
  display: inline-flex; align-items: center; gap: 2px; animation: ad-cta-glow 1.7s ease-in-out infinite;
}
.ad-offer-go:hover  { filter: brightness(1.08); }
.ad-offer-go:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--drop-c); }
@media (prefers-reduced-motion: reduce) { .ad-offer-go { animation: none; } }
.ad-offer-x {
  position: absolute; top: -9px; right: -9px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--paper-2); border: 2px solid var(--outline-c); color: var(--ink-soft);
  font: 700 14px/1 system-ui, sans-serif; cursor: pointer; z-index: 1;
  display: flex; align-items: center; justify-content: center;
}
.ad-offer-x:hover { color: var(--ink); }

/* active rewarded-boost timers */
/* active-boost countdown — pinned under the top bar, centered */
#hud-boosts {
  position: fixed; top: calc(92px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); z-index: 1190;
  display: none; flex-direction: row; gap: 6px; pointer-events: none;
  max-width: 96vw; flex-wrap: wrap; justify-content: center;
}
/* the top banner pushes the HUD down by --banner-h, so the boost badges must drop too */
body.has-banner #hud-boosts { top: calc(92px + var(--banner-h)); }
@media (max-height: 620px), (max-width: 900px) {
  #hud-boosts { top: calc(70px + env(safe-area-inset-top, 0px)); }
  body.has-banner #hud-boosts { top: calc(70px + var(--banner-h)); }
}
.boost-badge {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 9px; border-radius: 999px;
  font-family: 'Fredoka', sans-serif; font-size: 11px; font-weight: 700; color: #fff;
  border: 2px solid var(--drop-c); box-shadow: var(--drop-sm);
  -webkit-text-stroke: 0.6px var(--drop-c); paint-order: stroke fill;
}
.boost-badge.x2   { background: linear-gradient(180deg, #f2b134, #d68800); }
.boost-badge.fast { background: linear-gradient(180deg, #f0824a, #c8531f); }
.bb-ico { width: 15px; height: 15px; display: inline-flex; }
.bb-ico svg { width: 100%; height: 100%; }

/* ── Phase 1 rewarded surfaces ─────────────────────────────────────────────── */

/* generic centred ad modal (offline-2× / daily) */
.ad-modal-backdrop {
  position: fixed; inset: 0; z-index: 1600;
  display: flex; align-items: center; justify-content: center; padding: 22px;
  background: rgba(6,4,14,0.7); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity 0.2s;
}
.ad-modal-backdrop.in  { opacity: 1; }
.ad-modal-backdrop.out { opacity: 0; }
.ad-modal {
  position: relative; overflow: hidden;
  width: min(336px, 92%); padding: 22px 18px 16px; text-align: center;
  background: linear-gradient(180deg, color-mix(in srgb, #b46bff 13%, var(--paper)) 0%, var(--paper) 68%);
  border: 2.5px solid #b46bff; border-radius: 20px;
  box-shadow: var(--drop), 0 14px 44px rgba(0,0,0,0.5), 0 0 26px 3px rgba(180,107,255,0.5);
  transform: scale(0.82); transition: transform 0.28s cubic-bezier(0.34,1.56,0.64,1);
  animation: ad-modal-glow 2.4s ease-in-out infinite;
}
@keyframes ad-modal-glow {
  0%,100% { box-shadow: var(--drop), 0 14px 44px rgba(0,0,0,0.5), 0 0 20px 2px rgba(180,107,255,0.45); }
  50%     { box-shadow: var(--drop), 0 14px 44px rgba(0,0,0,0.5), 0 0 40px 7px rgba(180,107,255,0.85); }
}
@media (prefers-reduced-motion: reduce) { .ad-modal { animation: none; } }
.ad-modal::before {   /* soft reward glow behind the icon */
  content: ''; position: absolute; top: -34px; left: 50%; transform: translateX(-50%);
  width: 210px; height: 170px; pointer-events: none;
  background: radial-gradient(ellipse at 50% 50%, rgba(180,107,255,0.34), rgba(180,107,255,0) 70%);
}
.ad-modal > * { position: relative; }
.ad-modal-backdrop.in .ad-modal { transform: scale(1); }
.ad-modal-x {
  position: absolute; top: 9px; right: 9px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--paper-2); border: 2px solid var(--outline-c); color: var(--ink-soft);
  font: 700 17px/1 system-ui, sans-serif; cursor: pointer; z-index: 3;
  display: flex; align-items: center; justify-content: center;
}
.ad-modal-x:hover  { filter: brightness(0.95); }
.ad-modal-x:active { transform: scale(0.92); }
.ad-modal-ico {
  width: 64px; height: 64px; margin: 2px auto 8px;
  filter: drop-shadow(0 3px 0 rgba(0,0,0,0.26));
  animation: ad-ico-pop 0.5s cubic-bezier(0.34,1.56,0.64,1);
}
.ad-modal-ico svg { width: 100%; height: 100%; }
@keyframes ad-ico-pop { 0% { transform: scale(0.3) rotate(-14deg); opacity: 0; } 60% { transform: scale(1.14) rotate(5deg); opacity: 1; } 100% { transform: scale(1) rotate(0); } }
.ad-modal-title { font-family: 'Luckiest Guy', cursive; font-size: 24px; letter-spacing: 1.2px;
  background: linear-gradient(90deg, #b46bff, #ff6d96, #ffb620); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 rgba(0,0,0,0.28)); }
.ad-modal-body { font-family: 'Fredoka', sans-serif; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin: 5px 0 15px; line-height: 1.45; }
.ad-modal-row { display: flex; gap: 10px; align-items: stretch; }
.ad-modal-btn {
  flex: 1; font-family: 'Luckiest Guy', cursive; font-size: 13px; letter-spacing: 0.5px; color: #fff;
  padding: 12px 8px; border-radius: 12px; cursor: pointer;
  border: 2.5px solid var(--drop-c); box-shadow: 0 3px 0 var(--drop-c);
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  background: linear-gradient(180deg, #8a93a3, #5d6473);   /* primary / non-ad path */
}
.ad-modal-btn.cyan { background: linear-gradient(180deg, #6fe4ff, #2bb8e8); border-color: #1a7a98; }   /* matches the cashout (SP) theme */
.ad-modal-btn.ad {   /* the conversion button — emphasized + pulsing */
  flex: 1.35; background: linear-gradient(180deg, #46e07e, #1f9a4d);
  box-shadow: 0 3px 0 var(--drop-c), 0 0 14px rgba(60,209,107,0.5);
  animation: ad-cta-glow 1.7s ease-in-out infinite;
}
@keyframes ad-cta-glow { 0%,100% { box-shadow: 0 3px 0 var(--drop-c), 0 0 12px rgba(60,209,107,0.4); } 50% { box-shadow: 0 3px 0 var(--drop-c), 0 0 22px rgba(60,209,107,0.8); } }
.ad-modal-btn:hover  { filter: brightness(1.08); }
.ad-modal-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--drop-c); }
.ad-modal-btn .ad-ico { width: 18px; height: 18px; }
@media (prefers-reduced-motion: reduce) { .ad-modal-ico, .ad-modal-btn.ad { animation: none; } }
/* one-shot diagonal shine sweep when a modal opens */
.ad-modal::after { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 4;
  background: linear-gradient(120deg, transparent 33%, rgba(255,255,255,0.20) 48%, transparent 63%);
  transform: translateX(-130%); animation: ad-shine 1.1s ease-out 0.15s 1; }
@keyframes ad-shine { to { transform: translateX(130%); } }
@media (prefers-reduced-motion: reduce) { .ad-modal::after { display: none; } }

/* ── per-reward "ad watched" celebration (rewardFx) ── */
.reward-fx { position: fixed; inset: 0; z-index: 1700; pointer-events: none; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.reward-fx.rfx-out { opacity: 0; transition: opacity 0.34s ease; }
.rfx-glow { position: absolute; width: 460px; height: 460px; max-width: 96vw; max-height: 96vw; border-radius: 50%; animation: rfx-glow 0.55s ease-out forwards; }
@keyframes rfx-glow { 0% { transform: scale(0.3); opacity: 0; } 40% { opacity: 0.95; } 100% { transform: scale(1.35); opacity: 0; } }
.rfx-ring { position: absolute; width: 96px; height: 96px; border: 5px solid #fff; border-radius: 50%; opacity: 0; animation: rfx-ring 1s ease-out forwards; }
.rfx-ring2 { animation-delay: 0.13s; }
@keyframes rfx-ring { 0% { transform: scale(0.4); opacity: 0.85; } 100% { transform: scale(3.8); opacity: 0; } }
.rfx-ico { position: absolute; width: 104px; height: 104px; filter: drop-shadow(0 5px 0 rgba(0,0,0,0.32)) drop-shadow(0 0 18px rgba(255,255,255,0.35)); animation: rfx-ico 0.95s cubic-bezier(0.34,1.56,0.64,1) forwards; }
.reward-fx.big .rfx-ico { width: 128px; height: 128px; }
.rfx-ico svg { width: 100%; height: 100%; display: block; }
@keyframes rfx-ico { 0% { transform: scale(0) rotate(-22deg); opacity: 0; } 55% { transform: scale(1.22) rotate(9deg); opacity: 1; } 74% { transform: scale(0.94) rotate(-4deg); } 100% { transform: scale(1) rotate(0); } }
.rfx-label { position: absolute; top: calc(50% + 78px); font-family: 'Luckiest Guy', cursive; font-size: 30px; letter-spacing: 1px; color: #fff;
  -webkit-text-stroke: 3px #241406; paint-order: stroke fill; text-shadow: 0 3px 0 rgba(0,0,0,0.4); white-space: nowrap; animation: rfx-label 1.15s ease-out forwards; }
.reward-fx.big .rfx-label { font-size: 40px; top: calc(50% + 96px); }
@keyframes rfx-label { 0% { transform: translateY(20px) scale(0.6); opacity: 0; } 28% { transform: translateY(0) scale(1.12); opacity: 1; } 78% { opacity: 1; } 100% { transform: translateY(-16px) scale(1); opacity: 0; } }


/* small rewarded "skip / fill / charge" buttons (purple, video icon) */
.skip-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 3px;
  margin: 6px 0 2px; padding: 8px 12px; width: 100%;
  font-family: 'Luckiest Guy', cursive; font-size: 12px; letter-spacing: 0.5px; color: #fff;
  border: 2.5px solid var(--drop-c); border-radius: 11px; cursor: pointer;
  background: linear-gradient(180deg, #b46bff, #7a37d6); box-shadow: 0 3px 0 var(--drop-c);
}
.skip-btn:hover  { filter: brightness(1.08); }
.skip-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--drop-c); }
.skip-btn.fac-fill { margin: 5px 0 0; padding: 6px 10px; font-size: 11px; }

/* inline free-upgrade offer card (top of the Upgrade tab) */
.free-upg-offer {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; margin: 0 0 8px;
  background: linear-gradient(180deg, color-mix(in srgb, #b46bff 16%, var(--cream)) 0%, var(--cream) 100%);
  border: 2.5px solid color-mix(in srgb, #b46bff 55%, var(--outline-c)); border-radius: var(--r);
  box-shadow: var(--drop-sm);
}
.fuo-ico { width: 32px; height: 32px; flex-shrink: 0; }
.fuo-ico svg { width: 100%; height: 100%; }
.fuo-txt { flex: 1; min-width: 0; }
.fuo-name { font-family: 'Luckiest Guy', cursive; font-size: 12px; letter-spacing: 0.5px; color: var(--ink); }
.fuo-desc { font-family: 'Fredoka', sans-serif; font-size: 11px; font-weight: 600; color: var(--ink-soft); }
.free-upg-offer .skip-btn { width: auto; margin: 0; flex-shrink: 0; }


/* ══ Start gate ("Let's Play") — CrazyGames: gameplayStart + audio fire only on the tap ══ */
#start-gate {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 38%, #1a1830, #0a0814 72%);
  padding: 24px calc(24px + env(safe-area-inset-right)) 24px calc(24px + env(safe-area-inset-left));
  animation: sg-in .35s ease both;
}
#start-gate.out { animation: sg-out .32s ease forwards; }
@keyframes sg-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes sg-out { to { opacity: 0; } }
.sg-card { display: flex; flex-direction: column; align-items: center; gap: 20px; text-align: center; }
.sg-logo svg { width: min(78vw, 360px); height: auto; filter: drop-shadow(0 6px 0 rgba(0,0,0,.4)); }
.sg-tag { font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 15px; letter-spacing: 1px; color: #c7c4e0; opacity: .85; }
.sg-play {
  margin-top: 4px; padding: 16px 46px;
  font-family: 'Luckiest Guy', cursive; font-size: 24px; letter-spacing: 2px; color: #fff;
  background: linear-gradient(180deg, #59e07f, #2faa57);
  border: 3px solid #0b0a12; border-radius: 18px;
  box-shadow: 0 6px 0 #1c6b39, 0 10px 24px rgba(0,0,0,.45);
  cursor: pointer; -webkit-text-stroke: 1.4px rgba(0,0,0,.35); paint-order: stroke fill;
  animation: sg-pulse 1.8s ease-in-out infinite;
}
.sg-play:active { transform: translateY(4px); box-shadow: 0 2px 0 #1c6b39, 0 6px 16px rgba(0,0,0,.4); }
@keyframes sg-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.04); } }
@media (prefers-reduced-motion: reduce) { #start-gate, .sg-play { animation: none; } }

/* ══ Settings dialog (gear button) — theme · sound · delete ══ */
#settings-pop {
  position: fixed; inset: 0; z-index: 1600;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10,8,22,0.72); backdrop-filter: blur(6px); padding: 20px;
}
.set-card {
  width: min(340px, 92vw);
  background: var(--paper); border: 3px solid var(--outline-c); border-radius: 22px;
  box-shadow: 0 8px 0 var(--drop-c), 0 18px 40px rgba(0,0,0,.5);
  padding: 20px; display: flex; flex-direction: column; gap: 10px;
}
.set-title {
  font-family: 'Luckiest Guy', cursive; font-size: 22px; letter-spacing: 2px; text-align: center;
  color: var(--ink); -webkit-text-stroke: 1.4px var(--drop-c); paint-order: stroke fill; margin-bottom: 4px;
}
.set-row {
  display: flex; align-items: center; gap: 12px;
  background: color-mix(in srgb, #000 6%, var(--paper));
  border: 2px solid var(--outline-c); border-radius: 14px;
  padding: 12px 14px; cursor: pointer; color: var(--ink);
  font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 15px; text-align: left;
  transition: transform .08s, filter .08s;
}
.set-row:hover  { filter: brightness(1.05); }
.set-row:active { transform: translateY(2px); }
.set-ico { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--ink); }
.set-ico svg { width: 100%; height: 100%; }
.set-row.off { opacity: .72; }
.set-row.danger { color: #e8606e; border-color: color-mix(in srgb, #e8606e 55%, var(--outline-c)); }
.set-row.danger .set-ico { color: #e8606e; }
.set-close {
  margin-top: 4px; padding: 12px; border: none; border-radius: 14px; cursor: pointer;
  background: linear-gradient(180deg, #6f7686, #545b69); color: #fff;
  font-family: 'Luckiest Guy', cursive; font-size: 16px; letter-spacing: 1.5px; box-shadow: 0 3px 0 var(--drop-c);
}
.set-close:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--drop-c); }
