:root {
  --bg: #f8f4ea;
  --panel: #fffdf7;
  --ink: #3f4a3c;
  --soft: #8a917f;
  --green: #5f8f6a;
  --green-l: #dde8d8;
  --blue: #a8d0e6;
  --sand: #efe3c8;
  --peach: #f4c2a8;
  --gold: #e8b64c;
  --line: #e4dccb;
  --shadow: 0 6px 0 rgba(63, 74, 60, .12);
  --word-font: "Simplified Arabic", "Noto Naskh Arabic", "Geeza Pro", "Traditional Arabic", "Segoe UI", Tahoma, sans-serif;
  --ui-font: "Segoe UI", "Noto Sans Arabic", "Geeza Pro", Tahoma, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--ui-font); overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
svg { display: block; width: 100%; height: 100%; }
#app { height: 100%; }
.screen { position: relative; height: 100%; display: flex; flex-direction: column; align-items: center; padding: 16px 20px 20px; overflow-y: auto; }

/* الشريط العلوي */
.topbar { width: 100%; display: flex; align-items: center; gap: 14px; min-height: 76px; padding-left: 230px; }
.back, .repeat, .gear { width: 72px; height: 72px; border-radius: 22px; background: var(--panel); box-shadow: var(--shadow); font-size: 38px; flex: none; }
.repeat { margin-inline-start: auto; background: var(--green-l); }
.star-count { font-size: 32px; background: var(--panel); border-radius: 22px; padding: 8px 20px; box-shadow: var(--shadow); }
.star-count b { color: #b7862a; }
.gear { margin-inline-start: auto; font-size: 30px; color: var(--soft); width: 56px; height: 56px; position: relative; overflow: hidden; }
.gear.holding::after { content: ""; position: absolute; inset: 0; background: rgba(95, 143, 106, .35); animation: fill 2s linear forwards; transform-origin: right; }
@keyframes fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.pet-btn { width: 76px; height: 76px; border-radius: 50%; background: var(--panel); box-shadow: var(--shadow); font-size: 36px; padding: 6px; }

/* زر الموسيقى */
.music { position: fixed; top: 16px; left: 16px; display: flex; align-items: center; gap: 6px; background: var(--panel); border-radius: 26px; padding: 6px; box-shadow: var(--shadow); z-index: 10; direction: ltr; }
.mbtn { width: 58px; height: 58px; border-radius: 20px; background: var(--green-l); font-size: 30px; font-weight: bold; }
.mnote { font-size: 24px; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 36px; }
.bars i { width: 9px; border-radius: 4px; background: var(--line); }
.bars i:nth-child(1) { height: 30%; } .bars i:nth-child(2) { height: 55%; } .bars i:nth-child(3) { height: 78%; } .bars i:nth-child(4) { height: 100%; }
.bars i.on { background: var(--green); }

/* البداية */
.splash { justify-content: center; gap: 10px; }
.splash h1 { font-family: var(--word-font); font-size: 110px; margin: 0; color: var(--green); line-height: 1.1; }
.splash-letters { display: flex; gap: 18px; font-family: var(--word-font); font-size: 54px; }
.splash-letters span { width: 84px; height: 84px; display: grid; place-items: center; border-radius: 24px; background: var(--panel); box-shadow: var(--shadow); animation: bob 3s ease-in-out infinite; }
.splash-letters span:nth-child(2) { animation-delay: .4s; } .splash-letters span:nth-child(3) { animation-delay: .8s; } .splash-letters span:nth-child(4) { animation-delay: 1.2s; }
.splash-pet { width: 170px; height: 180px; }
.play-btn { width: 150px; height: 150px; border-radius: 50%; background: var(--green); color: #fff; font-size: 70px; box-shadow: 0 8px 0 #4a7353; animation: pulse 2s ease-in-out infinite; padding-left: 10px; }

/* الخريطة */
.map { width: 100%; max-width: 1100px; display: flex; flex-direction: column; gap: 26px; padding: 16px 0 30px; }
.unit { background: var(--panel); border-radius: 32px; padding: 18px 22px 24px; box-shadow: var(--shadow); }
.unit-title { display: flex; align-items: baseline; gap: 16px; margin-bottom: 14px; font-size: 28px; }
.unit-title span { font-family: var(--word-font); font-size: 34px; color: var(--soft); }
.nodes { display: flex; flex-wrap: wrap; gap: 18px; }
.node { width: 150px; height: 168px; border-radius: 34px; background: var(--green-l); display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: var(--shadow); }
.node-letter { font-family: var(--word-font); font-size: 76px; line-height: 1; }
.node.review { background: var(--sand); } .node.review .node-letter { font-size: 54px; }
.node-page { font-size: 20px; color: var(--soft); margin-top: 6px; }
.node-stars { font-size: 24px; color: var(--gold); letter-spacing: 2px; }
.node.locked { background: #ece8de; color: #b3aea0; filter: grayscale(.6); opacity: .65; }
.node.current { outline: 5px solid var(--green); animation: pulse 2.2s ease-in-out infinite; }

/* الدرس */
.lesson-head { display: flex; flex-direction: column; align-items: center; margin: 4px 0 18px; }
.lesson-letter { width: 190px; height: 190px; border-radius: 48px; background: var(--green); color: #fff; font-family: var(--word-font); font-size: 130px; line-height: 1; display: grid; place-items: center; box-shadow: 0 8px 0 #4a7353; }
.lesson-letter.review { width: auto; padding: 0 40px; font-size: 90px; background: var(--sand); color: var(--ink); box-shadow: var(--shadow); }
.lesson-page { margin-top: 12px; font-size: 22px; color: var(--soft); }
.acts { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; max-width: 1100px; }
.act { width: 180px; height: 190px; border-radius: 34px; background: var(--panel); box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.act-icon { font-size: 68px; line-height: 1.1; }
.act-name { font-size: 22px; }
.act-stars { font-size: 24px; color: var(--gold); min-height: 30px; }
.act.next { outline: 5px solid var(--green); animation: pulse 2.2s ease-in-out infinite; }

/* اللعبة */
.game .stage { flex: 1; width: 100%; max-width: 1150px; display: flex; align-items: center; justify-content: center; min-height: 0; }
.dots { display: flex; gap: 10px; margin-inline-start: 10px; }
.dots i { width: 22px; height: 22px; border-radius: 50%; background: var(--line); }
.dots i.done { background: var(--green); } .dots i.now { background: var(--gold); transform: scale(1.25); }

/* البطاقات */
.cards { display: flex; align-items: center; gap: 22px; width: 100%; justify-content: center; }
.nav-btn { width: 96px; height: 96px; border-radius: 50%; background: var(--green); color: #fff; font-size: 52px; box-shadow: 0 6px 0 #4a7353; flex: none; }
.nav-btn.prev { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.card { width: min(560px, 70vw); min-height: min(540px, 72vh); background: var(--panel); border-radius: 40px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 22px; cursor: pointer; }
.card.flip { animation: cardIn .45s ease-out; }
.card-pic { width: min(300px, 40vh); height: min(300px, 40vh); }
.card-word { font-family: var(--word-font); font-size: 92px; line-height: 1.3; }
.card-word .hl, .find-word .hl { color: #e07b39; }
.card-meaning { font-size: 24px; color: var(--soft); text-align: center; max-width: 460px; line-height: 1.5; }
.card-letter { font-family: var(--word-font); font-size: 250px; line-height: 1.1; color: var(--green); }
.card-caption { font-size: 34px; color: var(--soft); }

/* الكتابة */
.trace-wrap { display: flex; align-items: center; gap: 18px; width: 100%; height: 100%; max-height: 640px; }
.trace-side { display: flex; flex-direction: column; align-items: center; gap: 16px; flex: none; }
.trace-model { width: 130px; height: 130px; border-radius: 34px; background: var(--panel); box-shadow: var(--shadow); display: grid; place-items: center; font-family: var(--word-font); font-size: 92px; line-height: 1; padding-bottom: 16px; color: var(--green); }
.level-pills { display: flex; gap: 6px; }
.level-pills span { width: 36px; height: 36px; border-radius: 50%; background: var(--line); display: grid; place-items: center; font-size: 20px; }
.level-pills span.on { background: var(--gold); color: #fff; }
.demo-btn { background: var(--sand); border-radius: 20px; padding: 12px 18px; font-size: 24px; box-shadow: var(--shadow); }
svg.trace { flex: 1; height: 100%; max-height: 620px; background: var(--panel); border-radius: 36px; box-shadow: var(--shadow); touch-action: none; }
svg.trace.win { animation: winGlow 1s ease-out; }
.ink { fill: none; stroke: #5b8fc7; stroke-width: 24; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.start-dot { fill: #6dbb6a; stroke: #fff; stroke-width: 5; animation: dotPulse 1.3s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.start-num { fill: #fff; font: bold 28px var(--ui-font); pointer-events: none; }
.nudge { animation: shake .4s; }

/* البالونات */
.balloons { display: flex; justify-content: center; align-items: center; gap: min(60px, 5vw); width: 100%; height: 100%; }
.balloon { position: relative; width: min(210px, 26vw); height: min(250px, 31vw); border-radius: 50% 50% 47% 53% / 55% 55% 45% 45%; background: var(--c); box-shadow: inset -18px -14px 0 rgba(0, 0, 0, .06), 0 6px 0 rgba(63, 74, 60, .1); animation: bob 3.2s ease-in-out infinite; animation-delay: var(--d); }
.balloon::before { content: ""; position: absolute; top: 18%; left: 22%; width: 18%; height: 22%; border-radius: 50%; background: rgba(255, 255, 255, .5); }
.balloon::after { content: ""; position: absolute; left: 50%; top: 100%; width: 3px; height: 90px; background: #b9b1a0; }
.balloon span { font-family: var(--word-font); font-size: min(130px, 15vw); line-height: 1; position: relative; top: -4px; }
.balloon.popped { animation: popped .45s ease-out forwards; }
.balloon.shake { animation: shake .45s; }

/* أين الصورة */
.pics { display: flex; justify-content: center; gap: min(36px, 3vw); width: 100%; }
.pic-card { position: relative; width: min(300px, 29vw); height: min(300px, 29vw); background: var(--panel); border-radius: 36px; box-shadow: var(--shadow); padding: 20px; transition: transform .2s, opacity .3s; }
.pic-card.right { outline: 8px solid var(--green); transform: scale(1.06); }
.pic-card.wrong { opacity: .35; animation: shake .45s; }
.pic-label { position: absolute; bottom: -14px; left: 50%; transform: translateX(-50%); background: var(--green); color: #fff; font-family: var(--word-font); font-size: 40px; padding: 0 22px; border-radius: 18px; }

/* الحرف في الكلمة */
.find { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "pic target" "word word"; align-items: center; gap: 10px 30px; background: var(--panel); border-radius: 40px; padding: 26px 40px; box-shadow: var(--shadow); }
.find-pic { grid-area: pic; width: min(240px, 30vh); height: min(240px, 30vh); cursor: pointer; }
.find-target { grid-area: target; justify-self: center; width: 140px; height: 140px; border-radius: 36px; background: var(--sand); display: grid; place-items: center; font-family: var(--word-font); font-size: 100px; cursor: pointer; }
.find-word { grid-area: word; justify-self: center; font-family: var(--word-font); font-size: min(170px, 20vw); line-height: 1.35; cursor: pointer; padding: 0 20px; }
.find-word span { transition: color .2s; }
.find-word span.bad { color: #d98b7e; animation: shake .4s; display: inline-block; }

/* النتيجة */
.result { justify-content: center; gap: 18px; }
.result-stars { display: flex; gap: 14px; font-size: 120px; line-height: 1; color: var(--line); }
.result-stars span.on { color: var(--gold); animation: starIn .5s ease-out both; animation-delay: calc(var(--i) * .25s); }
.result-pet { width: 180px; height: 190px; animation: bob 2s ease-in-out infinite; }
.result-btns { display: flex; gap: 20px; }
.big-btn { min-width: 120px; height: 110px; border-radius: 34px; background: var(--panel); box-shadow: var(--shadow); font-size: 50px; padding: 0 26px; }
.big-btn.go { background: var(--green); color: #fff; box-shadow: 0 6px 0 #4a7353; min-width: 190px; animation: pulse 2s ease-in-out infinite; }

/* الحيوان الأليف */
.pet-choices { flex: 1; display: flex; align-items: center; justify-content: center; gap: 30px; flex-wrap: wrap; }
.pet-choice { width: 230px; height: 280px; background: var(--panel); border-radius: 36px; box-shadow: var(--shadow); padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 30px; }
.pet-choice svg { height: 200px; }
.pet-big { width: 320px; height: 340px; transform: scale(var(--scale, 1)); transition: transform .5s; cursor: pointer; }
.pet-big.happy { animation: happy .7s ease-out; }
.pet-xp { width: 320px; height: 26px; border-radius: 13px; background: var(--line); overflow: hidden; margin: 10px 0 18px; }
.pet-xp i { display: block; height: 100%; background: var(--gold); transition: width .4s; }
.feed { background: var(--gold); color: #fff; box-shadow: 0 6px 0 #c2932f; font-size: 40px; }

/* ولي الأمر */
.parent { align-items: stretch; }
.parent .topbar h2 { margin: 0; font-size: 28px; }
.parent-body { max-width: 900px; margin: 0 auto; font-size: 20px; line-height: 1.6; }
.tables { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.parent table { border-collapse: collapse; background: var(--panel); border-radius: 16px; overflow: hidden; }
.parent th, .parent td { padding: 6px 16px; border-bottom: 1px solid var(--line); text-align: center; }
.parent td:first-child { font-family: var(--word-font); font-size: 28px; }
.parent tr.hard { background: #fbe6df; }
.toggle { display: flex; gap: 10px; align-items: center; margin: 22px 0; font-size: 22px; }
.toggle input { width: 28px; height: 28px; }
.reset { background: #f1d6cf; border-radius: 16px; padding: 12px 22px; font-size: 20px; }

/* تسجيل الأصوات */
.rec-open { display: block; background: var(--green); color: #fff; border-radius: 16px; padding: 14px 22px; font-size: 22px; margin: 22px 0 0; box-shadow: 0 5px 0 #4a7353; }
.rec-status { position: sticky; top: 0; z-index: 2; background: var(--sand); border-radius: 14px; padding: 10px 16px; margin: 10px 0; font-size: 20px; }
.rec-list h3 { margin: 22px 0 8px; font-size: 24px; color: var(--green); }
.rec-row { display: flex; align-items: center; gap: 10px; background: var(--panel); border-radius: 16px; padding: 8px 12px; margin-bottom: 8px; box-shadow: 0 3px 0 rgba(63, 74, 60, .08); }
.rec-row.done { background: #eef5ea; }
.rec-row.next { outline: 3px solid var(--gold); }
.rec-row.recording { outline: 4px solid #d9534f; background: #fbe6df; }
.rec-ok { width: 28px; text-align: center; color: var(--green); font-size: 22px; }
.rec-text { flex: 1; font-family: var(--word-font); font-size: 28px; line-height: 1.5; }
.rec-row button { width: 56px; height: 56px; border-radius: 16px; font-size: 26px; background: var(--green-l); flex: none; }
.rec-row .rec-rec { background: #f1d6cf; color: #c0392b; }
.rec-row.recording .rec-rec { background: #d9534f; color: #fff; animation: pulse 1s infinite; }

@keyframes bob{ 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
@keyframes popped { 0% { transform: scale(1); opacity: 1; } 60% { transform: scale(1.3); opacity: .7; } 100% { transform: scale(.2); opacity: 0; } }
@keyframes cardIn { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes starIn { from { transform: scale(0) rotate(-40deg); } to { transform: scale(1) rotate(0); } }
@keyframes dotPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.2); } }
@keyframes happy { 0% { transform: scale(var(--scale, 1)); } 30% { transform: scale(calc(var(--scale, 1) * 1.12)) translateY(-20px); } 60% { transform: scale(var(--scale, 1)) rotate(-4deg); } 100% { transform: scale(var(--scale, 1)); } }
@keyframes winGlow { 0% { box-shadow: 0 0 0 0 rgba(95, 143, 106, .6); } 100% { box-shadow: 0 0 0 30px rgba(95, 143, 106, 0); } }
.shake { animation: shake .45s; }

/* شاشات صغيرة (جوال) */
@media (max-width: 760px) {
  .topbar { padding-left: 0; padding-top: 70px; }
  .music { top: 8px; left: 8px; }
  .node { width: 120px; height: 140px; } .node-letter { font-size: 60px; }
  .act { width: 140px; height: 150px; } .act-icon { font-size: 50px; }
  .trace-wrap { flex-direction: column; } .trace-side { flex-direction: row; }
  .trace-model { width: 80px; height: 80px; font-size: 56px; }
  .cards { gap: 8px; } .nav-btn { width: 64px; height: 64px; font-size: 34px; }
  .card-word { font-size: 64px; } .card-letter { font-size: 170px; }
  .find { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; } }
