@font-face {
  font-family: 'Fredoka';
  src: url('/fonts/fredoka.woff2') format('woff2-variations'), url('/fonts/fredoka.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --ink: #2a2150;
  --ink-soft: #625a8c;
  --sky1: #5cc8fb;
  --sky2: #b6ecff;
  --orange: #ff8a3d; --orange-d: #dd6418;
  --pink: #ff5fa2; --pink-d: #d63d80;
  --yellow: #ffd23f; --yellow-d: #dba700;
  --green: #2fd38b; --green-d: #17a466;
  --purple: #8b5cf6; --purple-d: #6a3fdc;
  --blue: #3aa0ff; --blue-d: #1d7ddc;
  --grey: #c9c6dc; --grey-d: #a19db9;
  --card: #ffffff;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --nav-h: 76px;
  --emoji: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', 'Twemoji Mozilla', sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: 'Fredoka', ui-rounded, 'Arial Rounded MT Bold', 'Segoe UI', system-ui, sans-serif;
  color: var(--ink);
  background: var(--sky2);
  min-height: 100dvh;
  overflow-x: hidden;
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
  -webkit-font-smoothing: antialiased;
  -webkit-touch-callout: none;
}
body::before {
  content: ''; position: fixed; inset: 0; z-index: -2;
  background:
    radial-gradient(60px 34px at 12% 14%, #fff9 60%, transparent 62%),
    radial-gradient(90px 40px at 18% 16%, #fff9 60%, transparent 62%),
    radial-gradient(70px 36px at 84% 26%, #fff8 60%, transparent 62%),
    radial-gradient(110px 44px at 90% 28%, #fff8 60%, transparent 62%),
    radial-gradient(80px 34px at 70% 72%, #ffffff70 60%, transparent 62%),
    linear-gradient(180deg, var(--sky1) 0%, var(--sky2) 55%, #e9fbff 100%);
}
input, textarea { -webkit-user-select: text; user-select: text; font-family: inherit; }
button { font-family: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 4px solid var(--yellow); outline-offset: 2px; }
.emoji { font-family: var(--emoji); line-height: 1; font-weight: 400; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- candy buttons ---------- */
.btn {
  --c: var(--orange); --cd: var(--orange-d);
  border: 0; border-radius: 20px; padding: 12px 22px; min-height: 56px;
  font-size: clamp(18px, 2.2vw, 22px); font-weight: 600; letter-spacing: .2px;
  background: var(--c); color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.12);
  box-shadow: 0 6px 0 var(--cd), 0 10px 20px rgba(42,33,80,.15);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform .08s ease, box-shadow .08s ease, filter .15s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--cd), 0 4px 10px rgba(42,33,80,.15); }
.btn[disabled] { filter: grayscale(.6) opacity(.6); pointer-events: none; }
.btn.green { --c: var(--green); --cd: var(--green-d); }
.btn.pink { --c: var(--pink); --cd: var(--pink-d); }
.btn.purple { --c: var(--purple); --cd: var(--purple-d); }
.btn.blue { --c: var(--blue); --cd: var(--blue-d); }
.btn.yellow { --c: var(--yellow); --cd: var(--yellow-d); color: var(--ink); text-shadow: none; }
.btn.white { --c: #fff; --cd: #d9d4ee; color: var(--ink); text-shadow: none; }
.btn.big { font-size: clamp(22px, 3vw, 28px); min-height: 66px; padding: 14px 30px; border-radius: 24px; }
.btn.small { font-size: 16px; min-height: 44px; padding: 8px 14px; border-radius: 16px; box-shadow: 0 4px 0 var(--cd); }
.btn .emoji { font-size: 1.2em; }
.icon-btn {
  width: 48px; height: 48px; border-radius: 16px; border: 0; background: #fff;
  box-shadow: 0 4px 0 #d9d4ee; font-size: 24px; display: grid; place-items: center; flex: none;
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #d9d4ee; }

/* ---------- animations ---------- */
@keyframes bob { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-8px) } }
@keyframes wiggle { 0%,100% { transform: rotate(0) } 25% { transform: rotate(-8deg) } 75% { transform: rotate(8deg) } }
@keyframes pulse { 0%,100% { transform: scale(1) } 50% { transform: scale(1.08) } }
@keyframes shake { 0%,100% { transform: translateX(0) } 20%,60% { transform: translateX(-10px) } 40%,80% { transform: translateX(10px) } }
@keyframes popin { 0% { transform: scale(0) rotate(-20deg); opacity: 0 } 70% { transform: scale(1.15) rotate(4deg); opacity: 1 } 100% { transform: scale(1) rotate(0) } }
@keyframes floaty { 0%,100% { transform: translateY(0) rotate(-4deg) } 50% { transform: translateY(-14px) rotate(4deg) } }
@keyframes blink { 0%,92%,100% { transform: scaleY(1) } 95% { transform: scaleY(.1) } }
@keyframes rise { from { transform: translateY(0) } to { transform: translateY(calc(-1 * var(--travel, 800px))) } }
@keyframes sway { 0%,100% { margin-left: -6px } 50% { margin-left: 6px } }
@keyframes burst { to { transform: scale(1.8); opacity: 0 } }
@keyframes spin { to { transform: rotate(360deg) } }
@keyframes glow { 0%,100% { box-shadow: 0 0 0 0 rgba(255,138,61,.55), 0 7px 0 var(--orange-d) } 50% { box-shadow: 0 0 0 14px rgba(255,138,61,0), 0 7px 0 var(--orange-d) } }
@keyframes bubblein { from { transform: scale(.94); opacity: .5 } to { transform: scale(1); opacity: 1 } }
.bubble.popin { animation: bubblein .25s ease-out both; }
.bob { animation: bob 2.2s ease-in-out infinite; }
.wiggle { animation: wiggle .5s ease-in-out 2; }
.shake { animation: shake .45s ease; }
.popin { animation: popin .5s cubic-bezier(.2,1.4,.4,1) both; }
.floaty { animation: floaty 3s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  .bob, .floaty, .node.current { animation: none !important; }
}

/* ---------- mascot ---------- */
.mascot-svg { width: 100%; height: auto; display: block; overflow: visible; }
.mascot-svg .eyes { transform-box: fill-box; transform-origin: center; animation: blink 4s infinite; }

/* ---------- login ---------- */
.login {
  min-height: 100dvh; display: grid; place-items: center;
  padding: calc(var(--safe-t) + 20px) 16px calc(var(--safe-b) + 20px); position: relative; overflow: hidden;
}
.float-letters { position: fixed; inset: 0; pointer-events: none; z-index: -1; overflow: hidden; }
.float-letters span {
  position: absolute; font-weight: 700; opacity: .55; animation: floaty 5s ease-in-out infinite;
  font-size: clamp(36px, 7vw, 72px); text-shadow: 0 4px 0 rgba(0,0,0,.08);
}
.login-card {
  width: 100%; max-width: 440px; background: #fff; border-radius: 32px; padding: 24px 22px 26px;
  box-shadow: 0 10px 0 #cfe9f7, 0 24px 50px rgba(42,33,80,.18); text-align: center; position: relative;
}
.login-mascot { width: 120px; margin: -84px auto 4px; }
.logo { font-size: clamp(44px, 9vw, 62px); font-weight: 700; margin: 0; line-height: 1; letter-spacing: 1px; }
.logo span { display: inline-block; animation: bob 2s ease-in-out infinite; text-shadow: 0 4px 0 rgba(0,0,0,.1); }
.tagline { margin: 8px 0 18px; font-size: 18px; color: var(--ink-soft); }
.field { text-align: left; margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: 17px; margin: 0 0 6px 6px; }
.input-wrap { position: relative; }
.input {
  width: 100%; font-size: 20px; padding: 14px 16px; border-radius: 18px; border: 3px solid #e6e1f7;
  background: #faf9ff; color: var(--ink); outline: none; transition: border-color .15s;
}
.input:focus { border-color: var(--purple); background: #fff; }
.input-wrap .input { padding-right: 58px; }
.input-wrap .peek { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 46px; height: 46px; border: 0; background: transparent; font-size: 24px; border-radius: 12px; }
.login .btn { width: 100%; margin-top: 6px; }
.form-error { background: #fff0f6; color: #b0205e; border-radius: 16px; padding: 10px 14px; font-weight: 500; margin: 0 0 12px; }
.login-foot { margin-top: 16px; font-size: 14px; color: var(--ink-soft); }
.login-foot a { color: var(--ink-soft); }

/* ---------- app shell ---------- */
.screen {
  max-width: 860px; margin: 0 auto;
  padding: calc(var(--safe-t) + 84px) 16px calc(var(--nav-h) + var(--safe-b) + 28px);
  min-height: 100dvh;
}
.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 30; padding: calc(var(--safe-t) + 8px) 12px 8px; display: flex; justify-content: center; pointer-events: none; }
.topbar-inner {
  pointer-events: auto; width: 100%; max-width: 860px; display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.9); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-radius: 24px; padding: 6px 8px; box-shadow: 0 6px 0 rgba(42,33,80,.08), 0 10px 24px rgba(42,33,80,.1);
}
.me-chip { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; border: 0; background: transparent; padding: 0; text-align: left; }
.avatar { width: 48px; height: 48px; border-radius: 50%; background: #fff3c4; display: grid; place-items: center; font-size: 30px; flex: none; box-shadow: inset 0 -4px 0 #ffe17a; }
.me-chip .who { min-width: 0; }
.me-chip .name { font-weight: 700; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-chip .lvl { font-size: 13px; color: var(--ink-soft); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 380px) { .pill.coins { display: none; } }
.pill { display: inline-flex; align-items: center; gap: 4px; background: #f4f1ff; border-radius: 999px; padding: 6px 10px; font-weight: 700; font-size: 17px; white-space: nowrap; }
.pill .emoji { font-size: 20px; }

.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; padding: 8px 12px calc(var(--safe-b) + 10px); display: flex; justify-content: center; pointer-events: none; }
.bottomnav-inner { pointer-events: auto; width: 100%; max-width: 560px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: #fff; border-radius: 28px; padding: 6px; box-shadow: 0 6px 0 rgba(42,33,80,.08), 0 12px 30px rgba(42,33,80,.18); }
.navbtn { border: 0; background: transparent; border-radius: 22px; padding: 6px 2px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 14px; font-weight: 600; color: var(--ink-soft); min-height: 58px; justify-content: center; }
.navbtn .emoji { font-size: 28px; transition: transform .2s; }
.navbtn.active { background: #fff1e5; color: var(--orange-d); }
.navbtn.active .emoji { transform: scale(1.15) translateY(-2px); }

/* ---------- home / map ---------- */
.hello-card {
  background: #fff; border-radius: 30px; padding: 18px; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: center;
  box-shadow: 0 8px 0 rgba(42,33,80,.08), 0 16px 34px rgba(42,33,80,.12); margin-bottom: 26px;
}
.hello-card .mascot { width: clamp(78px, 16vw, 116px); flex: none; }
.hello-card h1 { margin: 0; font-size: clamp(24px, 5vw, 34px); line-height: 1.1; }
.hello-card p { margin: 4px 0 12px; color: var(--ink-soft); font-size: clamp(16px, 3.4vw, 19px); }
.hello-card .grow { flex: 1; min-width: 0; }
.xpbar { height: 18px; background: #efeaff; border-radius: 999px; overflow: hidden; position: relative; margin: 4px 0 12px; }
.xpbar > i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--yellow), var(--orange)); border-radius: 999px; transition: width 1s cubic-bezier(.2,.8,.2,1); }
.xpbar > b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; color: var(--ink); }

.section-title { text-align: center; margin: 34px 0 14px; }
.section-title > span {
  display: inline-flex; align-items: center; gap: 8px; background: #fff; border-radius: 999px; padding: 10px 20px;
  font-size: clamp(19px, 4vw, 24px); font-weight: 700; box-shadow: 0 6px 0 rgba(42,33,80,.08);
}
.section-title small { display: block; margin-top: 8px; color: var(--ink-soft); font-size: 15px; font-weight: 500; }
.path { position: relative; display: flex; flex-direction: column; align-items: center; gap: 40px; padding: 50px 0 10px; overflow: hidden; }
.node-wrap { position: relative; display: flex; flex-direction: column; align-items: center; transform: translateX(calc(var(--x, 0) * min(0.85vw, 5.2px))); }
.node {
  --c: var(--grey); --cd: var(--grey-d);
  width: clamp(78px, 17vw, 96px); height: clamp(78px, 17vw, 96px); border-radius: 50%; border: 0;
  background: radial-gradient(circle at 35% 30%, #ffffff55 0 22%, transparent 23%), var(--c);
  box-shadow: 0 7px 0 var(--cd), 0 12px 20px rgba(42,33,80,.18);
  color: #fff; font-weight: 700; font-size: clamp(28px, 6vw, 36px); text-shadow: 0 3px 0 rgba(0,0,0,.15);
  display: grid; place-items: center; position: relative; transition: transform .1s;
}
.node:active { transform: translateY(4px); box-shadow: 0 3px 0 var(--cd); }
.node.done { --c: var(--green); --cd: var(--green-d); }
.node.current { --c: var(--orange); --cd: var(--orange-d); animation: glow 1.6s ease-in-out infinite; }
.node.purple { --c: var(--purple); --cd: var(--purple-d); }
.node.pink { --c: var(--pink); --cd: var(--pink-d); }
.node.blue { --c: var(--blue); --cd: var(--blue-d); }
.node.locked { color: #fff; }
.node .lock { position: absolute; right: -4px; bottom: -4px; font-size: 24px; }
.node .icon { font-size: 1.15em; }
.node-stars { margin-top: 10px; font-size: 18px; letter-spacing: -2px; min-height: 20px; }
.node-label { margin-top: 6px; font-weight: 600; font-size: 15px; background: #ffffffd0; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.node-deco { position: absolute; top: 12px; font-size: clamp(30px, 7vw, 40px); pointer-events: none; }
.node-deco.left { right: calc(100% + 12px); }
.node-deco.right { left: calc(100% + 12px); }
.you-here { position: absolute; top: -44px; font-size: 40px; z-index: 2; pointer-events: none; }
.play-cta { width: 100%; grid-column: 1 / -1; margin-top: 4px; }

/* ---------- generic cards / grids ---------- */
.panel { background: #fff; border-radius: 28px; padding: 18px; box-shadow: 0 8px 0 rgba(42,33,80,.08), 0 16px 34px rgba(42,33,80,.1); margin-bottom: 18px; }
.panel h2 { margin: 0 0 12px; font-size: 24px; }
.page-title { text-align: center; margin: 4px 0 18px; font-size: clamp(28px, 6vw, 38px); }
.page-title small { display: block; font-size: 17px; color: var(--ink-soft); font-weight: 500; margin-top: 4px; }
.grid { display: grid; gap: 12px; }
.sticker-grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
.sticker {
  aspect-ratio: 1; border-radius: 22px; background: #fff; display: grid; place-items: center; font-size: clamp(40px, 9vw, 52px);
  box-shadow: 0 5px 0 rgba(42,33,80,.08);
}
.sticker.missing { background: #ffffff80; color: #b9b3d6; font-family: inherit; font-weight: 700; font-size: 34px; }
.stats { grid-template-columns: repeat(2, 1fr); }
.stat { background: #f7f5ff; border-radius: 20px; padding: 14px; text-align: center; }
.stat b { display: block; font-size: 28px; }
.stat span { color: var(--ink-soft); font-weight: 500; font-size: 15px; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.avatar-grid { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
.avatar-pick { aspect-ratio: 1; border: 4px solid transparent; border-radius: 22px; background: #f7f5ff; font-size: 40px; position: relative; display: grid; place-items: center; }
.avatar-pick.on { border-color: var(--orange); background: #fff3e8; }
.avatar-pick.locked { filter: grayscale(1); opacity: .5; }
.avatar-pick small { position: absolute; bottom: 2px; left: 0; right: 0; font-size: 11px; font-weight: 700; font-family: 'Fredoka', sans-serif; color: var(--ink); }
.profile-hero { text-align: center; }
.profile-hero .avatar { width: 110px; height: 110px; font-size: 66px; margin: 0 auto 8px; }
.profile-hero h1 { margin: 0; font-size: 32px; }
.rank { display: inline-flex; gap: 6px; align-items: center; background: #fff3c4; padding: 6px 14px; border-radius: 999px; font-weight: 700; margin: 8px 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.center { justify-content: center; }
.switch-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 2px dashed #eee9ff; font-weight: 600; font-size: 18px; gap: 10px; }
.switch-row:last-child { border: 0; }
.toggle { width: 66px; height: 38px; border-radius: 999px; border: 0; background: var(--grey); position: relative; flex: none; transition: background .2s; }
.toggle::after { content: ''; position: absolute; top: 4px; left: 4px; width: 30px; height: 30px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 2px 4px rgba(0,0,0,.2); }
.toggle.on { background: var(--green); }
.toggle.on::after { transform: translateX(28px); }

/* ---------- flash cards ---------- */
.tabs { display: flex; gap: 8px; justify-content: center; margin-bottom: 16px; flex-wrap: wrap; }
.tab { border: 0; border-radius: 999px; padding: 10px 18px; font-size: 17px; font-weight: 600; background: #ffffffb0; }
.tab.on { background: var(--purple); color: #fff; box-shadow: 0 4px 0 var(--purple-d); }
.tab[disabled] { opacity: .5; }
.letter-grid { grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); }
.letter-tile { aspect-ratio: 1; border: 0; border-radius: 20px; background: #fff; font-size: 28px; font-weight: 700; box-shadow: 0 5px 0 rgba(42,33,80,.1); display: grid; place-items: center; }
.letter-tile.locked { opacity: .45; }
.flash-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.flashcard { width: min(84vw, 380px, calc(48dvh * .75)); aspect-ratio: 3 / 4; perspective: 1200px; border: 0; background: transparent; padding: 0; }
.flashcard .inner { position: relative; width: 100%; height: 100%; transition: transform .55s cubic-bezier(.3,1.3,.5,1); transform-style: preserve-3d; }
.flashcard.flipped .inner { transform: rotateY(180deg); }
.flashcard .face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 34px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 16px;
  box-shadow: 0 10px 0 rgba(42,33,80,.12), 0 20px 40px rgba(42,33,80,.16);
}
.flashcard .front { background: linear-gradient(160deg, #fff, #fff6e9); }
.flashcard .back { background: linear-gradient(160deg, #fff, #eefaff); transform: rotateY(180deg); }
.flashcard .big { font-size: clamp(90px, 26vw, 150px); font-weight: 700; line-height: 1; }
.flashcard .pic { font-size: clamp(90px, 26vw, 140px); }
.flashcard .word { font-size: clamp(30px, 8vw, 44px); font-weight: 700; text-align: center; }
.flashcard .hint { color: var(--ink-soft); font-size: 16px; }
.hl { color: var(--pink); }

/* ---------- game frame ---------- */
.game {
  position: fixed; inset: 0; width: 100%; max-width: 1040px; margin: 0 auto; z-index: 40;
  display: flex; flex-direction: column; padding: calc(var(--safe-t) + 8px) 12px calc(var(--safe-b) + 12px);
}
.game-head { display: flex; align-items: center; gap: 10px; flex: none; }
.dots { flex: 1; display: flex; justify-content: center; gap: 8px; align-items: center; flex-wrap: wrap; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: #ffffff90; transition: all .3s; }
.dot.done { background: var(--green); }
.dot.now { width: 30px; border-radius: 999px; background: var(--orange); }
.mascot-row { display: flex; align-items: center; gap: 10px; margin: 8px 0 4px; flex: none; }
.mascot-row .mascot { width: clamp(62px, min(13vw, 13vh), 108px); flex: none; }
.bubble {
  position: relative; flex: 1; background: #fff; border-radius: 24px; padding: 12px 16px; min-height: 56px;
  font-size: clamp(17px, min(4.6vw, 4.4vh), 28px); font-weight: 600; line-height: 1.2; display: flex; align-items: center; gap: 8px;
  box-shadow: 0 6px 0 rgba(42,33,80,.08);
}
.bubble::before { content: ''; position: absolute; left: -10px; top: 50%; margin-top: -10px; border: 10px solid transparent; border-right-color: #fff; border-left: 0; }
.bubble .txt { flex: 1; min-width: 0; }
.bubble .again { flex: none; width: 44px; height: 44px; border-radius: 14px; border: 0; background: #f2eeff; font-size: 22px; }
.stage { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(10px, 2vh, 20px); }
.stage-foot { flex: none; display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; padding-top: 6px; }

/* meet */
.meet-letter { display: flex; gap: clamp(14px, 4vw, 30px); }
.case-card {
  border: 0; background: #fff; border-radius: 30px; width: clamp(110px, min(32vw, 26vh), 200px); aspect-ratio: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 8px 0 rgba(42,33,80,.12);
}
.case-card b { font-size: clamp(70px, min(22vw, 18vh), 140px); line-height: 1; }
.case-card small { font-size: clamp(14px, 2vh, 18px); color: var(--ink-soft); font-weight: 600; }
.case-card.cap b { color: var(--orange); }
.case-card.low b { color: var(--purple); }
.word-cards { display: flex; gap: clamp(8px, 2.4vw, 16px); justify-content: center; flex-wrap: wrap; }
.word-card {
  border: 0; background: #fff; border-radius: 24px; width: clamp(96px, min(28vw, 20vh), 160px); padding: 10px 6px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; box-shadow: 0 6px 0 rgba(42,33,80,.1); position: relative;
}
.word-card .emoji { font-size: clamp(44px, min(12vw, 9vh), 76px); }
.word-card span:last-child { font-size: clamp(16px, min(4vw, 3vh), 22px); font-weight: 600; }
.word-card.seen::after { content: '✓'; position: absolute; top: -8px; right: -8px; background: var(--green); color: #fff; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 17px; }

/* balloons */
.sky { position: absolute; inset: 0; overflow: hidden; border-radius: 28px; background: linear-gradient(180deg, #ffffff30, #ffffff10); }
.counter { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 2; background: #fff; border-radius: 999px; padding: 6px 16px; font-weight: 700; font-size: 22px; box-shadow: 0 4px 0 rgba(42,33,80,.1); white-space: nowrap; }
.balloon {
  --size: clamp(66px, min(15vw, 15vh), 112px);
  position: absolute; bottom: calc(-1 * var(--size) - 60px); width: var(--size); height: calc(var(--size) * 1.18);
  border: 0; padding: 0; background: transparent; animation: rise linear forwards; z-index: 1;
}
.balloon .b {
  position: absolute; inset: 0; border-radius: 50% 50% 48% 48% / 55% 55% 45% 45%;
  background: radial-gradient(circle at 32% 28%, #ffffffa0 0 12%, transparent 13%), var(--bc, var(--pink));
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: calc(var(--size) * .5); text-shadow: 0 3px 0 rgba(0,0,0,.18);
  animation: sway 2.4s ease-in-out infinite;
}
.balloon .b::after { content: ''; position: absolute; bottom: -8px; left: 50%; margin-left: -7px; border: 7px solid transparent; border-bottom: 9px solid var(--bc, var(--pink)); transform: rotate(180deg); }
.balloon .s { position: absolute; top: 100%; left: 50%; width: 2px; height: 46px; background: #ffffffb0; margin-top: 8px; }
.balloon.popped .b { animation: burst .25s ease-out forwards; }
.balloon.popped .s { display: none; }
.balloon.nope .b { animation: shake .4s; }
.plus { position: absolute; font-weight: 700; font-size: 30px; color: #fff; text-shadow: 0 3px 0 var(--green-d); pointer-events: none; animation: popin .3s both; z-index: 3; }

/* trace */
.trace-box { position: relative; background: #fff; border-radius: 30px; box-shadow: 0 8px 0 rgba(42,33,80,.12); touch-action: none; }
.trace-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 30px; touch-action: none; }

/* memory match */
.memory { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(8px, 2vw, 16px); width: min(100%, 560px, calc((100dvh - 260px) * 1.45)); }
.mcard { aspect-ratio: 1; border: 0; padding: 0; background: transparent; perspective: 900px; }
.mcard .inner { position: relative; width: 100%; height: 100%; transition: transform .4s; transform-style: preserve-3d; }
.mcard.up .inner, .mcard.matched .inner { transform: rotateY(180deg); }
.mcard .face { position: absolute; inset: 0; border-radius: 22px; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: grid; place-items: center; box-shadow: 0 6px 0 rgba(42,33,80,.12); }
.mcard .back-f { background: repeating-linear-gradient(45deg, var(--purple) 0 12px, #9b72ff 12px 24px); color: #fff; font-size: clamp(30px, 7vw, 46px); font-weight: 700; }
.mcard .front-f { background: #fff; transform: rotateY(180deg); font-size: clamp(42px, min(11vw, 9vh), 76px); font-weight: 700; color: var(--ink); }
.mcard.matched .front-f { background: #dcffe9; color: var(--green-d); }

/* choices */
.prompt-letter { font-size: clamp(64px, min(18vw, 15vh), 130px); font-weight: 700; line-height: 1; background: #fff; border-radius: 28px; padding: 6px 28px 12px; box-shadow: 0 8px 0 rgba(42,33,80,.12); color: var(--orange); }
.choices { display: grid; gap: clamp(10px, 2.4vw, 18px); width: min(100%, 620px); }
.choices.c2 { grid-template-columns: repeat(2, 1fr); }
.choices.c3 { grid-template-columns: repeat(3, 1fr); }
.choices.c4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 520px) { .choices.c4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-height: 500px) and (orientation: landscape) { .choices.c4 { grid-template-columns: repeat(4, 1fr); } }
.choice {
  border: 0; border-radius: 26px; background: #fff; aspect-ratio: 1; max-height: 22dvh; width: 100%; justify-self: center;
  box-shadow: 0 7px 0 rgba(42,33,80,.12); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: clamp(46px, min(12vw, 10vh), 84px); font-weight: 700; color: var(--ink); transition: transform .1s, background .2s;
}
.choice:active { transform: translateY(4px); box-shadow: 0 3px 0 rgba(42,33,80,.12); }
.choice .emoji { font-size: clamp(46px, min(12vw, 10vh), 84px); }
.choice small { font-size: clamp(14px, 2vh, 18px); font-weight: 600; color: var(--ink-soft); }
.choice.right { background: #d9ffe9; box-shadow: 0 7px 0 var(--green); }
.choice.wrong { background: #ffe6f0; animation: shake .4s; }
.choice.dim { opacity: .45; }

/* say it */
.mic-btn { width: clamp(110px, 20vh, 160px); height: clamp(110px, 20vh, 160px); border-radius: 50%; border: 0; font-size: clamp(50px, 9vh, 70px); background: var(--pink); box-shadow: 0 8px 0 var(--pink-d); }
.mic-btn.listening { animation: pulse .8s infinite; background: var(--green); box-shadow: 0 8px 0 var(--green-d); }

/* spelling / phrase builder */
.big-pic { font-size: clamp(70px, min(20vw, 16vh), 130px); }
.slots { display: flex; gap: clamp(6px, 1.6vw, 12px); justify-content: center; flex-wrap: wrap; }
.slot {
  min-width: clamp(56px, min(15vw, 11vh), 90px); height: clamp(64px, min(17vw, 12vh), 96px); padding: 0 10px; border-radius: 18px; border: 4px dashed #ffffffd0;
  background: #ffffff50; display: grid; place-items: center; font-size: clamp(32px, min(9vw, 7vh), 52px); font-weight: 700; color: #ffffffd0;
}
.slot.word { font-size: clamp(20px, min(5vw, 4vh), 30px); min-width: clamp(70px, 18vw, 120px); }
.slot.ghost { color: #2a215035; }
.slot.filled { border-style: solid; border-color: var(--green); background: #fff; color: var(--ink); animation: popin .35s both; }
.tiles { display: flex; gap: clamp(8px, 2vw, 14px); justify-content: center; flex-wrap: wrap; max-width: 640px; }
.tile {
  min-width: clamp(58px, min(15vw, 11vh), 88px); height: clamp(58px, min(15vw, 11vh), 88px); padding: 0 12px; border: 0; border-radius: 20px;
  background: var(--yellow); box-shadow: 0 6px 0 var(--yellow-d); font-size: clamp(30px, min(8vw, 6vh), 46px); font-weight: 700; color: var(--ink);
}
.tile.word { font-size: clamp(20px, min(5vw, 4vh), 28px); background: #fff; box-shadow: 0 6px 0 #d9d4ee; }
.tile.used { visibility: hidden; }
.tile.nope { animation: shake .4s; }

/* exam boss */
.boss-area { display: flex; align-items: center; gap: 14px; width: min(100%, 620px); flex: none; }
.boss { width: clamp(80px, min(20vw, 17vh), 150px); flex: none; }
.boss.hit { animation: wiggle .3s 2; }
.hp { flex: 1; }
.hp .bar { height: 22px; background: #ffffff80; border-radius: 999px; overflow: hidden; border: 3px solid #fff; }
.hp .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--pink), var(--purple)); transition: width .5s; border-radius: 999px; }
.hp b { display: block; margin-bottom: 6px; font-size: clamp(16px, 2.4vh, 20px); }

/* ---------- overlay / modal / reward ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: calc(var(--safe-t) + 16px) 16px calc(var(--safe-b) + 16px);
  background: rgba(42,33,80,.55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); overflow-y: auto;
}
.modal { width: 100%; max-width: 460px; background: #fff; border-radius: 34px; padding: 26px 22px 24px; text-align: center; box-shadow: 0 12px 0 rgba(0,0,0,.12); animation: popin .45s both; }
.modal h2 { margin: 6px 0 8px; font-size: clamp(26px, 6vw, 34px); line-height: 1.1; }
.modal p { margin: 0 0 16px; font-size: 18px; color: var(--ink-soft); }
.modal .actions { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.modal .mascot { width: 110px; margin: 0 auto; }
.big-stars { display: flex; justify-content: center; gap: 6px; font-size: clamp(54px, 13vw, 72px); margin: 6px 0; }
.big-stars span { opacity: .2; filter: grayscale(1); transition: all .3s; }
.big-stars span.on { opacity: 1; filter: none; animation: popin .5s both; }
.reward-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 8px 0 14px; }
.gift { border: 0; background: transparent; font-size: 86px; animation: wiggle 1s ease-in-out infinite; padding: 0; line-height: 1; }
.gift-got { font-size: 92px; animation: popin .6s both; }
.levelup { background: linear-gradient(90deg, var(--yellow), var(--orange)); color: #fff; font-weight: 700; padding: 8px 16px; border-radius: 999px; display: inline-block; margin-bottom: 10px; text-shadow: 0 2px 0 rgba(0,0,0,.15); animation: pulse 1s infinite; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 24px); transform: translateX(-50%); z-index: 120;
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px; font-weight: 600; font-size: 18px; max-width: calc(100vw - 32px);
  text-align: center; animation: popin .3s both; box-shadow: 0 8px 20px rgba(0,0,0,.25);
}
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 200; }

/* ---------- certificate ---------- */
.cert-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.cert-img { width: 100%; max-width: 900px; border-radius: 18px; box-shadow: 0 10px 0 rgba(42,33,80,.12), 0 20px 50px rgba(42,33,80,.2); background: #fff; }
.loading { display: grid; place-items: center; min-height: 100dvh; font-size: 22px; font-weight: 600; }
.loading .mascot { width: 110px; margin: 0 auto 12px; }

/* ---------- short landscape phones ---------- */
@media (max-height: 500px) and (orientation: landscape) {
  .mascot-row { margin: 4px 0 2px; }
  .mascot-row .mascot { width: 54px; }
  .bubble { min-height: 44px; padding: 8px 12px; }
  .bubble .again { width: 38px; height: 38px; }
  .icon-btn { width: 42px; height: 42px; font-size: 20px; }
  .btn { min-height: 48px; padding: 8px 18px; }
  .btn.big { min-height: 52px; }
  .stage { gap: 8px; }
  .screen { padding-top: calc(var(--safe-t) + 74px); }
}

@media print {
  body::before, .topbar, .bottomnav, .no-print { display: none !important; }
  body { background: #fff; }
  .screen { padding: 0; }
  .cert-img { box-shadow: none; border-radius: 0; max-width: 100%; }
}
