/* KiddoLearn — "paper notebook" game look: cream grid paper, ink outlines, chunky
   3D buttons, the owl guide, an island map and lesson paths. */
:root {
  --paper: #FBF5E6;
  --paper-line: #EFE3C8;
  --card: #FFFDF7;
  --ink: #3A3530;
  --ink-soft: #6E655B;
  --line: #E6D9BD;
  --green: #6BAA5E;
  --green-dark: #4E8A45;
  --blue: #4F8FCF;
  --sun: #F6C445;
  --sun-dark: #D9A21E;
  --coral: #EE7F45;
  --coral-dark: #C9602B;
  --pink: #E0708A;
  --good: #6BAA5E;
  --good-soft: #E3F1D8;
  --bad: #E0708A;
  --bad-soft: #FADFE5;
  --primary: #4F8FCF;
  --primary-soft: #DCEAF8;
  --star: #F6C445;
  --muted: var(--ink-soft);
  --surface: var(--card);
  --radius: 22px;
  /* --font-script: the active language's font for scripts these lack (set by i18n.js) */
  --font-ui: 'Nunito', var(--font-script, system-ui), system-ui, sans-serif;
  --font-head: 'Baloo 2', 'Nunito', var(--font-script, system-ui), system-ui, sans-serif;
  --font-glyph: 'Andika', 'Comic Sans MS', var(--font-script, sans-serif), sans-serif;
  --zc: var(--blue);
  --zs: var(--primary-soft);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background-color: var(--paper);
  background-image: linear-gradient(var(--paper-line) 1.5px, transparent 1.5px),
    linear-gradient(90deg, var(--paper-line) 1.5px, transparent 1.5px);
  background-size: 34px 34px;
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: 700;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
  touch-action: manipulation; /* no double-tap zoom */
  -webkit-touch-callout: none; /* no "save image" menu on long press */
  -webkit-text-size-adjust: 100%;
}
img { -webkit-user-drag: none; }
#app {
  max-width: 1100px; margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right))
    calc(24px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; touch-action: manipulation; }
h2, h3 { font-family: var(--font-head); }
.loading { text-align: center; margin-top: 22vh; font-size: 24px; color: var(--ink-soft); font-family: var(--font-head); }
.loading .owl { margin: 0 auto 12px; }

/* Paper cards and chunky buttons */
.paper { background: var(--card); border: 3px solid var(--ink); border-radius: var(--radius); box-shadow: 0 5px 0 var(--ink); }
.btn3d, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 26px; border-radius: 999px; font-family: var(--font-head); font-size: 22px; font-weight: 800;
  border: 3px solid var(--ink); box-shadow: 0 6px 0 var(--ink); transition: transform .08s, box-shadow .08s;
}
.btn3d:active, .btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.btn-go, .btn-primary { background: var(--green); color: #fff; text-shadow: 0 2px 0 var(--green-dark); }
.btn-light, .btn-ghost { background: var(--card); }
.btn:disabled, .btn3d:disabled { opacity: .45; }
.round-btn {
  position: relative; width: 64px; height: 64px; border-radius: 999px; background: var(--card); font-size: 26px;
  border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); flex: none;
}
.round-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.pill {
  display: inline-flex; align-items: center; gap: 4px; background: var(--card); border: 3px solid var(--ink);
  border-radius: 999px; padding: 6px 14px; font-family: var(--font-head); font-size: 20px; font-weight: 800; white-space: nowrap;
}
.pill-fire { background: #FFE2D2; }
.pill-star { background: #FFF1C4; }
.danger { color: #B4364F; }

/* Owl */
.owl { display: block; overflow: visible; }
.owl .owl-body { transform-origin: 60px 126px; animation: owl-bob 3s ease-in-out infinite; }
.owl .owl-lids { transform-origin: 60px 60px; transform: scaleY(0); animation: owl-blink 4.5s infinite; }
.owl .owl-happy-eyes { opacity: 0; }
.owl .owl-beak-low { transform-origin: 60px 82px; }
.owl .owl-wing-l { transform-origin: 26px 66px; }
.owl .owl-wing-r { transform-origin: 94px 66px; }
.owl.talk .owl-beak-low { animation: owl-talk .26s ease-in-out infinite alternate; }
.owl.happy .owl-body { animation: owl-jump .5s ease-out 2; }
.owl.happy .owl-wing-l { animation: wing-l .25s ease-in-out 4 alternate; }
.owl.happy .owl-wing-r { animation: wing-r .25s ease-in-out 4 alternate; }
.owl.happy .owl-happy-eyes, .owl.dance .owl-happy-eyes { opacity: 1; }
.owl.happy .owl-eyes, .owl.dance .owl-eyes, .owl.happy .owl-lids, .owl.dance .owl-lids { opacity: 0; }
.owl.dance .owl-body { animation: owl-jump .6s ease-out infinite; }
.owl.dance .owl-wing-l { animation: wing-l .3s ease-in-out infinite alternate; }
.owl.dance .owl-wing-r { animation: wing-r .3s ease-in-out infinite alternate; }
.owl.sad .owl-body { animation: owl-sad .9s ease-in-out; }
@keyframes owl-bob { 50% { transform: translateY(-3px); } }
@keyframes owl-blink { 0%, 92%, 100% { transform: scaleY(0); } 95% { transform: scaleY(1); } }
@keyframes owl-talk { to { transform: translateY(5px) scaleY(1.25); } }
@keyframes owl-jump { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-16px) scale(1.04, .97); } }
@keyframes wing-l { to { transform: rotate(28deg); } }
@keyframes wing-r { to { transform: rotate(-28deg); } }
@keyframes owl-sad { 25% { transform: rotate(-8deg); } 60% { transform: rotate(6deg) translateY(2px); } }

.owl-say { display: flex; align-items: center; gap: 12px; margin: 4px 0 14px; }
.owl-btn { flex: none; padding: 0; }
.bubble {
  position: relative; flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--card); border: 3px solid var(--ink); border-radius: 24px; box-shadow: 0 4px 0 var(--ink);
  padding: 12px 18px; font-family: var(--font-head); font-size: clamp(22px, 3vw, 30px); font-weight: 700; line-height: 1.2;
}
.bubble::before {
  content: ''; position: absolute; inset-inline-start: -15px; top: 50%; width: 22px; height: 22px; margin-top: -11px;
  background: var(--card); border-left: 3px solid var(--ink); border-bottom: 3px solid var(--ink); transform: rotate(45deg);
}
[dir="rtl"] .bubble::before { transform: rotate(225deg); }
.bubble.good { background: var(--good-soft); }
.bubble.good::before { background: var(--good-soft); }
.bubble-speaker { font-size: 26px; opacity: .7; flex: none; }
button.bubble { color: var(--ink); text-align: start; cursor: pointer; min-height: 64px; }
button.bubble:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.bubble.small {
  position: absolute; top: -34px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  font-size: 15px; padding: 4px 12px; border-radius: 14px; box-shadow: 0 3px 0 var(--ink); flex: none;
  animation: bob 1.6s ease-in-out infinite;
}
.bubble.small::before { display: none; }

.popup {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  display: flex; align-items: center; gap: 10px; max-width: min(92vw, 560px);
  background: var(--card); border: 3px solid var(--ink); border-radius: 26px; box-shadow: 0 5px 0 var(--ink);
  padding-block: 8px; padding-inline: 10px 20px; font-family: var(--font-head); font-size: 22px; animation: popup-in .3s ease-out;
}
@keyframes popup-in { from { transform: translate(-50%, 30px); opacity: 0; } }

.burst { position: fixed; left: 50%; top: 45%; z-index: 30; pointer-events: none; }
.burst i {
  position: absolute; font-style: normal; font-size: 34px; color: var(--sun); -webkit-text-stroke: 2px var(--ink);
  animation: burst .9s ease-out var(--d) both;
}
@keyframes burst {
  0% { transform: rotate(var(--a)) translateY(0) scale(.4); opacity: 1; }
  100% { transform: rotate(var(--a)) translateY(-150px) scale(1.1); opacity: 0; }
}

/* HUD */
.hud { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.hud-me { display: flex; align-items: center; gap: 8px; padding-block: 4px; padding-inline: 6px 16px; background: var(--card);
  border: 3px solid var(--ink); border-radius: 999px; box-shadow: 0 4px 0 var(--ink); }
.hud-lv { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; font-family: var(--font-head); font-size: 18px; }
.xpbar { display: block; width: 120px; height: 14px; border: 2.5px solid var(--ink); border-radius: 999px; background: #EFE6D2; overflow: hidden; }
.xpbar > span { display: block; height: 100%; background: var(--sun); transition: width 1.2s ease-out; }
.xpbar.big { width: 200px; height: 18px; }
.hud-right { display: flex; align-items: center; gap: 10px; }
.hold-btn { font-size: 22px; }
.hold-ring { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); transform: rotate(-90deg); pointer-events: none; }
.hold-ring circle { fill: none; stroke: var(--coral); stroke-width: 4; stroke-dasharray: 145; stroke-dashoffset: 145; }
.hold-btn.holding .hold-ring circle { transition: stroke-dashoffset 1s linear; stroke-dashoffset: 0; }

/* Today's quest */
.quest { display: flex; align-items: center; gap: 14px; padding: 10px 14px; margin-bottom: 14px; flex-wrap: wrap; }
.quest-head { font-family: var(--font-head); font-size: 22px; font-weight: 800; }
.quest-steps { display: flex; align-items: center; flex: 1; min-width: 0; }
.q-link { flex: 1; min-width: 10px; max-width: 40px; border-top: 4px dashed var(--line); }
.q-step {
  position: relative; width: 74px; height: 74px; border-radius: 999px; background: var(--primary-soft); flex: none;
  border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); display: flex; align-items: center; justify-content: center;
}
.q-step:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.q-step.kind-review { background: var(--good-soft); }
.q-step.done { background: #E8E2D2; }
.q-step.done .q-face { opacity: .5; }
.q-face .hero-glyph { font-size: 34px; }
.q-face .hero-word { font-size: 22px; }
.q-face .hero-emoji { font-size: 34px; }
.q-face svg { width: 40px; height: 40px; }
.q-tag { position: absolute; top: -10px; inset-inline-start: -8px; font-size: 20px; }
.q-check {
  position: absolute; inset-inline-end: -6px; bottom: -6px; width: 28px; height: 28px; border-radius: 999px; background: var(--green);
  color: #fff; border: 2.5px solid var(--ink); font-size: 16px; display: flex; align-items: center; justify-content: center;
}
.q-chest { background: #FFF1C4; }
.q-chest.open:not(.done) { animation: wiggle 1.4s ease-in-out infinite; }
.btn-go { animation: go-pulse 1.6s ease-in-out infinite; }
.btn-go:active { animation: none; }
.quest-done { font-size: 40px; }
@keyframes go-pulse { 50% { transform: scale(1.05); } }
@keyframes wiggle { 0%, 70%, 100% { transform: rotate(0); } 80% { transform: rotate(-8deg); } 90% { transform: rotate(8deg); } }
@keyframes bob { 50% { transform: translate(-50%, -4px); } }

/* Island map */
.map-wrap { display: flex; justify-content: center; }
.map { width: 100%; max-height: calc(100vh - 230px); border: 3px solid var(--ink); border-radius: 30px; box-shadow: 0 6px 0 var(--ink); background: #9ED3E6; }
.screen-home .map { height: auto; }
.map .stop { cursor: pointer; }
.map .stop-art { transition: transform .15s; }
.map .stop:active .stop-art { transform-box: fill-box; }
.map .stop:hover .stop-art, .map .stop:focus .stop-art { filter: brightness(1.05); }
.map .stop.locked .stop-art { filter: grayscale(1) opacity(.6); }
.map .stop:focus { outline: none; }
.map-label { font-family: var(--font-head); font-size: 26px; font-weight: 800; fill: var(--ink); }
.map-sub { font-family: var(--font-head); font-size: 18px; font-weight: 700; fill: var(--ink-soft); }
.glyph-text { font-family: var(--font-glyph); font-weight: 700; }
.map .cloud { animation: drift 14s ease-in-out infinite alternate; }
.map .cloud.c2 { animation-duration: 18s; }
.map-owl { animation: owl-hop 2.4s ease-in-out infinite; }
@keyframes drift { to { transform: translateX(60px); } }
@keyframes owl-hop { 50% { transform: translateY(-6px); } }

/* Zone path */
.zone-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px;
  position: sticky; top: 0; z-index: 5; padding: 6px 0; }
.zone-title { display: flex; align-items: center; gap: 6px; font-family: var(--font-head); font-size: 28px; font-weight: 800;
  background: var(--zs); border: 3px solid var(--ink); border-radius: 999px; box-shadow: 0 4px 0 var(--ink); padding-inline: 10px 22px; }
.zone-title .landmark { margin: -8px 0 -6px; }
.screen-zone .path {
  position: relative; border: 3px solid var(--ink); border-radius: 30px; box-shadow: 0 6px 0 var(--ink);
  background: var(--zs) radial-gradient(circle at 20px 20px, rgba(255, 255, 255, .5) 4px, transparent 5px) 0 0 / 46px 46px;
  overflow: hidden;
}
.path-line { position: absolute; inset: 0; pointer-events: none; }
.path-line path { fill: none; stroke: var(--card); stroke-width: 16; stroke-dasharray: 2 26; stroke-linecap: round; }
.sign {
  position: absolute; left: 50%; transform: translate(-50%, -50%); max-width: 86%; text-align: center;
  background: #D9A66B; color: #fff; border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 4px 0 var(--ink);
  padding: 8px 20px; font-family: var(--font-head); font-size: 22px; font-weight: 800; text-shadow: 0 2px 0 #9C6D3A;
}
.sign.locked { background: #B9AFA3; text-shadow: none; }
.sign.later { background: #A8C69A; text-shadow: none; opacity: .75; }
.node {
  position: absolute; width: 92px; height: 92px; margin: -46px 0 0 -46px; border-radius: 999px;
  border: 4px solid var(--ink); box-shadow: 0 6px 0 var(--ink); background: var(--card);
  display: flex; align-items: center; justify-content: center;
}
.node:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.node-face { display: flex; align-items: center; justify-content: center; }
.node-face .hero-glyph { font-size: 40px; color: var(--ink); }
.node-face .hero-word { font-size: 24px; color: var(--ink); }
.node-face .hero-emoji { font-size: 40px; }
.node-face svg { width: 48px; height: 48px; }
.node-face .hero-img { max-width: 60px; max-height: 60px; }
.node.st-done { background: var(--zc); }
.node.st-done .hero-glyph, .node.st-done .hero-word { color: #fff; }
.node.st-current { background: var(--sun); width: 110px; height: 110px; margin: -55px 0 0 -55px; animation: node-pulse 1.4s ease-in-out infinite; }
.node.st-locked { background: #E4DDCF; font-size: 30px; box-shadow: 0 6px 0 #8F877C; border-color: #8F877C; }
.node.st-locked .node-face { opacity: .7; }
.node-stars { position: absolute; bottom: -24px; font-style: normal; font-size: 20px; letter-spacing: -2px; white-space: nowrap; }
.node-stars i, .card-stars i { font-style: normal; color: #D8CDB6; -webkit-text-stroke: 1.5px var(--ink); }
.node-stars i.on, .card-stars i.on { color: var(--sun); }
.node-due { position: absolute; top: -12px; inset-inline-end: -12px; font-size: 22px; }
.node-kind {
  position: absolute; inset-inline-start: -10px; bottom: -6px; width: 34px; height: 34px; border-radius: 999px; background: var(--card);
  border: 2.5px solid var(--ink); font-size: 17px; display: flex; align-items: center; justify-content: center;
}
.node.st-locked .node-kind { display: none; }
/* above the child's level: dimmed, waiting for later */
.node.st-later { background: #E7F0E1; font-size: 30px; box-shadow: 0 6px 0 #8FA387; border-color: #8FA387; opacity: .6; }
.node.st-later .node-kind { display: none; }
.decor-spot { position: absolute; pointer-events: none; opacity: .85; }
/* Physical sides on purpose: they follow the path coordinates from world.js */
.decor-spot.left { left: 2%; }
.decor-spot.right { right: 2%; }
@media (max-width: 700px) { .decor-spot { opacity: .35; } }
.node.chest { background: #FFF1C4; }
.node.chest.open { animation: wiggle 2s ease-in-out infinite; }
@keyframes node-pulse { 0%, 100% { box-shadow: 0 6px 0 var(--ink), 0 0 0 0 rgba(246, 196, 69, .6); }
  50% { box-shadow: 0 6px 0 var(--ink), 0 0 0 16px rgba(246, 196, 69, 0); } }
.path-owl { position: absolute; transform: translate(-50%, -60%); pointer-events: none; }
.path-owl .bubble.small { top: -30px; }

/* Playground */
.cats { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 12px; }
.cat {
  display: flex; align-items: center; gap: 6px; padding: 10px 18px; border-radius: 999px; white-space: nowrap;
  background: var(--card); border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); font-family: var(--font-head); font-size: 20px;
}
.cat span { font-size: 24px; }
.cat.active { background: var(--zc); color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
.card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 10px 10px; min-height: 180px;
  transition: transform .1s;
}
.card:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
.card.done { background: var(--good-soft); }
.card-hero { height: 100px; display: flex; align-items: center; justify-content: center; }
.card-title { font-size: 16px; text-align: center; line-height: 1.25; }
.card-stars { font-size: 18px; min-height: 20px; }
.hero-glyph { font-family: var(--font-glyph); font-size: 60px; line-height: 1; color: var(--primary); }
.hero-word { font-family: var(--font-glyph); font-size: 36px; color: var(--primary); }
.hero-emoji { font-size: 56px; line-height: 1; }
.hero-img { max-height: 100px; max-width: 130px; object-fit: contain; border-radius: 10px; }

/* Children: who is learning, and the HUD switch */
.screen-profiles { display: flex; flex-direction: column; align-items: center; gap: 28px; padding-top: 6vh; }
.kid-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 22px; max-width: 820px; }
.kid-card { width: 180px; padding: 18px 10px 14px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: transform .1s; }
.kid-card:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
.kid-card .kid-face { font-size: 88px; line-height: 1; }
.kid-card .kid-name { font-family: var(--font-head); font-size: 26px; font-weight: 800; }
.hud-kid { font-weight: 800; font-size: 17px; }
.hud-kid .kid-face { font-size: 24px; line-height: 1; }
.has-dot { position: relative; }
.has-dot::after { content: ''; position: absolute; top: -2px; inset-inline-end: -2px; width: 14px; height: 14px;
  border-radius: 999px; background: var(--coral); border: 2.5px solid var(--ink); }
.kid-rows { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.kid-row { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 18px; border: 2.5px solid transparent; }
.kid-row.active { background: var(--good-soft); border-color: var(--ink); }
.kid-row .kid-face { font-size: 36px; width: 54px; height: 54px; border-radius: 999px; background: var(--card); border: 2.5px solid var(--ink); }
.kid-row .kid-name { flex: 1; text-align: start; font-size: 20px; font-weight: 800; padding: 8px 4px; }

/* Lesson player */
.player-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 4px 0 6px; }
.road { position: relative; flex: 1; height: 22px; border: 3px solid var(--ink); border-radius: 999px; background: #EFE6D2; margin: 0 18px; }
.road-fill { position: absolute; inset-inline-start: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--green); transition: width .5s; }
.road-owl { position: absolute; top: 50%; transform: translate(-50%, -62%); transition: inset-inline-start .5s; }
[dir="rtl"] .road-owl { transform: translate(50%, -62%); }
.road-flag { position: absolute; inset-inline-end: -16px; top: 50%; transform: translateY(-60%); font-size: 26px; }
.stage { display: flex; flex-direction: column; align-items: center; gap: 22px; }

/* Tokens */
.tok { display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.tok-emoji.tok-lg { font-size: 72px; }
.tok-emoji.tok-md { font-size: 56px; }
.tok-glyph { font-family: var(--font-glyph); font-weight: 700; }
.tok-glyph.tok-lg { font-size: 84px; }
.tok-glyph.tok-md { font-size: 60px; }
.tok-word { font-family: var(--font-glyph); font-weight: 700; }
.tok-word.tok-lg { font-size: 56px; }
.tok-word.tok-md { font-size: 40px; }
.tok-blank { width: 96px; height: 96px; border: 4px dashed var(--coral); border-radius: 20px; color: var(--coral); font-size: 48px; }
.tok-blank.tok-md { width: 72px; height: 72px; }
.tok.filled { animation: pop .4s; }
.tok-emoji.tok-sm { font-size: 44px; }
.tok-shadow { filter: brightness(0); opacity: .6; }
.tok-color { border-radius: 999px; background: var(--c); border: 3px solid var(--ink); }
.tok-color.tok-md { width: 56px; height: 56px; }
.tok-color.tok-sm { width: 40px; height: 40px; }
.tok-frames { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.tenframe { display: grid; grid-template-columns: repeat(5, 28px); grid-auto-rows: 28px; gap: 3px; padding: 4px;
  border: 3px solid var(--ink); border-radius: 10px; background: var(--card); }
.tenframe i { border: 2px solid var(--ink-soft, #b9a98a); border-radius: 6px; }
.tenframe i.on { background: var(--sun); border-color: var(--ink); border-radius: 50%; }
.privacy-link { color: var(--primary, #2F6FB5); font-weight: 800; font-size: 20px; }
.wg-grid { display: grid; grid-template-columns: repeat(var(--n), 1fr); margin: 0 auto; padding: 6px; background: var(--card);
  border: 3px solid var(--ink); border-radius: 18px; box-sizing: content-box; touch-action: none; user-select: none; }
.wg-cell { border: 0; background: transparent; border-radius: 12px; padding: 0; font-family: var(--font-glyph); font-weight: 700;
  font-size: calc(var(--cell, 64px) * .52); color: var(--ink); min-width: 0; min-height: 0; }
.wg-cell.sel { background: var(--sun); }
.wg-cell.found { color: #fff; }
.wg-cell.found-0 { background: #EF6C57; } .wg-cell.found-1 { background: #3B82F6; } .wg-cell.found-2 { background: #22A06B; }
.wg-cell.found-3 { background: #A855F7; } .wg-cell.found-4 { background: #E0A100; }
.wg-clues { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.wg-clue { display: inline-flex; align-items: center; gap: 8px; min-height: 64px; padding: 4px 14px; background: var(--card);
  border: 3px solid var(--ink); border-radius: 18px; font-family: var(--font-glyph); font-size: 24px; }
.wg-clue b { letter-spacing: 2px; font-weight: 700; }
.wg-clue.done { background: var(--good-soft); border-color: var(--green-dark); }
.cw-grid { display: grid; grid-template-columns: repeat(var(--cols), var(--cell, 64px)); grid-auto-rows: var(--cell, 64px); gap: 3px;
  margin: 0 auto; width: max-content; }
.cw-gap { display: block; }
.cw-cell { position: relative; background: var(--card); border: 3px solid var(--ink); border-radius: 12px; padding: 0;
  font-family: var(--font-glyph); font-weight: 700; font-size: calc(var(--cell, 64px) * .5); }
.cw-cell sup { position: absolute; top: 2px; left: 6px; font-size: 14px; font-family: var(--font-head); }
.cw-cell.line { background: #FFF1C2; }
.cw-cell.active { background: var(--sun); box-shadow: 0 0 0 4px var(--ink); }
.cw-cell.filled { background: var(--good-soft); border-color: var(--green-dark); pointer-events: none; }
.cw-clues, .cw-tray { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.cw-clue { display: inline-flex; align-items: center; gap: 6px; min-height: 64px; padding: 4px 14px; background: var(--card);
  border: 3px solid var(--ink); border-radius: 18px; font-family: var(--font-head); font-size: 22px; }
.cw-clue.on { box-shadow: 0 0 0 4px var(--sun); } .cw-clue.done { background: var(--good-soft); border-color: var(--green-dark); }
.cw-key { width: 64px; height: 64px; background: var(--card); border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 4px 0 var(--ink);
  font-family: var(--font-glyph); font-weight: 700; font-size: 30px; padding: 0; }
.spot { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; }
.spot-board { display: grid; grid-template-columns: repeat(var(--cols), 68px); gap: 4px; padding: 8px; background: var(--card);
  border: 3px solid var(--ink); border-radius: 18px; }
.spot-cell { width: 68px; height: 68px; border: 0; border-radius: 14px; background: transparent; padding: 0;
  display: flex; align-items: center; justify-content: center; }
.spot-cell.found { box-shadow: inset 0 0 0 4px var(--green-dark); background: var(--good-soft); }
.tok-clock { display: inline-flex; }
.set-clock { position: relative; margin: 0 auto; }
.set-clock .clock-face { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.clock-num { position: absolute; width: 64px; height: 64px; transform: translate(-50%, -50%); border-radius: 50%;
  border: 0; background: transparent; font-size: 0; }
.clock-num:active, .clock-num.picked { background: color-mix(in srgb, var(--sun) 60%, transparent); }
.tok-group { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; font-size: 38px; max-width: 240px; }

/* Choose */
.objects, .sequence {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; max-width: 760px;
  background: var(--card); border: 3px solid var(--ink); border-radius: var(--radius); box-shadow: 0 5px 0 var(--ink); padding: 16px;
}
.sequence { max-width: 100%; padding: 18px; }
.obj { position: relative; font-size: 64px; width: 96px; height: 96px; border-radius: 20px; }
.objects-many .obj { font-size: 52px; width: 80px; height: 80px; }
.obj.counted { background: var(--primary-soft); }
.obj-n { position: absolute; top: 2px; inset-inline-end: 4px; font-size: 20px; color: var(--primary); }
.options { display: grid; grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); gap: 18px; width: min(100%, 760px); }
.options-2 { --n: 2; } .options-3 { --n: 3; } .options-4 { --n: 4; }
.opt, .cell {
  background: var(--card); border: 3px solid var(--ink); border-radius: var(--radius); box-shadow: 0 6px 0 var(--ink);
  min-height: 140px; display: flex; align-items: center; justify-content: center; padding: 10px;
  transition: transform .1s, background .2s, box-shadow .1s;
}
.opt:active, .cell:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.opt.correct, .cell.correct { background: var(--good-soft); border-color: var(--green-dark); animation: pop .35s; }
.opt.wrong, .cell.wrong { background: var(--bad-soft); }
.opt:disabled { opacity: .5; }

/* Tap all */
.tap-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; width: min(100%, 620px); }
.cell { min-height: 110px; }

/* Trace, color, dots, puzzle, flashcards */
.trace-wrap, .color-wrap, .dots-wrap {
  background: var(--card); border-radius: var(--radius); padding: 8px; border: 3px solid var(--ink); box-shadow: 0 6px 0 var(--ink);
}
.color-wrap, .dots-wrap { padding: 0; overflow: hidden; }
.trace-canvas { display: block; touch-action: none; border-radius: 18px; }
.trace-actions { display: flex; gap: 16px; }
.tok-img { object-fit: contain; border-radius: 14px; background: #fff; }
.tok-img.tok-lg { width: 100%; max-width: 200px; height: 200px; }
.tok-img.tok-md { width: 100%; height: 110px; }
.color-canvas { display: block; touch-action: none; }
.color-art { touch-action: none; }
.color-art svg { display: block; width: 100%; height: 100%; }
.color-art [data-r] { cursor: pointer; }
.palette { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.swatch { width: 64px; height: 64px; border-radius: 999px; background: var(--c); border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink); font-size: 22px; }
.swatch.active { transform: translateY(-4px) scale(1.12); box-shadow: 0 0 0 4px var(--sun), 0 5px 0 var(--ink); }
.dots-wrap { position: relative; }
.dots-img { display: block; width: 100%; height: 100%; }
.dots-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.dot-hit { position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 999px; }
.dot-hit.next { box-shadow: 0 0 0 4px var(--sun); animation: pulse 1.2s infinite; }
.dot-hit.done { background: rgba(79, 143, 207, .3); }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(246, 196, 69, .3); } }
.puzzle { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 4px; background: var(--ink); padding: 4px; border-radius: 18px; box-shadow: 0 6px 0 var(--ink); }
.tile { border-radius: 10px; background-repeat: no-repeat; border: 0; }
.tile.hole { background: var(--paper); }
.puzzle.solved { gap: 0; }
.puzzle.solved .tile { border-radius: 0; }
.puzzle-hint { width: 120px; aspect-ratio: 1; object-fit: cover; border-radius: 12px; border: 3px solid var(--ink); }
.flashcard { display: flex; flex-direction: column; align-items: center; gap: 10px; background: var(--card); border-radius: var(--radius);
  border: 3px solid var(--ink); box-shadow: 0 6px 0 var(--ink); padding: 14px; }
.flashcard img { max-height: calc(100vh - 420px); max-width: min(100%, 420px); object-fit: contain; }
.flashcard-word { font-family: var(--font-glyph); font-weight: 700; font-size: 44px; color: var(--primary); }

/* Result */
.result { text-align: center; margin: 4vh auto 0; max-width: 620px; padding: 18px 20px 26px; }
.result-owl { display: flex; justify-content: center; padding-top: 6px; }
.result-stars { display: flex; justify-content: center; gap: 10px; margin-top: -8px; }
.rs { font-size: 76px; line-height: 1; color: #D8CDB6; -webkit-text-stroke: 3px var(--ink); }
.rs.on { color: var(--sun); animation: star-in .5s cubic-bezier(.3, 1.6, .5, 1) var(--d) both; }
@keyframes star-in { from { transform: scale(0) rotate(-90deg); } }
.result h2 { font-size: 40px; margin: 6px 0 10px; }
.xp-row { display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; }
.xp-gain { font-family: var(--font-head); font-size: 28px; font-weight: 800; color: var(--coral-dark); background: #FFE2D2;
  border: 3px solid var(--ink); border-radius: 999px; padding: 2px 16px; animation: pop .5s .9s both; }
.levelup { margin-top: 14px; display: inline-block; font-family: var(--font-head); font-size: 30px; font-weight: 800;
  background: var(--sun); border: 3px solid var(--ink); border-radius: 18px; box-shadow: 0 5px 0 var(--ink); padding: 6px 22px;
  animation: pop .5s 1.2s both, wiggle 1.6s 1.8s infinite; }
.result-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 24px; }

/* Sort, match, maze */
.sort { display: flex; flex-direction: column; align-items: center; gap: 22px; width: min(100%, 860px); }
.sort-tray { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; min-height: 96px; }
.sort-tile, .match-tile, .match-slot {
  background: var(--card); border: 3px solid var(--ink); border-radius: 20px; box-shadow: 0 5px 0 var(--ink);
  width: 96px; height: 96px; display: flex; align-items: center; justify-content: center; padding: 0;
}
.picked { box-shadow: 0 0 0 5px var(--sun), 0 5px 0 var(--ink); transform: translateY(-4px); }
.placed { pointer-events: none; animation: pop .35s; }
.gap { visibility: hidden; }
.sort-bins { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 16px; width: 100%; }
.bin {
  position: relative; min-height: 190px; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px;
  background: #F6E7C8; border: 4px dashed var(--bc, var(--ink)); border-radius: 0 0 36px 36px; border-top-style: solid;
}
.bin-label { background: var(--card); border: 3px solid var(--ink); border-radius: 999px; padding: 6px; display: flex; }
.bin-items { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.bin-items .sort-tile { width: 64px; height: 64px; box-shadow: none; border-width: 2px; }
.bin-items .tok-emoji.tok-sm { font-size: 34px; }
.match { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(40px, 12vw, 160px); }
.match-col { display: flex; flex-direction: column; gap: 16px; }
.match-tile, .match-slot { width: 112px; height: 112px; position: relative; }
.match-slot { background: #EFE6D2; border-style: dashed; box-shadow: none; }
.match-slot.correct { background: var(--good-soft); border-style: solid; border-color: var(--green-dark); }
.match-slot .match-tile { position: absolute; inset: -3px; width: auto; height: auto; box-shadow: none; background: transparent; border: 0; }
.match-slot.correct > .tok-shadow { visibility: hidden; }
.fill { display: flex; flex-direction: column; align-items: center; gap: 22px; width: min(100%, 860px); }
.fill-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; }
.fill-cell { display: flex; align-items: center; justify-content: center; min-width: 64px; }
.fill-slot { position: relative; background: #EFE6D2; border: 3px dashed var(--ink); border-radius: 20px; width: 96px; height: 96px; padding: 0; }
.fill-slot.correct { background: var(--good-soft); border-style: solid; border-color: var(--green-dark); }
.fill-slot .sort-tile { position: absolute; inset: -3px; width: auto; height: auto; box-shadow: none; background: transparent; border: 0; }
.maze { position: relative; margin: 14px; background: var(--card); border-radius: 4px; box-shadow: 0 0 0 12px var(--card), 0 0 0 15px var(--ink); }
.maze-grid { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.maze-walls { stroke: var(--ink); stroke-width: .12; stroke-linecap: round; }
.maze-trail { stroke: var(--sun); stroke-width: .34; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
.maze-owl, .maze-goal { position: absolute; transform: translate(-50%, -50%); pointer-events: none; display: flex; }
.maze-owl { transition: left .12s, top .12s; z-index: 2; }
.maze-owl .owl { width: calc(var(--cell) * .8); height: calc(var(--cell) * .9); margin-top: 8%; }
.maze-goal .tok-emoji.tok-sm { font-size: calc(var(--cell) * .6); }
.maze.solved .maze-goal { animation: pop .5s; }

/* drag.js */
.dragging { position: relative; z-index: 20; cursor: grabbing; filter: drop-shadow(0 8px 6px rgba(0, 0, 0, .25)); }
.drag-return { transition: transform .25s ease-out; }

.shake { animation: shake .4s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-10px); } 75% { transform: translateX(10px); } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* Parents' corner */
.parent-title { margin: 0; font-size: 26px; }
.langs { display: flex; gap: 6px; }
.lang { font-size: 24px; width: 50px; height: 50px; border-radius: 999px; border: 3px solid var(--ink); background: var(--card); opacity: .5; }
.lang.lang-name { width: auto; padding: 0 12px; font-size: 18px; }
.lang.active { opacity: 1; background: var(--sun); box-shadow: 0 3px 0 var(--ink); }
[dir="rtl"] .flip-rtl { display: inline-block; transform: scaleX(-1); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin: 8px 0 18px; }
.stat { padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.stat b { font-family: var(--font-head); font-size: 26px; }
.stat span, .muted { color: var(--ink-soft); font-size: 15px; }
.panel { padding: 14px 18px; margin-bottom: 18px; }
.panel h3 { margin: 2px 0 12px; font-size: 22px; }
.track-row { margin-bottom: 14px; }
.track-head { display: flex; justify-content: space-between; font-size: 18px; }
.bar { height: 16px; background: #EFE6D2; border: 2.5px solid var(--ink); border-radius: 999px; overflow: hidden; margin: 6px 0; }
.bar span { display: block; height: 100%; background: var(--zc); }
.track-where { color: var(--ink-soft); font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--primary-soft); border: 2.5px solid var(--ink); border-radius: 999px; padding: 8px 14px; }
.level-chip { font-size: 18px; font-weight: 800; padding: 10px 22px; opacity: .6; }
.level-chip.active { opacity: 1; background: var(--sun); box-shadow: 0 3px 0 var(--ink); }
.level-ready { font-weight: 800; margin: 10px 0 0; }
.panel h4 { margin: 16px 0 8px; font-size: 18px; }
.time-today { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; margin: 0 0 12px; font-size: 20px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; max-width: 560px; }
.cal-day { display: flex; flex-direction: column; align-items: center; padding: 4px 2px 6px; border-radius: 12px;
  border: 2px solid #E4D8BE; background: #F7F0E0; color: var(--ink-soft); min-height: 70px; }
.cal-day i { font-style: normal; font-size: 12px; }
.cal-day span { font-weight: 800; font-size: 17px; }
.cal-day b { font-size: 14px; color: var(--green-dark); }
.cal-day.on { background: var(--good-soft); border-color: var(--green-dark); color: var(--ink); }
.cal-day.today { box-shadow: 0 0 0 3px var(--sun); }
.lv-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.lv-pill { font-size: 13px; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: #EFE6D2; border: 1.5px solid var(--ink); }
.lv-pill.later { opacity: .55; }
.quest-done.time-up { font-family: var(--font-head); font-size: 20px; font-weight: 800; }

@media (max-width: 700px) {
  .hud-lv .xpbar { width: 80px; }
  .quest-head { width: 100%; }
  .q-step { width: 60px; height: 60px; }
  .zone-title { font-size: 20px; padding-inline-end: 14px; }
  .zone-title .landmark { width: 46px; }
  .options { gap: 10px; }
  .opt { min-height: 110px; }
  .tok-emoji.tok-lg { font-size: 52px; }
  .tok-glyph.tok-lg { font-size: 60px; }
  .tok-blank { width: 70px; height: 70px; }
  .obj { width: 72px; height: 72px; font-size: 48px; }
  .owl-say .owl { width: 64px; height: 72px; }
  .sort-tile { width: 76px; height: 76px; }
  .match-tile, .match-slot { width: 88px; height: 88px; }
  .fill-slot { width: 76px; height: 76px; }
}

/* Phones: keep the parents' button on screen (the iPad layout needs ~420px for the header) */
@media (max-width: 440px) {
  .hud { gap: 6px; }
  .hud-right { gap: 6px; }
  .hud-me { padding-inline-end: 10px; gap: 4px; }
  .hud-lv .xpbar { width: 52px; }
  .hud-right .pill { padding-inline: 8px; }
}

[hidden] { display: none !important; }
