/* Layout: one screen at a time under a slim top bar; big touch targets (min 72px), calm sea-glass palette. */
@font-face { font-family: "Andika App"; src: url("../fonts/andika.woff") format("woff"); font-display: block; }
:root {
  --bg: #EAF3F0;        /* sea-glass mist */
  --panel: #FFFFFF;
  --ink: #2C3A38;
  --ink-soft: #5F716D;
  --teal: #2F6F6A;      /* primary */
  --teal-soft: #CFE5DF;
  --apricot: #F2A65A;   /* warm accent */
  --apricot-soft: #FCE6CF;
  --gold: #F4C430;
  --good: #4FA36B;
  --try: #D9785F;
  --line-blue: #9CC3E0;
  --line-red: #E39A92;
  --lock: #B9C6C2;
  --en: "Andika App", "Andika", "Comic Sans MS", "Trebuchet MS", sans-serif;
  --ar: "Segoe UI", Tahoma, "Noto Sans Arabic", "Geeza Pro", "Arial", sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--ar); font-size: 20px; overscroll-behavior: none; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 4px solid var(--apricot); outline-offset: 3px; }
[hidden] { display: none !important; }
.en { font-family: var(--en); direction: ltr; unicode-bidi: isolate; }
.ic { width: 1em; height: 1em; display: block; }

#app { height: 100%; display: flex; flex-direction: column; }
#bar { display: flex; align-items: center; gap: 10px; padding: 10px max(14px, env(safe-area-inset-left, 0px)); padding-top: max(10px, env(safe-area-inset-top, 0px)); }
#bar .spacer { flex: 1; }
.barbtn { width: 60px; height: 60px; border-radius: 20px; background: var(--panel); color: var(--teal); font-size: 30px; display: grid; place-items: center; box-shadow: 0 3px 0 #D3E3DE; }
.barbtn.small { width: 48px; height: 48px; font-size: 22px; border-radius: 16px; }
.barbtn:active { transform: translateY(2px); box-shadow: none; }
.starcount { display: flex; align-items: center; gap: 6px; height: 60px; padding: 0 14px 0 8px; border-radius: 20px; background: var(--panel); box-shadow: 0 3px 0 #D3E3DE; }
.starcount #petMini { width: 46px; height: 46px; }
.starcount .num { font-family: var(--en); font-size: 28px; color: #9A7400; display: flex; align-items: center; gap: 4px; }
.starcount .num::before { content: ""; width: 26px; height: 26px; background: var(--gold); clip-path: polygon(50% 0, 62% 36%, 100% 38%, 70% 60%, 80% 98%, 50% 76%, 20% 98%, 30% 60%, 0 38%, 38% 36%); }
.vol { display: flex; align-items: center; gap: 6px; background: var(--panel); border-radius: 20px; padding: 6px; box-shadow: 0 3px 0 #D3E3DE; }
.vol .barbtn { box-shadow: none; background: var(--teal-soft); }
.volmeter { display: flex; gap: 3px; align-items: flex-end; height: 34px; padding: 0 4px; direction: ltr; color: var(--teal); }
.volmeter .note { width: 22px; height: 22px; margin-inline-end: 2px; }
.volmeter i { width: 6px; border-radius: 3px; background: var(--teal-soft); }
.volmeter i.on { background: var(--teal); }

#screen { flex: 1; min-height: 0; overflow-y: auto; padding: 8px max(16px, env(safe-area-inset-right, 0px)) max(20px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.wrap { max-width: 980px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
h1, h2 { margin: 0; text-wrap: balance; }
.hint { color: var(--ink-soft); font-size: 18px; }

/* Start */
.start { min-height: 100%; display: grid; place-items: center; text-align: center; }
.start .pet-big { width: min(240px, 50vw); margin: 0 auto; }
.start h1 { font-size: 34px; color: var(--teal); }
.bigplay { width: 150px; height: 150px; border-radius: 50%; background: var(--teal); color: #fff; font-size: 70px; display: grid; place-items: center; margin: 18px auto 0; box-shadow: 0 8px 0 #1F4E4A; animation: breathe 2.4s ease-in-out infinite; }
.bigplay svg { transform: scaleX(-1); }
[dir=rtl] .bigplay svg { transform: none; }

/* Home: lesson path */
.unit { display: flex; flex-direction: column; gap: 12px; }
.unit-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.unit-title h2 { font-size: 26px; color: var(--teal); }
.unit-title .en { font-size: 22px; color: var(--ink-soft); }
.lessons { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.lesson-card { position: relative; display: flex; align-items: center; gap: 14px; padding: 14px; min-height: 120px; border-radius: 26px; background: var(--panel); box-shadow: 0 5px 0 #D3E3DE; text-align: start; }
.lesson-card .num { flex: none; width: 66px; height: 66px; border-radius: 50%; display: grid; place-items: center; font-family: var(--en); font-size: 34px; background: var(--teal-soft); color: var(--teal); }
.lesson-card .txt { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.lesson-card .t { font-size: 24px; font-weight: 700; }
.lesson-card .pages { font-size: 17px; color: var(--ink-soft); }
.lesson-card .pages b { font-family: var(--en); font-weight: 400; direction: ltr; unicode-bidi: isolate; }
.lesson-card .stars3 { display: flex; gap: 2px; margin-top: 2px; }
.lesson-card.done .num { background: var(--good); color: #fff; }
.lesson-card.current { box-shadow: 0 5px 0 var(--apricot), 0 0 0 4px var(--apricot) inset; }
.lesson-card.locked { background: #F2F6F5; color: var(--lock); box-shadow: none; }
.lesson-card.locked .num { background: #E3EBE9; color: var(--lock); font-size: 30px; }
.lesson-card .thumbs { margin-inline-start: auto; display: flex; gap: 4px; }
.lesson-card .thumbs svg { width: 56px; height: 56px; }
.lesson-card.locked .thumbs { opacity: .35; filter: grayscale(1); }
.parent-btn { align-self: center; width: 52px; height: 52px; color: var(--lock); font-size: 26px; display: grid; place-items: center; border-radius: 50%; }

/* Lesson screen */
.lesson-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.lesson-head h1 { font-size: 30px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; background: var(--apricot-soft); color: #8A4E14; font-size: 18px; }
.chip b { font-family: var(--en); font-weight: 400; direction: ltr; unicode-bidi: isolate; }
.games { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.game-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 170px; border-radius: 28px; background: var(--panel); box-shadow: 0 6px 0 #D3E3DE; padding: 14px; }
.game-tile .gi { width: 82px; height: 82px; border-radius: 26px; display: grid; place-items: center; font-size: 50px; color: #fff; }
.game-tile .gl { font-size: 20px; font-weight: 700; }
.game-tile .gs { display: flex; gap: 3px; min-height: 22px; }
.game-tile.cards .gi { background: var(--apricot); }
.game-tile.listen .gi { background: #5B9BC9; }
.game-tile.trace .gi { background: #E08A7A; }
.game-tile.memory .gi { background: #8C7CC6; }
.game-tile.sentence .gi { background: #4FA36B; }
.game-tile.say .gi { background: #D3A82A; }
.game-tile.pulse { animation: nudge 1.6s ease-in-out infinite; box-shadow: 0 6px 0 var(--apricot), 0 0 0 4px var(--apricot) inset; }
.s { width: 22px; height: 22px; background: #E2E8E6; clip-path: polygon(50% 0, 62% 36%, 100% 38%, 70% 60%, 80% 98%, 50% 76%, 20% 98%, 30% 60%, 0 38%, 38% 36%); }
.s.on { background: var(--gold); }

/* Game shell */
.game { max-width: 980px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; min-height: 100%; }
.progress { display: flex; gap: 6px; justify-content: center; direction: ltr; }
.progress i { width: 18px; height: 18px; border-radius: 50%; background: #D6E3DF; }
.progress i.done { background: var(--good); }
.progress i.now { background: var(--apricot); transform: scale(1.25); }
.prompt { display: flex; justify-content: center; }
.hear { display: inline-flex; align-items: center; gap: 12px; height: 84px; padding: 0 28px; border-radius: 42px; background: var(--teal); color: #fff; font-size: 40px; box-shadow: 0 6px 0 #1F4E4A; }
.hear .lbl { font-size: 30px; }
.hear:active { transform: translateY(3px); box-shadow: 0 3px 0 #1F4E4A; }
.choices { display: grid; grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); gap: 16px; }
.choice { aspect-ratio: 1; border-radius: 30px; background: var(--panel); box-shadow: 0 6px 0 #D3E3DE; padding: 10px; display: grid; place-items: center; transition: transform .15s; }
.choice svg { width: 100%; height: 100%; }
.choice.right { box-shadow: 0 0 0 7px var(--good); animation: pop .5s; }
.choice.wrong { animation: shake .45s; opacity: .45; }
.choice:disabled { cursor: default; }

/* Flashcards */
.card { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: center; background: var(--panel); border-radius: 36px; padding: 22px; box-shadow: 0 8px 0 #D3E3DE; }
.card .art { border-radius: 26px; overflow: hidden; }
.card .art svg { width: 100%; height: auto; display: block; }
.card .words { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.card .word-en { font-family: var(--en); font-size: clamp(48px, 9vw, 92px); line-height: 1; color: var(--teal); direction: ltr; }
.card .word-ar { font-size: clamp(30px, 5vw, 44px); color: var(--ink); }
.card .row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.pill { display: inline-flex; align-items: center; gap: 10px; height: 64px; padding: 0 20px; border-radius: 32px; font-size: 22px; font-weight: 700; }
.pill .ic { width: 30px; height: 30px; }
.pill.en-btn { background: var(--teal); color: #fff; }
.pill.ar-btn { background: var(--apricot-soft); color: #8A4E14; }
.navrow { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.navbtn { width: 84px; height: 84px; border-radius: 50%; background: var(--apricot); color: #fff; font-size: 44px; display: grid; place-items: center; box-shadow: 0 6px 0 #C67B33; }
.navbtn:disabled { background: #E3EBE9; color: #fff; box-shadow: none; }
.navbtn.go { background: var(--good); box-shadow: 0 6px 0 #357A4D; }
.dots { display: flex; gap: 8px; direction: ltr; }
.dots i { width: 14px; height: 14px; border-radius: 50%; background: #D6E3DF; }
.dots i.on { background: var(--teal); }

/* Tracing */
.trace-wrap { display: grid; grid-template-columns: minmax(120px, 200px) minmax(0, 1fr); gap: 16px; align-items: center; }
.trace-side { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.trace-side .art svg { width: 100%; height: auto; border-radius: 24px; }
.trace-side .lbl { font-family: var(--en); font-size: 40px; color: var(--teal); direction: ltr; }
.trace-board { background: var(--panel); border-radius: 30px; box-shadow: 0 6px 0 #D3E3DE; padding: 10px; display: flex; justify-content: center; }
.trace-board svg { width: 100%; max-height: 58vh; touch-action: none; display: block; }
.trace-board .guide { fill: none; stroke: #C9D6D2; stroke-linecap: round; stroke-linejoin: round; }
.trace-board .dash { fill: none; stroke: #8FA39E; stroke-linecap: round; stroke-dasharray: 2 14; }
.trace-board .ink { fill: none; stroke: var(--teal); stroke-linecap: round; stroke-linejoin: round; }
.trace-board .done-ink { fill: none; stroke: var(--good); stroke-linecap: round; stroke-linejoin: round; }
.trace-board .startdot { fill: #E04A5A; }
.trace-board .startring { fill: none; stroke: #E04A5A; stroke-width: 4; animation: ring 1.4s ease-out infinite; transform-box: fill-box; transform-origin: center; }
.trace-board .arrow { fill: #E04A5A; }
.trace-board .numtag { font-family: var(--en); font-size: 30px; fill: #E04A5A; }
.trace-board .finger { fill: var(--apricot); opacity: .9; }

/* Memory */
.memgrid { display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); gap: 14px; max-width: 760px; margin: 0 auto; width: 100%; }
.mem { aspect-ratio: 1; perspective: 800px; }
.mem .in { display: block; position: relative; width: 100%; height: 100%; transition: transform .45s; transform-style: preserve-3d; }
.mem.open .in, .mem.matched .in { transform: rotateY(180deg); }
.mem .face { position: absolute; inset: 0; border-radius: 22px; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: grid; place-items: center; }
.mem .back { background: var(--teal); box-shadow: 0 5px 0 #1F4E4A; color: #fff; font-size: 44px; }
.mem .back .ic { opacity: .5; }
.mem .front { background: var(--panel); transform: rotateY(180deg); padding: 6px; box-shadow: 0 5px 0 #D3E3DE; }
.mem .front svg { width: 100%; height: 100%; }
.mem.matched .front { box-shadow: 0 0 0 5px var(--good); }

/* Say it */
.say-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: center; background: var(--panel); border-radius: 36px; padding: 22px; box-shadow: 0 8px 0 #D3E3DE; }
.say-card .art svg { width: 100%; height: auto; border-radius: 26px; display: block; }
.say-card .side { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.mic { position: relative; width: 140px; height: 140px; border-radius: 50%; background: #E04A5A; color: #fff; font-size: 70px; display: grid; place-items: center; box-shadow: 0 7px 0 #A8303E; }
.mic.rec { animation: breathe 1s ease-in-out infinite; }
.mic svg.ringp { position: absolute; inset: -10px; width: calc(100% + 20px); height: calc(100% + 20px); transform: rotate(-90deg); }
.mic:disabled { background: #E3EBE9; box-shadow: none; }
.saysteps { display: flex; gap: 10px; }
.saysteps span { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: #EEF3F1; color: var(--lock); font-size: 28px; }
.saysteps span.on { background: var(--teal-soft); color: var(--teal); }
.saysteps span.ok { background: var(--good); color: #fff; }

/* Overlay: reward */
#overlay { position: fixed; inset: 0; background: rgba(44, 58, 56, .55); display: grid; place-items: center; z-index: 50; padding: 20px; }
.reward { background: var(--panel); border-radius: 40px; padding: 26px 30px; text-align: center; max-width: 520px; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; animation: rise .4s ease-out; }
.reward .petsvg { width: 200px; height: 200px; animation: hop 0.9s ease-in-out 2; }
.reward .bigstars { display: flex; gap: 10px; direction: ltr; }
.reward .bigstars .s { width: 64px; height: 64px; }
.reward .bigstars .s.on { animation: starpop .5s backwards; }
.reward .bigstars .s.on:nth-child(2) { animation-delay: .25s; }
.reward .bigstars .s.on:nth-child(3) { animation-delay: .5s; }
.reward h2 { font-size: 30px; color: var(--teal); }

/* Pet room */
.petroom { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.petroom .petsvg { width: min(320px, 70vw); height: auto; cursor: pointer; }
.petroom .petsvg.hop { animation: hop .7s ease-in-out; }
.gifts { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.gift { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 14px; border-radius: 20px; background: var(--panel); min-width: 96px; }
.gift .need { font-family: var(--en); display: flex; gap: 4px; align-items: center; font-size: 18px; color: #9A7400; direction: ltr; }
.gift.got { background: var(--teal-soft); }
.gift.not { opacity: .5; }

/* Parent corner */
.parent { background: var(--panel); border-radius: 28px; padding: 22px; display: flex; flex-direction: column; gap: 14px; max-width: 640px; margin: 0 auto; }
.parent p { margin: 0; line-height: 1.7; font-size: 18px; color: var(--ink-soft); }
.pbtn { min-height: 56px; padding: 0 20px; border-radius: 18px; background: var(--teal-soft); color: var(--teal); font-weight: 700; }
.pbtn.warn { background: #F7DCD5; color: #9B3A26; }
.holdring { position: fixed; inset: 0; pointer-events: none; }

@keyframes breathe { 50% { transform: scale(1.06); } }
@keyframes nudge { 50% { transform: translateY(-4px); } }
@keyframes pop { 40% { transform: scale(1.08); } }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
@keyframes ring { from { transform: scale(.6); opacity: 1; } to { transform: scale(2); opacity: 0; } }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }
@keyframes hop { 30% { transform: translateY(-26px) rotate(-4deg); } 60% { transform: translateY(0); } 75% { transform: translateY(-8px); } }
@keyframes starpop { from { transform: scale(0) rotate(-40deg); } 70% { transform: scale(1.25); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@media (max-width: 640px) {
  body { font-size: 18px; }
  .barbtn { width: 52px; height: 52px; font-size: 26px; }
  .starcount { height: 52px; }
  .vol .volmeter { display: none; }
  .card, .say-card { grid-template-columns: 1fr; }
  .trace-wrap { grid-template-columns: 1fr; }
  .trace-side { flex-direction: row; justify-content: center; }
  .trace-side .art { width: 110px; }
  .choices { gap: 10px; }
  .games { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lessons { grid-template-columns: 1fr; }
}
