:root {
  --bg: #F6F2EA;
  --card: #FFFFFF;
  --ink: #34495E;
  --muted: #7F8C8D;
  --teal: #5B9A8B;
  --teal-soft: #D7EAE4;
  --peach: #E8A87C;
  --peach-soft: #F8E3D3;
  --blue: #7DA7C9;
  --blue-soft: #DCE8F2;
  --green: #6FBF73;
  --red: #D98880;
  --radius: 22px;
  --shadow: 0 4px 0 rgba(52, 73, 94, .12);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: "Geeza Pro", "Noto Naskh Arabic", "Noto Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  font-size: 20px; min-height: 100vh; user-select: none; -webkit-user-select: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
#app { max-width: 980px; margin: 0 auto; padding: 0 16px 40px; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .45; cursor: default; }

.big-btn {
  background: var(--teal); color: #fff; border-radius: var(--radius); padding: 16px 30px;
  font-size: 26px; font-weight: 700; box-shadow: var(--shadow); min-height: 68px;
}
.big-btn.soft { background: var(--blue-soft); color: var(--ink); }
.big-btn.danger { background: var(--red); }
.big-btn:active { transform: translateY(3px); box-shadow: none; }

/* شريط علوي */
.top { display: flex; align-items: center; gap: 10px; padding: 14px 0; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.top-title { flex: 1; text-align: center; font-size: 24px; font-weight: 700; line-height: 1.2; }
.top-title small { display: block; font-size: 16px; color: var(--muted); font-weight: 500; }
.icon-btn { width: 60px; height: 60px; border-radius: 50%; background: var(--card); font-size: 28px; box-shadow: var(--shadow); flex: none; }
.spacer { width: 60px; flex: none; }
.stars-pill { background: var(--peach-soft); border-radius: 999px; padding: 8px 14px; font-weight: 700; white-space: nowrap; }
.vol { display: flex; align-items: center; gap: 6px; background: var(--card); border-radius: 999px; padding: 6px 12px; box-shadow: var(--shadow); }
.vol input { width: 90px; accent-color: var(--teal); direction: ltr; }

/* بداية */
.start { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 90vh; gap: 16px; text-align: center; }
.start h1 { font-size: 44px; margin: 0; color: var(--teal); }
.start p { margin: 0; color: var(--muted); }
.start-emoji { font-size: 110px; animation: float 3s ease-in-out infinite; }
.pet-choice { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.pet-choice button { font-size: 80px; width: 130px; height: 130px; border-radius: 30px; background: var(--card); box-shadow: var(--shadow); }

/* الحيوان الأليف */
.home-pet { display: flex; flex-direction: column; align-items: center; margin: 4px 0 10px; }
.pet { position: relative; display: inline-flex; flex-direction: column; align-items: center; background: none; cursor: pointer; }
.pet-face { font-size: calc(72px * var(--s)); line-height: 1; animation: float 3s ease-in-out infinite; }
.pet.big .pet-face { font-size: calc(110px * var(--s)); }
.pet-items { font-size: 26px; min-height: 30px; }
.pet-level { font-size: 16px; color: var(--muted); }
.bounce .pet-face, .bounce { animation: bounce .6s ease; }
@keyframes float { 50% { transform: translateY(-6px); } }
@keyframes bounce { 30% { transform: scale(1.25) rotate(-6deg); } 60% { transform: scale(.95) rotate(4deg); } }

/* الوحدات والدروس */
.unit { background: var(--card); border-radius: 28px; padding: 18px; margin: 16px 0; box-shadow: var(--shadow); }
.unit h2 { margin: 0 0 14px; font-size: 24px; color: var(--teal); }
.path { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.lesson-node { background: var(--bg); border-radius: 24px; padding: 14px 8px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.node-circle {
  width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center;
  background: var(--teal); color: #fff; font-size: 40px; font-weight: 700; box-shadow: var(--shadow);
}
.lesson-node.done .node-circle { background: var(--peach); }
.lesson-node.locked .node-circle { background: #CFCAC0; font-size: 34px; }
.node-label { font-size: 16px; color: var(--muted); }
.node-title { font-size: 20px; font-weight: 700; }
.node-stars { font-size: 16px; min-height: 22px; }
.parent-btn { display: block; margin: 26px auto 0; background: none; color: var(--muted); font-size: 16px; padding: 10px; }

/* شاشة الدرس */
.lesson-letters { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin: 6px 0 14px; }
.letter-chip { background: var(--card); border-radius: 24px; padding: 10px 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; }
.lc-big { font-size: 64px; line-height: 1.2; color: var(--teal); }
.lc-name { font-size: 18px; }
.lc-forms { font-size: 24px; color: var(--muted); white-space: pre; }
.game-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.game-tile { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto auto; column-gap: 14px; text-align: right; align-items: center; min-height: 120px; }
.game-tile.played { background: var(--teal-soft); }
.gt-icon { font-size: 54px; grid-row: 1 / 4; }
.gt-name { font-size: 24px; font-weight: 700; }
.gt-goal { font-size: 15px; color: var(--muted); }
.gt-stars { font-size: 20px; color: var(--peach); }

/* هيكل اللعبة */
.progress { display: flex; gap: 8px; justify-content: center; margin: 4px 0 14px; }
.progress span { width: 18px; height: 18px; border-radius: 50%; background: #E2DDD3; }
.progress span.on { background: var(--green); }
.game-body { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.speaker { font-size: 70px; width: 140px; height: 140px; border-radius: 50%; background: var(--blue-soft); box-shadow: var(--shadow); }
.word-prompt { display: flex; align-items: center; gap: 14px; background: var(--card); border-radius: 30px; padding: 12px 28px; box-shadow: var(--shadow); font-size: 40px; }
.pic { font-size: 84px; line-height: 1.1; }
.choices { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.choice { background: var(--card); border-radius: 28px; box-shadow: var(--shadow); min-width: 150px; min-height: 150px; display: grid; place-items: center; transition: transform .15s, background .2s; }
.choices.letters .choice { font-size: 84px; color: var(--ink); }
.choice.right { background: #CDEBCF; transform: scale(1.08); }
.choice.wrong { background: #F3D6D3; animation: shake .4s; }

/* بطاقة الكلمة */
.word-card { background: var(--card); border-radius: 34px; box-shadow: 0 6px 0 rgba(52,73,94,.12); width: min(440px, 100%); padding: 26px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.wc-pic { font-size: 150px; line-height: 1.1; }
.wc-ar { font-size: 72px; font-weight: 700; color: var(--teal); }
.wc-ar.phrase { font-size: 48px; }
.wc-en { font-size: 26px; color: var(--muted); }
.card-nav { display: flex; gap: 14px; }

/* الكتابة */
.write-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: center; }
.write-letter { font-size: 70px; width: 110px; height: 110px; border-radius: 26px; background: var(--card); box-shadow: var(--shadow); color: var(--teal); }
.write-ex { font-size: 34px; background: var(--card); border-radius: 22px; padding: 10px 20px; box-shadow: var(--shadow); }
.tracer-wrap { width: 100%; max-width: 560px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.tracer { background: #fff; border-radius: 28px; box-shadow: var(--shadow); touch-action: none; display: block; }
.watch-btn { background: var(--peach-soft); border-radius: 999px; padding: 12px 24px; font-size: 22px; }

/* الذاكرة */
.memory { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; width: 100%; max-width: 760px; }
.mem-card { aspect-ratio: 1; border-radius: 22px; background: var(--blue); box-shadow: var(--shadow); position: relative; font-size: 44px; color: #fff; }
.mem-card .mem-front { display: none; }
.mem-card.flip { background: var(--card); color: var(--ink); }
.mem-card.flip .mem-back { display: none; }
.mem-card.flip .mem-front { display: block; }
.mem-front.pic { font-size: 64px; }
.mem-front.word { font-size: 40px; font-weight: 700; color: var(--teal); }
.mem-front.word.phrase { font-size: 22px; }
.mem-card.matched { background: #CDEBCF; }
@media (max-width: 560px) { .memory { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ركّب الكلمة */
.slots { display: flex; gap: 10px; }
.slot { width: 86px; height: 96px; border-radius: 20px; border: 4px dashed #C9C2B5; display: grid; place-items: center; font-size: 56px; background: #fff; }
.slot.filled { border-style: solid; border-color: var(--green); }
.built-word { font-size: 80px; font-weight: 700; color: var(--teal); min-height: 1.3em; opacity: 0; transition: opacity .4s; }
.built-word.show { opacity: 1; }
.tiles { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.tile { width: 100px; height: 100px; border-radius: 24px; background: var(--peach-soft); box-shadow: var(--shadow); font-size: 58px; }
.tile.used { visibility: hidden; }
.shake { animation: shake .4s; background: #F3D6D3; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* النتيجة */
.result { display: flex; flex-direction: column; align-items: center; gap: 18px; min-height: 85vh; justify-content: center; text-align: center; }
.result-stars { font-size: 70px; color: var(--peach); letter-spacing: 6px; }
.result-btns { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.unlock { font-size: 26px; font-weight: 700; color: var(--teal); }

/* صفحة الأب */
.parent { background: var(--card); border-radius: 26px; padding: 20px; box-shadow: var(--shadow); font-size: 18px; }
.parent h3 { color: var(--teal); margin: 18px 0 8px; }
.parent .big-btn { font-size: 18px; min-height: 52px; padding: 10px 20px; margin: 10px 0; }
.set-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #EEE9DF; }
.set-row select, .set-row input { font: inherit; transform: scale(1.3); }
.set-row select { transform: none; padding: 6px; border-radius: 10px; }
.weak li { margin: 4px 0; }
.note { color: var(--muted); font-size: 15px; }

@media (max-width: 600px) {
  body { font-size: 18px; }
  .vol input { width: 60px; }
  .top { flex-wrap: wrap; }
  .choice { min-width: 110px; min-height: 110px; }
  .pic { font-size: 64px; }
  .slot { width: 66px; height: 78px; font-size: 44px; }
  .tile { width: 78px; height: 78px; font-size: 46px; }
}

/* ---------- ميرا: ألوان أنعم وعناصر أكبر ---------- */
:root { --teal: #9B7BB8; --teal-soft: #EADCF0; --bg: #FAF5F0; }
.node-circle.big-letter { font-size: 56px; }
.word-card { position: relative; }
.wc-letter { font-size: 190px; line-height: 1.1; color: var(--teal); font-weight: 700; }
.wc-sounds { font-size: 54px; color: var(--ink); white-space: pre; }
.wc-corner { position: absolute; top: 14px; right: 18px; font-size: 40px; color: var(--peach); font-weight: 700; }
.wc-ar { font-size: 80px; }
.card-nav .big-btn { min-width: 110px; font-size: 34px; }
.bubble-field { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; max-width: 760px; }
.bubble {
  width: 120px; height: 120px; border-radius: 50%; font-size: 64px; font-weight: 700; color: var(--ink);
  box-shadow: inset -8px -10px 0 rgba(255,255,255,.55), var(--shadow);
  animation: float 3s ease-in-out infinite; animation-delay: var(--d);
  transition: transform .25s, opacity .25s;
}
.bubble.popped { transform: scale(1.6); opacity: 0; pointer-events: none; }
@media (max-width: 600px) { .bubble { width: 92px; height: 92px; font-size: 50px; } .wc-letter { font-size: 140px; } }
