/* ==========================================================================
   Oppimisseikkailu — toddler learning PWA
   Theme colors come from CSS custom properties set by js/themes.js
   ========================================================================== */

/* Baloo 2 (OFL license) — bundled so the app stays offline-capable */
@font-face {
  font-family: 'Baloo 2';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('../assets/fonts/baloo2-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Baloo 2';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('../assets/fonts/baloo2-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg1: #a5d8f5;
  --bg2: #e3f3fd;
  --accent: #4aa3df;
  --accent2: #8f6fd8;
  --card: #ffffff;
  --card-text: #2b3a55;
  --good: #47c47e;
  --star: #ffcf40;
  --shadow: 0 6px 0 rgba(43, 58, 85, 0.15);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Baloo 2", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  font-weight: 500;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; /* no double-tap zoom — critical for toddlers */
}

body {
  background: linear-gradient(180deg, var(--bg1), var(--bg2));
  color: var(--card-text);
}

button {
  font-family: inherit;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}

.hidden { display: none !important; }

/* ---------- backdrop scene (theme SVG) ---------- */
#scene-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
#scene-backdrop svg { width: 100%; height: 100%; display: block; }

/* ---------- weather: gently falling snow ---------- */
#weather {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
#weather span {
  position: absolute;
  top: -20px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffffff, #e8f4fc);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
  animation: snowfall linear infinite;
}
@keyframes snowfall {
  0% { transform: translate(0, -4vh); }
  25% { transform: translate(18px, 26vh); }
  50% { transform: translate(-14px, 52vh); }
  75% { transform: translate(14px, 78vh); }
  100% { transform: translate(-8px, 108vh); }
}

/* ---------- screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: none;
  flex-direction: column;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
           max(10px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  opacity: 0;
  transition: opacity 0.25s ease;
}
.screen.active { display: flex; opacity: 1; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex: 0 0 auto;
  min-height: 64px;
}

.screen-title {
  font-size: clamp(22px, 4vw, 34px);
  margin: 0;
  color: var(--card-text);
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.6);
}

.chip {
  min-width: 64px;
  min-height: 64px;
  border-radius: 22px;
  background: var(--card);
  color: var(--card-text);
  font-size: 26px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.1s ease;
}
.chip:active { transform: scale(0.92); }
.chip-ghost { visibility: hidden; }
.chip svg { display: block; }

/* parent-gate progress ring (fills during long press) */
.gate-ring {
  position: absolute;
  inset: -4px;
  border-radius: 26px;
  border: 4px solid transparent;
  pointer-events: none;
}
.chip-gear:active { transform: none; } /* must not shrink away under the held finger */
.chip-gear { touch-action: none; -webkit-touch-callout: none; }
.chip-gear.holding { background: #eef4fb; }
.chip-gear.holding .gate-ring { border-color: var(--accent); animation: gate-pulse 2s linear; }
@keyframes gate-pulse {
  from { opacity: 0.15; transform: rotate(0deg); }
  to { opacity: 1; transform: rotate(360deg); }
}
.chip-gear.holding .gate-ring { border-top-color: var(--accent2); }

/* ---------- star meter ---------- */
.star-meter {
  flex: 1;
  max-width: 420px;
  height: 44px;
  margin: 0 8px;
  background: rgba(255, 255, 255, 0.65);
  border-radius: 22px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 2px 6px rgba(43, 58, 85, 0.15);
}
.star-meter-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(90deg, var(--star), #ffb340);
  border-radius: 22px;
  transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.star-meter-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 26px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.2));
}
.star-meter-count {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-weight: bold;
  font-size: 20px;
}
.star-meter.bump .star-meter-icon { animation: star-bump 0.5s ease; }
@keyframes star-bump {
  30% { transform: translateY(-50%) scale(1.6) rotate(-15deg); }
  100% { transform: translateY(-50%) scale(1); }
}

/* ---------- home ---------- */
.home-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex: 0 0 auto;
  padding: 4px 0;
}
.home-hero-char { width: clamp(90px, 16vh, 150px); cursor: pointer; transition: transform 0.12s ease; }
.home-hero-char:active { transform: scale(0.92); }
.home-hero-char svg { width: 100%; height: auto; display: block; animation: float 3s ease-in-out infinite; }
.home-hero-bubble {
  background: var(--card);
  border-radius: 24px;
  padding: 14px 22px;
  font-size: clamp(18px, 3vw, 26px);
  font-weight: bold;
  box-shadow: var(--shadow);
  position: relative;
}
.home-hero-bubble::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  border: 10px solid transparent;
  border-right-color: var(--card);
  transform: translateY(-50%);
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.game-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(10px, 2vw, 18px);
  align-content: center;
  padding: 8px 2px calc(8px + env(safe-area-inset-bottom));
  overflow-y: auto;
}
@media (max-aspect-ratio: 4/3) { .game-grid { grid-template-columns: repeat(2, 1fr); } }

.game-card {
  min-height: clamp(120px, 22vh, 190px);
  border-radius: 28px;
  background: var(--card);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: clamp(16px, 2.4vw, 24px);
  font-weight: bold;
  color: var(--card-text);
  border-bottom: 6px solid rgba(43, 58, 85, 0.12);
  transition: transform 0.12s ease;
}
.game-card:active { transform: scale(0.94); }
.game-card .game-icon { font-size: clamp(40px, 8vh, 64px); line-height: 1; }
.game-card .game-icon svg { width: clamp(48px, 9vh, 72px); height: auto; }
.game-card.card-collection { background: linear-gradient(160deg, var(--accent2), var(--accent)); color: #fff; }

/* ---------- profile picker ---------- */
.profiles-title {
  text-align: center;
  font-size: clamp(30px, 6vw, 52px);
  margin: clamp(10px, 4vh, 40px) 0 0;
}
.profile-cards {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 4vw, 40px);
  flex-wrap: wrap;
}
.profile-card {
  width: clamp(160px, 24vw, 250px);
  border-radius: 32px;
  background: var(--card);
  box-shadow: var(--shadow);
  border-bottom: 6px solid rgba(43, 58, 85, 0.12);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-size: clamp(20px, 3vw, 28px);
  font-weight: bold;
  color: var(--card-text);
  border: 5px solid transparent;
  transition: transform 0.12s ease;
}
.profile-card:active { transform: scale(0.94); }
.profile-card.selected { border-color: var(--good); }
.profile-card .profile-avatar { width: clamp(90px, 14vw, 140px); }
.profile-card .profile-avatar svg { width: 100%; height: auto; }
.profile-card .profile-stars { font-size: clamp(15px, 2vw, 20px); color: #7b88a3; }

.topbar-group { display: flex; gap: 10px; }
#btn-profile svg { width: 44px; height: 44px; }

.settings-subtitle { margin: 4px 0 0; font-size: 18px; color: #7b88a3; }
.setting-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
}
.setting-name-row .mini-avatar { width: 40px; flex: 0 0 auto; }
.setting-name-row .mini-avatar svg { width: 100%; height: auto; display: block; }
.setting-name-row input {
  flex: 1;
  font-size: 18px;
  font-family: inherit;
  padding: 8px 12px;
  border-radius: 12px;
  border: 2px solid #cfd8e8;
  min-width: 0;
}

/* ---------- theme picker ---------- */
.theme-cards {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 3vw, 30px);
  flex-wrap: wrap;
  overflow-y: auto;
}
.theme-card {
  width: clamp(180px, 26vw, 280px);
  border-radius: 30px;
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: bold;
  border: 5px solid transparent;
  transition: transform 0.12s ease;
}
.theme-card:active { transform: scale(0.95); }
.theme-card.selected { border-color: var(--good); }
.theme-card .theme-art { width: 100%; }
.theme-card .theme-art svg { width: 100%; height: auto; display: block; }
.theme-card.locked { filter: grayscale(0.6); opacity: 0.75; }
.theme-card.locked .coming-soon {
  font-size: 15px;
  color: var(--accent2);
  background: rgba(143, 111, 216, 0.15);
  border-radius: 12px;
  padding: 4px 12px;
}

/* ---------- game stage ---------- */
.round-dots { display: flex; gap: 10px; }
.round-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 1px 3px rgba(43, 58, 85, 0.25);
}
.round-dot.done { background: var(--star); }
.round-dot.current { outline: 3px solid var(--accent); outline-offset: 2px; }

.game-prompt {
  flex: 0 0 auto;
  text-align: center;
  font-size: clamp(24px, 4.5vw, 40px);
  font-weight: bold;
  padding: 6px 12px;
  min-height: 1.4em;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.65);
}
.game-prompt .en-word { color: var(--accent2); }

.game-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: calc(6px + env(safe-area-inset-bottom));
  overflow: hidden;
}

.choice-grid {
  display: grid;
  gap: clamp(12px, 2.5vw, 26px);
  width: 100%;
  max-width: 1080px;
  align-items: stretch;
  justify-items: stretch;
}

.choice {
  min-height: clamp(120px, 26vh, 220px);
  min-width: 120px;
  border-radius: 30px;
  background: var(--card);
  box-shadow: var(--shadow);
  border-bottom: 6px solid rgba(43, 58, 85, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: clamp(48px, 12vh, 96px);
  font-weight: bold;
  color: var(--card-text);
  transition: transform 0.12s ease;
  position: relative;
  overflow: hidden;
}
.choice:active { transform: scale(0.94); }
.choice svg { width: clamp(70px, 16vh, 130px); height: auto; display: block; }
.choice .choice-label { font-size: clamp(15px, 2.2vw, 22px); color: #7b88a3; }
.choice-flags {
  display: flex;
  gap: 12px;
  margin-top: 4px;
  padding-bottom: 2px;
}
.flag-btn {
  width: clamp(52px, 7vh, 68px);
  border-radius: 10px;
  display: inline-flex;
  transition: transform 0.1s ease;
  box-shadow: 0 3px 0 rgba(43, 58, 85, 0.18);
}
.flag-btn:active { transform: scale(0.88); }
.flag-btn svg { width: 100%; height: auto; display: block; }
.choice.correct-pop { animation: correct-pop 0.55s ease; background: #e9fbf1; border-bottom-color: var(--good); }
.choice.wrong-wiggle { animation: wrong-wiggle 0.5s ease; }
.choice.faded { opacity: 0.35; pointer-events: none; }
@keyframes correct-pop {
  30% { transform: scale(1.12); }
  60% { transform: scale(0.96); }
  100% { transform: scale(1); }
}
@keyframes wrong-wiggle {
  20% { transform: translateX(-10px) rotate(-3deg); }
  40% { transform: translateX(10px) rotate(3deg); }
  60% { transform: translateX(-7px); }
  80% { transform: translateX(7px); }
}

/* tap-to-count field: items scattered for tapping */
.count-field {
  width: 100%;
  max-width: 1080px;
  height: 100%;
  position: relative;
}
.count-item {
  position: absolute;
  width: clamp(84px, 15vh, 130px);
  height: clamp(84px, 15vh, 130px);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease;
}
.count-item svg { width: 78%; height: 78%; }
.count-item:active { transform: scale(0.92); }
.count-item.counted {
  background: #e9fbf1;
  outline: 4px solid var(--good);
  pointer-events: none;
  animation: correct-pop 0.5s ease;
}
.count-item .count-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--good);
  color: #fff;
  font-size: 22px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* memory game: flipping cards */
.mem-grid {
  display: grid;
  gap: clamp(10px, 2vw, 20px);
  width: 100%;
  max-width: 980px;
  align-content: center;
  height: 100%;
  padding: 4px;
}
.mem-card {
  position: relative;
  min-height: clamp(88px, 19vh, 160px);
  background: transparent;
  perspective: 700px;
  border: none;
  padding: 0;
}
.mem-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.mem-card.flipped .mem-inner,
.mem-card.matched .mem-inner { transform: rotateY(180deg); }
.mem-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}
.mem-front {
  background: linear-gradient(160deg, var(--accent), var(--accent2));
  color: rgba(255, 255, 255, 0.9);
  font-size: clamp(34px, 8vh, 60px);
  font-weight: bold;
}
.mem-back {
  background: var(--card);
  transform: rotateY(180deg);
}
.mem-back svg { width: 68%; height: 68%; }
.mem-back .mem-emoji { font-size: clamp(34px, 9vh, 68px); line-height: 1.1; }
.mem-card.matched .mem-back { background: #e9fbf1; outline: 4px solid var(--good); }
.mem-card.matched { animation: correct-pop 0.5s ease; }

/* addition layout */
.addition-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2vw, 22px);
  flex-wrap: wrap;
}
.addition-group {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.addition-group svg { width: clamp(44px, 9vh, 72px); height: auto; }
.addition-op { font-size: clamp(40px, 9vh, 72px); font-weight: bold; }

/* ---------- celebration ---------- */
.screen-celebrate { align-items: center; justify-content: center; }
.celebrate-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 2;
}
.celebrate-title {
  font-size: clamp(34px, 7vw, 60px);
  margin: 6px 0;
  color: var(--card-text);
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.7);
  animation: title-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes title-pop { from { transform: scale(0.3); opacity: 0; } }
.celebrate-stars { display: flex; gap: 10px; font-size: clamp(38px, 8vh, 64px); min-height: 1em; }
.celebrate-stars .cstar { animation: cstar-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) backwards; }
.celebrate-stars .cstar.dim { filter: grayscale(1); opacity: 0.35; }
@keyframes cstar-in { from { transform: scale(0) rotate(-180deg); } }
.celebrate-chars { display: flex; align-items: flex-end; gap: 14px; }
.celebrate-chars > div { width: clamp(80px, 16vh, 140px); }
.celebrate-chars svg { width: 100%; height: auto; }
.celebrate-chars > div { animation: dance 0.9s ease-in-out infinite; }
.celebrate-chars > div:nth-child(2n) { animation-delay: 0.22s; }
.celebrate-chars > div:nth-child(3n) { animation-delay: 0.45s; }
@keyframes dance {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-14px) rotate(4deg); }
}
.celebrate-buttons { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }

.big-btn {
  min-height: 76px;
  padding: 14px 34px;
  border-radius: 26px;
  font-size: clamp(20px, 3.4vw, 30px);
  font-weight: bold;
  background: var(--good);
  color: #fff;
  box-shadow: 0 6px 0 rgba(43, 58, 85, 0.25);
  transition: transform 0.12s ease;
}
.big-btn:active { transform: scale(0.94) translateY(3px); box-shadow: 0 3px 0 rgba(43, 58, 85, 0.25); }
.big-btn-alt { background: var(--accent); }
.big-btn-danger { background: #e2574c; }
.big-btn-huge { font-size: clamp(26px, 5vw, 40px); min-height: 96px; padding: 18px 48px; }

/* confetti */
.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti i {
  position: absolute;
  top: -20px;
  width: 14px;
  height: 20px;
  border-radius: 4px;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  to { transform: translateY(110vh) rotate(720deg); }
}

/* ---------- unlock ceremony ---------- */
.screen-unlock { align-items: center; justify-content: center; }
.unlock-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.unlock-gift { width: clamp(160px, 30vh, 260px); }
.unlock-gift svg { width: 100%; height: auto; }
.unlock-gift.wiggling { animation: gift-wiggle 0.8s ease-in-out infinite; cursor: pointer; }
@keyframes gift-wiggle {
  0%, 100% { transform: rotate(-4deg) scale(1); }
  50% { transform: rotate(4deg) scale(1.05); }
}
.unlock-gift.opening { animation: gift-open 0.6s ease forwards; }
@keyframes gift-open {
  40% { transform: scale(1.25); }
  100% { transform: scale(0); opacity: 0; }
}
.unlock-reveal { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.unlock-item {
  width: clamp(150px, 28vh, 240px);
  animation: item-reveal 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 0 24px rgba(255, 227, 120, 0.9));
}
.unlock-item svg { width: 100%; height: auto; }
@keyframes item-reveal { from { transform: scale(0) rotate(-360deg); } }
.unlock-name { font-size: clamp(26px, 5vw, 42px); font-weight: bold; }

/* ---------- collection / dress-up ---------- */
.collection-layout {
  flex: 1;
  display: flex;
  gap: 16px;
  min-height: 0;
  padding-bottom: calc(6px + env(safe-area-inset-bottom));
}
.collection-hero {
  flex: 1.1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 30px;
  box-shadow: inset 0 2px 8px rgba(43, 58, 85, 0.1);
  min-width: 0;
}
.collection-hero svg { height: 92%; max-height: 70vh; width: auto; }
.collection-items {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  align-content: start;
  padding: 4px;
}
.coll-item {
  min-height: 130px;
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 15px;
  font-weight: bold;
  color: var(--card-text);
  border: 4px solid transparent;
  transition: transform 0.12s ease;
  padding: 8px;
}
.coll-item:active { transform: scale(0.93); }
.coll-item svg { width: 64px; height: 64px; }
.coll-item.equipped { border-color: var(--good); background: #e9fbf1; }
.coll-item.locked { filter: grayscale(1); opacity: 0.45; pointer-events: none; }
.coll-item .coll-lock { font-size: 22px; }
.coll-item.friend-hop { animation: friend-hop 0.5s ease; }
@keyframes friend-hop {
  30% { transform: translateY(-12px) rotate(-4deg); }
  60% { transform: translateY(0) rotate(3deg); }
}

.hero-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 100%;
  width: 100%;
  padding: 10px;
}
.hero-main { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.hero-main svg { height: 100%; max-height: 52vh; width: auto; }
.hero-friends { display: flex; gap: 10px; align-items: flex-end; flex: 0 0 auto; }
.hero-friends > div { width: clamp(48px, 9vh, 80px); animation: float 3s ease-in-out infinite; }
.hero-friends > div:nth-child(2n) { animation-delay: 0.6s; }
.hero-friends svg { width: 100%; height: auto; }
@media (max-aspect-ratio: 1/1) {
  .collection-layout { flex-direction: column; }
  .collection-hero svg { max-height: 38vh; }
}

/* ---------- overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(43, 58, 85, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.overlay-card {
  background: var(--card);
  border-radius: 28px;
  padding: 26px;
  width: min(440px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}
.overlay-card h2 { margin: 0 0 4px; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 20px;
  min-height: 48px;
}
.setting-row input[type="checkbox"] { width: 32px; height: 32px; }

.start-card {
  background: var(--card);
  border-radius: 34px;
  padding: 30px 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  text-align: center;
}
.start-card h1 { margin: 0; font-size: clamp(28px, 6vw, 44px); color: var(--card-text); }
.start-char { width: clamp(110px, 24vh, 180px); }
.start-char svg { width: 100%; height: auto; animation: float 3s ease-in-out infinite; }

/* flying star (correct answer → meter) */
.fly-star {
  position: fixed;
  z-index: 60;
  font-size: 40px;
  pointer-events: none;
  transition: transform 0.7s cubic-bezier(0.5, -0.3, 0.6, 1), opacity 0.7s ease;
}

/* sparkle burst when equipping in the dress-up room */
.equip-spark {
  position: absolute;
  font-size: 26px;
  pointer-events: none;
  animation: equip-spark 0.8s ease forwards;
}
@keyframes equip-spark {
  0% { transform: scale(0); opacity: 1; }
  60% { transform: scale(1.4) translateY(-18px); opacity: 1; }
  100% { transform: scale(0.6) translateY(-34px); opacity: 0; }
}

/* speech highlight for TTS fallback */
.speech-caption {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 40;
  background: rgba(43, 58, 85, 0.85);
  color: #fff;
  font-size: 22px;
  font-weight: bold;
  padding: 10px 24px;
  border-radius: 20px;
  pointer-events: none;
  animation: caption-in 0.25s ease;
}
@keyframes caption-in { from { opacity: 0; transform: translateX(-50%) translateY(10px); } }
