/* =========================================================
   MATH SQUAD RUNNER — styles  (v0.4, multi-grade)
   ========================================================= */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
  width: 100%; height: 100%;
  background: #0a1428;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #fff;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#game {
  position: fixed; inset: 0; overflow: hidden;
  background: linear-gradient(180deg, #1e3a5f 0%, #2a5980 40%, #6b8e3d 70%, #4a6b2a 100%);
}

/* ---------- 3D corridor ---------- */
#world { position: absolute; inset: 0; perspective: 900px; perspective-origin: 50% 8%; }
#floor {
  position: absolute; top: 8%; left: 50%; width: 100vw; height: 280vh;
  transform-origin: 50% 0%;
  transform: translate(-50%, 0) rotateX(72deg);
  background:
    linear-gradient(90deg, transparent 0 18%, rgba(0,0,0,0.18) 18% 19%, transparent 19% 81%, rgba(0,0,0,0.18) 81% 82%, transparent 82%),
    repeating-linear-gradient(0deg, #c9b993 0 80px, #b8a880 80px 160px);
  box-shadow: inset 0 0 200px rgba(0,0,0,0.4);
}
.wall {
  position: absolute; top: 8%; width: 6vw; height: 280vh; transform-origin: 50% 0%;
  background: linear-gradient(180deg, #4a6b2a, #2d4218); opacity: 0.85;
}
.wall.left  { left: 6%;  transform: translateY(0) rotateX(72deg) rotateY(15deg); }
.wall.right { right: 6%; transform: translateY(0) rotateX(72deg) rotateY(-15deg); }

/* ---------- Gates ---------- */
.gate-pair {
  position: absolute; left: 50%; top: 0;
  width: 80%; max-width: 520px;
  pointer-events: none; transition: filter 0.2s;
  will-change: transform, opacity;
  transform: translate3d(-50%, 0, 0);
}
.gate-pair .problem {
  position: absolute;
  top: -64px; left: 0; right: 0;
  text-align: center;
  font-size: 38px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 4px 0 #000, 0 0 16px rgba(0,0,0,0.6);
  letter-spacing: 1px;
  line-height: 1.05;
  word-wrap: break-word;
}
.gate-pair .problem.big-emoji {
  font-size: 32px;
  letter-spacing: 0;
  line-height: 1.0;
  word-break: break-all;
  top: -68px;
}
.gate-pair .review-tag {
  position: absolute; top: -98px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(180deg, #ffd86b, #ff8a3d);
  color: #2d1810; font-weight: 900; font-size: 12px;
  padding: 3px 10px; border-radius: 99px;
  border: 2px solid rgba(0,0,0,0.4);
  letter-spacing: 1px; white-space: nowrap;
}
.gate-row { display: flex; gap: 10px; }
.gate {
  flex: 1;
  height: 100px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 44px; font-weight: 900;
  color: #fff;
  text-shadow: 0 3px 0 rgba(0,0,0,0.5);
  border: 4px solid rgba(255,255,255,0.5);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4), inset 0 -8px 0 rgba(0,0,0,0.25);
  text-align: center;
  padding: 0 6px;
  word-break: break-word;
}
.gate.left  { background: linear-gradient(180deg, #2ec4b6, #1a8c82); }
.gate.right { background: linear-gradient(180deg, #ff6b6b, #c93f3f); }
.gate-pair.passed-good { filter: brightness(1.4) saturate(1.5) drop-shadow(0 0 16px #6dffb1); }
.gate-pair.passed-bad  { filter: brightness(0.5) saturate(0.4); }

/* ---------- Inline enemy groups ---------- */
.enemy-group {
  position: absolute; left: 50%; top: 0;
  width: 80%; max-width: 520px;
  display: flex; justify-content: center; gap: 6px;
  pointer-events: none;
  transition: filter 0.3s;
  will-change: transform, opacity;
  transform: translate3d(-50%, 0, 0);
}
.enemy-group.boss::before {
  content: 'BOSS';
  position: absolute; top: -38px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(180deg, #ff6b6b, #c93f3f);
  color: #fff; font-weight: 900; font-size: 16px;
  padding: 4px 14px; border-radius: 99px;
  letter-spacing: 2px; border: 2px solid rgba(0,0,0,0.4);
}
.enemy-group.clashing { filter: brightness(1.4) saturate(1.5); animation: shake 0.4s; }
.enemy-group.gone     { opacity: 0; transform: translateX(-50%) scale(0.5); }
@keyframes shake {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  25% { transform: translateX(calc(-50% - 8px)) translateY(-4px); }
  75% { transform: translateX(calc(-50% + 8px)) translateY(4px); }
}
.corridor-enemy { position: relative; width: 36px; height: 60px; flex-shrink: 0; }
.corridor-enemy .head { position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 20px; height: 20px; background: #6b8a3b; border-radius: 50%; border: 2px solid #2d3f12; }
.corridor-enemy .body { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); width: 28px; height: 34px; background: #4a5a2a; border-radius: 4px; border: 2px solid #2d3f12; }
.corridor-enemy .sword { position: absolute; top: 12px; left: -10px; width: 4px; height: 26px; background: linear-gradient(180deg, #aaa, #555); border-radius: 2px; }

/* ---------- Squad ---------- */
#squad {
  position: absolute; bottom: 12%; left: 50%; transform: translateX(-50%);
  width: 240px; height: 180px; pointer-events: none;
  transition: left 0.06s linear;
}
.soldier {
  position: absolute; width: 38px; height: 64px;
  bottom: 0; left: 50%; transform: translateX(-50%);
  animation: run-bob 0.35s infinite;
}
.soldier .head { position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 20px; height: 20px; background: #f5cfa5; border-radius: 50%; border: 2px solid #2d2218; }
.soldier .body { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); width: 28px; height: 34px; background: #3a6f3a; border-radius: 6px; border: 2px solid #1f3d1f; }
.soldier .legs { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 22px; height: 16px; background: #2d2218; border-radius: 4px; }
.soldier .sword { position: absolute; top: 12px; right: -10px; width: 4px; height: 28px; background: linear-gradient(180deg, #ddd, #888); border-radius: 2px; }
@keyframes run-bob { 0%, 100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-4px); } }
.soldier.dying { animation: die 0.5s forwards; }
@keyframes die { to { transform: translateX(-50%) rotate(80deg) translateY(20px); opacity: 0; } }

.clash {
  position: absolute; width: 50px; height: 50px;
  background: radial-gradient(circle, #fff 0%, #ffd86b 30%, transparent 70%);
  border-radius: 50%; pointer-events: none;
  animation: clash 0.5s forwards;
}
@keyframes clash { 0% { transform: scale(0.3); opacity: 1; } 100% { transform: scale(2); opacity: 0; } }

/* ---------- HUD ---------- */
#hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between;
  padding: max(env(safe-area-inset-top), 16px) 16px 0;
  pointer-events: none; z-index: 10;
}
.hud-pill {
  background: rgba(0,0,0,0.55);
  border: 2px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  padding: 8px 16px;
  display: flex; gap: 8px; align-items: center;
  font-weight: 800; font-size: 18px;
  backdrop-filter: blur(4px);
}
.hud-pill .icon { font-size: 22px; }
.hud-pill.center { font-size: 14px; opacity: 0.9; }

.popup {
  position: absolute;
  font-size: 36px; font-weight: 900;
  color: #fff; text-shadow: 0 3px 0 #000;
  pointer-events: none;
  animation: pop 0.9s ease-out forwards; z-index: 20;
}
.popup.good { color: #6dffb1; }
.popup.bad  { color: #ff6d6d; }
@keyframes pop { 0% { transform: translate(-50%, 0) scale(0.6); opacity: 0; } 30% { transform: translate(-50%, -20px) scale(1.2); opacity: 1; } 100% { transform: translate(-50%, -80px) scale(1); opacity: 0; } }

/* ---------- Overlays ---------- */
.overlay {
  position: absolute; inset: 0;
  background: rgba(10, 20, 40, 0.92);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  z-index: 100;
  backdrop-filter: blur(6px);
  padding: 24px;
  overflow-y: auto;
}
.overlay h1 {
  font-size: 48px; font-weight: 900;
  background: linear-gradient(180deg, #ffd86b, #ff8a3d);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 4px 0 #000;
  letter-spacing: 2px; margin-bottom: 8px; text-align: center;
}
.overlay h2 { font-size: 24px; font-weight: 800; margin-bottom: 16px; opacity: 0.9; text-align: center; }
.overlay p { font-size: 15px; opacity: 0.85; max-width: 360px; text-align: center; line-height: 1.5; margin-bottom: 8px; }

.btn {
  background: linear-gradient(180deg, #ffd86b, #ff8a3d);
  color: #2d1810; border: none;
  border-bottom: 4px solid #a55818;
  padding: 16px 36px; border-radius: 14px;
  font-size: 20px; font-weight: 900;
  cursor: pointer; pointer-events: auto;
  text-shadow: 0 1px 0 rgba(255,255,255,0.4);
  transition: transform 0.1s; margin-top: 8px;
}
.btn:active { transform: translateY(2px); border-bottom-width: 2px; }

.btn-link {
  background: none; border: none; color: #ffd86b;
  font-size: 14px; padding: 8px 12px; margin-top: 4px;
  cursor: pointer; pointer-events: auto;
  text-decoration: underline;
}

/* ---------- Grade picker ---------- */
.grade-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 380px;
  margin: 12px 0 16px;
}
.grade-btn {
  background: linear-gradient(180deg, #4a78c9, #2c5798);
  color: #fff; border: none;
  border-bottom: 4px solid #1a3868;
  padding: 12px 8px; border-radius: 14px;
  font-size: 36px; font-weight: 900;
  cursor: pointer; pointer-events: auto;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  transition: transform 0.1s;
  min-height: 88px;
}
.grade-btn:active { transform: translateY(2px); border-bottom-width: 2px; }
.grade-btn span {
  font-size: 13px;
  letter-spacing: 1px;
  font-weight: 700;
  opacity: 0.95;
}

/* ---------- Stars / missed list ---------- */
.stars { display: flex; gap: 8px; justify-content: center; margin: 12px 0 16px; }
.star { font-size: 56px; filter: grayscale(1) brightness(0.4); }
.star.lit { filter: none; animation: pop-star 0.4s ease-out; }
@keyframes pop-star { from { transform: scale(0.3); } to { transform: scale(1); } }

.missed-list { background: rgba(0,0,0,0.4); padding: 12px; border-radius: 8px; max-width: 320px; margin: 4px auto 12px; }
.missed-list .title { font-size: 13px; opacity: 0.7; margin-bottom: 6px; text-align: center; letter-spacing: 1px; font-weight: 700; }
.missed-row { display: flex; justify-content: space-between; padding: 4px 8px; font-size: 16px; border-bottom: 1px solid rgba(255,255,255,0.08); gap: 8px; }
.missed-row:last-child { border-bottom: none; }
.missed-row .you { color: #ff8a8a; }
.missed-row .right { color: #6dffb1; }

.hidden { display: none !important; }

/* =========================================================
   DICE — visual numbers for K (v0.5)
   ========================================================= */
.dice {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 56px; height: 56px;
  background: #fff;
  border: 2.5px solid #1a1a1a;
  border-radius: 9px;
  padding: 5px;
  gap: 3px;
  vertical-align: middle;
  box-shadow: 0 3px 0 rgba(0,0,0,0.35), inset 0 -3px 0 rgba(0,0,0,0.08);
  flex-shrink: 0;
}
.dice .dot {
  background: #1a1a1a;
  border-radius: 50%;
  align-self: center;
  justify-self: center;
  width: 100%; height: 100%;
}
.dice .dot-empty { background: transparent; }
.dice.empty { background: #ddd; }

.dice-pair {
  display: inline-flex;
  gap: 6px;
  vertical-align: middle;
  align-items: center;
}

/* Dice in the problem prompt area — needs more vertical room */
.gate-pair .problem.dice-prompt {
  font-size: 28px;
  top: -98px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.gate-pair .problem.dice-prompt .dice { width: 64px; height: 64px; }

/* Dice inside the gate cells (when gate value is dice) */
.gate .dice { width: 50px; height: 50px; }
.gate .dice-pair .dice { width: 44px; height: 44px; }

/* When the gate's content is dice, drop the giant font */
.gate-row .gate:has(.dice) { font-size: 0; }

/* =========================================================
   v0.6 — vanish-on-answer + symbol-hint chip
   ========================================================= */
.gate-pair.vanish {
  transition: opacity 0.1s ease-out, transform 0.15s ease-out;
  opacity: 0 !important;
  transform: translateX(-50%) scale(1.18) !important;
  pointer-events: none;
}

/* Symbol-hint chip: shows >, <, = next to the word so kids
   learn the symbol along with the spoken word. */
.gate-pair .problem .sym {
  display: inline-block;
  background: linear-gradient(180deg, #ffd86b, #ff8a3d);
  color: #2d1810;
  padding: 2px 16px;
  border-radius: 10px;
  margin-left: 12px;
  font-weight: 900;
  text-shadow: 0 1px 0 rgba(255,255,255,0.4);
  border: 2.5px solid #2d1810;
  vertical-align: middle;
  line-height: 1;
}

/* =========================================================
   v0.7 — DEV helpers (skip concept, fast-forward indicator)
   ========================================================= */
#dev-panel {
  position: absolute;
  top: max(env(safe-area-inset-top), 16px);
  right: 16px;
  margin-top: 56px;
  z-index: 11;
  pointer-events: none;
  display: flex;
  gap: 8px;
}
.dev-btn {
  background: rgba(255, 138, 61, 0.92);
  color: #2d1810;
  border: 2px solid rgba(0,0,0,0.4);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  pointer-events: auto;
  letter-spacing: 1px;
  transition: transform 0.1s;
}
.dev-btn:active { transform: scale(0.95); }
.dev-btn.hidden { display: none; }

/* Fast-forward indicator — appears when ↑ is held */
#ff-indicator {
  position: absolute;
  bottom: 30%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 216, 107, 0.85);
  color: #2d1810;
  font-weight: 900;
  font-size: 13px;
  padding: 4px 14px;
  border-radius: 99px;
  letter-spacing: 2px;
  pointer-events: none;
  z-index: 25;
  border: 2px solid #2d1810;
  opacity: 0;
  transition: opacity 0.15s;
}
#ff-indicator.on { opacity: 1; }

/* =========================================================
   v0.8 — Hero picker, single-character power system
   ========================================================= */
.hero-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-width: 380px;
  margin: 4px 0 12px;
}
.hero-btn {
  background: rgba(255,255,255,0.08);
  color: #fff;
  border: 3px solid rgba(255,255,255,0.2);
  border-radius: 14px;
  padding: 14px 8px;
  font-size: 56px;
  font-weight: 900;
  cursor: pointer;
  pointer-events: auto;
  display: flex; flex-direction: column;
  align-items: center; gap: 6px;
  transition: transform 0.1s, border-color 0.2s, background 0.2s;
  line-height: 1;
}
.hero-btn span {
  font-size: 14px; letter-spacing: 1px; font-weight: 700;
}
.hero-btn.selected {
  border-color: #ffd86b;
  background: rgba(255, 216, 107, 0.18);
  box-shadow: 0 0 20px rgba(255,216,107,0.4);
}
.hero-btn:active { transform: scale(0.96); }

#character {
  position: absolute;
  bottom: 10%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 80px;
  line-height: 1;
  pointer-events: none;
  text-align: center;
  z-index: 5;
  transition: font-size 0.4s ease-out, filter 0.4s ease-out, left 0.06s linear;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.5));
}

/* Power-bar HUD (replaces squad count) */
.power-bar {
  background: rgba(0,0,0,0.55);
  border: 2px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  padding: 6px 12px;
  display: flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 16px;
  backdrop-filter: blur(4px);
  min-width: 90px;
}
.power-bar .track {
  position: relative;
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  overflow: hidden;
}
.power-bar .fill {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  background: linear-gradient(90deg, #ff6d6d, #ffd86b, #6dffb1);
  transition: width 0.3s, left 0.3s;
}
.power-bar .num { font-size: 14px; min-width: 32px; text-align: center; }
.power-bar .num.positive { color: #6dffb1; }
.power-bar .num.negative { color: #ff8a8a; }

/* =========================================================
   v0.9 — 3D character canvas wrapper + FF indicator
   ========================================================= */
#char-wrap {
  position: absolute;
  bottom: 6%;
  left: 50%;
  transform: translateX(-50%);
  width: 280px;
  height: 280px;
  pointer-events: none;
  z-index: 5;
  transition: left 0.06s linear;
}
#char-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
}
#char-egg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 140px;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.5));
}
#char-egg.hidden { display: none; }

/* Fast-forward indicator (returns in v0.9) */
#ff-indicator {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 216, 107, 0.92);
  color: #2d1810;
  font-weight: 900;
  font-size: 14px;
  padding: 5px 16px;
  border-radius: 99px;
  letter-spacing: 2px;
  pointer-events: none;
  z-index: 25;
  border: 2px solid #2d1810;
  opacity: 0;
  transition: opacity 0.15s;
}
#ff-indicator.on { opacity: 1; }

/* Update skip-concept dev button label hint */
.dev-btn { position: relative; }

/* =========================================================
   v1.0 — Corridor scrolling + review tag clear
   ========================================================= */

/* Floor scroll: makes it feel like the hero is running forward,
   instead of gates floating down to a stationary character. */
@keyframes corridor-scroll {
  0%   { background-position-y: 0px; }
  100% { background-position-y: 160px; }
}
#floor {
  animation: corridor-scroll 1.4s linear infinite;
}

/* Push REVIEW tag well above the problem text so it doesn't sit
   on top of dice-prompt problems (which themselves use top:-98px). */
.gate-pair .review-tag {
  top: -140px !important;
}

/* =========================================================
   v1.0 — Fireworks particles
   ========================================================= */
.firework {
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(0, 0);
  animation: firework-burst 1s ease-out forwards;
  box-shadow: 0 0 8px currentColor;
  z-index: 999;
  position: fixed;
}
.firework.big { width: 14px; height: 14px; }
@keyframes firework-burst {
  0% {
    transform: translate(-50%, -50%) scale(0.4);
    opacity: 1;
  }
  60% {
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.4);
    opacity: 0;
  }
}

/* =========================================================
   v1.2 — Stronger fly-past vanish + cupcake enemies (unicorn mode)
   ========================================================= */

/* When a gate vanishes, scale it up dramatically so it reads as
   "flew past the camera" rather than just disappearing on the hero. */
.gate-pair.vanish {
  transition: opacity 0.18s ease-out, transform 0.25s ease-out !important;
  opacity: 0 !important;
  transform: translateX(-50%) scale(2.2) !important;
  pointer-events: none;
}

/* Same fly-past vibe for enemy groups */
.enemy-group.gone {
  transition: opacity 0.25s ease-out, transform 0.3s ease-out;
  opacity: 0 !important;
  transform: translateX(-50%) scale(1.8) !important;
}

/* ---------- Cupcake enemies (unicorn mode) ---------- */
.cupcake-enemy {
  position: relative;
  width: 48px; height: 80px;
  flex-shrink: 0;
}
/* Legs poking out the bottom */
.cupcake-enemy .leg {
  position: absolute;
  bottom: 0;
  width: 6px; height: 14px;
  background: linear-gradient(180deg, #c98a3e, #8e5a25);
  border: 1.5px solid #3d240e;
  border-radius: 2px 2px 1px 1px;
  z-index: 0;
}
.cupcake-enemy .leg.left  { left: 14px; }
.cupcake-enemy .leg.right { right: 14px; }
.cupcake-enemy .leg::after {
  /* tiny shoe / foot */
  content: '';
  position: absolute;
  bottom: -3px; left: -2px;
  width: 10px; height: 4px;
  background: #2d180a;
  border-radius: 2px;
}

/* Wrapper (corrugated paper) */
.cupcake-enemy .wrapper {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 38px; height: 26px;
  background: repeating-linear-gradient(90deg, #c98a3e 0 5px, #8e5a25 5px 10px);
  border: 2px solid #3d240e;
  border-radius: 0 0 6px 6px;
  clip-path: polygon(8% 0, 92% 0, 100% 100%, 0% 100%);
  z-index: 1;
}

/* Frosting on top */
.cupcake-enemy .frosting {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: 42px; height: 24px;
  background: radial-gradient(ellipse at 30% 30%, #ffb0e0, #ff6bb8 70%, #c93f8f);
  border-radius: 50% 50% 6px 6px / 60% 60% 6px 6px;
  border: 2px solid #5a1838;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
  z-index: 2;
}
.cupcake-enemy .frosting::before,
.cupcake-enemy .frosting::after {
  /* sprinkles */
  content: '';
  position: absolute;
  width: 3px; height: 6px;
  border-radius: 2px;
  top: 5px;
}
.cupcake-enemy .frosting::before { left: 9px;  background: #6dffb1; transform: rotate(-15deg); }
.cupcake-enemy .frosting::after  { right: 9px; background: #6db5ff; transform: rotate(20deg); }

/* Arms — left arm dangles, right arm angled up to hold the candle */
.cupcake-enemy .arm {
  position: absolute;
  width: 6px; height: 18px;
  background: linear-gradient(180deg, #d99a4e, #a06525);
  border: 1.5px solid #3d240e;
  border-radius: 3px;
  z-index: 3;
}
.cupcake-enemy .arm.left {
  left: 0;
  top: 32px;
  transform: rotate(20deg);
  transform-origin: top center;
}
.cupcake-enemy .arm.right {
  right: 0;
  top: 28px;
  width: 7px; height: 22px;
  transform: rotate(-35deg);
  transform-origin: top center;
}

/* Candle — held in the right arm (positioned relative to the arm) */
.cupcake-enemy .arm.right .candle {
  position: absolute;
  top: -14px;
  left: -2px;
  width: 5px; height: 18px;
  background: linear-gradient(90deg, #fff, #f0f0f0 50%, #ddd);
  border: 1.5px solid #444;
  border-bottom: none;
  border-radius: 1px 1px 0 0;
  transform: rotate(35deg);
  transform-origin: bottom center;
}
.cupcake-enemy .arm.right .flame {
  position: absolute;
  top: -28px;
  left: 0;
  width: 10px; height: 14px;
  background: radial-gradient(ellipse at 50% 80%, #ffd86b 0%, #ff8a3d 60%, transparent 100%);
  border-radius: 50% 50% 50% 50% / 70% 70% 30% 30%;
  animation: flame-flicker 0.32s infinite alternate;
  box-shadow: 0 0 8px #ffd86b, 0 0 16px rgba(255, 138, 61, 0.6);
  transform-origin: bottom center;
  transform: rotate(35deg);
}
@keyframes flame-flicker {
  from { transform: rotate(35deg) scaleY(1)    skewX(-2deg); }
  to   { transform: rotate(35deg) scaleY(1.18) skewX(2deg); }
}

/* =========================================================
   v1.3 — Speed/pause control panel
   ========================================================= */
#speed-panel {
  position: absolute;
  top: max(env(safe-area-inset-top), 16px);
  margin-top: 60px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  align-items: center;
  background: rgba(0,0,0,0.55);
  border: 2px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  padding: 5px 8px;
  z-index: 11;
  backdrop-filter: blur(4px);
  pointer-events: auto;
}
.speed-btn {
  background: rgba(255, 138, 61, 0.92);
  color: #2d1810;
  border: 2px solid rgba(0,0,0,0.4);
  border-radius: 999px;
  width: 36px; height: 36px;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  pointer-events: auto;
  transition: transform 0.1s, background 0.15s;
}
.speed-btn:active { transform: scale(0.92); }
.speed-btn.disabled { opacity: 0.4; cursor: default; }
.speed-readout {
  color: #fff; font-weight: 800; font-size: 14px;
  min-width: 40px; text-align: center;
  letter-spacing: 1px;
}
.speed-readout.paused { color: #ffd86b; }
