/* ==========================================================
   Learning Quest — kid-friendly PWA styles
   ========================================================== */
:root {
  --sky1: #bfe3ff;
  --sky2: #eef6ff;
  --forest: #3fa34d;
  --mountain: #7c5cff;
  --lab: #00b8a9;
  --robot: #1b2a5e;
  --neon: #39e6ff;
  --star: #ffc93c;
  --ink: #2b2350;
  --card: #ffffff;
  --shadow: 0 6px 0 rgba(43, 35, 80, 0.12);
  --radius: 22px;
  --tap: 56px;
  font-size: 17px;
}

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

html, body { height: 100%; margin: 0; }

body {
  font-family: 'Nunito', 'Segoe UI', 'Comic Sans MS', system-ui, sans-serif;
  font-weight: 700;
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky1), var(--sky2) 60%);
  min-height: 100dvh;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

h1, h2, h3, .world-name, #brand, .gate-q {
  font-family: 'Baloo 2', 'Nunito', 'Comic Sans MS', system-ui, sans-serif;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

/* ------- themed backgrounds ------- */
body[data-theme="forest"]   { background: linear-gradient(180deg, #d3f5d9, #eefcf0 60%); }
body[data-theme="mountain"] { background: linear-gradient(180deg, #e4dcff, #f5f1ff 60%); }
body[data-theme="lab"]      { background: linear-gradient(180deg, #c8f5f0, #eefcfb 60%); }
body[data-theme="robot"]    { background: linear-gradient(180deg, #16224d, #24356e 70%); color: #eaf6ff; }
body[data-theme="robot"] .chip,
body[data-theme="robot"] #stage-map .tier-label { color: #eaf6ff; }

/* ==================== top bar ==================== */
#topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
}

#brand {
  font-size: 1.25rem; font-weight: 800; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}

.top-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

#star-count {
  background: var(--card);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 1.05rem;
  box-shadow: var(--shadow);
  min-height: 40px;
  display: flex;
  align-items: center;
  white-space: nowrap;
}

body[data-theme="robot"] #star-count { background: #2c3f7d; }

.icon-btn {
  min-width: var(--tap);
  min-height: var(--tap);
  width: var(--tap);
  height: var(--tap);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 1.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s;
}

body[data-theme="robot"] .icon-btn { background: #2c3f7d; }

.icon-btn:active { transform: scale(0.92); }

#btn-sound.muted { opacity: 0.55; }

/* ==================== screens ==================== */
main { padding: 6px 14px calc(24px + env(safe-area-inset-bottom)); max-width: 900px; margin: 0 auto; }

.screen { display: none; animation: screenIn 0.28s ease; }
.screen.active { display: block; }

@keyframes screenIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* ==================== home ==================== */
.hero { text-align: center; margin-top: 4px; }

.hero-mascots { font-size: 2.4rem; display: flex; justify-content: center; gap: 14px; }
.hero-mascots span { display: inline-block; animation: bob 2.4s ease-in-out infinite; }
.hero-mascots span:nth-child(2) { animation-delay: 0.3s; }
.hero-mascots span:nth-child(3) { animation-delay: 0.6s; }
.hero-mascots span:nth-child(4) { animation-delay: 0.9s; }

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.hero h1 { margin: 6px 0 0; font-size: 2.2rem; }
.hero-sub { margin: 4px 0 14px; opacity: 0.75; }

.difficulty { display: flex; gap: 12px; justify-content: center; margin-bottom: 18px; }

.diff-btn {
  min-height: var(--tap);
  border-radius: 999px;
  padding: 10px 20px;
  background: var(--card);
  box-shadow: var(--shadow);
  font-weight: 800;
  font-size: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
  border: 3px solid transparent;
}

.diff-btn small { font-weight: 700; opacity: 0.6; font-size: 0.75rem; }

.diff-btn.selected { border-color: var(--star); background: #fff7df; }

#world-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.world-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 150px;
  transition: transform 0.15s;
  border-bottom: 8px solid transparent;
}

.world-card:active { transform: scale(0.96); }

.world-card[data-world="forest"]   { border-bottom-color: var(--forest); }
.world-card[data-world="mountain"] { border-bottom-color: var(--mountain); }
.world-card[data-world="lab"]      { border-bottom-color: var(--lab); }
.world-card[data-world="robot"]    { border-bottom-color: var(--neon); background: #223368; color: #eaf6ff; }

.world-scene { font-size: 2.6rem; }
.world-name { font-size: 1.35rem; font-weight: 800; }
.world-tag { font-size: 0.85rem; opacity: 0.65; }

.world-progress { width: 100%; display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.world-progress .bar {
  flex: 1; height: 12px; border-radius: 999px; background: rgba(43,35,80,0.12); overflow: hidden;
}
.world-card[data-world="robot"] .bar { background: rgba(255,255,255,0.2); }
.world-progress .fill {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--star), #ffb347);
  border-radius: 999px; transition: width 0.5s;
}
.world-progress .pct { font-size: 0.8rem; opacity: 0.7; }

.home-footer { display: flex; gap: 14px; justify-content: center; margin-top: 20px; }

.pill-btn {
  min-height: var(--tap);
  border-radius: 999px;
  padding: 12px 24px;
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 1.1rem;
  font-weight: 800;
  transition: transform 0.12s;
}
.pill-btn:active { transform: scale(0.94); }
.pill-btn.primary { background: var(--star); }
.pill-btn.danger { background: #ffd9d9; color: #a33; }

/* ==================== world / stage map ==================== */
.world-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 0 10px;
}

.world-title { display: flex; align-items: center; gap: 10px; }
.world-title h2 { margin: 0; font-size: 1.5rem; }
.big-mascot { font-size: 2.2rem; animation: bob 2.4s ease-in-out infinite; display: inline-block; }

.chip {
  background: rgba(255,255,255,0.7);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 800;
}
body[data-theme="robot"] .chip { background: rgba(255,255,255,0.12); }

#stage-map { padding-bottom: 30px; }

.tier-label {
  text-align: center;
  font-family: 'Baloo 2', sans-serif;
  font-size: 1.15rem;
  margin: 18px 0 8px;
  opacity: 0.85;
}

.stage-row { display: flex; justify-content: center; gap: 18px; margin-bottom: 16px; }
.stage-row.rev { flex-direction: row-reverse; }

.stage-bubble {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 1.5rem;
  position: relative;
  transition: transform 0.15s;
  border: 4px solid rgba(43,35,80,0.08);
}
body[data-theme="robot"] .stage-bubble { background: #2c3f7d; border-color: rgba(57,230,255,0.25); }

.stage-bubble:active { transform: scale(0.92); }
.stage-bubble .s-num {
  position: absolute; top: -6px; left: -6px;
  background: var(--star); color: var(--ink);
  font-size: 0.75rem; font-weight: 800;
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 0 rgba(43,35,80,0.15);
}
.stage-bubble .s-stars { font-size: 0.7rem; letter-spacing: -1px; }

.stage-bubble.locked { filter: grayscale(1); opacity: 0.5; }
.stage-bubble.current { border-color: var(--star); animation: pulse 1.6s infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: var(--shadow), 0 0 0 0 rgba(255,201,60,0.55); }
  50% { box-shadow: var(--shadow), 0 0 0 14px rgba(255,201,60,0); }
}

/* ==================== game screen ==================== */
.game-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 8px;
}

.game-title { display: flex; align-items: center; gap: 8px; flex: 1; font-weight: 800; font-size: 1.05rem; }
#game-mascot { font-size: 1.7rem; }

#round-dots { display: flex; gap: 6px; }
#round-dots .dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: rgba(43,35,80,0.15);
}
body[data-theme="robot"] #round-dots .dot { background: rgba(255,255,255,0.2); }
#round-dots .dot.done { background: var(--star); }
#round-dots .dot.now { background: var(--star); animation: pulse 1.6s infinite; }

.read-btn {
  min-width: var(--tap);
  min-height: var(--tap);
  border-radius: 50%;
  background: var(--star);
  box-shadow: var(--shadow);
  font-size: 1.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s;
}
.read-btn:active { transform: scale(0.9); }
.read-btn.reading { animation: pulse 1.2s infinite; }

#prompt-bar {
  background: rgba(255,255,255,0.85);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px;
  font-size: 1.3rem;
  font-weight: 800;
  text-align: center;
  min-height: 58px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0 7px;
  line-height: 1.5;
}
body[data-theme="robot"] #prompt-bar { background: rgba(255,255,255,0.1); }

#prompt-bar .w { border-radius: 8px; padding: 0 3px; transition: background 0.1s; }
#prompt-bar .w.lit { background: var(--star); color: var(--ink); }
#prompt-bar .p-emoji { font-size: 1.7rem; }

#game-area {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  min-height: 55vh;
}
#game-area.locked { pointer-events: none; }

/* toast (encouragement) */
#toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  padding: 12px 22px;
  font-size: 1.05rem;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 60;
  max-width: 90vw;
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --------- shared game pieces --------- */
.big-emoji { font-size: clamp(4rem, 18vw, 7rem); line-height: 1; }

.choices {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  width: 100%;
}

.choice-btn {
  min-width: 110px;
  min-height: 90px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 1.2rem;
  font-weight: 800;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.12s;
  color: var(--ink);
}
.choice-btn:active { transform: scale(0.93); }
.choice-btn .c-emoji { font-size: 2.6rem; }
.choice-btn.big .c-emoji { font-size: 3.4rem; }
.choice-btn.right { background: #d9f7dc; border: 3px solid var(--forest); }
.choice-btn.hinted { animation: pulse 1.2s infinite; border: 3px solid var(--star); }

.shake { animation: shake 0.4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px) rotate(-2deg); }
  40% { transform: translateX(9px) rotate(2deg); }
  60% { transform: translateX(-7px); }
  80% { transform: translateX(7px); }
}

.pop { animation: popIn 0.35s; }
@keyframes popIn {
  0% { transform: scale(0.4); }
  70% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* --------- spell it --------- */
.spell-slots { display: flex; gap: 10px; justify-content: center; }
.spell-slot {
  width: 62px; height: 70px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  border-bottom: 5px dashed rgba(43,35,80,0.25);
  font-family: 'Baloo 2', sans-serif;
  font-size: 2.2rem;
  display: flex; align-items: center; justify-content: center;
}
.spell-slot.filled { border-bottom-style: solid; border-bottom-color: var(--forest); background: #e8f8ea; }

.letter-bank { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; max-width: 480px; }
.letter-tile {
  width: var(--tap); height: var(--tap);
  border-radius: 16px;
  background: var(--forest);
  color: #fff;
  font-family: 'Baloo 2', sans-serif;
  font-size: 1.8rem;
  box-shadow: 0 5px 0 #2c7a38;
  transition: transform 0.1s;
}
.letter-tile:active { transform: translateY(3px); }
.letter-tile.used { visibility: hidden; }
.letter-tile.hinted { animation: pulse 1.2s infinite; }

/* --------- habitat match --------- */
.match-board { display: flex; gap: clamp(20px, 10vw, 90px); justify-content: center; width: 100%; }
.match-col { display: flex; flex-direction: column; gap: 16px; }
.match-card {
  width: clamp(96px, 26vw, 140px);
  height: clamp(96px, 26vw, 140px);
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: clamp(3rem, 12vw, 4.6rem);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s;
  border: 4px solid transparent;
}
.match-card:active { transform: scale(0.93); }
.match-card.selected { border-color: var(--lab); background: #e2fbf8; transform: scale(1.06); }
.match-card.matched { opacity: 0.35; filter: grayscale(0.6); pointer-events: none; transform: scale(0.9); }

/* --------- sink or float --------- */
.tank-wrap { position: relative; width: min(340px, 88vw); }
.tank {
  width: 100%; height: 240px;
  border-radius: 20px;
  border: 5px solid rgba(43,35,80,0.2);
  overflow: hidden;
  position: relative;
  background: linear-gradient(180deg, #f2fbff 0%, #f2fbff 35%, #7fd4ff 35%, #4db4f0 100%);
}
.tank .wave {
  position: absolute; left: 0; right: 0; top: calc(35% - 8px);
  font-size: 1rem; letter-spacing: 6px; color: rgba(255,255,255,0.8);
  text-align: center;
}
.tank .obj {
  position: absolute;
  left: 50%;
  top: 6%;
  transform: translateX(-50%);
  font-size: 4rem;
  transition: top 1.4s cubic-bezier(0.4, 0, 0.6, 1);
}
.tank .obj.floaty { top: 24%; animation: floatBob 2s ease-in-out infinite; }
.tank .obj.sunk { top: 72%; }

@keyframes floatBob {
  0%, 100% { transform: translateX(-50%) translateY(0) rotate(-4deg); }
  50% { transform: translateX(-50%) translateY(-8px) rotate(4deg); }
}

.sf-buttons { display: flex; gap: 18px; }
.sf-btn {
  min-width: 130px; min-height: 84px;
  border-radius: var(--radius);
  font-size: 1.25rem; font-weight: 800;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--ink);
}
.sf-btn .c-emoji { font-size: 2.2rem; }
.sf-btn.sink { background: #cfe3ff; }
.sf-btn.float { background: #ffe9c9; }
.sf-btn:active { transform: scale(0.93); }

/* --------- weather (big scene) --------- */
.scene-emoji {
  font-size: clamp(5rem, 24vw, 8.5rem);
  line-height: 1;
  animation: bob 3s ease-in-out infinite;
  display: inline-block;
}

/* --------- simon --------- */
.simon-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(110px, 150px));
  gap: 16px;
}
.simon-pad {
  aspect-ratio: 1;
  border-radius: 26px;
  font-size: 3rem;
  box-shadow: var(--shadow);
  opacity: 0.75;
  transition: transform 0.1s, opacity 0.1s, box-shadow 0.1s;
}
.simon-pad:active { transform: scale(0.93); }
.simon-pad.flash { opacity: 1; transform: scale(1.08); box-shadow: 0 0 30px 6px rgba(255,255,255,0.55); }
.simon-pad[data-p="0"] { background: #39e6ff; }
.simon-pad[data-p="1"] { background: #ff7ad9; }
.simon-pad[data-p="2"] { background: #ffc93c; }
.simon-pad[data-p="3"] { background: #6ef78b; }

.simon-status { font-size: 1.1rem; font-weight: 800; min-height: 1.5em; }

/* --------- debug it --------- */
.prog-strip { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 520px; }
.prog-chip {
  width: var(--tap); height: var(--tap);
  border-radius: 16px;
  background: #2c3f7d;
  color: #fff;
  font-size: 1.6rem;
  box-shadow: 0 5px 0 #14204a;
  border: 3px solid transparent;
  transition: transform 0.1s;
}
.prog-chip:active { transform: translateY(3px); }
.prog-chip.running { border-color: var(--neon); }
.prog-chip.fixed { background: var(--forest); box-shadow: 0 5px 0 #2c7a38; }
.prog-chip.hinted { animation: pulse 1.2s infinite; border-color: var(--star); }

/* --------- maze --------- */
.maze-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }

.maze-board {
  position: relative;
  display: grid;
  background: #101c42;
  border-radius: 18px;
  padding: 6px;
  box-shadow: 0 0 0 4px rgba(57,230,255,0.35), 0 10px 30px rgba(0,0,0,0.4);
  touch-action: none;
}
.maze-cell {
  width: var(--cell, 52px);
  height: var(--cell, 52px);
  position: relative;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--cell, 52px) * 0.62);
}
.maze-cell.visited::after {
  content: '';
  position: absolute;
  width: 22%; height: 22%;
  border-radius: 50%;
  background: rgba(57,230,255,0.25);
}
.maze-cell.wall-t { border-top: 4px solid var(--neon); }
.maze-cell.wall-l { border-left: 4px solid var(--neon); }
.maze-cell.wall-b { border-bottom: 4px solid var(--neon); }
.maze-cell.wall-r { border-right: 4px solid var(--neon); }
.maze-cell.goal { animation: goalGlow 1.6s infinite; border-radius: 12px; }

@keyframes goalGlow {
  0%, 100% { background: rgba(255,201,60,0.15); }
  50% { background: rgba(255,201,60,0.4); }
}

#maze-bot {
  position: absolute;
  width: var(--cell, 52px);
  height: var(--cell, 52px);
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--cell, 52px) * 0.72);
  transition: transform 0.18s ease;
  z-index: 5;
  will-change: transform;
}
#maze-bot .bot-inner { display: inline-block; }
#maze-bot .bot-inner.bump { animation: shake 0.35s; }
#maze-bot .bot-inner.dance { animation: dance 0.8s ease-in-out 2; }

@keyframes dance {
  0%, 100% { transform: rotate(0) scale(1); }
  25% { transform: rotate(-15deg) scale(1.2); }
  75% { transform: rotate(15deg) scale(1.2); }
}

.maze-hud { display: flex; gap: 12px; align-items: center; font-weight: 800; }
body[data-theme="robot"] .maze-hud { color: #eaf6ff; }

.hint-btn {
  min-height: 48px;
  border-radius: 999px;
  padding: 8px 18px;
  background: rgba(255,201,60,0.9);
  color: var(--ink);
  font-weight: 800;
  box-shadow: var(--shadow);
}

/* D-pad controller — bottom of screen */
.dpad {
  position: sticky;
  bottom: calc(10px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-areas: ". up ." "left mid right" ". down .";
  gap: 8px;
  margin-top: 6px;
  z-index: 40;
}
.dpad button {
  width: 68px; height: 68px;
  border-radius: 20px;
  background: linear-gradient(180deg, #3a51a5, #24356e);
  color: var(--neon);
  font-size: 2rem;
  box-shadow: 0 6px 0 #101c42, 0 0 14px rgba(57,230,255,0.35);
  transition: transform 0.08s;
}
.dpad button:active { transform: translateY(4px); box-shadow: 0 2px 0 #101c42; }
.dpad button.hinted { animation: pulse 1s infinite; color: var(--star); }
.dpad .d-up { grid-area: up; }
.dpad .d-down { grid-area: down; }
.dpad .d-left { grid-area: left; }
.dpad .d-right { grid-area: right; }
.dpad .d-mid {
  grid-area: mid;
  background: none;
  box-shadow: none;
  font-size: 1.7rem;
  pointer-events: none;
}

/* ==================== celebration ==================== */
.celebrate-card {
  max-width: 460px;
  margin: 6vh auto 0;
  background: var(--card);
  color: var(--ink);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 28px 22px;
  text-align: center;
}
.cel-mascot { font-size: 4.5rem; animation: bob 1.8s ease-in-out infinite; }
.celebrate-card h2 { margin: 6px 0; font-size: 2rem; }
.cel-stars { font-size: 3.2rem; display: flex; justify-content: center; gap: 10px; min-height: 70px; }
.cel-star { opacity: 0.18; filter: grayscale(1); transform: scale(0.7); transition: all 0.3s; }
.cel-star.earned { opacity: 1; filter: none; animation: popIn 0.45s; transform: scale(1); }
#cel-msg { font-size: 1.1rem; }
.cel-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }

/* ==================== rewards ==================== */
.rewards-hint { text-align: center; opacity: 0.75; }

#avatar-shelf, #badge-shelf {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  margin-bottom: 14px;
}

.avatar-card {
  width: 108px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 8px;
  text-align: center;
  font-size: 2.6rem;
  border: 4px solid transparent;
  color: var(--ink);
}
.avatar-card small { display: block; font-size: 0.75rem; font-weight: 800; margin-top: 4px; }
.avatar-card.locked { filter: grayscale(1); opacity: 0.5; }
.avatar-card.selected { border-color: var(--star); background: #fff7df; }
.avatar-card:active { transform: scale(0.94); }

.badges-title { text-align: center; margin: 10px 0 4px; }
.badge-card {
  width: 130px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 8px;
  text-align: center;
  font-size: 2.2rem;
}
.badge-card small { display: block; font-size: 0.72rem; font-weight: 800; margin-top: 2px; }
.badge-card.locked { filter: grayscale(1); opacity: 0.45; }

/* ==================== parent ==================== */
.parent-card {
  max-width: 480px;
  margin: 20px auto;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  text-align: center;
}
.gate-q { font-size: 2rem; margin: 8px 0; }
#gate-input {
  font: inherit;
  font-size: 1.5rem;
  text-align: center;
  width: 120px;
  min-height: var(--tap);
  border-radius: 14px;
  border: 3px solid rgba(43,35,80,0.2);
  margin-bottom: 12px;
}
#gate-msg { color: #a33; font-weight: 800; min-height: 1.4em; }

#parent-table { text-align: left; margin-bottom: 16px; }

.voice-hint { font-size: 0.85rem; opacity: 0.7; margin: 4px 0 10px; }
#voice-row { display: flex; gap: 10px; justify-content: center; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
#voice-select {
  font: inherit;
  font-size: 0.95rem;
  min-height: var(--tap);
  max-width: 240px;
  border-radius: 14px;
  border: 3px solid rgba(43,35,80,0.2);
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}
.p-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 6px;
  border-bottom: 2px dashed rgba(43,35,80,0.12);
  gap: 8px;
}
.p-row .p-world { font-weight: 800; }
.p-row .p-nums { font-size: 0.9rem; opacity: 0.8; text-align: right; }

/* ==================== confetti ==================== */
#confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 100;
}
.confetti {
  position: absolute;
  width: 12px; height: 12px;
  border-radius: 3px;
  animation: confettiFly 1.1s ease-out forwards;
}
@keyframes confettiFly {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; }
}

/* ==================== responsive ==================== */
@media (max-width: 480px) {
  :root { font-size: 15px; }
  #brand { display: none; }
  #topbar { gap: 8px; }
  #topbar .top-right { flex: 1; justify-content: flex-end; }
  .stage-bubble { width: 74px; height: 74px; }
  .stage-row { gap: 12px; }
  .dpad button { width: 62px; height: 62px; }
}

@media (min-width: 700px) {
  .maze-cell, #maze-bot { --cell: 60px; }
}

/* ==================== reduced motion ==================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  #maze-bot { transition: none; }
  .confetti { display: none; }
}
