:root {
  --bg: #fff4e6;
  --ink: #343a40;
  --soft: #868e96;
  --card: #ffffff;
  --accent: #7048e8;
  --good: #37b24d;
  --shadow: 0 6px 0 rgba(0, 0, 0, 0.08), 0 10px 24px rgba(0, 0, 0, 0.08);
  --font: "Baloo 2", "Baloo Bhaijaan 2", "Segoe UI", system-ui, sans-serif;
}
[dir="rtl"] { --font: "Baloo Bhaijaan 2", "Baloo 2", "Segoe UI", system-ui, sans-serif; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background: linear-gradient(180deg, #e7f5ff 0%, var(--bg) 55%);
  color: var(--ink);
  font-family: var(--font);
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; color: inherit; border: 0; cursor: pointer; background: none; }
button:disabled { opacity: 0.3; cursor: default; }

#fx { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 50; }

.sky { position: fixed; inset: 0; pointer-events: none; z-index: -1; overflow: hidden; }
.sky span { position: absolute; font-size: 80px; opacity: 0.55; animation: drift 40s linear infinite; }
.sky span:nth-child(1) { top: 8%; animation-duration: 55s; }
.sky span:nth-child(2) { top: 30%; font-size: 56px; animation-duration: 70s; animation-delay: -30s; }
.sky span:nth-child(3) { top: 62%; font-size: 64px; animation-duration: 62s; animation-delay: -12s; }
@keyframes drift { from { left: -120px; } to { left: 110vw; } }

.screen { max-width: 1100px; margin: 0 auto; padding: 12px 16px 32px; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.top h1 { flex: 1; margin: 0; font-size: clamp(22px, 4.5vw, 36px); font-weight: 800; line-height: 1.1; }
.logo { font-size: 40px; }
.top-right { display: flex; align-items: center; gap: 8px; }
.stars { cursor: pointer; background: #fff3bf; padding: 6px 14px; border-radius: 999px; font-weight: 800; font-size: 20px; box-shadow: var(--shadow); white-space: nowrap; }
.lang-btn { background: var(--accent); color: #fff; padding: 8px 16px; border-radius: 999px; font-weight: 700; font-size: 18px; box-shadow: var(--shadow); }

.round-btn {
  width: 56px; height: 56px; flex: none; border-radius: 50%;
  background: var(--card); box-shadow: var(--shadow); font-size: 26px;
  display: grid; place-items: center; transition: transform .1s;
}
.round-btn:active { transform: translateY(3px) scale(.96); }
/* ➜ points right; flip it for "back/prev" in LTR and for "next" in RTL */
[dir="ltr"] .back, [dir="ltr"] .prev, [dir="rtl"] .next { transform: scaleX(-1); }

.hint { text-align: center; color: var(--soft); font-size: 20px; margin: 4px 0 14px; }
.center { text-align: center; }
.row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.hidden { display: none !important; }

.pill {
  background: var(--card); padding: 10px 22px; border-radius: 999px; font-size: 22px; font-weight: 700;
  box-shadow: var(--shadow); min-height: 56px; transition: transform .1s;
}
.pill:active { transform: translateY(3px); }
.pill.go, .pill.yes { background: var(--good); color: #fff; }
.pill.no { background: #ffe8cc; }

/* ---------- tiles (home + hub) ---------- */
.home-grid, .act-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.tile {
  background: var(--bg);
  aspect-ratio: 1; border-radius: 32px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  animation: rise .45s cubic-bezier(.3, 1.6, .5, 1) both; transition: transform .12s;
}
.tile:active { transform: scale(.94) rotate(-2deg); }
.tile-icon { font-size: clamp(56px, 10vw, 84px); }
.tile-name { font-size: clamp(22px, 3.5vw, 32px); font-weight: 800; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.18); }
.act .tile-name { color: var(--ink); text-shadow: none; }
@keyframes rise { from { opacity: 0; transform: translateY(30px) scale(.8); } }

.hub-preview { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 18px; }
.hub-preview .emoji { width: 72px; height: 72px; display: grid; place-items: center; }
.float { animation: bob 3s ease-in-out infinite; }
.float:nth-child(2n) { animation-delay: -1s; }
.float:nth-child(3n) { animation-delay: -2s; }
@keyframes bob { 50% { transform: translateY(-10px); } }

/* ---------- cards ---------- */
.card-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.card {
  background: var(--card); border-radius: 24px; box-shadow: var(--shadow); padding: 12px 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  transition: transform .12s;
}
.card:active { transform: scale(.95); }
.card .emoji { height: 96px; display: grid; place-items: center; line-height: 1; }
.card-label { font-size: 20px; font-weight: 700; text-align: center; }
.glyph { color: var(--accent); font-size: 26px; }

.detail { display: flex; align-items: center; justify-content: center; gap: 14px; }
.big-card {
  background: var(--card); border-radius: 36px; box-shadow: var(--shadow);
  padding: 20px 28px; min-width: min(360px, 64vw);
  display: flex; flex-direction: column; align-items: center; cursor: pointer;
}
.big-card .emoji { line-height: 1.1; }
.big-glyph { font-size: clamp(80px, 16vw, 140px); font-weight: 800; color: var(--accent); line-height: 1; }
.big-name { font-size: clamp(30px, 6vw, 48px); font-weight: 800; }
.speak { font-size: 32px; padding: 8px 40px; }

.pop { animation: pop .4s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes pop { 40% { transform: scale(1.12); } }
.wobble { animation: wobble .5s ease; }
@keyframes wobble { 20% { transform: rotate(-5deg); } 40% { transform: rotate(4deg); } 60% { transform: rotate(-3deg); } 80% { transform: rotate(2deg); } }

/* ---------- quiz ---------- */
.quiz { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.dots { display: flex; gap: 10px; }
.dot { width: 34px; height: 34px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 3px #dee2e6; display: grid; place-items: center; font-size: 20px; }
.dot.on { box-shadow: none; background: #fff3bf; }
.prompt { display: flex; align-items: center; gap: 12px; font-size: clamp(26px, 5vw, 40px); font-weight: 700; }
.prompt b { color: var(--accent); }
.options { display: grid; grid-template-columns: repeat(2, minmax(130px, 200px)); gap: 16px; }
@media (min-width: 760px) { .options { grid-template-columns: repeat(4, 180px); } }
.option { aspect-ratio: 1; }
.option .emoji { font-size: 72px !important; }
.option.right { background: #d3f9d8; box-shadow: 0 0 0 5px var(--good), var(--shadow); }
.option.tried { opacity: .35; }
.opt-glyph { font-size: 84px; font-weight: 800; color: var(--accent); line-height: 1; }

/* ---------- play: memory + puzzle ---------- */
.game { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.mem-grid { --size: 120px; display: grid; grid-template-columns: repeat(var(--cols, 3), var(--size)); gap: 12px; justify-content: center; }
.mem-card { width: var(--size); height: calc(var(--size) * 1.2); padding: 0; perspective: 900px; }
.mem-inner { position: relative; display: block; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .5s cubic-bezier(.3, 1.4, .5, 1); }
.mem-card.up .mem-inner { transform: rotateY(180deg); }
.mem-face {
  position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; border-radius: 22px;
  backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: var(--shadow);
}
.mem-back { background: radial-gradient(circle at 30% 25%, #b197fc, #7048e8); font-size: calc(var(--size) * .38); }
.mem-front { background: #fff; transform: rotateY(180deg); }
.mem-front canvas { width: 82% !important; height: auto !important; }
.mem-front .emoji { font-size: calc(var(--size) * .52) !important; line-height: 1; }
.mem-glyph { font-size: calc(var(--size) * .62); font-weight: 800; color: var(--accent); line-height: 1; font-family: "Baloo Bhaijaan 2", "Baloo 2", sans-serif; }
.mem-card.done .mem-front { background: #d3f9d8; box-shadow: 0 0 0 4px var(--good), var(--shadow); }

.puzzle { position: relative; margin: 4px auto 0; }
.puzzle-board { position: absolute; border-radius: 16px; box-shadow: var(--shadow); }
.piece { position: absolute; left: 0; top: 0; touch-action: none; cursor: grab; filter: drop-shadow(0 4px 3px rgba(0, 0, 0, .2)); }
.piece.lift { cursor: grabbing; filter: drop-shadow(0 12px 10px rgba(0, 0, 0, .3)); }
.piece.placed { cursor: default; filter: none; }
.puzzle.solved .piece { opacity: 0; transition: opacity .6s; }

.finale { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 30px; }
.trophy { font-size: 160px; animation: pop .8s cubic-bezier(.3, 1.8, .5, 1), bob 2.5s 1s ease-in-out infinite; }

/* ---------- feedback bubble ---------- */
.bubble {
  position: fixed; left: 50%; top: 18%; transform: translateX(-50%);
  z-index: 60; display: flex; align-items: center; gap: 12px; white-space: nowrap;
  padding: 14px 28px; border-radius: 999px; font-size: clamp(26px, 5vw, 40px); font-weight: 800;
  box-shadow: var(--shadow); animation: bubble-in .45s cubic-bezier(.3, 1.8, .5, 1);
  transition: opacity .4s, transform .4s; pointer-events: none;
}
.bubble.good { background: #fff3bf; color: #e67700; }
.bubble.soft { background: #e7f5ff; color: #1971c2; }
.bubble.out { opacity: 0; transform: translateX(-50%) translateY(-20px); }
.bubble-face { font-size: 1.3em; }
@keyframes bubble-in { from { transform: translateX(-50%) scale(.3); opacity: 0; } }

/* ---------- draw ---------- */
.tabs { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.tab { padding: 10px 20px; border-radius: 999px; background: #fff; font-size: 20px; font-weight: 700; box-shadow: var(--shadow); }
.tab.on { background: var(--accent); color: #fff; }
.glyph-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
.glyph-btn {
  aspect-ratio: 1; border-radius: 22px; font-size: 48px; font-weight: 800;
  background: hsl(var(--hue) 90% 88%); color: hsl(var(--hue) 60% 35%); box-shadow: var(--shadow);
  font-family: "Baloo Bhaijaan 2", "Baloo 2", sans-serif;
}
.glyph-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.glyph-btn .mastery { font-size: 12px; margin-top: 4px; }
.glyph-btn:active { transform: scale(.92); }

.draw { display: flex; flex-direction: column; align-items: center; }
.draw-row { display: flex; align-items: center; gap: 12px; }
.pad { position: relative; background: #fff; border-radius: 28px; box-shadow: var(--shadow); touch-action: none; }
.pad .layer { position: absolute; inset: 0; border-radius: 28px; }
.pad .ink { cursor: crosshair; touch-action: none; }
.crayons { display: flex; gap: 12px; margin-top: 14px; }
.crayon { width: 44px; height: 44px; border-radius: 50%; background: var(--c); box-shadow: var(--shadow); transition: transform .12s; }
.crayon.on { transform: scale(1.2); box-shadow: 0 0 0 4px #fff, 0 0 0 7px var(--c); }

/* ---------- mastery stars ---------- */
.mastery { color: #fab005; font-size: 15px; letter-spacing: 1px; }
.round-btn.small { width: 44px; height: 44px; font-size: 18px; }
.pill.small { font-size: 17px; min-height: 44px; padding: 6px 16px; }
.pill.danger { background: #ffe3e3; color: #c92a2a; }

/* ---------- stickers ---------- */
.sticker-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
.sticker { aspect-ratio: 1; border-radius: 50%; background: #fff; box-shadow: var(--shadow); font-size: 48px; }
.sticker.locked { background: #f1f3f5; color: #ced4da; font-weight: 800; font-size: 32px; opacity: 1; }
.sticker-reveal {
  position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(255, 244, 230, .85); backdrop-filter: blur(4px); animation: fade-in .3s;
}
.sticker-big { font-size: 180px; animation: spin-in .9s cubic-bezier(.3, 1.6, .5, 1); }
.sticker-title { font-size: 42px; font-weight: 800; color: var(--accent); }
@keyframes spin-in { from { transform: scale(0) rotate(-540deg); } }
@keyframes fade-in { from { opacity: 0; } }

/* ---------- parents ---------- */
.gate { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 40px; }
.gate-q { font-size: 28px; font-weight: 700; text-align: center; }
.gate-opt { min-width: 80px; font-size: 26px; }
.parents { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
.panel { background: #fff; border-radius: 24px; box-shadow: var(--shadow); padding: 16px 18px; }
.panel h2 { margin: 0 0 10px; font-size: 22px; }
.prog-row { padding: 10px 0; border-bottom: 1px solid #f1f3f5; }
.prog-row:last-child { border-bottom: 0; }
.prog-head { display: flex; justify-content: space-between; font-size: 18px; }
.prog-head span { color: var(--soft); font-size: 15px; }
.bar { height: 12px; background: #f1f3f5; border-radius: 999px; overflow: hidden; margin: 6px 0; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #51cf66, #fcc419); border-radius: 999px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chips-label { color: var(--soft); font-size: 14px; }
.chip { background: #fff4e6; border-radius: 999px; padding: 2px 10px; font-size: 16px; font-weight: 700; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #f1f3f5; font-size: 17px; flex-wrap: wrap; }
.row-end { display: flex; align-items: center; gap: 8px; }
.model-status, .learned-counts { color: var(--soft); font-size: 15px; }
.switch { appearance: none; width: 52px; height: 30px; border-radius: 999px; background: #dee2e6; position: relative; cursor: pointer; transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: inset-inline-start .2s; }
.switch:checked { background: var(--good); }
.switch:checked::after { inset-inline-start: 25px; }
.seg { display: flex; background: #f1f3f5; border-radius: 999px; padding: 3px; }
.seg button { padding: 6px 14px; border-radius: 999px; font-size: 15px; font-weight: 700; }
.seg button.on { background: var(--accent); color: #fff; }
input[type=range] { accent-color: var(--accent); }
.diag-facts { font-size: 14px; display: grid; gap: 2px; overflow-wrap: anywhere; }
.diag-log { font-size: 12px; background: #f8f9fa; border-radius: 12px; padding: 8px; max-height: 220px; overflow: auto; white-space: pre-wrap; direction: ltr; text-align: left; }

@media (max-width: 560px) {
  .draw-row .nav { display: none; }
  .detail .nav { width: 44px; height: 44px; font-size: 20px; }
  .top h1 { font-size: 22px; }
  .logo { display: none; }
}
