@font-face {
  font-family: 'Naskh';
  src: url(../fonts/naskh-arabic.woff2) format('woff2');
  font-weight: 400 700;
  font-display: block;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F;
}
@font-face {
  font-family: 'Fredoka';
  src: url(../fonts/fredoka-latin.woff2) format('woff2');
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --ink: #2b2350;
  --ink2: #5b5480;
  --sky1: #aee3ff;
  --sky2: #eaf8ff;
  --card: #ffffff;
  --purple: #8b5cf6;
  --pink: #ff6fae;
  --green: #22c55e;
  --yellow: #facc15;
  --orange: #fb923c;
  --blue: #38bdf8;
  --red: #f43f5e;
  --c0: #ff6fae; --c1: #38bdf8; --c2: #22c55e; --c3: #f59e0b; --c4: #a855f7; --c5: #fb7185;
  --shadow: 0 6px 0 rgba(43, 35, 80, .14), 0 12px 24px rgba(43, 35, 80, .12);
  --r: 26px;
  --fab: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Fredoka', 'Naskh', system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky1), var(--sky2) 70%);
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
input, textarea, select { user-select: text; -webkit-user-select: text; font: inherit; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; touch-action: manipulation; }
button:disabled { opacity: .45; cursor: default; }
.ku { font-family: 'Naskh', serif; font-weight: 700; }
.hidden { display: none !important; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 12px 0; }
.row.center { justify-content: center; }
.spacer { flex: 1; }
.small { font-size: .85rem; color: var(--ink2); }
.note { color: var(--ink2); text-align: center; max-width: 520px; margin: 10px auto; font-size: 1rem; }

#app { height: 100dvh; }
#loading { display: grid; place-items: center; height: 100%; font-size: 80px; animation: bob 1s ease-in-out infinite; }

.screen { position: relative; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- buttons */
.btn {
  --b: var(--purple);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 18px;
  background: var(--b); color: #fff; font-weight: 600; font-size: 1.05rem;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .2);
  transition: transform .08s, box-shadow .08s;
  text-decoration: none;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0, 0, 0, .2); }
.btn.green { --b: var(--green); }
.btn.red { --b: var(--red); }
.btn.gray { --b: #8e8aa8; }
.btn.big { font-size: 1.4rem; padding: 14px 34px; border-radius: 22px; }
.btn.small { font-size: .9rem; padding: 8px 14px; }

.round-btn {
  --b: var(--purple);
  width: 74px; height: 74px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 34px; color: #fff; font-weight: 700;
  background: var(--b);
  box-shadow: 0 6px 0 rgba(0, 0, 0, .2), 0 10px 20px rgba(0, 0, 0, .12);
  transition: transform .1s;
}
.round-btn:active { transform: translateY(4px) scale(.97); box-shadow: 0 2px 0 rgba(0, 0, 0, .2); }
.round-btn.big { width: 96px; height: 96px; font-size: 46px; }
.round-btn.yellow { --b: #fbbf24; }
.round-btn.green { --b: var(--green); }
.round-btn.blue { --b: var(--blue); }
.round-btn.ready { animation: pulse 1.2s ease-in-out infinite; }

.next-btn {
  width: 96px; height: 96px; border-radius: 50%;
  background: var(--green); color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 7px 0 #15803d, 0 12px 24px rgba(0, 0, 0, .15);
  transition: transform .1s;
}
.next-btn svg { width: 54px; height: 54px; }
.next-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 #15803d; }
.next-btn.ready { animation: pulse 1.1s ease-in-out infinite; }
.next-btn:disabled { opacity: .3; filter: grayscale(1); box-shadow: 0 4px 0 rgba(0, 0, 0, .15); }

.speaker {
  width: 72px; height: 72px; border-radius: 50%;
  font-size: 34px; background: #fff;
  box-shadow: var(--shadow);
  display: grid; place-items: center;
  transition: transform .1s;
}
.speaker.big { width: 116px; height: 116px; font-size: 58px; }
.speaker.mute { opacity: .55; }
.speaker.playing { animation: wiggle .4s ease-in-out infinite; background: #fff7c2; }
.speaker.me { width: auto; padding: 0 18px; border-radius: 40px; font-size: 30px; }
.speaker:active { transform: scale(.94); }

.instr {
  font-size: 46px; width: 82px; height: 82px; border-radius: 24px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .7);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .9);
}

/* ---------------------------------------------------------------- top bars */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; padding-left: calc(var(--fab) + 26px);
  position: relative; z-index: 3;
}
.back-btn, .x-btn {
  width: 62px; height: 62px; border-radius: 20px; flex: none;
  background: #fff; color: var(--purple);
  box-shadow: var(--shadow);
  display: grid; place-items: center; font-size: 28px;
}
.back-btn svg { width: 36px; height: 36px; }
.back-btn:active, .x-btn:active { transform: translateY(3px); }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; border-radius: 40px; padding: 8px 16px;
  box-shadow: var(--shadow); font-weight: 700; font-size: 1.25rem;
}
.pill-i { font-size: 1.5rem; }
.pill.gold { background: linear-gradient(180deg, #fff6c9, #ffe27a); }
.lock-mini, .corner-lock { font-size: 26px; opacity: .55; width: 52px; height: 52px; }
.corner-lock { position: absolute; right: 14px; bottom: 12px; }
.map-title { display: flex; flex-direction: column; font-weight: 700; font-size: 1.4rem; line-height: 1.1; }
.map-title .ku { font-size: 1.1rem; color: var(--ink2); }

/* ---------------------------------------------------------------- sky decoration */
.sky { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.cloud { position: absolute; font-size: 90px; opacity: .85; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .06)); animation: drift 40s linear infinite; }
.cl0 { top: 6%; animation-duration: 55s; }
.cl1 { top: 22%; font-size: 60px; animation-duration: 38s; animation-delay: -20s; }
.cl2 { top: 60%; font-size: 120px; animation-duration: 70s; animation-delay: -40s; opacity: .6; }
.cl3 { top: 78%; font-size: 70px; animation-duration: 48s; animation-delay: -10s; }

/* ---------------------------------------------------------------- mascot */
.mascot { position: relative; width: 120px; z-index: 5; pointer-events: none; }
.mascot svg { width: 100%; height: auto; display: block; overflow: visible; }
.mascot.big { width: min(26vmin, 190px); margin: 0 auto; }
.mascot.corner { position: fixed; left: 10px; bottom: 6px; width: min(15vmin, 110px); }
.chick-body { transform-origin: 60px 110px; animation: bob 2.4s ease-in-out infinite; }
.chick .eyes { transform-origin: 60px 60px; animation: blink 4s infinite; }
.chick .happy-eyes, .chick .sad-brows { display: none; }
.mascot.happy .happy-eyes { display: block; }
.mascot.happy .eyes { display: none; }
.mascot.sad .sad-brows { display: block; }
.mascot.sad .chick-body { animation: sadtilt .7s ease-in-out; }
.mascot.jump .chick-body { animation: jump .6s ease-out 2; }
.mascot.happy .wing { animation: flap .25s ease-in-out infinite alternate; }
.chick .wl { transform-origin: 22px 74px; }
.chick .wr { transform-origin: 98px 74px; }
.mascot.talk .beak-bottom { animation: talk .18s ease-in-out infinite alternate; transform-origin: 60px 75px; }
.bubble {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: #fff; border-radius: 22px; padding: 8px 16px;
  font-size: 30px; white-space: nowrap; box-shadow: var(--shadow);
  animation: popIn .3s ease-out;
}
.bubble::after { content: ''; position: absolute; top: 100%; left: 50%; margin-left: -10px; border: 10px solid transparent; border-top-color: #fff; }
.mascot.corner .bubble { left: 20px; transform: none; }

/* ---------------------------------------------------------------- profiles */
.screen-profiles { align-items: center; justify-content: center; gap: 1.5vh; padding: 16px; }
.title-wrap { text-align: center; position: relative; z-index: 1; }
.title {
  margin: 0; font-size: min(15vmin, 120px); line-height: 1.2;
  color: #fff; -webkit-text-stroke: 3px var(--purple); paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--purple), 0 12px 20px rgba(139, 92, 246, .4);
}
.subtitle { font-weight: 700; color: var(--purple); font-size: 1.3rem; letter-spacing: 2px; }
.profile-grid { display: flex; flex-wrap: wrap; gap: 20px; justify-content: center; position: relative; z-index: 1; max-width: 1100px; }
.profile-card {
  --pc: var(--purple);
  width: 180px; padding: 18px 10px 14px; border-radius: 32px;
  background: #fff; box-shadow: 0 8px 0 var(--pc), 0 14px 26px rgba(0, 0, 0, .14);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  animation: popIn .4s ease-out backwards; transition: transform .12s;
}
.profile-card:active { transform: translateY(5px); }
.profile-card .avatar { font-size: 84px; line-height: 1.1; }
.profile-card .pname { font-weight: 700; font-size: 1.4rem; }
.profile-card .pstats { font-size: .95rem; color: var(--ink2); white-space: pre; }
.profile-card.add { background: rgba(255, 255, 255, .55); box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .9); justify-content: center; min-height: 180px; }
.profile-card.add .avatar { font-size: 56px; }

/* ---------------------------------------------------------------- pop-ups */
.modal-back {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(43, 35, 80, .45); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 16px;
  animation: fadeIn .2s;
}
.modal-back.closing { animation: fadeOut .2s forwards; }
.modal-box {
  background: #fff; border-radius: 32px; padding: 24px;
  max-width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  animation: popIn .3s ease-out;
  text-align: center;
}
.modal-box.wide { max-width: min(880px, 100%); width: 100%; }
.modal-box h2, .modal-box h3 { margin: 0 0 12px; }
.confirm-text { font-size: 1.3rem; margin: 6px 0 18px; }
.name-input { width: 100%; font-size: 1.6rem; padding: 12px 16px; border-radius: 18px; border: 3px solid #e4defc; text-align: center; outline: none; }
.name-input:focus { border-color: var(--purple); }
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; margin: 16px 0; }
.av { font-size: 46px; padding: 6px; border-radius: 20px; background: #f6f3ff; transition: transform .1s; }
.av.on { background: #ffe9a8; box-shadow: inset 0 0 0 4px var(--yellow); transform: scale(1.08); }
.color-row { display: flex; gap: 12px; justify-content: center; margin-bottom: 8px; }
.cl { width: 52px; height: 52px; border-radius: 50%; box-shadow: 0 4px 0 rgba(0, 0, 0, .2); }
.cl.on { outline: 5px solid #fff; box-shadow: 0 0 0 9px currentColor, 0 4px 0 rgba(0, 0, 0, .2); transform: scale(1.1); }

.kp { width: 360px; }
.kp-title { font-size: 2rem; margin: 0; }
.kp-hint { color: var(--ink2); margin: 6px 0; }
.kp-dots { display: flex; gap: 10px; justify-content: center; margin: 14px 0 18px; min-height: 22px; flex-wrap: wrap; }
.kp-dots span { width: 18px; height: 18px; border-radius: 50%; background: #e6e1fb; }
.kp-dots span.on { background: var(--purple); }
.kp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kp-key { font-size: 2rem; font-weight: 700; padding: 12px 0; border-radius: 18px; background: #f3f0ff; box-shadow: 0 4px 0 #ddd6fe; }
.kp-key:active { transform: translateY(3px); box-shadow: none; }
.kp-key.ok { background: var(--green); color: #fff; box-shadow: 0 4px 0 #15803d; }

.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 40px); z-index: 200;
  background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 20px;
  font-size: 1.1rem; opacity: 0; transition: .3s; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 150; }
.burst {
  position: fixed; z-index: 160; pointer-events: none; font-size: 30px;
  transform: translate(-50%, -50%); animation: burst .9s ease-out forwards;
}

/* ---------------------------------------------------------------- home */
.me { display: flex; align-items: center; gap: 8px; background: #fff; border-radius: 40px; padding: 6px 18px 6px 8px; box-shadow: 0 5px 0 var(--pc), 0 10px 20px rgba(0, 0, 0, .1); }
.me .avatar { font-size: 42px; }
.me .pname { font-weight: 700; font-size: 1.3rem; }
.chapters {
  flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 22px;
  padding: 10px 24px; align-content: center; position: relative; z-index: 1;
}
.chapter-card {
  position: relative; border-radius: 34px; padding: 18px 14px 16px;
  background: linear-gradient(160deg, var(--c1), var(--c2));
  color: #fff; display: flex; flex-direction: column; align-items: center; gap: 4px;
  box-shadow: 0 9px 0 rgba(0, 0, 0, .18), 0 16px 30px rgba(0, 0, 0, .15);
  animation: popIn .45s ease-out backwards; transition: transform .12s;
  min-height: 0;
}
.chapter-card:nth-child(2) { animation-delay: .08s; }
.chapter-card:nth-child(3) { animation-delay: .16s; }
.chapter-card:nth-child(4) { animation-delay: .24s; }
.chapter-card:active { transform: translateY(6px); }
.chapter-card.locked { filter: grayscale(.75) brightness(.95); }
.ch-num { position: absolute; top: 10px; right: 14px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255, 255, 255, .3); display: grid; place-items: center; font-weight: 700; font-size: 1.3rem; }
.ch-icon { font-size: min(11vmin, 84px); filter: drop-shadow(0 6px 6px rgba(0, 0, 0, .15)); }
.ch-sample { font-size: min(6.5vmin, 46px); line-height: 1.5; text-shadow: 0 3px 0 rgba(0, 0, 0, .15); white-space: nowrap; }
.ch-title { font-weight: 700; font-size: 1.3rem; opacity: .95; }
.ch-progress { width: 86%; height: 14px; border-radius: 10px; background: rgba(255, 255, 255, .35); overflow: hidden; margin-top: 6px; }
.ch-progress div { height: 100%; background: #fff; border-radius: 10px; }
.ch-count { font-weight: 600; font-size: 1rem; }
.ch-lock { position: absolute; inset: 0; display: grid; place-items: center; font-size: 70px; background: rgba(255, 255, 255, .15); border-radius: inherit; }
.home-foot { display: flex; align-items: flex-end; justify-content: center; gap: 20px; padding: 0 24px 14px; position: relative; z-index: 1; }
.home-foot .mascot { width: min(16vmin, 120px); }
.money-bar {
  display: flex; align-items: center; gap: 14px; background: #fff; border-radius: 40px;
  padding: 10px 16px; box-shadow: var(--shadow); cursor: pointer; flex: 0 1 620px;
}
.mini-bill { height: 44px; border-radius: 6px; box-shadow: 0 3px 6px rgba(0, 0, 0, .2); transform: rotate(-6deg); }
.mb-track { position: relative; flex: 1; height: 30px; border-radius: 20px; background: #ecfdf3; overflow: hidden; box-shadow: inset 0 2px 4px rgba(0, 0, 0, .08); }
.mb-fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #4ade80, #16a34a); border-radius: 20px; transition: width .6s; }
[dir=rtl] .mb-fill { inset: 0 0 0 auto; }
.mb-text { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; color: var(--ink); }
.chest { font-size: 40px; }
.money-bar.full .chest { animation: wiggle .5s ease-in-out infinite; }

/* ---------------------------------------------------------------- chapter map */
.screen-chapter { background: linear-gradient(180deg, color-mix(in srgb, var(--c1) 30%, #fff), color-mix(in srgb, var(--c2) 25%, #fff)); }
.map-scroll { flex: 1; overflow-y: auto; position: relative; padding: 20px 8% 120px; -webkit-overflow-scrolling: touch; }
.map-path {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 26px 20px;
  max-width: 820px; margin: 0 auto;
}
.map-deco { position: absolute; inset: 0; pointer-events: none; }
.map-deco span { position: absolute; font-size: 54px; opacity: .8; }
.node {
  position: relative; justify-self: center;
  width: min(19vmin, 130px); aspect-ratio: 1; border-radius: 50%;
  background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 8px 0 color-mix(in srgb, var(--c1) 60%, #000 10%), 0 14px 22px rgba(0, 0, 0, .15);
  animation: popIn .4s ease-out backwards; transition: transform .1s;
}
.node:active { transform: translateY(5px); }
.node-label { font-size: min(8vmin, 56px); line-height: 1.2; color: var(--ink); }
.node.game { background: linear-gradient(160deg, #fff7c2, #ffd6ec); }
.node.done { background: linear-gradient(160deg, #fff2a8, #ffc94d); }
.node.locked { background: #e7e4f2; box-shadow: 0 8px 0 #c8c3dd; }
.node.locked .node-label { opacity: .35; }
.node-lock { position: absolute; bottom: -6px; right: -6px; font-size: 30px; }
.node-stars { position: absolute; bottom: -14px; font-size: 22px; color: #f59e0b; letter-spacing: -2px; text-shadow: 0 2px 0 #fff, 0 -1px 0 #fff; white-space: nowrap; }
.node-bill { position: absolute; top: -18px; left: -12px; font-size: 38px; animation: wiggle 1s ease-in-out infinite; }
.node.current { outline: 6px solid #fff; animation: pulseNode 1.4s ease-in-out infinite; }

/* ---------------------------------------------------------------- level */
.screen-level { background: linear-gradient(160deg, color-mix(in srgb, var(--c1) 22%, #fff), color-mix(in srgb, var(--c2) 22%, #fff)); }
.level-top { display: flex; align-items: center; gap: 14px; padding: 10px 16px; padding-left: calc(var(--fab) + 26px); }
.step-dots { flex: 1; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.step-dots span {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-size: 26px;
  background: rgba(255, 255, 255, .6); filter: grayscale(1); opacity: .55; transition: .3s;
}
.step-dots span.now { background: #fff; filter: none; opacity: 1; transform: scale(1.18); box-shadow: var(--shadow); }
.step-dots span.done { background: #bbf7d0; filter: none; opacity: 1; }
.level-label { width: 62px; height: 62px; border-radius: 20px; background: #fff; display: grid; place-items: center; font-size: 34px; box-shadow: var(--shadow); }
.rec-hint { text-align: center; font-size: .9rem; color: var(--ink2); background: rgba(255, 255, 255, .6); margin: 0 auto; padding: 4px 14px; border-radius: 20px; direction: ltr; }
.stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 8px 24px 16px; position: relative; }
.stage.enter > * { animation: slideIn .35s ease-out; }
.stage > * { width: 100%; height: 100%; }

.prompt-row { display: flex; align-items: center; justify-content: center; gap: 22px; min-height: 120px; }
.step-foot { display: flex; align-items: center; justify-content: center; gap: 20px; }
.round-dots { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }
.round-dots span { width: 16px; height: 16px; border-radius: 50%; background: rgba(255, 255, 255, .8); }
.round-dots span.done { background: var(--green); }
.round-dots span.now { background: var(--yellow); transform: scale(1.3); }

/* meet a letter */
.meet { display: flex; flex-direction: column; align-items: center; justify-content: space-evenly; }
.meet-main { display: flex; align-items: center; justify-content: center; gap: 6vw; flex-wrap: wrap; }
.big-letter {
  font-size: min(32vmin, 300px); line-height: 1.3; min-width: min(42vmin, 360px);
  padding: 0 30px; border-radius: 48px; background: #fff; color: var(--purple);
  box-shadow: 0 10px 0 #ddd6fe, 0 18px 40px rgba(0, 0, 0, .12);
}
.example { display: flex; flex-direction: column; align-items: center; padding: 14px 28px; border-radius: 36px; background: rgba(255, 255, 255, .85); box-shadow: var(--shadow); }
.example .emoji { font-size: min(16vmin, 130px); line-height: 1.15; }
.example .word { font-size: min(9vmin, 70px); line-height: 1.5; }
.hl { color: var(--pink); }
.forms { display: flex; gap: 18px; font-size: min(7vmin, 52px); color: var(--ink2); direction: rtl; }
.forms span { background: rgba(255, 255, 255, .7); border-radius: 18px; padding: 0 18px; line-height: 1.6; }

/* listen & find */
.find { display: flex; flex-direction: column; align-items: center; justify-content: space-evenly; }
.read-card { font-size: min(14vmin, 110px); line-height: 1.4; background: #fff; padding: 0 40px; border-radius: 36px; box-shadow: var(--shadow); }
.read-card.long { font-size: min(9vmin, 70px); }
.look-card { font-size: min(13vmin, 100px); line-height: 1.4; background: #fff; padding: 0 34px; border-radius: 30px; box-shadow: var(--shadow); }
.choices { display: flex; gap: 4vw; justify-content: center; flex-wrap: wrap; }
.choice {
  --cc: var(--c0);
  width: min(24vmin, 190px); aspect-ratio: 1; border-radius: 50%;
  font-size: min(13vmin, 100px); line-height: 1; color: #fff;
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--cc) 40%, #fff), var(--cc) 60%);
  box-shadow: 0 9px 0 color-mix(in srgb, var(--cc) 70%, #000), 0 16px 26px rgba(0, 0, 0, .15);
  animation: float 3s ease-in-out infinite;
  display: grid; place-items: center; padding-bottom: .1em;
  text-shadow: 0 3px 0 rgba(0, 0, 0, .15);
}
.choice.long { font-size: min(7vmin, 52px); }
.choice.pic { background: #fff; box-shadow: 0 9px 0 #e0dbf5, 0 16px 26px rgba(0, 0, 0, .12); font-size: min(14vmin, 110px); }
.choice.right { animation: popOut .5s ease-out forwards; }
.c0 { --cc: var(--c0); } .c1 { --cc: var(--c1); } .c2 { --cc: var(--c2); } .c3 { --cc: var(--c3); } .c4 { --cc: var(--c4); } .c5 { --cc: var(--c5); }

/* trace */
.trace { display: flex; align-items: center; gap: 18px; }
.trace-side { display: flex; flex-direction: column; gap: 16px; align-items: center; }
.trace-pad {
  flex: 1; height: 100%; max-height: 640px; min-height: 240px;
  background: #fff; border-radius: 36px; box-shadow: 0 10px 0 #e4defc, 0 16px 40px rgba(0, 0, 0, .12);
  touch-action: none; overflow: hidden;
}
.trace-pad canvas { display: block; touch-action: none; }

/* say it */
.say { display: flex; flex-direction: column; align-items: center; justify-content: space-evenly; }
.say-card { display: flex; align-items: center; gap: 30px; background: #fff; border-radius: 40px; padding: 6px 40px; box-shadow: var(--shadow); }
.say-emoji { font-size: min(14vmin, 110px); }
.say-text { font-size: min(18vmin, 150px); line-height: 1.4; color: var(--purple); }
.say-text.long { font-size: min(9vmin, 72px); }
.say-controls { display: flex; align-items: center; gap: 30px; }
.mic-btn {
  position: relative; width: 136px; height: 136px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff9ac6, #ff4f9a);
  box-shadow: 0 9px 0 #c2185b, 0 16px 30px rgba(255, 79, 154, .4);
  display: grid; place-items: center;
}
.mic-icon { font-size: 66px; position: relative; z-index: 2; }
.mic-level { position: absolute; inset: 0; border-radius: 50%; background: rgba(255, 79, 154, .3); z-index: 0; transition: transform .08s; }
.mic-btn.rec { background: radial-gradient(circle at 35% 30%, #ff8080, #ef4444); box-shadow: 0 9px 0 #991b1b, 0 0 0 10px rgba(239, 68, 68, .25); }
.mic-btn.rec .mic-icon { animation: wiggle .5s ease-in-out infinite; }
.say-stars { display: flex; gap: 12px; min-height: 76px; justify-content: center; align-items: center; }
.say-stars span { font-size: 70px; color: #ddd8f0; }
.say-stars span.on { color: #fbbf24; animation: starPop .5s ease-out backwards; text-shadow: 0 4px 0 #d97706; }

/* syllables */
.meet-syl { display: flex; flex-direction: column; align-items: center; justify-content: space-evenly; gap: 10px; }
.big-con { font-size: min(14vmin, 110px); line-height: 1.3; background: #fff; border-radius: 30px; padding: 0 34px; color: var(--purple); box-shadow: var(--shadow); }
.syl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.syl-card {
  display: flex; align-items: center; gap: 12px; padding: 4px 22px; border-radius: 28px;
  background: #fff; box-shadow: 0 7px 0 color-mix(in srgb, var(--cc) 60%, #fff), 0 12px 20px rgba(0, 0, 0, .08);
  transition: transform .2s, background .2s;
}
.syl-card .parts { font-size: min(6vmin, 44px); color: var(--ink2); display: flex; gap: 6px; align-items: center; }
.syl-card .parts i { font-style: normal; font-family: 'Fredoka'; color: var(--cc); }
.syl-card .eq { font-size: 34px; color: var(--cc); font-weight: 700; }
.syl-card .syl { font-size: min(10vmin, 78px); color: var(--cc); line-height: 1.4; }
.syl-card.lit { background: color-mix(in srgb, var(--cc) 20%, #fff); transform: scale(1.08); }

/* build */
.spell { display: flex; flex-direction: column; align-items: center; justify-content: space-evenly; }
.spell-pic { font-size: min(15vmin, 120px); }
.preview { font-size: min(10vmin, 80px); min-height: 1.5em; line-height: 1.5; color: var(--purple); }
.slots { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.slot {
  min-width: min(15vmin, 110px); height: min(15vmin, 110px); padding: 0 10px; border-radius: 24px;
  border: 5px dashed rgba(139, 92, 246, .45); background: rgba(255, 255, 255, .55);
  font-size: min(9vmin, 70px); line-height: 1;
}
.slots.words .slot { min-width: min(18vmin, 150px); font-size: min(6.5vmin, 50px); }
.slot.full { border: 5px solid #fff; background: #fff; box-shadow: var(--shadow); color: var(--purple); }
.slot.bad { background: #ffe4e6; color: var(--red); }
.slots.win .slot { background: #dcfce7; color: #15803d; animation: bounceIn .5s; }
.tray { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.tile {
  min-width: min(14vmin, 100px); height: min(14vmin, 100px); padding: 0 12px; border-radius: 24px;
  font-size: min(9vmin, 66px); line-height: 1; color: #fff;
  background: var(--cc); box-shadow: 0 7px 0 color-mix(in srgb, var(--cc) 70%, #000);
  transition: transform .1s, opacity .2s;
}
.tray.words .tile { font-size: min(6vmin, 46px); min-width: min(16vmin, 140px); }
.tile:active { transform: translateY(4px); }
.tile.used { opacity: .18; transform: scale(.9); pointer-events: none; }

/* meet words / sentences */
.meet-card { display: flex; flex-direction: column; align-items: center; justify-content: space-evenly; }
.card-emoji { font-size: min(22vmin, 170px); line-height: 1.1; filter: drop-shadow(0 10px 8px rgba(0, 0, 0, .12)); }
.card-text { font-size: min(14vmin, 110px); line-height: 1.4; background: #fff; padding: 0 40px; border-radius: 36px; box-shadow: var(--shadow); cursor: pointer; }
.card-text.sentence { font-size: min(9vmin, 70px); display: flex; gap: 14px; padding: 6px 24px; background: transparent; box-shadow: none; }
.word-chip { background: #fff; border-radius: 26px; padding: 0 22px; box-shadow: var(--shadow); line-height: 1.5; }
.letter-row { display: flex; gap: 10px; }
.mini-tile { width: min(10vmin, 74px); height: min(10vmin, 74px); border-radius: 18px; color: #fff; font-size: min(6vmin, 46px); background: var(--cc); box-shadow: 0 5px 0 color-mix(in srgb, var(--cc) 70%, #000); }

/* balloons */
.balloons { display: flex; flex-direction: column; }
.balloon-area { position: relative; flex: 1; overflow: hidden; border-radius: 30px; }
.balloon {
  position: absolute; bottom: -200px; width: min(19vmin, 150px); aspect-ratio: .82; border-radius: 50% 50% 48% 48%;
  background: radial-gradient(circle at 32% 28%, color-mix(in srgb, var(--cc) 35%, #fff), var(--cc) 65%);
  box-shadow: inset -10px -14px 0 rgba(0, 0, 0, .08);
  display: grid; place-items: center; color: #fff; font-size: min(9vmin, 70px);
  animation: rise linear infinite;
  touch-action: none;
}
.balloon.long { font-size: min(5vmin, 40px); }
.balloon span { text-shadow: 0 3px 0 rgba(0, 0, 0, .18); line-height: 1; padding-bottom: .15em; }
.balloon::after { content: ''; position: absolute; top: 100%; left: 50%; width: 2px; height: 70px; background: rgba(43, 35, 80, .35); }
.balloon::before { content: ''; position: absolute; top: calc(100% - 4px); left: calc(50% - 8px); border: 8px solid transparent; border-bottom-color: var(--cc); }
.balloon.popped { animation: none; transform: scale(1.4); opacity: 0; transition: .25s; }
.balloon.wobble { animation-play-state: paused; filter: brightness(.9); }
.balloon.wobble span { animation: shake .4s; display: inline-block; }

/* memory */
.memory { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.memory-grid { display: grid; grid-template-columns: repeat(4, min(19vmin, 150px)); gap: 14px; }
.memory-grid.many { grid-template-columns: repeat(4, min(16vmin, 130px)); }
.mcard { aspect-ratio: 1; perspective: 700px; }
.mcard-inner { position: relative; width: 100%; height: 100%; transition: transform .45s; transform-style: preserve-3d; }
.mcard.open .mcard-inner, .mcard.matched .mcard-inner { transform: rotateY(180deg); }
.mcard-back, .mcard-front { position: absolute; inset: 0; border-radius: 24px; display: grid; place-items: center; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.mcard-back { background: linear-gradient(135deg, var(--purple), var(--pink)); color: #fff; font-size: 46px; box-shadow: 0 7px 0 #6d28d9; }
.mcard-front { background: #fff; transform: rotateY(180deg); font-size: min(9vmin, 70px); line-height: 1.2; box-shadow: 0 7px 0 #e4defc; padding: 4px; }
.mcard-front.pic { font-size: min(10vmin, 80px); }
.mcard-front.long { font-size: min(3.6vmin, 28px); }
.mcard.matched .mcard-front { background: #dcfce7; box-shadow: 0 7px 0 #86efac; }

/* result */
.result { display: grid; place-items: center; }
.result-card { background: #fff; border-radius: 44px; padding: 20px 50px 26px; box-shadow: 0 12px 0 #e4defc, 0 20px 50px rgba(0, 0, 0, .15); text-align: center; animation: popIn .4s ease-out; max-width: 92%; }
.result-title { font-size: min(13vmin, 96px); color: var(--purple); line-height: 1.4; }
.result-stars { display: flex; justify-content: center; gap: 14px; }
.result-stars span { font-size: min(14vmin, 100px); color: #e6e2f3; }
.result-stars span.on.pop { color: #fbbf24; animation: starPop .5s ease-out; text-shadow: 0 6px 0 #d97706; }
.sticker-won { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 1.4rem; font-weight: 700; color: var(--ink2); margin: 6px 0; }
.sticker-big { font-size: 70px; animation: spinIn .8s ease-out; }
.result-btns { display: flex; justify-content: center; gap: 22px; margin-top: 12px; }
.limit-note { display: flex; flex-direction: column; align-items: center; margin-top: 12px; font-size: 40px; }
.limit-note small { font-size: .95rem; color: var(--ink2); direction: ltr; }

.bill-modal { background: linear-gradient(180deg, #fffbe6, #fff); }
.bill-stage { perspective: 900px; padding: 20px 0; }
.bill-fly { animation: billIn 1.1s cubic-bezier(.2, 1.4, .4, 1) both; cursor: pointer; transition: transform .5s; }
.bill-fly img { width: min(78vw, 480px); border-radius: 10px; box-shadow: 0 14px 30px rgba(0, 0, 0, .3); display: block; margin: 0 auto; }
.bill-fly.flip { transform: rotateY(360deg); }
.bill-label { font-size: 2.6rem; font-weight: 700; color: #15803d; margin: 6px 0 16px; animation: bounceIn .8s .6s both; direction: ltr; }

/* ---------------------------------------------------------------- wallet */
.wallet { flex: 1; overflow-y: auto; padding: 0 24px 40px; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.wallet-total { text-align: center; background: linear-gradient(180deg, #fff6c9, #ffe27a); border-radius: 36px; padding: 14px 44px; box-shadow: 0 8px 0 #eab308; direction: ltr; }
.wt-amount { font-size: min(10vmin, 72px); font-weight: 700; color: #854d0e; }
.wt-sub { font-size: 1.2rem; color: #a16207; }
.bill-pile { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; max-width: 1100px; }
.bill { width: min(40vw, 250px); transform: rotate(var(--r)); animation: popIn .4s ease-out backwards; transition: transform .4s; }
.bill img { width: 100%; display: block; border-radius: 8px; box-shadow: 0 8px 16px rgba(0, 0, 0, .25); }
.bill.flip { transform: rotate(var(--r)) rotateY(360deg); }
.empty-wallet { font-size: 120px; opacity: .5; }
.wallet-info { background: rgba(255, 255, 255, .8); border-radius: 26px; padding: 14px 22px; direction: ltr; text-align: left; display: flex; flex-direction: column; gap: 8px; max-width: 640px; width: 100%; }
.tchip { display: inline-block; background: #f3f0ff; border-radius: 12px; padding: 2px 10px; margin: 2px 4px; font-size: .95rem; }

/* ---------------------------------------------------------------- stickers & board */
.sticker-book { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 14px; padding: 10px 24px 40px; align-content: start; }
.sticker { position: relative; aspect-ratio: 1; border-radius: 26px; background: #fff; font-size: 58px; display: grid; place-items: center; box-shadow: var(--shadow); animation: popIn .35s ease-out backwards; }
.sticker sup { position: absolute; top: 6px; left: 10px; font-size: 1rem; font-weight: 700; color: var(--purple); }
.sticker.empty { background: rgba(255, 255, 255, .4); box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .8); color: rgba(43, 35, 80, .25); font-size: 40px; }
.board-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 14px; padding: 8px 24px 40px; align-content: start; }
.board-tile { aspect-ratio: 1; border-radius: 28px; color: #fff; background: var(--cc); box-shadow: 0 7px 0 color-mix(in srgb, var(--cc) 70%, #000); display: flex; flex-direction: column; align-items: center; justify-content: center; transition: transform .15s; }
.bt-letter { font-size: 62px; line-height: 1.1; }
.bt-emoji { font-size: 28px; }
.board-tile.lit { transform: scale(1.15); box-shadow: 0 0 0 6px #fff, 0 7px 0 color-mix(in srgb, var(--cc) 70%, #000); }
.board-tile.learned::after { content: '⭐'; position: absolute; transform: translate(42px, -42px); font-size: 22px; }

/* ---------------------------------------------------------------- whiteboard */
.wb-fab {
  position: fixed; left: 14px; top: 12px; z-index: 50;
  width: var(--fab); height: var(--fab); border-radius: 22px; font-size: 36px;
  background: conic-gradient(from 0deg, #ff6fae, #fbbf24, #4ade80, #38bdf8, #a78bfa, #ff6fae);
  box-shadow: 0 6px 0 rgba(0, 0, 0, .18), 0 10px 20px rgba(0, 0, 0, .15);
  display: grid; place-items: center;
}
.wb-fab:active { transform: translateY(3px); }
body.wb-open .wb-fab, body.parent-open .wb-fab { display: none; }
.wb-overlay { position: fixed; inset: 0; z-index: 90; display: flex; background: #f4f1ff; }
.wb-bar { width: 132px; flex: none; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 10px 8px; overflow-y: auto; background: #fff; box-shadow: 4px 0 20px rgba(0, 0, 0, .08); }
.wb-close { width: 64px; height: 64px; border-radius: 20px; background: var(--red); color: #fff; font-size: 30px; box-shadow: 0 5px 0 #be123c; flex: none; }
.wb-tools, .wb-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.wb-tool, .wb-act { width: 54px; height: 54px; border-radius: 16px; font-size: 28px; background: #f3f0ff; display: grid; place-items: center; }
.wb-tool.on { background: #ffe58a; box-shadow: inset 0 0 0 3px #f59e0b; }
.wb-act .ku { font-size: 24px; }
.wb-colors { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.wb-color { width: 34px; height: 34px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .12); }
.wb-color.on { outline: 4px solid var(--ink); outline-offset: 2px; }
.wb-sizes { display: flex; gap: 6px; }
.wb-size { width: 36px; height: 36px; border-radius: 12px; background: #f3f0ff; display: grid; place-items: center; }
.wb-size span { border-radius: 50%; display: block; }
.wb-size.on { box-shadow: inset 0 0 0 3px var(--purple); }
.wb-area { flex: 1; position: relative; margin: 10px; border-radius: 26px; overflow: hidden; background: #fff; box-shadow: 0 6px 20px rgba(0, 0, 0, .1); }
.wb-canvas { display: block; touch-action: none; }
.stamp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px; }
.stamp { font-size: 46px; padding: 8px; border-radius: 18px; background: #f6f3ff; }
.stamp-grid.ku .stamp { font-size: 44px; line-height: 1.3; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.gal-item { position: relative; border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); background: #fff; }
.gal-item img { width: 100%; display: block; aspect-ratio: 4/3; object-fit: contain; }
.gal-del { position: absolute; top: 6px; right: 6px; font-size: 22px; background: #fff; border-radius: 12px; padding: 4px; }
.empty { font-size: 50px; opacity: .5; }

/* ---------------------------------------------------------------- parent area (LTR, English) */
.parent-overlay { position: fixed; inset: 0; z-index: 80; background: #f7f6fb; display: flex; flex-direction: column; font-size: 1rem; user-select: text; -webkit-user-select: text; }
.parent-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .06); flex-wrap: wrap; }
.parent-tabs { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.ptab { padding: 10px 16px; border-radius: 14px; font-weight: 600; background: #f1eefb; }
.ptab.on { background: var(--purple); color: #fff; }
.parent-body { flex: 1; overflow-y: auto; padding: 16px 20px 80px; max-width: 1100px; width: 100%; margin: 0 auto; }
.parent-body h3 { margin: 26px 0 8px; }
.help { background: #eef6ff; border-radius: 16px; padding: 6px 16px; color: #1e3a5f; }
.help p { margin: 8px 0; }
.warn { color: #b91c1c; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.chip { padding: 8px 14px; border-radius: 20px; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .08); }
.chip.on { background: var(--purple); color: #fff; }
.chip b { font-weight: 700; }
.rec-list { display: flex; flex-direction: column; gap: 8px; }
.rec-row { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 16px; padding: 6px 12px; box-shadow: 0 2px 6px rgba(0, 0, 0, .05); }
.rec-row.recording { background: #fff1f2; box-shadow: 0 0 0 3px var(--red); }
.rec-dot { width: 14px; height: 14px; border-radius: 50%; background: #fca5a5; flex: none; }
.rec-dot.ok { background: var(--green); }
.rec-text { flex: 1; display: flex; align-items: center; gap: 10px; font-size: 2rem; line-height: 1.5; }
.rec-emoji { font-size: 1.8rem; }
.rec-en { color: var(--ink2); font-size: .9rem; max-width: 220px; }
.rec-meter { width: 80px; height: 10px; border-radius: 6px; background: #eee; overflow: hidden; flex: none; }
.rec-meter div { height: 100%; width: 0; background: var(--green); transition: width .08s; }
.rec-meter.big { width: 100%; height: 16px; margin: 10px 0; }
.icon-btn { width: 46px; height: 46px; border-radius: 14px; background: #f1eefb; font-size: 20px; flex: none; }
.icon-btn.rec { background: #ffe4ec; }
.qr { text-align: center; }
.qr-prog { color: var(--ink2); font-weight: 600; }
.qr-emoji { font-size: 60px; min-height: 10px; }
.qr-text { font-size: min(18vmin, 140px); line-height: 1.4; color: var(--purple); }
.qr-en { color: var(--ink2); min-height: 1.2em; }
.qr-msg { font-size: 1.6rem; font-weight: 700; min-height: 1.6em; }
.qr-msg.live { color: var(--red); animation: pulse 1s infinite; }
.qr-msg.ok { color: var(--green); }
.qr-opt { display: block; margin: 8px 0; color: var(--ink2); }
.player-card { background: #fff; border-radius: 20px; padding: 14px 18px; margin: 14px 0; box-shadow: 0 2px 8px rgba(0, 0, 0, .06); }
.pc-head { display: flex; align-items: center; gap: 10px; font-size: 1.2rem; flex-wrap: wrap; }
.pc-avatar { font-size: 40px; }
.pc-stat { color: var(--ink2); font-size: .95rem; }
.pc-chapters { margin: 8px 0; }
.pc-wallet { background: #fffbeb; border-radius: 14px; padding: 8px 12px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; margin: 6px 16px 6px 0; }
.toggle input { width: 22px; height: 22px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; font-weight: 600; }
.field input, .field select { font-weight: 400; }
input.num, select, input.wide, .letter-table input, textarea { padding: 8px 12px; border-radius: 12px; border: 2px solid #e4defc; font-size: 1.05rem; background: #fff; }
input.num { width: 220px; }
input.wide { width: 100%; font-size: 1.6rem; }
textarea { width: 100%; font-size: 1.5rem; line-height: 1.6; }
.letter-table { display: flex; flex-direction: column; gap: 6px; }
.lt-head, .lt-row { display: grid; grid-template-columns: 40px 80px 120px 1fr 100px 100px; gap: 8px; align-items: center; }
.lt-head { font-weight: 700; color: var(--ink2); }
.letter-table input.ku { font-size: 1.6rem; padding: 2px 10px; }
.emoji-in { font-size: 1.6rem; text-align: center; }
.info li { margin: 6px 0; }

/* ---------------------------------------------------------------- animations */
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes jump { 0% { transform: translateY(0); } 40% { transform: translateY(-26px) scale(1.05, .95); } 70% { transform: translateY(0) scale(1.08, .92); } 100% { transform: translateY(0); } }
@keyframes sadtilt { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-10deg); } 60% { transform: rotate(8deg); } }
@keyframes flap { from { transform: rotate(0); } to { transform: rotate(-25deg); } }
@keyframes talk { from { transform: scaleY(.6); } to { transform: scaleY(1.4); } }
@keyframes drift { from { transform: translateX(-30vw); } to { transform: translateX(130vw); } }
@keyframes popIn { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.06); opacity: 1; } 100% { transform: scale(1); } }
@keyframes popOut { 0% { transform: scale(1); } 40% { transform: scale(1.3); } 100% { transform: scale(0); opacity: 0; } }
@keyframes bounceIn { 0% { transform: scale(.3); opacity: 0; } 60% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.09); } }
@keyframes pulseNode { 0%, 100% { transform: scale(1); box-shadow: 0 8px 0 rgba(0, 0, 0, .15), 0 0 0 0 rgba(255, 255, 255, .9); } 50% { transform: scale(1.08); box-shadow: 0 8px 0 rgba(0, 0, 0, .15), 0 0 0 16px rgba(255, 255, 255, 0); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-10deg); } 75% { transform: rotate(10deg); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-14px); } 40% { transform: translateX(12px); } 60% { transform: translateX(-8px); } 80% { transform: translateX(6px); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
@keyframes slideIn { from { transform: translateX(-60px); opacity: 0; } }
@keyframes starPop { 0% { transform: scale(0) rotate(-90deg); } 70% { transform: scale(1.35) rotate(10deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes spinIn { 0% { transform: scale(0) rotate(-360deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes billIn { 0% { transform: translateY(-60vh) rotate(-30deg) scale(.4); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes rise { from { transform: translateY(0); } to { transform: translateY(calc(-100vh - 260px)); } }
@keyframes burst { 0% { transform: translate(-50%, -50%) scale(.5); opacity: 1; } 100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.2); opacity: 0; } }
.bounce { animation: bounceIn .45s ease-out; }
.pop-in { animation: popIn .5s ease-out backwards; }
.shake { animation: shake .45s ease-in-out; }

/* ---------------------------------------------------------------- portrait / small screens */
@media (orientation: portrait) {
  .chapters { grid-template-columns: repeat(2, 1fr); gap: 18px; }
  .trace { flex-direction: column; }
  .trace-side { flex-direction: row; }
  .trace-pad { width: 100%; max-height: none; }
  /* upright: exit · hearts · label on the first row, the steps below */
  .level-top { flex-wrap: wrap; row-gap: 6px; }
  .level-top .step-dots { order: 3; flex-basis: 100%; flex-wrap: nowrap; }
  .level-top .hearts { order: 1; margin-inline-start: auto; }
  .level-top .level-label { order: 2; }
  .syl-grid { grid-template-columns: repeat(2, 1fr); }
  .memory-grid, .memory-grid.many { grid-template-columns: repeat(4, min(21vw, 150px)); }
}
@media (max-height: 560px) {
  .instr { width: 60px; height: 60px; font-size: 34px; }
  .prompt-row { min-height: 80px; }
  .speaker.big { width: 86px; height: 86px; font-size: 42px; }
  .next-btn { width: 78px; height: 78px; }
  .mic-btn { width: 106px; height: 106px; }
  .step-dots span { width: 40px; height: 40px; font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  .balloon { animation-duration: 9s !important; animation-iteration-count: infinite !important; }
}

/* numbers & mixed text inside the right-to-left layout */
.mb-text, .ch-count, .pstats, .sticker-won, .node-stars, .pill-t, .wt-sub { direction: ltr; unicode-bidi: isolate; }
.mascot.big .bubble { left: 85%; bottom: 75%; transform: none; }
.mascot.big .bubble::after { left: 18px; }
.skip-btn { margin-top: 20px; width: 56px; height: 56px; border-radius: 50%; background: rgba(255, 255, 255, .7); font-size: 24px; opacity: .7; }
.say-wrong { font-size: 64px; font-weight: 700; color: var(--red); animation: shake .45s; }
.profile-card { position: relative; }
.pc-lock { position: absolute; top: 10px; left: 12px; font-size: 26px; }
.no-players { font-size: 2rem; background: rgba(255, 255, 255, .7); border-radius: 30px; padding: 14px 28px; direction: ltr; }
.music-btn { position: relative; width: 56px; height: 56px; border-radius: 50%; background: #fff; box-shadow: var(--shadow); font-size: 28px; display: grid; place-items: center; flex: none; }
.music-btn.off { opacity: .6; }
.music-btn.off::after { content: ''; position: absolute; width: 70%; height: 5px; border-radius: 3px; background: var(--red); transform: rotate(-45deg); }
.corner-music { position: absolute; right: 16px; top: 14px; z-index: 3; }
.rec-dot.builtin { background: var(--blue); }
.rec-row { flex-wrap: wrap; }
.rec-test { flex-basis: 100%; text-align: right; font-size: .95rem; color: var(--ink2); min-height: 0; }
.rec-test:empty { display: none; }
.rec-test.ok { color: #15803d; font-weight: 600; }
.rec-test.bad { color: #b91c1c; font-weight: 600; }

/* ---------------------------------------------------------------- hearts & game over */
.hearts { display: flex; gap: 2px; flex: none; direction: ltr; }
.heart { display: inline-block; font-size: 30px; line-height: 1.1; transition: filter .4s, opacity .4s; }
.heart.lost { filter: grayscale(1) brightness(1.3); opacity: .4; animation: heartLose .7s ease-out; }
.stage.blocked { pointer-events: none; }
.result-card.over { padding-top: 10px; }
.over-heart { font-size: min(32vmin, 170px); line-height: 1.15; animation: heartBreak .9s ease-out; }
.over-hearts { display: flex; justify-content: center; gap: 6px; font-size: 32px; filter: grayscale(1); opacity: .35; direction: ltr; }
@keyframes heartLose { 0% { transform: scale(1); filter: none; opacity: 1; } 30% { transform: scale(1.7) rotate(-14deg); filter: none; opacity: 1; } 60% { transform: scale(.8) rotate(8deg); } 100% { transform: scale(1); } }
@keyframes heartBreak { 0% { transform: scale(.3); opacity: 0; } 50% { transform: scale(1.2); opacity: 1; } 65% { transform: rotate(-10deg); } 80% { transform: rotate(8deg); } 100% { transform: none; } }

/* microphone test (parent ▸ settings) */
.mic-out { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; }
.mic-line { color: var(--ink2); }
.mic-line.ok { color: #15803d; font-weight: 600; }
.mic-line.bad { color: #b91c1c; font-weight: 600; }

/* phone held sideways: ask to turn it (the game is made for upright phones) */
.rotate-hint { display: none; }
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  body:not(.parent-open) .rotate-hint {
    display: grid; place-items: center; position: fixed; inset: 0; z-index: 400;
    background: linear-gradient(180deg, var(--sky1), var(--sky2)); font-size: 90px;
  }
  .rotate-hint span { display: inline-block; animation: turnPhone 2s ease-in-out infinite; }
}
@keyframes turnPhone { 0%, 30% { transform: rotate(-90deg); } 60%, 100% { transform: rotate(0); } }

/* ---------------------------------------------------------------- phones (upright) */
@media (max-width: 600px) {
  :root { --fab: 48px; --r: 20px; }
  .wb-fab { left: 10px; top: 10px; border-radius: 16px; font-size: 26px; }
  .topbar { gap: 8px; padding: 10px 10px; padding-left: calc(var(--fab) + 18px); flex-wrap: wrap; }
  .back-btn, .x-btn { width: 48px; height: 48px; border-radius: 16px; font-size: 22px; }
  .back-btn svg { width: 28px; height: 28px; }
  .pill { padding: 5px 11px; font-size: 1.05rem; gap: 4px; }
  .pill-i { font-size: 1.2rem; }
  .music-btn { width: 46px; height: 46px; font-size: 22px; }
  .lock-mini { width: 40px; height: 46px; font-size: 22px; }
  .map-title { font-size: 1.15rem; }
  .instr { width: 56px; height: 56px; font-size: 30px; border-radius: 18px; }
  .speaker { width: 60px; height: 60px; font-size: 28px; }
  .speaker.big { width: 92px; height: 92px; font-size: 44px; }
  .round-btn { width: 62px; height: 62px; font-size: 28px; }
  .round-btn.big { width: 78px; height: 78px; font-size: 38px; }
  .next-btn { width: 78px; height: 78px; }
  .next-btn svg { width: 44px; height: 44px; }
  .prompt-row { gap: 14px; min-height: 0; }
  .mascot.corner { width: 58px; left: 6px; bottom: 4px; }
  .mascot.corner .bubble { font-size: 22px; padding: 6px 12px; }

  /* home: name, music & lock on the first row – stars, money, stickers below */
  .screen-home .topbar .me { order: 0; }
  .screen-home .topbar .music-btn { order: 1; margin-inline-start: auto; }
  .screen-home .topbar .lock-mini { order: 1; }
  .screen-home .topbar .spacer { order: 2; flex-basis: 100%; height: 0; }
  .screen-home .topbar .pill { order: 3; }
  .me { padding: 4px 14px 4px 6px; }
  .me .avatar { font-size: 32px; }
  .me .pname { font-size: 1.1rem; }
  .chapters { gap: 14px; padding: 8px 14px; }
  .chapter-card { border-radius: 26px; padding: 14px 8px 12px; }
  .ch-num { width: 32px; height: 32px; font-size: 1.05rem; top: 8px; right: 10px; }
  .ch-title { font-size: 1.1rem; }
  .ch-lock { font-size: 54px; }
  .home-foot { padding: 0 12px 12px; gap: 8px; }
  .money-bar { padding: 8px 12px; gap: 10px; }
  .mini-bill { height: 34px; }
  .chest { font-size: 32px; }

  /* chapter map */
  .map-scroll { padding: 14px 4% 100px; }
  .map-path { gap: 22px 10px; }
  .node-stars { font-size: 17px; bottom: -12px; }
  .node-bill { font-size: 28px; top: -14px; left: -8px; }
  .map-deco span { font-size: 38px; }

  /* level: exit · hearts · label on the first row, the steps below */
  .level-top { flex-wrap: wrap; gap: 6px 10px; padding: 8px 10px 4px; padding-left: calc(var(--fab) + 18px); }
  .level-top .step-dots { order: 3; flex-basis: 100%; gap: 5px; flex-wrap: nowrap; }
  .level-top .hearts { order: 1; margin-inline-start: auto; }
  .level-top .level-label { order: 2; }
  .step-dots span { width: 32px; height: 32px; font-size: 17px; }
  .step-dots span.now { transform: scale(1.12); }
  .level-label { width: 48px; height: 48px; border-radius: 16px; font-size: 26px; }
  .heart { font-size: 24px; }
  .stage { padding: 6px 12px 64px; }
  .stage > * { gap: 10px; }

  .big-letter { font-size: min(38vw, 190px); min-width: min(44vw, 200px); padding: 0 18px; border-radius: 34px; }
  .meet-main { gap: 14px; }
  .example { padding: 8px 16px; border-radius: 26px; }
  .example .emoji { font-size: min(18vw, 84px); }
  .example .word { font-size: min(10vw, 46px); }
  .forms { gap: 8px; font-size: min(9vw, 40px); flex-wrap: wrap; justify-content: center; }
  .forms span { padding: 0 12px; border-radius: 14px; }

  .choices { gap: 12px; }
  .choice { width: min(27vw, 120px); font-size: min(14vw, 62px); }
  .choice.long { font-size: min(7.5vw, 34px); }
  .choice.pic { font-size: min(15vw, 64px); }
  .read-card { font-size: min(17vw, 76px); padding: 0 24px; border-radius: 26px; }
  .read-card.long { font-size: min(10vw, 44px); }
  .look-card { font-size: min(16vw, 70px); padding: 0 22px; }

  .trace { gap: 10px; }
  .trace-side { gap: 12px; }
  .trace-pad { border-radius: 26px; min-height: 200px; max-height: none; }

  .say-card { gap: 14px; padding: 4px 22px; border-radius: 28px; max-width: 100%; }
  .say-emoji { font-size: min(16vw, 70px); }
  .say-text { font-size: min(22vw, 100px); }
  .say-text.long { font-size: min(10vw, 44px); }
  .say-controls { gap: 16px; }
  .mic-btn { width: 108px; height: 108px; }
  .mic-icon { font-size: 52px; }
  .say-stars span { font-size: 54px; }
  .say-stars { min-height: 60px; }
  .skip-btn { margin-top: 0; }

  .big-con { font-size: min(16vw, 70px); padding: 0 22px; }
  .syl-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .syl-card { padding: 2px 12px; gap: 6px; border-radius: 22px; justify-content: center; }
  .syl-card .parts { font-size: min(6.5vw, 28px); }
  .syl-card .eq { font-size: 22px; }
  .syl-card .syl { font-size: min(11vw, 48px); }

  .spell-pic { font-size: min(18vw, 80px); }
  .preview { font-size: min(13vw, 56px); }
  .slots, .tray { gap: 8px; }
  .slot { min-width: min(17vw, 74px); height: min(17vw, 74px); border-width: 4px; border-radius: 18px; font-size: min(10vw, 44px); }
  .slots.words .slot { min-width: min(24vw, 110px); font-size: min(7vw, 30px); }
  .tile { min-width: min(16vw, 68px); height: min(16vw, 68px); border-radius: 18px; font-size: min(10vw, 42px); }
  .tray.words .tile { font-size: min(7vw, 30px); min-width: min(22vw, 100px); }

  .card-emoji { font-size: min(30vw, 130px); }
  .card-text { font-size: min(17vw, 76px); padding: 0 26px; border-radius: 26px; }
  .card-text.sentence { font-size: min(10vw, 44px); gap: 8px; flex-wrap: wrap; justify-content: center; padding: 4px 0; }
  .word-chip { padding: 0 14px; border-radius: 20px; }
  .letter-row { gap: 6px; flex-wrap: wrap; justify-content: center; }
  .mini-tile { width: min(13vw, 56px); height: min(13vw, 56px); font-size: min(8vw, 34px); border-radius: 14px; }

  .balloon { width: min(23vw, 100px); font-size: min(11vw, 48px); }
  .balloon.long { font-size: min(6vw, 28px); }
  .memory-grid, .memory-grid.many { grid-template-columns: repeat(4, min(21vw, 92px)); gap: 10px; }
  .mcard-back { font-size: 32px; border-radius: 18px; }
  .mcard-front { font-size: min(10vw, 44px); border-radius: 18px; }
  .mcard-front.pic { font-size: min(12vw, 52px); }
  .mcard-front.long { font-size: min(4.6vw, 20px); }

  .result-card { padding: 14px 22px 20px; border-radius: 34px; }
  .result-title { font-size: min(15vw, 64px); }
  .result-stars span { font-size: min(16vw, 66px); }
  .sticker-big { font-size: 56px; }
  .result-btns { gap: 14px; }
  .limit-note { font-size: 30px; }

  .wallet { padding: 0 14px 30px; gap: 14px; }
  .wallet-total { padding: 10px 28px; }
  .bill { width: min(42vw, 180px); }
  .bill-label { font-size: 2rem; }
  .sticker-book { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px; padding: 8px 14px 30px; }
  .sticker { font-size: 44px; border-radius: 20px; }
  .board-grid { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 10px; padding: 6px 14px 30px; }
  .board-tile { border-radius: 20px; }
  .bt-letter { font-size: 42px; }
  .bt-emoji { font-size: 20px; }
  .board-tile.learned::after { transform: translate(28px, -28px); font-size: 16px; }

  .modal-back { padding: 10px; }
  .modal-box { padding: 18px 14px; border-radius: 26px; }
  .kp { width: 100%; max-width: 340px; }
  .avatar-grid { grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 6px; }
  .av { font-size: 34px; border-radius: 16px; }
  .color-row { gap: 8px; flex-wrap: wrap; }
  .cl { width: 42px; height: 42px; }

  /* whiteboard: tools along the bottom */
  .wb-overlay { flex-direction: column; }
  .wb-area { order: 1; margin: 8px 8px 0; border-radius: 20px; }
  .wb-bar {
    order: 2; width: auto; flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center;
    gap: 8px 10px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); overflow: visible;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, .08);
  }
  .wb-close { width: 48px; height: 48px; border-radius: 16px; font-size: 22px; }
  .wb-tools, .wb-actions { display: flex; gap: 5px; }
  .wb-tool, .wb-act { width: 44px; height: 44px; border-radius: 14px; font-size: 22px; }
  .wb-colors { grid-template-columns: repeat(6, 1fr); gap: 5px; }
  .wb-color { width: 28px; height: 28px; }
  .wb-sizes { gap: 4px; }
  .wb-size { width: 32px; height: 32px; }

  /* parent area */
  .parent-head { padding: 8px 10px; gap: 8px; flex-wrap: nowrap; }
  .parent-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .parent-tabs::-webkit-scrollbar { display: none; }
  .ptab { padding: 8px 10px; white-space: nowrap; font-size: .95rem; }
  .parent-head .btn { padding: 8px 10px; font-size: .9rem; white-space: nowrap; }
  .parent-body { padding: 12px 12px 80px; }
  .rec-text { font-size: 1.6rem; }
  .rec-en { max-width: none; flex-basis: 100%; order: 3; }
  .rec-meter { width: 50px; }
  .icon-btn { width: 40px; height: 40px; }
  .lt-head, .lt-row { grid-template-columns: 22px 48px 64px 1fr 46px 58px; gap: 4px; }
  .lt-head { font-size: .75rem; }
  .letter-table input.ku { font-size: 1.25rem; padding: 2px 4px; width: 100%; min-width: 0; }
  .emoji-in { font-size: 1.2rem; width: 100%; min-width: 0; padding: 2px; }
  .lt-row .icon-btn { width: 28px; height: 32px; font-size: 14px; }
  input.num { width: 100%; max-width: 240px; }
  .player-card { padding: 12px; }
}

/* very small phones */
@media (max-width: 360px) {
  .step-dots span { width: 28px; height: 28px; font-size: 15px; }
  .heart { font-size: 20px; }
  .pill { padding: 4px 8px; font-size: .95rem; }
}

/* ---------------------------------------------------------------- money per chapter (parent settings + home bar) */
.money-ch { background: #fff; border-radius: 16px; padding: 4px 16px 10px; margin: 10px 0; box-shadow: 0 2px 6px rgba(0, 0, 0, .05); }
.money-ch .mc-title { font-weight: 700; margin-top: 8px; }
.money-ch .row { margin: 8px 0; gap: 10px 16px; }
.money-ch input.num { width: 84px; }
.mb-ch { font-size: 30px; }
.emo { white-space: nowrap; display: inline-block; }
