/* ============================================================================
   app.css — هوية «رحلة غيث»: 60% رملي دافئ، 30% أخضر واحة، 10% تراكوتا/زعفراني.
   جوال أولًا، لمس ≥64px، أزرار «صلصالية» بظل ناعم. RTL.
   ============================================================================ */
@font-face {
  font-family: 'Baloo';
  src: url('../assets/fonts/baloo-bhaijaan-2-arabic-400-normal.woff2') format('woff2');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'Baloo';
  src: url('../assets/fonts/baloo-bhaijaan-2-arabic-700-normal.woff2') format('woff2');
  font-weight: 700; font-display: swap;
}
@font-face {
  font-family: 'Baloo';
  src: url('../assets/fonts/baloo-bhaijaan-2-latin-700-normal.woff2') format('woff2');
  font-weight: 700; font-display: swap; unicode-range: U+0000-00FF;
}

:root {
  --sand: #f5e3c3; --sand-deep: #e8cf9f; --clay: #c96f4a; --clay-deep: #a8543a;
  --oasis: #2e8b57; --oasis-soft: #7fc99b; --saffron: #e8a530; --teal: #20a4a8;
  --ink: #4a3423; --ink-soft: #6b5539; --card: #fff8ec;   /* ink-soft غُمّق: 4.55:1 فوق الرملي كان حدّيًا */
  --saffron-ink: #9a6206;   /* ذهبي داكن للنص الصغير — الزعفراني الفاتح لا يقرأ فوق الفواتح */
  --shadow: 0 6px 0 rgba(74, 52, 35, .18), 0 12px 24px rgba(74, 52, 35, .12);
  /* توكنات نظام التخطيط (المرجع: لعبة-المناهج\14-نظام-تخطيط-UI.md) */
  --touch: 64px;          /* الحد الأدنى لأهداف اللمس الرئيسية */
  --touch-min: 48px;      /* الحد الأدنى للأزرار الثانوية (إغلاق/سماع) */
  --content-max: 560px;   /* أقصى عرض لعمود المحتوى */
  --gap-1: 6px; --gap-2: 10px; --gap-25: 12px; --gap-3: 14px; --gap-4: 18px;
  --pad-screen: 12px;     /* حشوة حواف الشاشات */
  --radius-card: 20px; --radius-btn: 22px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overscroll-behavior: none; overflow-x: hidden; }
body {
  font-family: 'Baloo', 'Segoe UI', sans-serif;
  background: linear-gradient(175deg, #fdf3dd 0%, var(--sand) 45%, var(--sand-deep) 100%);
  color: var(--ink);
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}

#fx-canvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 90; }

.screen { display: none; min-height: 100dvh; }
.screen.active { display: flex; flex-direction: column; }

/* ── الأزرار الصلصالية ── */
button { font-family: inherit; color: inherit; border: 0; cursor: pointer; }
.btn-big {
  min-height: var(--touch); padding: 14px 30px; border-radius: var(--radius-btn);
  font-size: 1.35rem; font-weight: 700; color: #fff;
  background: linear-gradient(180deg, var(--oasis-soft), var(--oasis));
  box-shadow: 0 6px 0 #1d6a40, 0 10px 18px rgba(46, 139, 87, .35);
  transition: transform .12s, box-shadow .12s;
}
.btn-big:active { transform: translateY(4px); box-shadow: 0 2px 0 #1d6a40; }
.btn-big:disabled { filter: grayscale(.7) opacity(.6); box-shadow: 0 4px 0 #999; }
.btn-round {
  width: 56px; height: 56px; border-radius: 50%; font-size: 1.5rem;
  background: var(--card); box-shadow: var(--shadow);
}

/* ═══ البداية ═══ */
#screen-splash { align-items: center; justify-content: center; text-align: center; padding: 24px 16px; }
.splash-inner { width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: var(--gap-4); align-items: center; }
.logo { font-size: clamp(2.6rem, 10vw, 3.6rem); line-height: 1.1; }
.logo span { color: var(--teal); white-space: nowrap; }
.tagline { font-size: 1.2rem; color: var(--ink-soft); margin-top: -10px; }
.char-pick { display: flex; gap: 16px; width: 100%; justify-content: center; }
.char-card {
  flex: 1; max-width: 190px; padding: 12px; border-radius: 26px;
  background: var(--card); box-shadow: var(--shadow);
  border: 4px solid transparent; transition: transform .15s, border-color .15s;
}
.char-card img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 18px; background: var(--sand-deep); }
.char-card .char-name { display: block; font-size: 1.5rem; font-weight: 700; margin-top: 6px; }
.char-card.picked { border-color: var(--saffron); transform: scale(1.05); }
.name-row { display: flex; align-items: center; gap: var(--gap-2); font-size: 1.15rem; font-weight: 700; }
.name-row input {
  font-family: inherit; font-size: 1.2rem; font-weight: 700; text-align: center;
  width: 100%; max-width: 170px; flex: 1 1 auto; min-width: 0; min-height: var(--touch); border: 3px solid var(--sand-deep); border-radius: 16px;
  background: var(--card); color: var(--ink); outline: none;
}
.name-row input:focus { border-color: var(--teal); }
.brand { font-size: .85rem; color: var(--ink-soft); }

/* الصفحة الرئيسية: حوار غيث وريم بالتناوب — الفقاعة تتجه للمتكلم وبطاقته تتحرك */
#screen-splash { position: relative; }
.splash-bubble { width: 100%; justify-content: center; text-align: center; font-size: 1.15rem; font-weight: 700; flex: none; }
.splash-bubble[hidden] { display: none; }
.splash-bubble::after {
  content: ''; position: absolute; bottom: -16px; border: 9px solid transparent; border-top-color: var(--card);
}
/* RTL: بطاقة غيث يمين وبطاقة ريم يسار — الذيل يشير لمن يتكلم */
.splash-bubble[data-who="ghaith"]::after { right: 22%; }
.splash-bubble[data-who="reem"]::after { left: 22%; }
.char-card.talking { border-color: var(--teal); }
.char-card.talking img { animation: talk .5s ease-in-out infinite alternate; }
@keyframes talk { to { transform: translateY(-6px) scale(1.03); } }
.tap-start {
  position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--gap-3); font-size: 1.6rem; font-weight: 700; color: var(--ink);
  background: rgba(245, 227, 195, .82); backdrop-filter: blur(4px);
}
.tap-start[hidden] { display: none; }
.tap-start .tap-icon {
  width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; font-size: 3rem; color: #fff;
  background: var(--oasis); box-shadow: 0 6px 0 #1d6a40, 0 12px 24px rgba(74, 52, 35, .2);
  animation: pulse-btn 1.6s ease-in-out infinite;
}
@keyframes pulse-btn { 50% { transform: scale(1.08); } }
@media (prefers-reduced-motion: reduce) {
  .char-card.talking img, .tap-start .tap-icon { animation: none; }
}
/* لون جانبي يميّز فقاعة كل أخ أينما ظهرت */
.bubble[data-who="ghaith"] { border-inline-start: 5px solid #2f6fb3; }
.bubble[data-who="reem"] { border-inline-start: 5px solid #c2477a; }

/* ═══ الخريطة ═══ */
#screen-map { padding: var(--pad-screen) 10px calc(16px + env(safe-area-inset-bottom)); gap: 8px; }
.hud { display: flex; justify-content: space-between; align-items: center; gap: var(--gap-2); }
.hud #btn-home { flex: none; }
.hud .hud-avatar { margin-inline-end: auto; }
.hud-avatar {
  display: flex; align-items: center; gap: var(--gap-2); padding: 6px 16px 6px 6px;
  border-radius: 40px; background: var(--card); box-shadow: var(--shadow); min-height: var(--touch);
}
.hud-avatar img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; object-position: top; background: var(--sand-deep); border: 3px solid transparent; }
.hud-avatar span { font-size: 1.15rem; font-weight: 700; }
.hud-drops {
  font-size: 1.3rem; font-weight: 700; padding: 10px 20px; border-radius: 40px;
  background: linear-gradient(180deg, #d9f3f4, #b3e5e7); box-shadow: var(--shadow); min-height: var(--touch);
  display: flex; align-items: center; gap: 4px; color: #0d6a6d;
}
.map-title { text-align: center; font-size: 1.25rem; color: var(--ink-soft); }
.map-wrap { flex: 1; display: flex; align-items: center; justify-content: center; }
#ksa-map { width: 100%; max-width: var(--content-max); max-height: 52dvh; }
.map-hint { text-align: center; font-size: 1.05rem; color: var(--ink-soft); }

/* عناصر الخريطة (SVG — حدود المناطق الحقيقية) */
.region { cursor: pointer; }
.region .r-shape {
  stroke: var(--card); stroke-width: 4; stroke-linejoin: round;
  filter: drop-shadow(0 4px 3px rgba(74, 52, 35, .25));
  transition: filter .2s;
}
.region.done .r-shape { stroke: #d4f7d4; }
.region.locked { opacity: .55; }
.region text { font-family: 'Baloo', sans-serif; pointer-events: none; }
.region .r-icon { font-size: 42px; }
.region .r-name { font-size: 28px; font-weight: 700; fill: #fff; paint-order: stroke; stroke: rgba(0,0,0,.4); stroke-width: 5px; }
.region .r-badge { font-size: 26px; }
.region.open:not(.done) .r-shape { animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { filter: drop-shadow(0 4px 3px rgba(74,52,35,.25)); }
  50% { filter: drop-shadow(0 0 14px rgba(232, 165, 48, .9)); }
}

/* الشخصية المرافقة وفقاعة الحوار */
.guide { display: flex; align-items: center; gap: var(--gap-2); max-width: var(--content-max); width: 100%; margin: 0 auto; }
.guide img {
  width: 72px; height: 72px; border-radius: 50%; object-fit: cover; object-position: top;
  background: var(--sand-deep); box-shadow: var(--shadow); flex: none;
}
.guide img.bounce { animation: bounce .6s; }
@keyframes bounce { 30% { transform: translateY(-12px) scale(1.06); } 60% { transform: translateY(0) scale(1); } 80% { transform: translateY(-5px); } }
.bubble {
  position: relative; background: var(--card); border-radius: 18px; padding: 10px 14px;
  box-shadow: var(--shadow); font-size: 1.02rem; line-height: 1.55; flex: 1; min-height: 52px;
  display: flex; align-items: center;
}
.guide .bubble::before {
  content: ''; position: absolute; right: -8px; top: 50%; transform: translateY(-50%);
  border: 9px solid transparent; border-left-color: var(--card);
}
.map-actions { display: flex; align-items: center; justify-content: center; gap: var(--gap-3); flex-wrap: wrap; }
.btn-shop, .btn-lessons, .btn-passport { font-size: 1.1rem; padding: 10px 22px; }
.btn-shop.attention { animation: shoppulse 1.4s ease-in-out infinite; }
@keyframes shoppulse { 50% { transform: scale(1.07); box-shadow: 0 6px 0 #b57708, 0 0 18px rgba(232,165,48,.8); } }
.hud-id { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.hud-id small { font-size: .78rem; color: var(--saffron-ink); font-weight: 700; }

/* حوار لوحة المنطقة */
.sheet-dialogue { display: flex; align-items: flex-start; gap: var(--gap-2); margin-bottom: 14px; }
.sheet-dialogue img {
  width: 64px; height: 64px; border-radius: 50%; object-fit: cover; object-position: top;
  background: var(--sand-deep); box-shadow: var(--shadow); flex: none;
}
.sheet-dialogue .bubble { margin-bottom: 0; }

/* سوق القطرات */
.shop-icon { font-size: 2.6rem; line-height: 1.2; }
.shop-card.cant { opacity: .55; }
.shop-card small { display: block; margin-top: 2px; }

/* ═══ لوحة المنطقة ═══ */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: rgba(74, 52, 35, .35); }
.sheet[hidden], .modal[hidden] { display: none; }
/* العناصر ذات display صريح تتجاهل خاصية hidden (نمط UA يُغلَب) — تثبيت عام */
.sheet-game[hidden], .sheet-subjects[hidden] { display: none; }
.sheet-card {
  width: 100%; max-width: 520px; background: var(--card);
  border-radius: 30px 30px 0 0; padding: 22px 20px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(74, 52, 35, .3); position: relative;
  animation: rise .25s ease-out;
  max-height: 92dvh; overflow-y: auto;   /* لوحة المدن أطول — لا خروج عن الشاشة أبدًا */
}
@keyframes rise { from { transform: translateY(60px); opacity: 0; } }
.sheet-close { position: absolute; top: 14px; left: 14px; width: var(--touch-min); height: var(--touch-min); border-radius: 50%; background: var(--sand); font-size: 1.1rem; font-weight: 700; }
.sheet-head { display: flex; align-items: center; gap: var(--gap-3); margin-bottom: 8px; }
.sheet-icon { font-size: 3rem; }
.sheet-head h3 { font-size: 1.7rem; }
.sheet-stars { font-size: 1.2rem; letter-spacing: 2px; }
.sheet-blurb { font-size: 1.1rem; line-height: 1.6; color: var(--ink-soft); margin-bottom: 14px; }
.sheet-game { display: flex; align-items: center; justify-content: space-between; gap: var(--gap-25); background: var(--sand); border-radius: var(--radius-card); padding: 12px 16px; }
.sheet-game-info b { display: block; font-size: 1.2rem; }
.sheet-game-info small { color: var(--ink-soft); font-size: .95rem; }
.btn-play { min-width: 130px; }
.sheet-locked-msg { text-align: center; font-size: 1.05rem; color: var(--clay-deep); background: #f9e8dc; border-radius: 16px; padding: 12px; }

/* ═══ مسارا المادة داخل لوحة المنطقة (لغتي/الرياضيات) ═══ */
.sheet-joined { display: block; color: var(--ink-soft); font-size: .85rem; margin-top: 2px; }
.sheet-subjects { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap-25); }
.subject-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-height: 108px; padding: 10px 8px; border-radius: var(--radius-card);
  background: var(--card); box-shadow: var(--shadow); border: 3px solid var(--saffron);
}
.subject-btn .sub-icon { font-size: 1.9rem; line-height: 1.2; }
.subject-btn b { font-size: 1.15rem; }
.subject-btn small { color: var(--ink-soft); font-size: .9rem; }
.subject-btn .sub-bar {
  width: 84%; height: 8px; border-radius: 6px; background: var(--sand-deep); overflow: hidden;
}
.subject-btn .sub-fill { display: block; height: 100%; border-radius: 6px; background: var(--oasis); }
.subject-btn.all-done { border-color: var(--oasis); }
.subjects-soon {
  grid-column: 1 / -1; text-align: center; color: var(--ink-soft);
  background: var(--sand); border-radius: 16px; padding: 10px 12px; font-size: .95rem;
}

/* ═══ اللعبة ═══ */
#screen-game { padding: var(--pad-screen) var(--pad-screen) calc(16px + env(safe-area-inset-bottom)); gap: var(--gap-2); }
.game-top { display: flex; align-items: center; justify-content: space-between; gap: var(--gap-2); }
.game-progress { display: flex; gap: var(--gap-1); }
.game-progress .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--sand-deep); }
.game-progress .dot.ok { background: var(--oasis); }
.game-progress .dot.bad { background: var(--clay); }
.game-progress .dot.now { outline: 3px solid var(--saffron); outline-offset: 2px; }
.game-drops { font-size: 1.15rem; font-weight: 700; color: #0d6a6d; background: #d9f3f4; padding: 8px 16px; border-radius: 30px; }
.game-stage { flex: 1; display: flex; flex-direction: column; gap: var(--gap-25); max-width: var(--content-max); width: 100%; margin: 0 auto; }

.g-scene { border-radius: 22px; overflow: hidden; box-shadow: var(--shadow); position: relative; min-height: 120px; max-height: 26dvh; }
.g-scene img { width: 100%; height: 100%; object-fit: cover; display: block; transition: filter 1.2s; }
.g-q {
  background: var(--card); border-radius: var(--radius-card); padding: 14px 16px; box-shadow: var(--shadow);
  font-size: 1.3rem; font-weight: 700; text-align: center; line-height: 1.5;
  display: flex; align-items: center; justify-content: center; gap: var(--gap-2); flex-wrap: wrap;
}
.btn-say { width: var(--touch-min); height: var(--touch-min); border-radius: 50%; background: var(--sand); font-size: 1.2rem; flex: none; }
.g-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: var(--gap-25); }
.g-opt {
  min-height: 72px; border-radius: var(--radius-card); font-size: 1.5rem; font-weight: 700;
  background: var(--card); box-shadow: var(--shadow); transition: transform .12s, background .2s;
}
.g-opt:active { transform: scale(.96); }
.g-opt.ok { background: #d4f7d4; }
/* حالة الخطأ الموحدة عبر الألعاب: هزة قصيرة + خلفية تنبيه */
.g-opt.bad, .rain-drop.bad, .parcel.bad, .scale-pan.bad, .scale-eq.bad { animation: shake .35s; }
.g-opt.bad, .rain-drop.bad, .parcel.bad, .scale-pan.bad { background: #f9d5c8; }
@keyframes shake { 25% { transform: translateX(6px); } 75% { transform: translateX(-6px); } }

/* المزرعة */
.farm-count { font-size: 2rem; text-align: center; font-weight: 700; }
.farm-count b { color: var(--oasis); font-size: 2.4rem; }
.farm-field {
  background: var(--card); border-radius: var(--radius-card); box-shadow: var(--shadow);
  padding: 12px; min-height: 130px; display: flex; flex-direction: column; gap: var(--gap-1); align-items: flex-start;
  font-size: 1.25rem; line-height: 1.5; overflow-y: auto; max-height: 30dvh;
}
.farm-row { background: #eef7ee; border-radius: 12px; padding: 2px 8px; }
.farm-controls { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--gap-2); }
.farm-controls .btn-big { font-size: 1.1rem; padding: 10px; }
.btn-undo { background: linear-gradient(180deg, #f0c9a0, var(--clay)); box-shadow: 0 6px 0 var(--clay-deep); }
.btn-gold, .btn-shop { background: linear-gradient(180deg, #f3c96b, var(--saffron)); box-shadow: 0 6px 0 #b57708; }

/* ورشة الحروف */
.trace-wrap { position: relative; background: var(--card); border-radius: 22px; box-shadow: var(--shadow); overflow: hidden; }
.trace-wrap canvas { display: block; width: 100%; touch-action: none; }
.trace-word { font-size: 1.3rem; text-align: center; font-weight: 700; color: var(--ink-soft); }

/* سوق السمك */
.fish-sea {
  position: relative; border-radius: 22px; overflow: hidden; flex: 1; min-height: min(300px, 42dvh);
  background: linear-gradient(180deg, #7fd4e8 0%, #2fa3c9 70%, #1d7fa3 100%);
  box-shadow: var(--shadow);
}
.fish {
  position: absolute; font-size: 1.35rem; font-weight: 700; color: #fff;
  min-width: var(--touch); min-height: var(--touch); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; gap: 2px;
  background: transparent; animation: swim 3.5s ease-in-out infinite alternate;
}
.fish .f-body { font-size: 2.6rem; filter: drop-shadow(0 3px 3px rgba(0,0,0,.25)); }
.fish .f-tag {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; text-shadow: 0 1px 3px rgba(0,0,0,.55); padding-bottom: 6px;
}
.fish .f-tag.f-long { font-size: .9rem; white-space: nowrap; }
/* المناطق البرّية (REGION_THEMES): أرض رملية بسماء صافية، والمعالم تتمايل بدل السباحة */
.fish-sea.land { background: linear-gradient(180deg, #bfe6f2 0%, #e9d7a8 55%, #d9bd7f 100%); }
.pearl-sea.land { background: linear-gradient(180deg, #bfe6f2 0%, #e9d7a8 50%, #cfae6c 100%); }
.fish-sea.land .fish { animation-name: bob; }
@keyframes bob { from { transform: translateY(-6px); } to { transform: translateY(6px); } }
.lesson-region { display: block; font-size: .78rem; color: var(--ink-soft); }

/* التمثيل بالصور (فصل البيانات — رياضيات) */
.chart-rows {
  background: rgba(255, 252, 244, .93); border-radius: 18px; padding: 10px 14px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px;
  margin: 6px 0; overflow-x: hidden;
}
.chart-title { text-align: center; color: var(--ink-soft); font-size: 1.05rem; }
.chart-row {
  display: flex; align-items: center; gap: 8px; min-height: 40px;
  border-bottom: 2px dashed rgba(0, 0, 0, .08); padding-bottom: 4px;
}
.chart-row:last-child { border-bottom: none; }
.chart-label { font-weight: 700; font-size: 1rem; min-width: 5.5em; }
.chart-icons { font-size: 1.25rem; letter-spacing: 2px; overflow-wrap: anywhere; line-height: 1.5; }

/* التمثيل بالأعمدة (درسا 4-5 و4-6 رياضيات): بناء وقراءة أعمدة رأسية بمقياس */
.bars-wrap {
  background: rgba(255, 252, 244, .93); border-radius: 18px; padding: 10px 12px;
  box-shadow: var(--shadow); margin: 6px 0;
  display: flex; flex-direction: column; gap: 8px;
}
.bars-tally { display: flex; flex-direction: column; gap: 2px; }
.bars-tally .chart-row { min-height: 30px; padding-bottom: 2px; }
.bars-tally .chart-icons { font-size: 1.05rem; letter-spacing: 1px; }
.bars-grid { display: flex; align-items: flex-end; justify-content: center; gap: 8px; }
/* عناصر المحور بارتفاع صفري وspace-between → الأرقام تقع على حدود المربعات */
.bars-axis {
  display: flex; flex-direction: column; justify-content: space-between;
  align-self: stretch; margin-bottom: calc(1.5rem + 2rem + 8px);
  font-weight: 800; font-size: .8rem; color: var(--ink-soft);
  width: 1.4em; text-align: center;
}
.bars-axis span { height: 0; line-height: 0; }
.bars-col {
  display: flex; flex-direction: column; gap: 4px; align-items: stretch;
  width: clamp(44px, 16vw, 60px); padding: 0;
  background: none; border: none; font: inherit; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.bars-col:disabled { opacity: 1; cursor: default; }
.bars-stack { display: flex; flex-direction: column-reverse; gap: 2px; }
.bars-cell {
  height: 20px; border-radius: 5px;
  background: rgba(0, 0, 0, .05); border: 2px dashed rgba(0, 0, 0, .12);
}
.bars-cell.fill { border-style: solid; border-color: rgba(0, 0, 0, .12); }
.bars-col:nth-of-type(5n+1) .bars-cell.fill { background: #e8734a; }
.bars-col:nth-of-type(5n+2) .bars-cell.fill { background: #4a9d6e; }
.bars-col:nth-of-type(5n+3) .bars-cell.fill { background: #5b8dd6; }
.bars-col:nth-of-type(5n+4) .bars-cell.fill { background: #d6a23e; }
.bars-col:nth-of-type(5n+5) .bars-cell.fill { background: #b06ab3; }
.bars-cap { height: 1.5rem; line-height: 1.5rem; font-size: 1.2rem; text-align: center; }
.bars-name {
  height: 2rem; font-size: .72rem; font-weight: 700; line-height: 1.1;
  display: flex; align-items: flex-start; justify-content: center; text-align: center;
  overflow-wrap: anywhere;
}
.bars-col.done .bars-cap::after { content: ' ✓'; color: #2e7d32; font-weight: 900; }
.bars-col.bad { animation: bars-shake .35s; }
@keyframes bars-shake {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* شحنة الميناء (فصلا الرقمين 5-6 — رياضيات): الحاوية = ١٠ */
.cargo-rows { display: flex; flex-direction: column; gap: var(--gap-2); }
.cargo-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 5px; row-gap: 4px;
  background: var(--card); border-radius: var(--radius-card); padding: 10px 12px; box-shadow: var(--shadow);
}
.cargo-lead { font-size: 2.1rem; margin-inline-end: 4px; }
/* نص الحاوية بلون الحبر الداكن: الأبيض على #e8964f تباينه 2.36:1 فقط (دون AA) */
.cargo-ten {
  width: 44px; height: 34px; border-radius: 8px; flex: none;
  background: #e8964f; color: var(--ink); font-weight: 700; font-size: 1.15rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.18);
}
.cargo-ones { font-size: 1.15rem; letter-spacing: 1px; overflow-wrap: anywhere; }
.cargo-num { margin-inline-start: auto; font-size: 1.5rem; color: var(--ink); }
.cargo-row.unloaded { opacity: .72; }
.cargo-row.unloaded .cargo-ten { background: #7c7264; color: #fff; }
/* كفة الميزان بوضع الرقمين (درس مقارنة الأعداد): حاويات مصغرة داخل الكفة */
.pan-cargo { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; max-width: 150px; }
.pan-cargo .cargo-ten.mini { width: 30px; height: 24px; font-size: .9rem; border-radius: 6px; }
.pan-cargo .cargo-ones { font-size: .95rem; }
@media (max-width: 385px) { .cargo-ten { width: 36px; height: 30px; font-size: 1rem; } .cargo-lead { font-size: 1.7rem; } }
/* وضع التقدير (درسا تقدير ناتج الجمع/الطرح): بطاقة قاعدة التقريب */
.est-rule {
  background: var(--card); border-radius: var(--radius-card); padding: 8px 12px;
  box-shadow: var(--shadow); font-size: .95rem; text-align: center; color: var(--ink);
}

/* تقدير الكميات (الطائف): وعاءان متطابقا الحجم — العشرة مرجع المقارنة */
.jars-wrap { display: flex; gap: var(--gap-2); flex: 1; min-height: min(230px, 32dvh); }
.jar-box {
  position: relative; flex: 1; overflow: hidden;
  background: linear-gradient(180deg, #fdf3e3 0%, #f3ddba 100%);
  border: 3px solid #caa36b; border-radius: 16px 16px 24px 24px;
  box-shadow: var(--shadow);
}
/* شارة الوعاء بأخضر أغمق من --oasis عمدًا: الأبيض على #2e8b57 تباينه ~3.9 (دون AA) */
.jar-tag {
  position: absolute; top: 4px; right: 50%; transform: translateX(50%);
  z-index: 1; background: #2f6d4f; color: #fff; border-radius: 999px;
  padding: 2px 14px; font-size: 1.05rem;
}
.jar-item { position: absolute; font-size: 1.05rem; line-height: 1; pointer-events: none; }
.jars-wrap.dense .jar-item { font-size: .8rem; }

/* نقشة الأعداد (السدو الرقمي — الأنماط والعد القفزي) */
.sadu-nums { font-size: 1.9rem; font-weight: 700; letter-spacing: 4px; }
.sadu-nums span { margin-inline: 6px; }
@media (max-width: 385px) { .sadu-nums { font-size: 1.5rem; letter-spacing: 2px; } }
.fish.caught { animation: caught .5s forwards; }
@keyframes swim { from { transform: translateX(-12px) rotate(-4deg); } to { transform: translateX(12px) rotate(4deg); } }
@keyframes caught { to { transform: scale(0) rotate(360deg); opacity: 0; } }

/* لغز القَطّ (عسير) */
.qatt-wall {
  display: flex; justify-content: center; gap: var(--gap-1);
  background: #fffdf6; border: 6px solid #8d6e63; border-radius: 18px;
  padding: 14px 10px; box-shadow: var(--shadow);
}
.qatt-cell {
  width: 52px; height: 52px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.7rem; color: #fff; flex: none;
}
.qatt-cell.mid { outline: 3px dashed var(--ink-soft); outline-offset: 2px; }
.qatt-cell.gap { background: #efe2c8; color: var(--clay); border: 3px dashed var(--clay); font-weight: 700; }
.qatt-opt { color: #fff; font-size: 2.2rem; }
.qatt-opt.ok, .qatt-opt.bad { filter: brightness(1.15); }
/* جولات القَطّ تصل 7 خلايا: القاعدي 52px يحتاج عرض ≥456px، و42px يحتاج ≥386px */
@media (max-width: 480px) { .qatt-cell { width: 42px; height: 42px; font-size: 1.4rem; } }
@media (max-width: 385px) { .qatt-cell { width: 30px; height: 30px; font-size: 1.05rem; border-radius: 8px; } }

/* صياد اللؤلؤ (الشرقية) */
.pearl-sea {
  background: linear-gradient(180deg, #6fc9e0 0%, #2a8db8 55%, #17618c 88%, #d9c58a 88%, #cbb478 100%);
  min-height: min(260px, 38dvh); flex: 1;
}
.oyster {
  position: absolute; font-size: 2.4rem; background: transparent;
  min-width: var(--touch); min-height: var(--touch);
  filter: drop-shadow(0 3px 3px rgba(0,0,0,.3));
  animation: sway 3.2s ease-in-out infinite alternate;
  transition: transform .2s;
}
.oyster.open { animation: pearl-pop .45s forwards; }
@keyframes sway { from { transform: rotate(-5deg); } to { transform: rotate(5deg); } }
@keyframes pearl-pop { 50% { transform: scale(1.35); } 100% { transform: scale(1.1); } }

/* مطر المقاطع (الباحة) */
.syll-slots { display: flex; justify-content: center; gap: var(--gap-2); }
.syll-slot {
  width: var(--touch); height: var(--touch); border-radius: 16px; flex: none;
  background: var(--card); border: 3px dashed var(--clay);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.55rem; font-weight: 700; color: var(--clay); box-shadow: var(--shadow);
}
.syll-slot.filled {
  border-style: solid; border-color: var(--oasis); color: var(--ink);
  background: #eef7ee; animation: pearl-pop .45s;
}
.rain-sky {
  position: relative; border-radius: 22px; overflow: hidden; flex: 1; min-height: min(300px, 42dvh);
  background: linear-gradient(180deg, #9fb8c8 0%, #7d9db2 55%, #33691e 100%);
  background-size: cover; background-position: center;
  box-shadow: var(--shadow);
}
.rain-sky::before {
  content: ''; position: absolute; inset: -10%; pointer-events: none;
  background: repeating-linear-gradient(105deg, transparent 0 16px, rgba(255,255,255,.16) 16px 18px);
  animation: rainfall 1.4s linear infinite;
  will-change: transform;
}
@keyframes rainfall { to { transform: translate(-10px, 20px); } }
.rain-trees {
  position: absolute; bottom: 2px; width: 100%; text-align: center;
  font-size: 2rem; pointer-events: none; filter: drop-shadow(0 2px 2px rgba(0,0,0,.3));
}
.rain-drop {
  position: absolute; min-width: var(--touch); min-height: var(--touch); border-radius: 50% 8px 50% 50%;
  background: linear-gradient(180deg, #d8f0f9, #8fd0e8); border: 3px solid #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 700; color: #0d4a6d;
  box-shadow: 0 4px 10px rgba(0, 40, 60, .25);
  animation: dropbob ease-in-out infinite alternate;
}
@keyframes dropbob { from { transform: translateY(-8px); } to { transform: translateY(10px); } }
.rain-drop.caught { animation: caught .5s forwards; }
.rain-drop.early { animation: pearl-pop .4s; background: #fff2c8; }
@media (prefers-reduced-motion: reduce) {
  .rain-sky::before, .rain-drop, .fish, .oyster, .city-stamp-row.stamp-new { animation: none; }
}

/* بريد القطار (تبوك) */
.train {
  display: flex; align-items: center; justify-content: center; gap: var(--gap-1); flex-wrap: wrap;
  background: var(--card); border-radius: var(--radius-card); padding: 12px; box-shadow: var(--shadow);
}
.train-engine { font-size: 2.4rem; filter: drop-shadow(0 2px 2px rgba(0,0,0,.25)); }
.train-wagon {
  width: 54px; height: 52px; border-radius: 10px; flex: none;
  background: #efe2c8; border: 3px dashed var(--ink-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.45rem; font-weight: 700;
}
.train-wagon.full {
  border-style: solid; border-color: var(--teal); background: #d9f3f4;
  color: #0d6a6d; animation: pearl-pop .45s;
}
.parcel-yard { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: var(--gap-25); }
.parcel {
  min-height: 84px; border-radius: 18px;
  background: linear-gradient(180deg, #f0d9b0, #d9b678); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 1.3rem; transition: transform .12s;
}
.parcel .p-num { font-size: 1.55rem; color: var(--ink); }
.parcel:active { transform: scale(.95); }
.parcel.gone { animation: caught .5s forwards; pointer-events: none; }

/* قافلة نجد (الرياض) + قافلة البخور (نجران) */
.caravan-row, .incense-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
  background: var(--card); border-radius: var(--radius-card); padding: 12px 14px; box-shadow: var(--shadow);
  font-size: 1.6rem; line-height: 1.4;
}
.incense-rows { display: flex; flex-direction: column; gap: var(--gap-2); }
.caravan-camel { font-size: 2.2rem; margin-inline-end: 6px; }
.sack { transition: opacity .5s, transform .5s; }
.sack.given { opacity: .25; transform: translateY(10px) scale(.85); }
.incense-jars { letter-spacing: 2px; }

/* سوق جدة (مكة) — الميزان */
.scale-wrap {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .6s;
}
.scale-wrap.tilt-a { transform: rotate(3deg); }
.scale-wrap.tilt-b { transform: rotate(-3deg); }
.scale-beam { font-size: 2.4rem; flex: none; }
.scale-pan {
  flex: 1; max-width: 220px; min-height: 110px; border-radius: var(--radius-card);
  background: var(--card); box-shadow: var(--shadow); padding: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 1.25rem; line-height: 1.5; transition: transform .12s;
}
.scale-pan:active { transform: scale(.96); }
.scale-pan .pan-fish { word-break: break-all; text-align: center; }
.scale-pan .pan-num { font-size: 1.4rem; color: var(--teal); }
.scale-pan.ok { background: #d4f7d4; }
.scale-eq { background: linear-gradient(180deg, #d9e6f3, #9db8d4); box-shadow: 0 6px 0 #5f7fa3; font-size: 1.15rem; }
.scale-eq.ok { background: #d4f7d4; color: var(--ink); box-shadow: 0 6px 0 #1d6a40; }
.scale-eq.bad { background: #f9d5c8; color: var(--ink); box-shadow: 0 6px 0 #b3705c; }

/* حكاية الواحة (المدينة) */
.story-beat { text-align: center; font-size: 1.05rem; font-weight: 700; color: var(--ink-soft); }
.story-text {
  background: var(--card); border-radius: var(--radius-card); padding: 14px 16px; box-shadow: var(--shadow);
  font-size: 1.2rem; line-height: 1.8; display: flex; align-items: flex-start; gap: var(--gap-2);
}
.story-text span { flex: 1; }

/* ═══ النتيجة ═══ */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(74, 52, 35, .45); padding: 18px; }
.modal-card {
  width: 100%; max-width: 440px; background: var(--card); border-radius: 28px;
  padding: 26px 22px; text-align: center; box-shadow: 0 12px 40px rgba(74,52,35,.4);
  animation: pop .3s cubic-bezier(.2, 1.4, .5, 1); max-height: 88dvh; overflow-y: auto;
}
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
.result-stars { font-size: 2.6rem; letter-spacing: 6px; margin: 8px 0; }
/* غيث وريم يعلّقان على النتيجة (يظهر الشريط حين يبدأ الكلام) */
.result-talk { display: flex; align-items: center; gap: var(--gap-2); text-align: start; }
.result-talk img {
  width: 56px; height: 56px; border-radius: 50%; object-fit: cover; object-position: top;
  background: var(--sand-deep); box-shadow: var(--shadow); flex: none;
}
.result-talk img.bounce { animation: bounce .6s; }
.result-talk .bubble { margin: 0; min-height: 44px; font-size: .98rem; background: var(--sand); box-shadow: none; }
.result-talk:has(.bubble:empty) { display: none; }
.result-title { font-size: 1.7rem; }
.result-sub { font-size: 1.15rem; color: var(--ink-soft); line-height: 1.6; margin-bottom: 14px; }
.result-scene { border-radius: 18px; overflow: hidden; margin-bottom: 14px; }
.result-scene img { width: 100%; display: block; }
.result-actions { display: flex; gap: var(--gap-2); justify-content: center; flex-wrap: wrap; }
.skin-unlock img { width: 60%; max-width: 220px; border-radius: 18px; margin: 10px auto; display: block; }

/* ═══ الخزانة ═══ */
.wardrobe-card h3 { font-size: 1.6rem; margin-bottom: 4px; }
.wardrobe-hint { color: var(--ink-soft); font-size: 1rem; margin-bottom: 14px; }
.wardrobe-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap-25); }
.skin-card { background: var(--sand); border-radius: 18px; padding: 10px; border: 3px solid transparent; }
.skin-card img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 12px; background: var(--sand-deep); }
.skin-card.locked img { filter: grayscale(1) brightness(.75); }
.skin-card b { display: block; font-size: .95rem; margin-top: 6px; }
.skin-card small { color: var(--ink-soft); font-size: .8rem; }
.skin-card.equipped { border-color: var(--saffron); }
.switch-card { border-color: var(--teal); }

/* ═══ دروسي (مسارا المنهج) ═══ */
.btn-lessons { background: linear-gradient(180deg, #6db3d9, var(--teal)); box-shadow: 0 6px 0 #275a7a; }
.cur-tabs { display: flex; gap: var(--gap-2); justify-content: center; margin-bottom: 6px; }
.cur-tab {
  min-height: var(--touch); padding: 8px 22px; border-radius: 16px;
  font-size: 1.12rem; font-weight: 700; color: var(--ink-soft);
  background: var(--sand); border: 3px solid transparent;
}
.cur-tab.on { background: var(--card); border-color: var(--saffron); color: inherit; box-shadow: var(--shadow); }
.cur-unit { text-align: right; margin: 14px 4px 8px; font-size: 1.05rem; color: var(--ink-soft); }
.cur-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap-25); }
.lesson-card { min-height: 96px; }
.lesson-card.locked { opacity: .55; }
.lesson-card.done-lesson { border-color: var(--oasis); }
.lesson-stars { display: block; font-size: .9rem; min-height: 1.2em; letter-spacing: 2px; }

/* زر إعادة الاستماع 🔁 */
.btn-replay-sm { width: var(--touch-min); height: var(--touch-min); font-size: 1.15rem; flex: none; }

/* ═══ محطات المدن (نموذج مكة) + جواز الرحلة ═══ */
.city-tabs { display: flex; gap: var(--gap-2); }
.city-tab {
  flex: 1; min-height: var(--touch); padding: 8px 4px; border-radius: 16px;
  background: var(--sand); border: 3px solid transparent;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-size: 1.02rem; font-weight: 700; line-height: 1.25;
}
.city-tab .c-icon { font-size: 1.4rem; }
.city-tab .c-stamp { font-size: .72rem; color: var(--ink-soft); }
.city-tab.on { background: var(--card); border-color: var(--saffron); box-shadow: var(--shadow); }
.city-tab.visited:not(.on) { border-color: var(--oasis-soft); }
.city-tab.visited .c-stamp { color: #1d6a40; font-weight: 700; }
.city-panel {
  background: var(--sand); border-radius: 18px; padding: var(--pad-screen);
  margin-top: var(--gap-2); display: flex; flex-direction: column; gap: var(--gap-2);
}
.city-fact { display: flex; align-items: flex-start; gap: var(--gap-2); }
.city-fact-text {
  flex: 1; background: var(--card); border-radius: 16px; padding: 10px 14px;
  font-size: 1.05rem; line-height: 1.6; box-shadow: var(--shadow);
}
.city-fact-text b { color: #0d6a6d; }
.city-stamp-row {
  text-align: center; font-size: 1rem; font-weight: 700; color: #1d6a40;
  background: #eef7ee; border-radius: 14px; padding: 8px 10px;
}
.city-stamp-row.stamp-new { animation: stamp-in .5s cubic-bezier(.2, 1.6, .5, 1); }
@keyframes stamp-in { from { transform: scale(.3) rotate(-14deg); opacity: 0; } }
.city-lesson {
  display: flex; align-items: center; gap: var(--gap-2); text-align: right;
  min-height: var(--touch); padding: 8px 14px; border-radius: 16px;
  background: var(--card); box-shadow: var(--shadow); font-size: 1rem;
}
.city-lesson span { font-size: 1.5rem; flex: none; }
.city-lesson b { flex: 1; }
.city-lesson small { color: var(--ink-soft); max-width: 40%; }
.city-lesson.locked { opacity: .55; }
.btn-passport { background: linear-gradient(180deg, #b3a2e8, #7e5fd4); box-shadow: 0 6px 0 #4c3396; }
.passport-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap-2); }
.passport-stamp {
  border: 3px dashed var(--sand-deep); border-radius: var(--radius-card); padding: var(--gap-3) var(--gap-1);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--ink-soft);
}
.passport-stamp.locked { opacity: .5; }
.passport-stamp .p-icon { font-size: 2rem; line-height: 1.3; }
.passport-stamp b { font-size: .98rem; color: var(--ink); }
.passport-stamp small { font-size: .72rem; line-height: 1.35; }
.passport-stamp.got {
  border-style: solid; border-color: var(--oasis); background: #eef7ee;
  transform: rotate(-2deg);
}
.passport-stamp.got:nth-child(even) { transform: rotate(2deg); }
@media (max-width: 360px) {
  .city-tab { font-size: .92rem; }
  .city-lesson small { display: none; }   /* يبقى العنوان والأيقونة — لا ازدحام */
  .passport-grid { gap: var(--gap-1); }
  .passport-stamp .p-icon { font-size: 1.7rem; }
  .passport-stamp b { font-size: .88rem; }
  .passport-stamp small { font-size: .66rem; }
}

/* ── نقاط الانكسار (نظام التخطيط) ──
   ≤360: جوال ضيق — خطوط/عناصر أصغر درجة
   361–699: الجوال المرجعي (الافتراضي أعلاه)
   ≥700: تابلت — الشيتات تتوسّط
   ≥1024: سطح مكتب — عمود المحتوى يتسع قليلًا */
@media (max-width: 360px) {
  .logo { font-size: 2.3rem; }
  .g-q { font-size: 1.12rem; padding: 12px; }
  .guide img { width: 60px; height: 60px; }
  .bubble { font-size: .95rem; }
  .btn-big { font-size: 1.15rem; padding: 12px 18px; }
  .char-card .char-name { font-size: 1.25rem; }
  .farm-controls .btn-big { font-size: .95rem; }
  .syll-slot { width: 54px; height: 54px; font-size: 1.3rem; }
  .train-engine { font-size: 1.9rem; }
  .train-wagon { width: 48px; height: 48px; font-size: 1.05rem; }
  .rain-drop { min-width: 58px; min-height: 58px; font-size: 1.15rem; }
}
@media (min-width: 700px) {
  .sheet { align-items: center; }
  .sheet-card { border-radius: 30px; }
}
@media (min-width: 1024px) {
  :root { --content-max: 640px; }   /* عمود المحتوى كله يتسع معًا عبر التوكن */
  /* استثناء موثق عن سقف 52dvh: شاشات ≥1024px عالية غالبًا، والخريطة الأكبر
     أوضح — تحقق layout-test يشمل مقاس سطح المكتب فيمسك أي تزاحم فعلي */
  #ksa-map { max-height: 60dvh; }
}
