/* ===========================================================================
   Mushroom Mash — trippy-cute UI
   =========================================================================== */
:root {
  --bg: #3b1d6e;
  --ink: #ffffff;
  --muted: #e6d4ff;
  --p1: #ff5fd2;   /* hot pink */
  --p2: #9b5de5;   /* purple   */
  --p3: #4dd6ff;   /* cyan     */
  --p4: #7CFFB2;   /* mint     */
  --sun: #ffd24d;  /* sunshine */
  --glass: rgba(255, 255, 255, 0.13);
  --glass-line: rgba(255, 255, 255, 0.38);
  --shadow-pop: 0 6px 0 rgba(40, 12, 80, 0.35), 0 14px 30px rgba(40, 12, 80, 0.35);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); }
body { overscroll-behavior: none; touch-action: none; user-select: none; -webkit-user-select: none; }

#app {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
}
#play-area { position: relative; flex: 1; min-height: 0; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

/* ---- HUD ---------------------------------------------------------------- */
#hud {
  position: absolute; top: 0; left: 0; right: 0;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  display: flex; justify-content: space-between; align-items: flex-start;
  pointer-events: none; z-index: 5;
}
#hud .icon-btn, #hud button { pointer-events: auto; }
.score-wrap { line-height: 1; }
.score {
  font-size: 48px; font-weight: 900; letter-spacing: -1px;
  text-shadow: 0 3px 0 rgba(40,12,80,0.45), 0 0 26px rgba(255,95,210,0.55);
}
.best { font-size: 15px; color: #fff; opacity: 0.85; font-weight: 800; margin-top: 2px; text-shadow: 0 1.5px 0 rgba(40,12,80,0.4); }
.mode-stat {
  background: var(--glass); border: 2px solid var(--glass-line); border-radius: 999px;
  padding: 8px 16px; font-size: 21px; font-weight: 900; backdrop-filter: blur(6px);
  text-shadow: 0 1.5px 0 rgba(40,12,80,0.4);
}
.mode-stat.urgent { border-color: #ff7088; color: #ffd5dc; animation: pulse 0.7s infinite; }
.combo {
  margin-top: 6px; font-weight: 900; font-size: 18px;
  background: linear-gradient(90deg, var(--p1), var(--p3));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: pop 0.3s ease;
}
.next-preview {
  background: var(--glass); border: 1.5px solid var(--glass-line); border-radius: 14px;
  padding: 3px 12px; display: flex; flex-direction: row; align-items: center; gap: 6px;
  backdrop-filter: blur(6px);
}
.next-preview canvas { width: 46px; height: 46px; }
.next-preview span { font-size: 9px; letter-spacing: 2px; color: var(--ink); opacity: 0.85; font-weight: 800; }
.icon-btn {
  pointer-events: auto;
  width: 44px; height: 44px; border-radius: 14px; border: 1.5px solid var(--glass-line);
  background: var(--glass); color: var(--ink); font-size: 18px; backdrop-filter: blur(6px); cursor: pointer;
}
.icon-btn:active { transform: scale(0.92); }

/* ---- dock / abilities (real space BELOW the play area, never overlaps) --- */
#dock {
  flex: 0 0 auto;
  padding: 6px 14px calc(8px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 8px;
  align-items: center; justify-content: center;
  z-index: 5;
}
.dock-row { display: flex; gap: 10px; align-items: center; justify-content: center; }
.spark-meter {
  display: flex; flex-direction: row; align-items: center; gap: 8px;
  background: var(--glass); border: 1.5px solid var(--glass-line); border-radius: 999px;
  padding: 8px 14px; backdrop-filter: blur(6px); font-weight: 800;
}
.spark-icon { filter: drop-shadow(0 0 6px rgba(255,230,120,0.8)); }
.spark-bar { width: 70px; height: 6px; border-radius: 4px; background: rgba(255,255,255,0.15); overflow: hidden; }
#spark-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--p4), var(--p3)); transition: width 0.25s; }
.abilities { display: flex; gap: 10px; pointer-events: auto; }
.ability {
  position: relative; width: 70px; height: 70px; border-radius: 20px;
  border: 2px solid var(--glass-line); background: var(--glass); backdrop-filter: blur(6px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ink); cursor: pointer; transition: transform 0.08s, box-shadow 0.08s;
  box-shadow: 0 4px 0 rgba(40,12,80,0.28), inset 0 1.5px 0 rgba(255,255,255,0.3);
}
.ability:active { transform: translateY(3px) scale(0.95); box-shadow: 0 1px 0 rgba(40,12,80,0.28); }
.ability .ico { font-size: 28px; }
.ability .nm { font-size: 10px; font-weight: 800; color: var(--ink); opacity: 0.9; letter-spacing: 0.3px; }
.ability .cost {
  position: absolute; top: -6px; right: -6px;
  background: linear-gradient(135deg, var(--p1), var(--p2)); color: #fff;
  font-size: 11px; font-weight: 900; border-radius: 999px; padding: 1px 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.ability.disabled { opacity: 0.42; }
.ability.armed { outline: 3px solid var(--p3); box-shadow: 0 0 22px var(--p3); animation: glow 1s infinite; }
/* each ability gets its own color identity */
.ability[data-id="sporePop"]   { background: linear-gradient(150deg, rgba(255,95,210,0.30), var(--glass)); border-color: rgba(255,95,210,0.55); }
.ability[data-id="mysticMist"] { background: linear-gradient(150deg, rgba(77,214,255,0.30), var(--glass)); border-color: rgba(77,214,255,0.55); }
.ability[data-id="shake"]      { background: linear-gradient(150deg, rgba(255,179,71,0.30), var(--glass)); border-color: rgba(255,179,71,0.55); }
.ability[data-id="swapNext"]   { background: linear-gradient(150deg, rgba(124,255,178,0.30), var(--glass)); border-color: rgba(124,255,178,0.55); }
.ability:not(.disabled) .ico { filter: drop-shadow(0 0 6px rgba(255,255,255,0.45)); }

/* spark meter lights up when you can afford an ability */
.spark-meter.charged { border-color: rgba(255,228,120,0.7); animation: sparkGlow 1.6s ease-in-out infinite; }
@keyframes sparkGlow {
  0%, 100% { box-shadow: 0 0 6px rgba(255,228,120,0.25); }
  50% { box-shadow: 0 0 18px rgba(255,228,120,0.55); }
}

/* combo fever — the combo badge goes full rainbow */
.combo.fever {
  background: linear-gradient(90deg, #ff5fd2, #ffb347, #7cffb2, #4dd6ff, #b59bff, #ff5fd2);
  background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: rainbowSlide 1.2s linear infinite, pop 0.3s ease;
  font-size: 21px;
}
@keyframes rainbowSlide { to { background-position: 300% 0; } }

/* ---- danger warning ----------------------------------------------------- */
.danger-vignette {
  position: absolute; inset: 0; z-index: 4; pointer-events: none; opacity: 0;
  transition: opacity 0.2s ease;
  box-shadow: inset 0 0 90px 30px rgba(255, 40, 80, 0.55), inset 0 0 30px 8px rgba(255,0,40,0.4);
}
.danger-vignette.on { animation: dangerPulse 0.7s ease-in-out infinite; }
@keyframes dangerPulse { 0%,100% { opacity: var(--danger, 0.4); } 50% { opacity: calc(var(--danger, 0.4) * 0.45); } }
.danger-banner {
  position: absolute; top: 16%; left: 50%; transform: translateX(-50%);
  z-index: 7; pointer-events: none; font-size: 30px; font-weight: 900; color: #fff;
  text-shadow: 0 2px 0 rgba(120,0,30,0.6), 0 0 18px rgba(255,40,80,0.9);
  animation: dangerShake 0.5s ease-in-out infinite;
}
@keyframes dangerShake { 0%,100% { transform: translateX(-50%) scale(1) rotate(-1.5deg); } 50% { transform: translateX(-50%) scale(1.08) rotate(1.5deg); } }

/* ---- score popups ------------------------------------------------------- */
#score-pops { position: absolute; inset: 0; pointer-events: none; z-index: 6; overflow: hidden; }
.pop {
  position: absolute; font-weight: 900; font-size: 22px; transform: translate(-50%, -50%);
  text-shadow: 0 2px 6px rgba(0,0,0,0.5); animation: floatUp 0.9s ease-out forwards; white-space: nowrap;
}
.pop .mult { font-size: 14px; opacity: 0.9; }

/* ---- target hint -------------------------------------------------------- */
.target-hint {
  position: absolute; top: 50%; left: 50%; transform: translateX(-50%);
  background: var(--p3); color: #06243a; font-weight: 800; padding: 10px 18px; border-radius: 999px;
  z-index: 7; box-shadow: 0 6px 24px rgba(0,0,0,0.4); animation: pulse 1.1s infinite;
}

/* ---- screens ------------------------------------------------------------ */
#screens { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
.screen {
  position: absolute; inset: 0; z-index: 10;
  display: none; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 14px; padding: calc(28px + var(--safe-top)) 22px calc(28px + var(--safe-bottom));
  text-align: center; pointer-events: auto;
  background:
    radial-gradient(130% 90% at 80% -10%, rgba(255, 158, 220, 0.55), rgba(255, 158, 220, 0) 55%),
    radial-gradient(120% 90% at 10% 110%, rgba(77, 214, 255, 0.4), rgba(77, 214, 255, 0) 55%),
    linear-gradient(160deg, #7b3fe4 0%, #a14fd8 35%, #e85fa8 70%, #ff9a5c 100%);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  animation: screenIn 0.32s ease both;   /* panel fades; children rise (see childRise) */
}
/* Auto-margin spacers: vertically CENTRE the content when it fits, but flow from
   the top and stay fully scrollable when it's taller than the screen. Fixes the
   classic `justify-content:center` bug where overflow above the centre line gets
   clipped and can't be scrolled to (settings / title buttons unreachable on short
   phones). Zero-height pseudo-elements, so nothing is drawn. */
.screen::before { content: ""; flex: 0 0 0; margin-top: auto; }
.screen::after  { content: ""; flex: 0 0 0; margin-bottom: auto; }
@keyframes screenIn {
  from { opacity: 0; transform: scale(0.985); }
  to { opacity: 1; transform: scale(1); }
}
.screen.active, .screen.show { display: flex; }
#pause-menu { display: none; }
#pause-menu.show { display: flex; }

/* Screen-transition juice: the panel fades, then its contents RISE in a gentle
   stagger so each screen ASSEMBLES with life instead of snapping in as a block.
   Applies to every screen (hub, gallery, game-over, pause, + the other forks'
   new screens) for free. Pure CSS; reduced-motion turns it all off below. */
@keyframes childRise { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
.screen.active > *, .screen.show > *, #pause-menu.show > * {
  animation: childRise 0.4s cubic-bezier(0.2, 1.25, 0.4, 1) both;
}
.screen > *:nth-child(1) { animation-delay: 0.02s; }
.screen > *:nth-child(2) { animation-delay: 0.06s; }
.screen > *:nth-child(3) { animation-delay: 0.10s; }
.screen > *:nth-child(4) { animation-delay: 0.13s; }
.screen > *:nth-child(5) { animation-delay: 0.16s; }
.screen > *:nth-child(6) { animation-delay: 0.19s; }
.screen > *:nth-child(n+7) { animation-delay: 0.22s; }
/* the mode-gallery cards + level nodes cascade individually too */
.modes-grid > *, .level-grid > * { animation: childRise 0.4s cubic-bezier(0.2, 1.25, 0.4, 1) both; }
.modes-grid > *:nth-child(odd), .level-grid > *:nth-child(odd) { animation-delay: 0.05s; }
.modes-grid > *:nth-child(even), .level-grid > *:nth-child(even) { animation-delay: 0.09s; }

/* game reveal: when a run starts the HUD drops from the top + the dock rises from
   the bottom, so the jar "frames up" instead of the chrome snapping in. Re-triggers
   on un-hide (display:none→flex restarts the animation). Every game's HUD gets it. */
#hud:not(.hidden) { animation: hudDrop 0.42s cubic-bezier(0.2, 1.2, 0.4, 1) both; }
#dock:not(.hidden) { animation: dockRise 0.46s cubic-bezier(0.2, 1.2, 0.4, 1) both; }
@keyframes hudDrop { from { opacity: 0; transform: translateY(-18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes dockRise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }

/* screen EXIT: the outgoing screen fades out ON TOP while the next one assembles
   beneath — so the hub DISSOLVES into the game instead of cutting instantly. JS
   (UI.showScreen → _animateOut) adds .leaving, then removes it after the fade. */
/* z-index:15 ranks the ghost above its siblings inside #screens (and lifts the
   top-level #pause-menu ghost above #screens) — enough for every current flow. */
.screen.leaving, #pause-menu.leaving {
  display: flex !important; z-index: 15; pointer-events: none;
  animation: screenOut 0.22s ease forwards;
}
/* a game-over / win dialog on the LEAVING screen must NOT ride along on top of the
   incoming screen during the fade — drop it instantly, fade only the backdrop. */
.screen.leaving .mdialog { display: none !important; }
@keyframes screenOut { from { opacity: 1; } to { opacity: 0; transform: scale(0.992) translateY(-4px); } }

@media (prefers-reduced-motion: reduce) {
  .screen, .screen.active > *, .screen.show > *, #pause-menu.show > *,
  .modes-grid > *, .level-grid > *,
  #hud:not(.hidden), #dock:not(.hidden) { animation: none !important; }
  .screen.leaving, #pause-menu.leaving { animation: none !important; display: none !important; }
}

.logo {
  font-size: 52px; font-weight: 900; margin: 0; line-height: 0.95; letter-spacing: -1.5px;
  background: linear-gradient(115deg, var(--p1), var(--p3), var(--p4), var(--p2), var(--p1));
  background-size: 320% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 18px rgba(255,95,210,0.4));
  animation: rainbowSlide 7s linear infinite, meltWobble 5s ease-in-out infinite;
}
/* woaah-dude: the logo slowly breathes and droops like warm taffy */
@keyframes meltWobble {
  0%, 100% { transform: scale(1, 1) skewX(0deg); }
  25% { transform: scale(1.025, 0.975) skewX(-1.2deg); }
  50% { transform: scale(0.985, 1.03) skewX(0.6deg); }
  75% { transform: scale(1.015, 0.985) skewX(1deg); }
}
/* lava-lamp blobs drifting behind the hub */
.lava { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
#screen-title > *:not(.lava) { position: relative; z-index: 1; }
.lava i {
  position: absolute; border-radius: 50%; filter: blur(34px); opacity: 0.5;
  animation: lavaFloat ease-in-out infinite alternate;
}
.lava i:nth-child(1) { width: 46vw; height: 46vw; left: -12vw; top: 8%;  background: #ff5fd2; animation-duration: 11s; }
.lava i:nth-child(2) { width: 38vw; height: 38vw; right: -10vw; top: 30%; background: #4dd6ff; animation-duration: 14s; }
.lava i:nth-child(3) { width: 42vw; height: 42vw; left: 18vw; bottom: -8%; background: #ffd24d; animation-duration: 17s; }
.lava i:nth-child(4) { width: 30vw; height: 30vw; right: 8vw; bottom: 16%; background: #7cffb2; animation-duration: 12s; }
@keyframes lavaFloat {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(-9vh) scale(1.18, 0.92); }
}
.logo span { display: block; background: linear-gradient(115deg, var(--p4), var(--p2), var(--p3), var(--p4)); background-size: 320% 100%; -webkit-background-clip: text; background-clip: text; animation: rainbowSlide 9s linear infinite reverse; }
.tagline { color: var(--muted); margin: -4px 0 4px; font-weight: 600; }
.title-art canvas { width: 214px; height: 120px; }
.title-links { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: min(320px, 86vw); }
.title-links .btn { width: 100%; padding: 11px 8px; font-size: 13.5px; }
.credit { color: var(--muted); font-size: 12px; margin-top: 2px; }
#screen-title { gap: 10px; }
/* Phone heights: compact the hub so all the mode buttons + links fit (or need
   only a tiny scroll). The decorative title canvas shrinks first, then drops on
   short screens — the buttons are what matter on a phone. */
@media (max-height: 900px) {
  #screen-title { gap: 7px; }
  .logo { font-size: 42px; }
  .title-art canvas { width: 150px; height: 84px; }
  #screen-title .btn-big { padding: 14px 20px; font-size: 19px; }
  .mode-row .btn { padding: 10px 6px; }
  .mission-chip { padding: 5px 10px; font-size: 11.5px; }
}
@media (max-height: 680px) {
  .title-art { display: none; }
  .logo { font-size: 34px; }
  #screen-title { gap: 5px; }
  #screen-title .btn { padding: 11px 16px; }
}

h2 { font-size: 30px; margin: 0; font-weight: 900; }
h3 { margin: 6px 0 0; }

/* buttons — candy-3D: top bevel highlight + hard bottom edge + press-down */
.btn {
  position: relative;
  border: none; border-radius: 18px; padding: 16px 22px; font-size: 18px; font-weight: 900;
  cursor: pointer; color: var(--ink);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.2s;
  width: min(340px, 88vw);
  box-shadow: var(--shadow-pop), inset 0 2px 0 rgba(255,255,255,0.35);
  text-shadow: 0 1.5px 0 rgba(40,12,80,0.3);
}
.btn:active { transform: translateY(4px) scale(0.985); box-shadow: 0 2px 0 rgba(40,12,80,0.35), 0 6px 14px rgba(40,12,80,0.3), inset 0 2px 0 rgba(255,255,255,0.35); }
.btn-primary { background: linear-gradient(180deg, #ff7fdc 0%, var(--p1) 45%, #d63ba8 100%); color: #fff; }
.btn-big { font-size: 21px; padding: 18px 22px; }
#btn-play { animation: playPulse 2.4s ease-in-out infinite; }
@keyframes playPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.14); }
}
.btn-trippy {
  background: linear-gradient(120deg, #4dd6ff, #b59bff, #ff5fd2, #4dd6ff); background-size: 280% 100%;
  color: #fff;
  animation: rainbowSlide 4s linear infinite;
}
.btn-ghost { background: var(--glass); border: 1.5px solid var(--glass-line); backdrop-filter: blur(8px); box-shadow: 0 4px 0 rgba(40,12,80,0.22), inset 0 1.5px 0 rgba(255,255,255,0.3); }
.btn-ghost:active { transform: translateY(3px) scale(0.985); box-shadow: 0 1px 0 rgba(40,12,80,0.22); }
.btn-small { width: auto; padding: 8px 14px; font-size: 14px; }

/* high-score confetti */
.confetti-box { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti-box i {
  position: absolute; top: -4vh; width: 9px; height: 14px; border-radius: 2px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0.7; }
}

/* game over */
.go-score { display: flex; gap: 28px; margin: 6px 0; }
.go-score div { display: flex; flex-direction: column; }
.go-score span { font-size: 40px; font-weight: 900; }
.go-score label { font-size: 12px; color: var(--muted); letter-spacing: 1px; }
#go-badge { background: linear-gradient(120deg, var(--p4), var(--p3)); color: #06243a; font-weight: 900; padding: 8px 16px; border-radius: 999px; animation: pop 0.5s ease; }
.go-biggest { color: var(--muted); font-weight: 700; }
.go-biggest canvas { vertical-align: middle; }
.go-summary { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.go-summary .sum-chip { background: var(--glass); border: 1.5px solid var(--glass-line); border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 800; }
.go-submit { display: flex; flex-direction: column; gap: 10px; align-items: center; width: min(320px, 86vw); }
.ident-row { display: flex; gap: 10px; width: 100%; }
.avatar-btn { width: 54px; height: 54px; border-radius: 14px; border: 1.5px solid var(--glass-line); background: var(--glass); font-size: 26px; cursor: pointer; }
#go-nick { flex: 1; border-radius: 14px; border: 1.5px solid var(--glass-line); background: rgba(0,0,0,0.25); color: var(--ink); padding: 0 14px; font-size: 17px; font-weight: 700; }
#go-nick::placeholder { color: var(--muted); }
.avatar-picker { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.avatar-picker button { width: 42px; height: 42px; font-size: 22px; border-radius: 12px; border: 1.5px solid var(--glass-line); background: var(--glass); cursor: pointer; }
.avatar-picker button.sel { outline: 2px solid var(--p3); }
.submit-status { font-size: 13px; color: var(--muted); min-height: 16px; }
.go-actions { display: flex; flex-direction: column; gap: 8px; align-items: center; margin-top: 6px; }

/* leaderboard */
.tabs { display: flex; gap: 8px; }
.tab { background: var(--glass); border: 1.5px solid var(--glass-line); color: var(--muted); border-radius: 999px; padding: 8px 16px; font-weight: 800; cursor: pointer; }
.tab.active { background: linear-gradient(120deg, var(--p1), var(--p2)); color: #fff; border-color: transparent; }
.board-list { width: min(420px, 92vw); display: flex; flex-direction: column; gap: 6px; max-height: 56vh; overflow-y: auto; }
.board-row { display: flex; align-items: center; gap: 12px; background: var(--glass); border: 1.5px solid var(--glass-line); border-radius: 14px; padding: 10px 14px; }
.board-row .rk { font-weight: 900; width: 30px; color: var(--muted); }
.board-row .av { font-size: 22px; }
.board-row .nm { flex: 1; font-weight: 800; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row .sc { font-weight: 900; }
.board-row.me { outline: 2px solid var(--p3); }
.board-row.top1 { background: linear-gradient(120deg, rgba(255,215,90,0.25), var(--glass)); }
.board-empty { color: var(--muted); padding: 30px; }

/* mushrupedia */
.pedia-sub { color: var(--muted); margin: -6px 0 4px; }
.pedia-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; width: min(460px, 92vw); max-height: 60vh; overflow-y: auto; padding: 4px; }
.pedia-card { background: var(--glass); border: 1.5px solid var(--glass-line); border-radius: 16px; padding: 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
.pedia-card canvas { width: 64px; height: 64px; }
.pedia-card .pn { font-size: 11px; font-weight: 800; }
.pedia-card.locked { opacity: 0.5; }
.pedia-card.locked canvas { filter: grayscale(1) brightness(0.4); }
.pedia-card .lock { font-size: 30px; }

/* settings */
.toggle { display: flex; justify-content: space-between; align-items: center; width: min(320px, 86vw); background: var(--glass); border: 1.5px solid var(--glass-line); border-radius: 14px; padding: 12px 16px; font-weight: 700; }
.toggle input { width: 22px; height: 22px; accent-color: var(--p1); }
.howto { width: min(320px, 86vw); background: var(--glass); border: 1.5px solid var(--glass-line); border-radius: 14px; padding: 14px; text-align: left; font-size: 14px; color: var(--muted); line-height: 1.5; }
.theme-section { width: min(320px, 86vw); }
.theme-label { font-weight: 800; font-size: 14px; margin-bottom: 8px; text-align: left; }
.theme-label small { color: var(--muted); font-weight: 600; }
.theme-grid { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.theme-chip { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 84px; padding: 8px 4px; border-radius: 14px; border: 2px solid var(--glass-line); background: var(--glass); color: var(--ink); cursor: pointer; font-size: 11px; font-weight: 800; }
.theme-chip .te { font-size: 22px; }
.theme-chip.sel { outline: 3px solid var(--sun); }
.theme-chip.locked { opacity: 0.45; }
.theme-chip .lk { font-size: 10px; color: var(--muted); font-weight: 700; }
.version { color: var(--muted); font-size: 12px; }

/* discovery card — everything lives INSIDE the card in normal flow: no
   negative offsets, no overflow clipping, nothing can ever be cut off. */
.discovery { position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; background: rgba(8,4,20,0.6); backdrop-filter: blur(4px); pointer-events: auto; animation: fadeIn 0.25s; padding: 16px; }
.discovery-inner {
  display: flex; flex-direction: column; align-items: center;
  background: radial-gradient(120% 100% at 50% 0%, rgba(60,28,100,0.95), rgba(20,10,40,0.98));
  border: 2px solid var(--glass-line); border-radius: 26px;
  padding: 18px 22px 20px; width: min(330px, 90vw);
  text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 40px rgba(155,93,229,0.25);
  animation: pop 0.4s ease;
}
.discovery-burst {
  background: linear-gradient(120deg, var(--p1), var(--p4)); color: #2a0a3a;
  font-weight: 900; font-size: 12px; padding: 5px 16px; border-radius: 999px;
  letter-spacing: 1px; margin-bottom: 4px; transform: rotate(-2deg);
}
.discovery-inner canvas { width: 156px; height: 156px; }
.discovery-inner h3 { font-size: 23px; font-weight: 900; margin: 2px 0 0; }
#disc-species { color: var(--p3); font-weight: 800; margin: 2px 0 0; }
#disc-latin { font-style: italic; color: var(--muted); font-size: 13px; margin: 0 0 6px; }
#disc-fact { font-size: 14px; line-height: 1.45; color: var(--ink); margin: 0 0 12px; }
#disc-ok { width: 100%; }
@media (max-height: 560px) {
  .discovery-inner canvas { width: 100px; height: 100px; }
  #disc-fact { font-size: 12px; }
  .discovery-inner h3 { font-size: 19px; }
}

/* install + toast */
.install { position: absolute; left: 50%; bottom: calc(16px + var(--safe-bottom)); transform: translateX(-50%); z-index: 30; display: flex; align-items: center; gap: 10px; background: var(--glass); border: 1.5px solid var(--glass-line); border-radius: 16px; padding: 10px 12px; backdrop-filter: blur(8px); width: min(360px, 92vw); }
.install span { flex: 1; font-size: 13px; }
.toast { position: absolute; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 30; background: rgba(0,0,0,0.8); padding: 10px 18px; border-radius: 999px; font-weight: 700; animation: fadeIn 0.2s; }

/* animations */
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); } 20% { opacity: 1; transform: translate(-50%, -70%) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -160%) scale(1); } }
@keyframes pop { 0% { transform: scale(0.4); } 70% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes glow { 0%,100% { box-shadow: 0 0 14px var(--p3); } 50% { box-shadow: 0 0 28px var(--p3); } }
@keyframes pulse { 0%,100% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.06); } }

/* ---- hub mode buttons ---------------------------------------------------- */
.mode-row { display: flex; gap: 8px; width: min(320px, 86vw); }
.mode-row .btn { flex: 1; padding: 12px 6px; font-size: 14px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.mode-sub { display: block; font-size: 10px; font-weight: 700; opacity: 0.85; }
.btn-daily { background: linear-gradient(120deg, #ff8a5c, #ffd24d); color: #4a2800; }
.btn-zen { background: linear-gradient(120deg, #2ea043, #7cffb2); color: #06281a; }
.btn-match {
  background: linear-gradient(120deg, #ff5fd2, #ff8a5c, #ffd24d, #ff5fd2); background-size: 280% 100%;
  color: #fff; animation: rainbowSlide 5s linear infinite;
  box-shadow: 0 8px 26px rgba(255,95,210,0.4);
}
.missions-strip { display: flex; flex-direction: column; gap: 4px; width: min(320px, 86vw); }
.mission-chip { display: flex; align-items: center; gap: 8px; background: var(--glass); border: 1.5px solid var(--glass-line); border-radius: 12px; padding: 7px 12px; font-size: 12.5px; font-weight: 700; text-align: left; }
.mission-chip.done { opacity: 0.65; text-decoration: line-through; border-color: rgba(124,255,178,0.5); }
.mission-chip .mi { font-size: 15px; }
.mission-chip .mr { margin-left: auto; color: var(--p4); text-decoration: none; }

/* ---- mode-select gallery ------------------------------------------------------- */
.modes-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  width: min(400px, 92vw); max-height: 64vh; overflow-y: auto; padding: 4px;
}
.mode-card {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: none; border-radius: 20px; padding: 14px 8px 12px;
  color: #fff; cursor: pointer; text-align: center;
  background: linear-gradient(165deg, rgba(255,255,255,0.24), rgba(255,255,255,0.08));
  box-shadow: 0 5px 0 rgba(40,12,80,0.3), inset 0 1.5px 0 rgba(255,255,255,0.4);
  backdrop-filter: blur(6px);
  transition: transform 0.08s, box-shadow 0.08s;
}
.mode-card:active { transform: translateY(3px) scale(0.97); box-shadow: 0 1px 0 rgba(40,12,80,0.3); }
.mode-card .mc-icon { font-size: 34px; filter: drop-shadow(0 3px 4px rgba(40,12,80,0.4)); }
.mode-card b { font-size: 16px; font-weight: 900; text-shadow: 0 1.5px 0 rgba(40,12,80,0.35); }
.mode-card small { font-size: 11px; opacity: 0.9; line-height: 1.25; min-height: 27px; }
.mode-card .mc-best { font-size: 11px; font-weight: 800; color: var(--sun); text-shadow: 0 1px 0 rgba(40,12,80,0.4); }
.mode-endless    { background: linear-gradient(165deg, rgba(255,95,210,0.55), rgba(155,93,229,0.35)); }
.mode-trippy     { background: linear-gradient(165deg, rgba(180,120,255,0.6), rgba(77,60,200,0.4)); }
.mode-daily      { background: linear-gradient(165deg, rgba(255,178,71,0.6), rgba(255,120,90,0.4)); }
.mode-rush       { background: linear-gradient(165deg, rgba(255,110,90,0.6), rgba(220,60,130,0.4)); }
.mode-reverse    { background: linear-gradient(165deg, rgba(232,138,200,0.55), rgba(110,70,180,0.45)); }
.mode-underwater { background: linear-gradient(165deg, rgba(63,184,230,0.6), rgba(14,92,150,0.45)); }
.mode-moon       { background: linear-gradient(165deg, rgba(120,140,220,0.55), rgba(35,45,100,0.5)); }
.mode-harvest    { background: linear-gradient(165deg, rgba(255,210,90,0.55), rgba(180,140,50,0.4)); }
.mode-windy      { background: linear-gradient(165deg, rgba(120,225,190,0.55), rgba(50,150,130,0.4)); }
.mode-sprout     { background: linear-gradient(165deg, rgba(150,235,170,0.55), rgba(80,170,110,0.4)); }
.mode-zen        { background: linear-gradient(165deg, rgba(190,220,170,0.5), rgba(110,160,130,0.4)); }

/* ---- level map ------------------------------------------------------------- */
.level-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; width: min(380px, 90vw); max-height: 58vh; overflow-y: auto; padding: 4px; }
.level-node {
  position: relative; aspect-ratio: 1; border-radius: 18px; border: 2px solid var(--glass-line);
  background: var(--glass); color: var(--ink); font-weight: 900; font-size: 20px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.level-node .stars { font-size: 11px; letter-spacing: -1px; }
.level-node.locked { opacity: 0.4; }
.level-node.current { border-color: var(--p1); box-shadow: 0 0 18px rgba(255,95,210,0.5); animation: glow 1.6s infinite; }
.level-node:active { transform: scale(0.93); }

/* ---- match screen ------------------------------------------------------------ */
.match-screen { justify-content: flex-start; padding-top: calc(12px + var(--safe-top)); gap: 8px; }
.match-top { display: flex; align-items: center; gap: 10px; width: min(440px, 94vw); }
.match-stat { display: flex; flex-direction: column; align-items: center; background: var(--glass); border: 1.5px solid var(--glass-line); border-radius: 12px; padding: 4px 12px; }
.match-stat label { font-size: 8px; letter-spacing: 1.5px; color: var(--muted); font-weight: 800; }
.match-stat span { font-size: 19px; font-weight: 900; }
#match-moves.low { color: #ff7088; animation: pulse 0.8s infinite; }
.match-objectives { flex: 1; display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }
.obj-chip { background: var(--glass); border: 1.5px solid var(--glass-line); border-radius: 999px; padding: 4px 10px; font-size: 12.5px; font-weight: 800; }
.obj-chip.done { border-color: rgba(124,255,178,0.7); color: var(--p4); }
.match-wrap {
  position: relative; display: flex; align-items: center; justify-content: center;
  /* PORTRAIT board (8 cols × 10 rows = 4/5) that fills the screen: as wide as the
     viewport allows, but never taller than the space under the header. */
  width: min(98vw, calc((100svh - 104px) * 0.8));
  aspect-ratio: 4 / 5;
  padding: 6px; border-radius: 22px;
  /* a chunky candy tray with a glossy lip + deep inner shadow */
  background: linear-gradient(160deg, #ffb3e6, #b06fe6 55%, #6a3fb0);
  box-shadow: 0 9px 0 rgba(40,12,80,0.4), 0 18px 36px rgba(40,12,80,0.45),
              inset 0 3px 0 rgba(255,255,255,0.5), inset 0 -4px 0 rgba(40,12,80,0.35);
}
#match-canvas {
  width: 100%; height: 100%; border-radius: 20px; touch-action: none;
  background: radial-gradient(120% 120% at 50% 0%, rgba(70,36,128,0.6), rgba(30,14,64,0.75));
  box-shadow: inset 0 6px 18px rgba(0,0,0,0.5);
}
.match-praise {
  position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%) rotate(-3deg);
  font-size: 42px; font-weight: 900; pointer-events: none; white-space: nowrap;
  background: linear-gradient(90deg, #ffd24d, #ff5fd2, #4dd6ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.6)); animation: praisePop 0.9s ease forwards;
}
@keyframes praisePop { 0% { transform: translate(-50%,-50%) scale(0.3) rotate(-3deg); opacity: 0; } 25% { transform: translate(-50%,-50%) scale(1.15) rotate(-3deg); opacity: 1; } 80% { opacity: 1; } 100% { transform: translate(-50%,-65%) scale(1) rotate(-3deg); opacity: 0; } }

/* ---- Spore Snake -------------------------------------------------------- */
.btn-snake {
  background: linear-gradient(120deg, #2bd47e, #13e0c2 55%, #4dd6ff);
  color: #06241c; box-shadow: 0 8px 26px rgba(43,212,126,0.4);
}

/* ---- Puzzle mode -------------------------------------------------------- */
.btn-puzzle {
  background: linear-gradient(120deg, #ffb347, #ff5fd2 55%, #9b5de5); background-size: 240% 100%;
  color: #fff; box-shadow: 0 8px 26px rgba(155,93,229,0.4); animation: rainbowSlide 6s linear infinite;
}
/* the goal chip floats at the very top-centre of the play area during a puzzle */
.puzzle-goal {
  position: absolute; top: calc(7px + var(--safe-top)); left: 50%; transform: translateX(-50%);
  background: var(--glass); border: 1.5px solid var(--glass-line); border-radius: 999px;
  padding: 6px 14px; font-size: 13px; font-weight: 800; backdrop-filter: blur(6px);
  white-space: nowrap; max-width: 78vw; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1.5px 0 rgba(40,12,80,0.4); pointer-events: none; z-index: 6;
}
.pintro-goal { font-size: 18px; font-weight: 900; color: var(--sun); text-align: center; }
#dock.no-abilities .abilities { display: none; }

/* ---- Spore Smash (brick breaker) ---------------------------------------- */
.btn-bricks {
  background: linear-gradient(120deg, #ff8a5c, #ffd24d 50%, #ff5fd2); background-size: 240% 100%;
  color: #3a1500; box-shadow: 0 8px 26px rgba(255,138,92,0.4); animation: rainbowSlide 6s linear infinite;
}
.bricks-screen { justify-content: flex-start; padding-top: calc(12px + var(--safe-top)); gap: 8px; }
.bricks-wrap {
  position: relative; width: min(540px, 98vw); flex: 1 1 auto; min-height: 0;
  margin-bottom: calc(8px + var(--safe-bottom));
  border-radius: 22px; overflow: hidden;
  box-shadow: 0 9px 0 rgba(40,12,80,0.4), 0 18px 36px rgba(40,12,80,0.45);
}
#bricks-canvas { width: 100%; height: 100%; display: block; touch-action: none; }
#bricks-over { border-radius: 22px; }

/* ---- Mush Rush (endless runner) ----------------------------------------- */
.btn-run {
  background: linear-gradient(120deg, #9b5de5, #ff5fd2 52%, #ffb347); background-size: 240% 100%;
  color: #fff; box-shadow: 0 8px 26px rgba(155,93,229,0.42); animation: rainbowSlide 6s linear infinite;
}
.run-screen { justify-content: flex-start; padding-top: calc(12px + var(--safe-top)); gap: 8px; }
.run-wrap {
  position: relative; width: min(540px, 98vw); flex: 1 1 auto; min-height: 0;
  margin-bottom: calc(8px + var(--safe-bottom));
  border-radius: 22px; overflow: hidden;
  box-shadow: 0 9px 0 rgba(40,12,80,0.4), 0 18px 36px rgba(40,12,80,0.45);
}
#run-canvas { width: 100%; height: 100%; display: block; touch-action: none; }
#run-over { border-radius: 22px; }
.snake-screen { justify-content: flex-start; padding-top: calc(12px + var(--safe-top)); gap: 8px; }
.snake-chips { flex: 1; display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }
.snake-chip { background: var(--glass); border: 1.5px solid var(--glass-line); border-radius: 999px; padding: 4px 10px; font-size: 12.5px; font-weight: 800; }
.snake-best { font-size: 13px !important; color: var(--muted); }
/* on-screen d-pad */
.snake-dpad { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); width: 156px; height: 156px; pointer-events: none; z-index: 30; }
.snake-dpad .dbtn { position: absolute; width: 52px; height: 52px; border-radius: 15px; border: 2px solid rgba(255,255,255,0.28);
  background: rgba(18,10,38,0.5); color: #fff; font-size: 21px; pointer-events: auto; display: flex; align-items: center; justify-content: center;
  touch-action: none; -webkit-tap-highlight-color: transparent; }
.snake-dpad .dbtn:active { background: rgba(90,210,140,0.65); transform: scale(0.93); }
.snake-dpad .up { top: 0; left: 52px; } .snake-dpad .down { bottom: 0; left: 52px; }
.snake-dpad .left { left: 0; top: 52px; } .snake-dpad .right { right: 0; top: 52px; }
/* difficulty chooser */
.diff-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 8px 0; }
.diff-row .btn.sel { border-color: var(--p4); background: rgba(124,255,178,0.18); }
.snake-help { font-size: 13.5px; color: var(--muted); max-width: 290px; margin: 0 auto 6px; line-height: 1.4; }
.snake-wrap-row { font-size: 13px; }
.snake-wrap {
  position: relative; width: min(460px, 96vw); flex: 1 1 auto; min-height: 0;
  margin-bottom: calc(10px + var(--safe-bottom));
  padding: 10px; border-radius: 28px;
  background: linear-gradient(160deg, #6ad49a, #3aa0b0 55%, #2a5fb0);
  box-shadow: 0 10px 0 rgba(12,40,30,0.4), 0 22px 40px rgba(12,40,30,0.45),
              inset 0 3px 0 rgba(255,255,255,0.5), inset 0 -4px 0 rgba(12,40,30,0.35);
}
#snake-canvas {
  width: 100%; height: 100%; border-radius: 20px; touch-action: none; display: block;
  background: radial-gradient(120% 90% at 50% 0%, rgba(60,40,110,0.6), rgba(24,12,52,0.78));
  box-shadow: inset 0 6px 18px rgba(0,0,0,0.5);
}
#snake-pops { position: absolute; inset: 0; pointer-events: none; }
#snake-over { border-radius: 20px; }

/* ---- last-second save prompt + rewind ----------------------------------- */
.last-chance {
  position: fixed; left: 50%; bottom: calc(150px + var(--safe-bottom)); transform: translateX(-50%);
  z-index: 60; pointer-events: none; white-space: nowrap;
  background: linear-gradient(90deg, #ff5f6d, #ffb347); color: #2a0a0a;
  font-weight: 900; font-size: 15px; padding: 9px 16px; border-radius: 999px;
  box-shadow: 0 6px 22px rgba(255,80,90,0.5); animation: lastChancePulse 0.7s ease-in-out infinite;
}
@keyframes lastChancePulse { 0%,100% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.06); } }
#dock.save-now .abilities { animation: dockSave 0.7s ease-in-out infinite; }
@keyframes dockSave { 0%,100% { filter: none; } 50% { filter: drop-shadow(0 0 10px #ffd24d) brightness(1.15); } }
.btn-rewind {
  background: linear-gradient(120deg, #4dd6ff, #b59bff); color: #08203a;
  box-shadow: 0 8px 26px rgba(77,214,255,0.45); font-weight: 900;
}

.match-intro {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  background: rgba(10,5,28,0.88); border: 1.5px solid var(--glass-line); border-radius: 14px;
  padding: 10px 16px; font-size: 14px; font-weight: 700; width: max-content; max-width: 92%;
  pointer-events: none; animation: fadeIn 0.3s;
}
#match-pops { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.mdialog { position: absolute; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: rgba(8,4,20,0.65); backdrop-filter: blur(5px); animation: fadeIn 0.25s; }
.mdialog-inner { display: flex; flex-direction: column; gap: 10px; align-items: center; background: radial-gradient(120% 100% at 50% 0%, rgba(60,28,100,0.95), rgba(20,10,40,0.98)); border: 2px solid var(--glass-line); border-radius: 24px; padding: 24px; width: min(300px, 86vw); text-align: center; animation: pop 0.35s ease; }
.mwin-stars { font-size: 38px; letter-spacing: 4px; animation: pop 0.5s ease; }
.mwin-score span { font-size: 34px; font-weight: 900; }
.mwin-score label { display: block; font-size: 11px; color: var(--muted); letter-spacing: 1px; }
.mlose-obj { color: var(--muted); font-weight: 700; }
.mdialog .btn { width: 100%; }

/* ---- stats & badges -------------------------------------------------------------- */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; width: min(380px, 90vw); }
.stat-card { background: var(--glass); border: 1.5px solid var(--glass-line); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; }
.stat-card b { font-size: 22px; font-weight: 900; }
.stat-card small { color: var(--muted); font-size: 11px; font-weight: 700; }
.stats-h { margin: 8px 0 0; font-size: 16px; }
.streak-row { display: flex; gap: 5px; align-items: center; }
.streak-dot { width: 16px; height: 16px; border-radius: 50%; background: rgba(255,255,255,0.12); }
.streak-dot.lit { background: linear-gradient(135deg, #ffd24d, #ff8a5c); box-shadow: 0 0 8px rgba(255,210,77,0.6); }
.streak-count { font-weight: 900; margin-left: 6px; }
.achv-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: min(380px, 90vw); max-height: 34vh; overflow-y: auto; padding: 2px; }
.achv-card { background: var(--glass); border: 1.5px solid var(--glass-line); border-radius: 14px; padding: 8px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.achv-card .ai { font-size: 24px; }
.achv-card b { font-size: 11px; }
.achv-card small { font-size: 9px; color: var(--muted); line-height: 1.2; }
.achv-card.locked { opacity: 0.38; filter: grayscale(0.8); }

/* achievement toast */
.achv-toast {
  position: absolute; top: calc(14px + var(--safe-top)); left: 50%; transform: translateX(-50%);
  z-index: 40; display: flex; align-items: center; gap: 10px;
  background: linear-gradient(120deg, rgba(80,40,140,0.97), rgba(30,14,60,0.97));
  border: 2px solid #ffd24d; border-radius: 16px; padding: 10px 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5), 0 0 24px rgba(255,210,77,0.35);
  animation: achvIn 0.45s ease; max-width: 92vw;
}
.achv-toast span { font-size: 26px; }
.achv-toast b { display: block; font-size: 14px; }
.achv-toast small { color: var(--muted); font-size: 11.5px; }
@keyframes achvIn { from { transform: translate(-50%, -120%); } to { transform: translate(-50%, 0); } }

@media (min-height: 760px) { .score { font-size: 46px; } }
@media (max-width: 420px) {
  .ability { width: 62px; height: 62px; border-radius: 17px; }
  .ability .ico { font-size: 24px; }
  .abilities { gap: 8px; }
  #dock { gap: 6px; padding-left: 8px; padding-right: 8px; }
  .dock-row { gap: 8px; }
  .spark-meter { padding: 6px 10px; }
  .spark-bar { width: 48px; }
  .next-preview { padding: 2px 8px; }
  .icon-btn { width: 40px; height: 40px; }
  .score { font-size: 40px; }
}

/* How-to-Play intro (first merge run) + Match legend share this card look */
.howto-intro {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8,4,20,0.74); backdrop-filter: blur(6px);
  animation: fadeIn 0.25s; padding: 16px;
}
.howto-card {
  display: flex; flex-direction: column; gap: 12px; align-items: stretch;
  background: radial-gradient(120% 100% at 50% 0%, rgba(60,28,100,0.96), rgba(20,10,40,0.98));
  border: 2px solid var(--glass-line); border-radius: 24px;
  padding: 22px; width: min(360px, 92vw); max-height: 88vh; overflow-y: auto;
  animation: pop 0.35s ease; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.howto-card h3 { text-align: center; font-size: 22px; margin: 0; }
.howto-intro-body { font-size: 14.5px; line-height: 1.55; text-align: left; color: var(--ink, #f3ecff); }
.howto-intro-body b { color: var(--p4, #9affc6); }
.howto-row { display: flex; align-items: flex-start; gap: 10px; margin: 9px 0; }
.howto-row .ic { font-size: 22px; line-height: 1.2; flex: 0 0 26px; text-align: center; }
.match-help-inner { width: min(370px, 92vw); max-height: 88vh; overflow-y: auto; text-align: left; }
.match-help-inner h3 { text-align: center; }

/* hub progress counters + mission header */
.hub-count { opacity: .72; font-size: .82em; margin-left: 5px; font-weight: 700; }
.mission-head { width: 100%; text-align: center; font-size: 11px; font-weight: 800; color: var(--muted); margin-bottom: 3px; letter-spacing: .3px; }
.btn-daily.done { opacity: .82; }
.mode-best-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.mode-best { display: flex; flex-direction: column; align-items: center; background: var(--glass); border: 1.5px solid var(--glass-line); border-radius: 12px; padding: 6px 12px; min-width: 58px; }
.mode-best .mb-ic { font-size: 16px; }
.mode-best b { font-size: 15px; }
.mode-best small { font-size: 9px; color: var(--muted); }

/* combo-chain callout on merges */
.chainpop { position: absolute; transform: translate(-50%, -50%); font-weight: 900; letter-spacing: 1px;
  pointer-events: none; white-space: nowrap; z-index: 6; text-shadow: 0 2px 8px rgba(0,0,0,0.6); animation: chainpop 0.88s ease-out forwards; }
@keyframes chainpop {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  22% { transform: translate(-50%, -85%) scale(1.18); opacity: 1; }
  100% { transform: translate(-50%, -175%) scale(1); opacity: 0; }
}

/* keyboard/switch accessibility — visible focus on interactive elements */
.btn:focus-visible, .icon-btn:focus-visible, .theme-chip:focus-visible, .snake-ab:focus-visible,
.obj-chip:focus-visible, input:focus-visible, .level-node:focus-visible {
  outline: 3px solid var(--p3, #4dd6ff); outline-offset: 2px;
}
.btn-danger { color: #ff8a9a; border-color: rgba(255,112,136,0.4); }

/* match: live star pips + objective-complete pop */
.match-stars-mini { display: flex; gap: 1px; font-size: 10px; line-height: 1; margin-top: 1px; justify-content: center; }
.match-stars-mini .sp { color: rgba(255,255,255,0.25); }
.match-stars-mini .sp.on { color: #ffd24d; text-shadow: 0 0 5px rgba(255,210,77,0.7); }
.obj-chip.just-done { animation: objdone 0.6s ease; }
@keyframes objdone { 0% { transform: scale(1); } 35% { transform: scale(1.35); } 100% { transform: scale(1); } }

/* Snake — abilities row, revive button, death panel */
.snake-abilities {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 2px auto 4px; flex: 0 0 auto;
}
.snake-ab {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-width: 50px; padding: 5px 9px; border-radius: 14px;
  border: 1.5px solid var(--glass-line); background: var(--glass); color: #fff;
  font-weight: 800; cursor: pointer; transition: transform .1s, opacity .2s, box-shadow .2s;
}
.snake-ab .ab-ic { font-size: 19px; line-height: 1; }
.snake-ab .ab-name { font-size: 9px; letter-spacing: .5px; opacity: .85; }
.snake-ab:disabled { opacity: .34; filter: grayscale(0.6); cursor: default; }
.snake-ab:not(:disabled):active { transform: scale(0.9); }
.snake-ab.active { border-color: #7cffb2; box-shadow: 0 0 14px rgba(124,255,178,0.7); }
.snake-charges { font-size: 14px; letter-spacing: 2px; color: #ffd24d; min-width: 26px; text-align: center; }
.btn-revive { background: linear-gradient(180deg, #3ad6a0, #16a079); border: none; color: #04241a; font-weight: 900; }
.sover-title { color: #ff7088; font-size: 25px; margin: 0 0 2px; }
.sover-title.win { color: #ffd24d; }
.snake-over-inner .go-score span { font-size: 38px; }
