@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;
  /* place value, the same on every screen: ones blue, tens pink, hundreds yellow */
  --p-o: #e2f1fd;
  --p-t: #fde7f1;
  --p-h: #fdf2cf;
  --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;
  /* full screen reaches the edges of the glass (viewport-fit=cover): what a camera hole, a notch or the home bar covers */
  --sa-t: env(safe-area-inset-top, 0px);
  --sa-r: env(safe-area-inset-right, 0px);
  --sa-b: env(safe-area-inset-bottom, 0px);
  --sa-l: env(safe-area-inset-left, 0px);
}

* { 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; }
/* Kurdish words (digits and signs in them use the round Latin font) */
.ku { font-family: 'Naskh', 'Fredoka', 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: calc(12px + var(--sa-t)) calc(16px + var(--sa-r)) 12px; padding-left: calc(var(--fab) + 26px + var(--sa-l));
  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; justify-content: center; gap: 6px;
  min-width: 56px; min-height: 56px;   /* (💰 📒 💯 lead to the wallet, the sticker book and the number board) */
  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: calc(14px + var(--sa-r)); bottom: calc(12px + var(--sa-b)); z-index: 2; }
.map-title { display: flex; flex-direction: column; justify-content: center; min-width: 0; font-weight: 700; font-size: 1.4rem; line-height: 1.2; }
.mt-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mt-icon { font-size: 1.5em; line-height: 1.1; flex: none; }
.mt-main .ku { font-size: 1.3rem; line-height: 1.5; }
.mt-sub { font-size: 1rem; line-height: 1.3; 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: calc(10px + var(--sa-l)); bottom: calc(6px + var(--sa-b)); 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 */
/* (more players than fit – a phone shows one card a row: the screen scrolls, from the top instead of cut at both ends) */
.screen-profiles { align-items: center; justify-content: center; justify-content: safe center; overflow-y: auto; gap: 1.5vh; padding: calc(16px + var(--sa-t)) calc(16px + var(--sa-r)) calc(16px + var(--sa-b)) calc(16px + var(--sa-l)); }
.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: calc(16px + var(--sa-t)) calc(16px + var(--sa-r)) calc(16px + var(--sa-b)) calc(16px + var(--sa-l));
  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 - var(--sa-t) - var(--sa-b)); 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: calc(30px + var(--sa-b)); 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 (the 11 chapters of the book + homework) */
.me { --pc: var(--purple); 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; }
/* the chapters scroll when they do not all fit (and stay in the middle when they do) */
.chapters-wrap {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  position: relative; z-index: 1;
  display: flex; flex-direction: column; padding: 16px calc(24px + var(--sa-r)) 14px calc(24px + var(--sa-l));
}
.chapters { margin: auto; width: 100%; max-width: 1240px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px 20px; }
.chapter-card {
  position: relative; min-width: 0; border-radius: 30px; padding: 12px 14px;
  background: linear-gradient(160deg, var(--c1), var(--c2));
  color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, .18), 0 14px 26px rgba(0, 0, 0, .14);
  animation: popIn .45s ease-out backwards; transition: transform .12s;
}
.chapter-card:active { transform: translateY(6px); }
.chapter-card.locked { filter: grayscale(.75) brightness(.95); }
/* the chapter he is working on: a white ring that glows, and his avatar on the corner */
.chapter-card.current { outline: 5px solid #fff; outline-offset: 2px; animation: popIn .45s ease-out backwards, glow 1.8s ease-in-out infinite; }
.ch-me { position: absolute; top: -14px; left: -10px; font-size: 40px; line-height: 1; pointer-events: none; filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .2)); animation: bob 1.6s ease-in-out infinite; }
.ch-top { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; max-width: 100%; }
.ch-icon { font-size: min(7.5vmin, 58px); line-height: 1.1; filter: drop-shadow(0 6px 6px rgba(0, 0, 0, .15)); }
.ch-sample { max-width: 100%; overflow: hidden; background: rgba(255, 255, 255, .93); color: var(--ink); border-radius: 16px; padding: 2px 12px; box-shadow: 0 4px 0 rgba(0, 0, 0, .12); }
.chapter-card .ch-eq { font-size: min(4vmin, 30px); }
.ch-name { display: flex; align-items: center; justify-content: center; gap: 8px; max-width: 100%; }
.ch-num { flex: none; min-width: 34px; height: 34px; padding: 0 6px; border-radius: 17px; background: rgba(255, 255, 255, .3); display: grid; place-items: center; font-weight: 700; font-size: 1.15rem; }
.ch-title { min-width: 0; font-size: min(3vmin, 1.3rem); line-height: 1.5; text-align: center; text-shadow: 0 2px 0 rgba(0, 0, 0, .15); }
.ch-foot { display: flex; align-items: center; gap: 10px; width: 92%; }
.ch-progress { flex: 1; height: 12px; border-radius: 10px; background: rgba(255, 255, 255, .35); overflow: hidden; }
.ch-progress div { height: 100%; background: #fff; border-radius: 10px; }
.ch-count { font-weight: 600; font-size: 1rem; white-space: nowrap; }
.ch-lock { position: absolute; inset: 0; display: grid; place-items: center; font-size: 56px; background: rgba(255, 255, 255, .15); border-radius: inherit; }
.home-foot { display: flex; align-items: flex-end; justify-content: center; gap: 20px; padding: 0 calc(24px + var(--sa-r)) calc(14px + var(--sa-b)) calc(24px + var(--sa-l)); 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 calc(8% + var(--sa-r)) calc(120px + var(--sa-b)) calc(8% + var(--sa-l)); -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); max-width: 90%; display: flex; justify-content: center; }
/* a little sum as the label: the longer it is, the smaller */
.node .node-eq { font-size: min(4.6vmin, 30px); }
.node .node-eq.len-s { font-size: min(6.2vmin, 42px); }
.node .node-eq.len-l { font-size: min(3.6vmin, 23px); }
.node.game { background: linear-gradient(160deg, #fff7c2, #ffd6ec); }
/* the chapter test: a trophy – gold with a gold ring */
.node.test { background: linear-gradient(160deg, #fffbeb, #fde68a); outline: 6px solid #fbbf24; outline-offset: 4px; }
.node.done { background: linear-gradient(160deg, #fff2a8, #ffc94d); }
.node.test.done { background: linear-gradient(160deg, #fde68a, #f59e0b); }
.node.locked { background: #e7e4f2; box-shadow: 0 8px 0 #c8c3dd; }
.node.test.locked { outline-color: #d9d4ea; }
.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; }
.node.test.current { outline-color: #fbbf24; }

/* ---------------------------------------------------------------- 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: calc(10px + var(--sa-t)) calc(16px + var(--sa-r)) 10px; padding-left: calc(var(--fab) + 26px + var(--sa-l)); }
.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); }
.level-label.sum { width: auto; min-width: 62px; padding: 0 12px; }
.level-label .lvl-eq { font-size: 24px; }
.level-label .lvl-eq.len-l { font-size: 19px; }
.stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 8px calc(24px + var(--sa-r)) calc(16px + var(--sa-b)) calc(24px + var(--sa-l)); 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); }

/* pick the right one */
.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); }

/* 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 calc(24px + var(--sa-r)) calc(40px + var(--sa-b)) calc(24px + var(--sa-l)); 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; }
/* (the tilt is its own property: the pop-in animation and the flip use transform) */
.bill { width: min(40vw, 250px); 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: 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 */
.sticker-book { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 14px; padding: 10px calc(24px + var(--sa-r)) calc(40px + var(--sa-b)) calc(24px + var(--sa-l)); 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; }

/* ---------------------------------------------------------------- number board (1 – 1000) */
.nb {
  flex: 1; min-height: 0; display: grid; gap: 12px 18px; padding: 0 calc(24px + var(--sa-r)) calc(14px + var(--sa-b)) calc(24px + var(--sa-l));
  grid-template-columns: minmax(0, 1fr) minmax(280px, 34%);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "pages pages" "chart side" "chart tools";
}
.nb-pages { grid-area: pages; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.nb-page { flex: none; display: inline-flex; align-items: center; justify-content: center; min-height: 56px; padding: 8px 14px; border-radius: 18px; background: rgba(255, 255, 255, .78); font-weight: 700; font-size: 1.05rem; white-space: nowrap; unicode-bidi: isolate; box-shadow: 0 4px 0 rgba(43, 35, 80, .12); transition: transform .1s; }
.nb-page:active { transform: translateY(3px); }
.nb-page.on { background: var(--purple); color: #fff; box-shadow: 0 4px 0 #6d28d9; }
/* the chart: as big a square as fits */
.nb-chart-wrap { grid-area: chart; min-width: 0; min-height: 0; display: grid; place-items: center; container-type: size; }
.nb-chart { width: 100%; height: 100%; width: min(100cqw, 100cqh); height: min(100cqw, 100cqh); }
.nb-side {
  grid-area: side; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 12px 14px; border-radius: 30px; background: rgba(255, 255, 255, .9); box-shadow: var(--shadow);
}
.nb-hint { font-size: 80px; opacity: .7; animation: bob 1.6s ease-in-out infinite; }
.nb-big { font-size: min(13vmin, 104px); font-weight: 700; line-height: 1.15; color: var(--purple); padding: 0 18px; border-radius: 24px; animation: popIn .35s ease-out; }
/* its places, biggest on the left like the written number: سەد · دەه · یەک */
.nb-split { display: flex; gap: 8px; direction: ltr; }
.nb-place {
  --pc: var(--green);
  display: flex; flex-direction: column; align-items: center; min-width: 62px; padding: 2px 10px 4px; border-radius: 18px;
  background: color-mix(in srgb, var(--pc) 15%, #fff); box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--pc) 45%, #fff);
  color: color-mix(in srgb, var(--pc) 70%, #000);
}
.nb-place.p-th { --pc: var(--purple); }
.nb-place.p-hu { --pc: var(--yellow); }
.nb-place.p-te { --pc: var(--pink); }
.nb-place.p-on { --pc: var(--blue); }
.nb-pw { font-size: 1rem; line-height: 1.6; }
.nb-pd { font-size: min(7vmin, 2.6rem); font-weight: 700; line-height: 1.1; }
.nb-blocks { width: 100%; flex: 1 1 auto; min-height: 80px; max-height: 260px; display: grid; place-items: center; }
.nb-blocks .m-blocks { max-height: 100%; }
.nb-chart .m-hc { width: 100%; }
.nb-tools { grid-area: tools; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; }
.nb-steps { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.nb-tool {
  min-width: 68px; height: 64px; padding: 0 14px; border-radius: 22px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: #fff; box-shadow: var(--shadow); font-weight: 700; font-size: 1.5rem; unicode-bidi: isolate; transition: transform .1s;
}
.nb-tool:active { transform: translateY(3px); }
.nb-tool.on { background: #fff3b0; box-shadow: inset 0 0 0 4px var(--yellow), var(--shadow); }
.nb-oe span { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 1.3rem; }
.oe-odd { background: #f472b6; }
.oe-even { background: #60a5fa; }
.nb-play { min-width: 78px; height: 62px; font-size: 1.7rem; border-radius: 20px; }
/* the numbers on the chart: skip counting, odd & even, the tapped one, counting along */
.screen-board .nb-chart .nb-skip { background: var(--skip); }
.screen-board .nb-chart .nb-odd { background: #fbcfe8; color: #9d174d; }
.screen-board .nb-chart .nb-even { background: #bfdbfe; color: #1e40af; }
.screen-board .nb-chart .nb-sel { box-shadow: inset 0 0 0 4px var(--purple); }
.screen-board .nb-chart .nb-lit { background: var(--green); color: #fff; transform: scale(1.18); z-index: 2; box-shadow: 0 0 0 4px #fff, 0 6px 14px rgba(0, 0, 0, .2); }
.screen-board .nb-chart .bounce { animation: bounceIn .45s ease-out; }

/* ---------------------------------------------------------------- whiteboard */
.wb-fab {
  position: fixed; left: calc(14px + var(--sa-l)); top: calc(12px + var(--sa-t)); 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: calc(132px + var(--sa-l)); flex: none; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: calc(10px + var(--sa-t)) 8px calc(10px + var(--sa-b)) calc(8px + var(--sa-l)); 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 .wb-num { font-size: 21px; font-weight: 700; color: var(--purple); }
.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: calc(10px + var(--sa-t)) calc(10px + var(--sa-r)) calc(10px + var(--sa-b)) 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; }
/* templates: the digits (and + − =) to trace, and squared paper */
.wb-tpl .stamp { font-weight: 700; line-height: 1.25; color: var(--purple); }
.wb-tpl .wb-paper { grid-column: span 2; color: #3b82f6; background: #eef6ff; }
.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: calc(12px + var(--sa-t)) calc(16px + var(--sa-r)) 12px calc(16px + var(--sa-l)); 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 calc(20px + var(--sa-r)) 80px calc(20px + var(--sa-l)); 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, 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; }
.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 glow { 0%, 100% { box-shadow: 0 8px 0 rgba(0, 0, 0, .18), 0 0 0 0 rgba(255, 255, 255, .9); } 50% { box-shadow: 0 8px 0 rgba(0, 0, 0, .18), 0 0 0 18px 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, minmax(0, 1fr)); gap: 18px; }
  /* 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; }
  .memory-grid, .memory-grid.many { grid-template-columns: repeat(4, min(21vw, 150px)); }
  /* number board: the chart on top, the tools and the number below */
  .nb { overflow-y: auto; -webkit-overflow-scrolling: touch; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto auto; grid-template-areas: "pages" "chart" "tools" "side"; }
  .nb-chart-wrap { height: min(94vw, 62vh); }
  .nb-side { min-height: 240px; }
  .nb-blocks { flex: none; height: 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; }
  .step-dots span { width: 40px; height: 40px; font-size: 20px; }
  .chapters { gap: 14px 16px; }
  .chapter-card { padding: 8px 12px; gap: 4px; }
  .ch-progress { height: 10px; }
  .nb-tool { height: 54px; min-width: 58px; font-size: 1.3rem; }
  .nb-big { font-size: 64px; }
}
@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; }
.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: calc(16px + var(--sa-r)); top: calc(14px + var(--sa-t)); z-index: 3; }
.rec-dot.builtin { background: var(--blue); }
.rec-row { flex-wrap: wrap; }

/* ---------------------------------------------------------------- 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; flex-wrap: wrap; 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: calc(10px + var(--sa-l)); top: calc(10px + var(--sa-t)); border-radius: 16px; font-size: 26px; }
  .topbar { gap: 8px; padding: calc(10px + var(--sa-t)) calc(10px + var(--sa-r)) 10px; padding-left: calc(var(--fab) + 18px + var(--sa-l)); flex-wrap: wrap; }
  .back-btn, .x-btn { width: 56px; height: 56px; border-radius: 18px; font-size: 24px; }
  .back-btn svg { width: 32px; height: 32px; }
  .pill { padding: 5px 11px; font-size: 1.05rem; gap: 4px; }
  .pill-i { font-size: 1.2rem; }
  .music-btn { width: 56px; height: 56px; font-size: 24px; }
  .lock-mini { width: 40px; height: 46px; font-size: 22px; }
  .map-title { font-size: 1.15rem; }
  .mt-main { gap: 6px; }
  .mt-main .ku { font-size: 1.05rem; line-height: 1.4; }
  .mt-sub { font-size: .9rem; }
  .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: calc(6px + var(--sa-l)); bottom: calc(4px + var(--sa-b)); }
  .mascot.corner .bubble { font-size: 22px; padding: 6px 12px; }

  /* home: name, music & lock on the first row – stars, money, stickers, numbers 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-wrap { padding: 14px 12px 10px; }
  .chapters { gap: 16px 12px; }
  .chapter-card { border-radius: 24px; padding: 10px 8px; gap: 5px; }
  .ch-top { gap: 8px; }
  .ch-icon { font-size: 34px; }
  .chapter-card .ch-eq { font-size: 19px; }
  .ch-sample { padding: 1px 8px; border-radius: 12px; box-shadow: 0 3px 0 rgba(0, 0, 0, .12); }
  .ch-name { gap: 6px; }
  .ch-num { min-width: 28px; height: 28px; font-size: .95rem; padding: 0 5px; }
  .ch-title { font-size: .95rem; line-height: 1.4; }
  .ch-foot { gap: 6px; width: 100%; }
  .ch-progress { height: 9px; }
  .ch-count { font-size: .8rem; }
  .ch-me { font-size: 30px; top: -12px; left: -6px; }
  .ch-lock { font-size: 44px; }
  .home-foot { padding: 0 12px calc(12px + var(--sa-b)); gap: 8px; }
  .money-bar { padding: 8px 12px; gap: 10px; }
  .mini-bill { height: 34px; }
  .chest { font-size: 32px; }

  /* chapter map */
  .map-scroll { padding: 14px 4% calc(100px + var(--sa-b)); }
  .map-path { gap: 22px 10px; }
  .node-stars { font-size: 17px; bottom: -12px; }
  .node-bill { font-size: 28px; top: -14px; left: -8px; }
  .node.test { outline-width: 4px; outline-offset: 3px; }
  .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: calc(8px + var(--sa-t)) calc(10px + var(--sa-r)) 4px; padding-left: calc(var(--fab) + 18px + var(--sa-l)); }
  .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; }
  .level-label.sum { width: auto; min-width: 48px; padding: 0 8px; }
  .level-label .lvl-eq { font-size: 18px; }
  .level-label .lvl-eq.len-l { font-size: 15px; }
  .heart { font-size: 24px; }
  .stage { padding: 6px 12px calc(64px + var(--sa-b)); }
  .stage > * { gap: 10px; }

  .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; }
  .skip-btn { margin-top: 0; }

  .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 calc(30px + var(--sa-b)); 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 calc(30px + var(--sa-b)); }
  .sticker { font-size: 44px; border-radius: 20px; }

  /* number board: the page chips scroll sideways, the number sits beside its places */
  .nb { padding: 0 12px calc(12px + var(--sa-b)); gap: 10px; }
  .nb-pages { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
  .nb-pages::-webkit-scrollbar { display: none; }
  .nb-page { padding: 6px 12px; font-size: .95rem; border-radius: 14px; }
  .nb-side { flex-direction: row; flex-wrap: wrap; gap: 8px 14px; padding: 10px; border-radius: 24px; min-height: 0; }
  .nb-hint { font-size: 56px; }
  .nb-big { font-size: 60px; padding: 0 8px; }
  .nb-place { min-width: 50px; padding: 2px 8px 3px; border-radius: 14px; }
  .nb-pw { font-size: .85rem; }
  .nb-pd { font-size: 1.8rem; }
  .nb-blocks { width: 100%; height: 130px; }
  .nb-tools, .nb-steps { gap: 8px; }
  .nb-tool { min-width: 56px; height: 56px; padding: 0 10px; border-radius: 18px; font-size: 1.2rem; }
  .nb-oe span { width: 32px; height: 32px; font-size: 1.05rem; }
  .nb-play { min-width: 60px; height: 56px; padding: 0 12px; font-size: 1.4rem; border-radius: 16px; }

  .modal-back { padding: calc(10px + var(--sa-t)) 10px calc(10px + var(--sa-b)); }
  .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: calc(8px + var(--sa-t)) 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 + var(--sa-b)); 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-act .wb-num { font-size: 17px; }
  .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: calc(8px + var(--sa-t)) 10px 8px; 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; }
  .emoji-in { font-size: 1.2rem; width: 100%; min-width: 0; padding: 2px; }
  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; }
  .ch-title { font-size: .85rem; }
}

/* ---------------------------------------------------------------- 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; }
