:root {
  --purple: #9775fa;
  --blue: #4dabf7;
  --orange: #ff922b;
  --green: #51cf66;
  --pink: #f783ac;
  --yellow: #ffd43b;
  --red: #ff6b6b;
  --bg: #eef6ff;
  --ink: #2b2d42;
  --card-radius: 28px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: linear-gradient(160deg, #eef6ff 0%, #fff0f6 100%);
  font-family: "Cairo", "Segoe UI", Tahoma, sans-serif;
  color: var(--ink);
  overflow-x: hidden;
  user-select: none;
}

#app {
  min-height: 100vh;
  padding: 150px 16px 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  box-sizing: border-box;
}

/* ===== شريط النجوم وزر الصوت ===== */
#star-bar {
  position: fixed;
  top: 14px;
  inset-inline-start: 14px;
  background: #fff;
  border: none;
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 1.4rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--ink);
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
#star-bar:active { transform: scale(0.95); }
.star-icon { font-size: 1.5rem; }
#profile-avatar { font-size: 1.5rem; }
#profile-name { font-size: 1.1rem; color: #888; }
#profile-name:empty { display: none; }

#sound-toggle {
  position: fixed;
  top: 14px;
  inset-inline-end: 14px;
  font-size: 1.6rem;
  background: #fff;
  border: none;
  border-radius: 50%;
  width: 54px;
  height: 54px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
  cursor: pointer;
  z-index: 50;
}
#sound-toggle:active { transform: scale(0.9); }

/* ===== المرافق ===== */
#mascot {
  position: fixed;
  bottom: 10px;
  inset-inline-end: 10px;
  width: 110px;
  height: 110px;
  z-index: 40;
  animation: float 3s ease-in-out infinite;
  cursor: pointer;
  filter: drop-shadow(0 8px 10px rgba(0,0,0,0.2));
}
#mascot.celebrate {
  animation: mascotCelebrate 1.3s ease;
  z-index: 70;
}
@keyframes mascotCelebrate {
  0% { transform: translate(0,0) scale(1) rotate(0deg); }
  35% { transform: translate(-42vw, -32vh) scale(2.1) rotate(-12deg); }
  55% { transform: translate(-42vw, -32vh) scale(2.3) rotate(10deg); }
  75% { transform: translate(-42vw, -32vh) scale(2.1) rotate(-6deg); }
  100% { transform: translate(0,0) scale(1) rotate(0deg); }
}
.celebrate-badge {
  position: fixed;
  top: 50%;
  left: 50%;
  font-size: 6rem;
  z-index: 71;
  pointer-events: none;
  animation: badgePop 1s ease forwards;
}
@keyframes badgePop {
  0% { transform: translate(-50%, -50%) scale(0.2); opacity: 0; }
  30% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
  60% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1) translateY(-40px); opacity: 0; }
}
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-14px) rotate(2deg); }
}
#mascot-bubble {
  position: fixed;
  bottom: 110px;
  inset-inline-end: 20px;
  max-width: 240px;
  background: #fff;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 1.1rem;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(0,0,0,0.15);
  z-index: 41;
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.25s ease;
  pointer-events: none;
  text-align: center;
}
#mascot-bubble.show { opacity: 1; transform: scale(1); }

/* ===== شاشة البداية ===== */
h1.title {
  font-family: "Baloo Bhaijaan 2", "Cairo", sans-serif;
  font-size: clamp(2.2rem, 8vw, 3.2rem);
  color: var(--purple);
  text-shadow: 3px 3px 0 #fff;
  margin: 4px 0 4px;
  text-align: center;
}
.subtitle {
  font-size: 1.3rem;
  color: #666;
  margin-bottom: 28px;
  text-align: center;
}

.path-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 26px;
  justify-content: center;
  width: 100%;
  max-width: 720px;
}

.path-card {
  flex: 1 1 260px;
  max-width: 320px;
  border: none;
  border-radius: 32px;
  padding: 34px 20px;
  font-family: inherit;
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 0 rgba(0,0,0,0.15);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.path-card:active { transform: translateY(8px); box-shadow: 0 2px 0 rgba(0,0,0,0.15); }
.path-card .icon { font-size: 4rem; }
.path-card.arabic { background: linear-gradient(160deg, var(--purple), #6741d9); }
.path-card.math { background: linear-gradient(160deg, var(--orange), #f76707); }
.path-card.english { background: linear-gradient(160deg, #4dabf7, #1c7ed6); }
.path-card.stories { background: linear-gradient(160deg, #ff922b, #e8590c); }

/* ===== أزرار عامة ===== */
.big-btn {
  font-family: inherit;
  border: none;
  border-radius: 20px;
  padding: 16px 30px;
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  background: var(--blue);
  cursor: pointer;
  box-shadow: 0 8px 0 rgba(0,0,0,0.15);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.big-btn:active { transform: translateY(6px); box-shadow: 0 2px 0 rgba(0,0,0,0.15); }
.big-btn.secondary { background: #adb5bd; }
.big-btn.green { background: var(--green); }
.big-btn.pink { background: var(--pink); }

.back-btn {
  position: fixed;
  top: 78px;
  inset-inline-start: 14px;
  z-index: 45;
  font-family: inherit;
  border: none;
  background: #fff;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 1.1rem;
  font-weight: 700;
  box-shadow: 0 6px 14px rgba(0,0,0,0.12);
  cursor: pointer;
}
.back-btn:active { transform: scale(0.95); }

/* ===== شبكة البطاقات (حروف / أرقام) ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 760px;
  margin-top: 10px;
}

.tile {
  aspect-ratio: 1;
  border: none;
  border-radius: 22px;
  font-size: 2.4rem;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 0 rgba(0,0,0,0.15);
  transition: transform 0.1s ease;
}
.tile:active { transform: scale(0.9) translateY(4px); }

.section-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--purple);
  margin: 6px 0 4px;
  text-align: center;
}

/* ===== شاشة الدرس (حرف / رقم مكبر) ===== */
.lesson-card {
  background: #fff;
  border-radius: 36px;
  padding: 30px 26px 26px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 14px 30px rgba(0,0,0,0.12);
  position: relative;
}

.big-letter {
  font-size: 8rem;
  font-weight: 800;
  color: var(--purple);
  line-height: 1;
  cursor: pointer;
  display: inline-block;
  transition: transform 0.15s ease;
}
.big-letter:active { transform: scale(1.15) rotate(-4deg); }

.letter-name { font-size: 1.4rem; color: #888; margin-top: 4px; }

.example-row {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: #f8f0ff;
  border-radius: 20px;
  padding: 14px;
  cursor: pointer;
}
.example-row .emoji { font-size: 3rem; }
.example-row .word { font-size: 2rem; font-weight: 700; color: var(--ink); }

.nav-row {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 26px;
  flex-wrap: wrap;
}

/* ===== لعبة الاختيار من متعدد ===== */
.quiz-wrap { width: 100%; max-width: 480px; text-align: center; }
.quiz-prompt {
  background: #fff;
  border-radius: 30px;
  padding: 26px;
  font-size: 1.4rem;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(0,0,0,0.1);
  margin-bottom: 24px;
  cursor: pointer;
}
.quiz-prompt .big-emoji { font-size: 5rem; display: block; margin-bottom: 8px; }
.quiz-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.quiz-options.two-col { grid-template-columns: repeat(2, 1fr); }
.option-btn {
  border: none;
  border-radius: 22px;
  background: #fff;
  font-size: 2.2rem;
  font-weight: 800;
  padding: 22px 6px;
  color: var(--ink);
  box-shadow: 0 8px 0 rgba(0,0,0,0.12);
  cursor: pointer;
  transition: transform 0.1s ease;
}
.option-btn:active { transform: translateY(6px); }
.option-btn.correct { background: var(--green) !important; color: #fff; animation: pop 0.4s ease; }
.option-btn.wrong { background: var(--red) !important; color: #fff; animation: shake 0.4s ease; }

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.25); }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

.progress-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 18px;
}
.progress-dots span {
  width: 12px; height: 12px; border-radius: 50%;
  background: #dee2e6;
}
.progress-dots span.done { background: var(--green); }
.progress-dots span.current { background: var(--orange); }

/* ===== الأشكال ===== */
.shape-box {
  width: 90px; height: 90px;
  display: flex; align-items: center; justify-content: center;
}
.shape-circle { width: 70px; height: 70px; border-radius: 50%; }
.shape-square { width: 70px; height: 70px; border-radius: 8px; }
.shape-rectangle { width: 90px; height: 55px; border-radius: 8px; }
.shape-triangle {
  width: 0; height: 0;
  border-left: 40px solid transparent;
  border-right: 40px solid transparent;
  border-bottom: 70px solid currentColor;
}
.shape-star {
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  width: 80px; height: 80px;
}

/* ===== نجوم الاحتفال ===== */
.confetti {
  position: fixed;
  top: -40px;
  font-size: 2rem;
  z-index: 60;
  animation: fall linear forwards;
  pointer-events: none;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(360deg); opacity: 0.3; }
}

/* ===== شاشة نتيجة نهائية ===== */
.result-card {
  background: #fff;
  border-radius: 32px;
  padding: 40px 26px;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 14px 30px rgba(0,0,0,0.12);
}
.result-card .big-emoji { font-size: 5rem; }
.result-card h2 { color: var(--purple); font-size: 2rem; }

/* ===== اختيار/إنشاء الملف الشخصي ===== */
.profile-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  max-width: 640px;
}
.profile-card {
  border: none;
  background: #fff;
  border-radius: 26px;
  padding: 22px 26px;
  min-width: 140px;
  cursor: pointer;
  box-shadow: 0 8px 0 rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  transition: transform 0.1s ease;
}
.profile-card:active { transform: translateY(6px); }
.profile-card .avatar { font-size: 3.4rem; }
.profile-card .name { font-size: 1.3rem; font-weight: 800; color: var(--ink); }
.profile-card .stars { font-size: 1rem; color: #888; }
.profile-card.add-new { background: #f1f3f5; color: #888; justify-content: center; }
.profile-card.add-new .avatar { font-size: 2.6rem; }

.avatar-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  max-width: 380px;
  margin: 18px 0;
}
.avatar-choice {
  border: 3px solid transparent;
  background: #fff;
  border-radius: 20px;
  font-size: 2.2rem;
  width: 70px;
  height: 70px;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,0.1);
}
.avatar-choice.selected { border-color: var(--purple); background: #f3ecff; }

.name-input {
  font-family: inherit;
  font-size: 1.5rem;
  text-align: center;
  padding: 14px 20px;
  border: 3px solid #dee2e6;
  border-radius: 18px;
  width: 100%;
  max-width: 280px;
  margin-bottom: 10px;
}
.name-input:focus { outline: none; border-color: var(--purple); }
.name-input.input-error { border-color: #fa5252; animation: shake 0.3s; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ===== خارطة الفصول ===== */
.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 480px;
}
.chapter-card {
  display: flex;
  align-items: center;
  gap: 16px;
  border: none;
  border-radius: 22px;
  padding: 16px 20px;
  background: #fff;
  box-shadow: 0 6px 0 rgba(0,0,0,0.1);
  cursor: pointer;
  font-family: inherit;
  text-align: right;
  transition: transform 0.1s ease;
}
.chapter-card:active { transform: translateY(4px); }
.chapter-card.soon { opacity: 0.55; cursor: default; }
.chapter-card.soon:active { transform: none; }
.chapter-card .num-badge {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--purple); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.1rem; flex-shrink: 0;
}
.chapter-card .icon2 { font-size: 1.8rem; }
.chapter-card .label { font-size: 1.2rem; font-weight: 700; flex: 1; }
.chapter-card .status-tag { font-size: 0.95rem; color: #999; }

/* ===== خارطة عقد الفصل (مسار متصل) ===== */
.level-path {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 360px;
  padding-top: 6px;
}
.level-connector {
  width: 6px;
  height: 34px;
  background: #dee2e6;
  border-radius: 3px;
}
.level-connector.done { background: var(--green); }
.level-node-btn {
  width: 92px;
  border: none;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 6px 0 rgba(0,0,0,0.12);
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-family: inherit;
}
.level-node-btn:active { transform: translateY(4px); }
.level-node-btn .node-circle {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  background: linear-gradient(160deg, var(--purple), #6741d9);
  color: #fff;
}
.level-node-btn.done .node-circle { background: linear-gradient(160deg, var(--green), #2f9e44); }
.level-node-btn.locked { opacity: 0.5; cursor: default; }
.level-node-btn.locked .node-circle { background: #ced4da; }
.level-node-btn .node-label { font-size: 0.95rem; font-weight: 700; color: var(--ink); text-align: center; }

/* ===== إطار العشرة (Ten-Frame) ===== */
.ten-frame-group { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.ten-frame { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.ten-frame .cell {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2.5px solid #dee2e6;
  background: #fff;
}
.ten-frame .cell { position: relative; }
.ten-frame .cell.filled { border-color: transparent; }
.ten-frame .cell.filled.crossed { opacity: 0.35; }
.ten-frame .cell.filled.crossed::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(45deg, transparent 42%, #333 42%, #333 58%, transparent 58%);
  border-radius: 50%;
}
.empty-note { font-size: 1.2rem; color: #aaa; margin-top: 8px; }

/* ===== مجموعات كائنات (قصص الجمع) ===== */
.count-group { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.count-row { font-size: 2rem; letter-spacing: 6px; }

/* ===== شرح الرمز (تعلّم قبل التدريب) ===== */
.concept-symbol {
  font-size: 5rem;
  font-weight: 800;
  color: var(--purple);
  background: #f3ecff;
  width: 120px; height: 120px;
  border-radius: 30px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
}
.concept-example { display: flex; align-items: center; justify-content: center; gap: 14px; font-size: 2rem; margin: 14px 0; }

/* ===== بيت الحقائق المترابطة ===== */
.fact-family-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.fact-family-row span {
  background: #f3ecff;
  color: var(--purple);
  font-weight: 800;
  font-size: 1.3rem;
  padding: 8px 16px;
  border-radius: 14px;
}

/* ===== لعبة التوصيل (مطابقة) ===== */
.match-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
  max-width: 420px;
}
.match-col { display: flex; flex-direction: column; gap: 12px; }
.match-card {
  border: 3px solid transparent;
  background: #fff;
  border-radius: 18px;
  padding: 12px;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(0,0,0,0.1);
}
.match-card .ten-frame { transform: scale(0.6); }
.match-card.selected { border-color: var(--orange); }
.match-card.matched { background: #d3f9d8; color: #2f9e44; opacity: 0.7; cursor: default; box-shadow: none; }
.match-card.wrong-flash { animation: shake 0.4s ease; border-color: var(--red); }

/* ===== مقارنة الأعداد ===== */
.compare-row {
  display: flex;
  gap: 18px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 10px;
}
.compare-card {
  border: 3px solid transparent;
  background: #fff;
  border-radius: 22px;
  padding: 16px;
  cursor: pointer;
  box-shadow: 0 8px 0 rgba(0,0,0,0.1);
}
.compare-card .ten-frame-group { transform: scale(0.8); }
.compare-card.correct { border-color: var(--green); animation: pop 0.4s ease; }
.compare-card.wrong { border-color: var(--red); animation: shake 0.4s ease; }

/* ===== ترتيب الأعداد ===== */
.order-slots {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 20px;
}
.order-slot {
  width: 52px; height: 52px;
  border-radius: 14px;
  border: 3px dashed #adb5bd;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 800; color: var(--purple);
}
.order-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.order-row .option-btn.matched { background: #d3f9d8; color: #2f9e44; opacity: 0.6; }

/* ===== العدد الترتيبي ===== */
.ordinal-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.ordinal-animal {
  border: 3px solid transparent;
  background: #fff;
  border-radius: 18px;
  font-size: 2.2rem;
  width: 66px; height: 66px;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(0,0,0,0.1);
}
.ordinal-animal.correct { border-color: var(--green); animation: pop 0.4s ease; }
.ordinal-animal.wrong { border-color: var(--red); animation: shake 0.4s ease; }

/* ===== التصنيف (اضغط على العنصر المطابق) ===== */
.sort-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  max-width: 420px;
  margin: 0 auto;
}
.sort-token {
  border: 3px solid transparent;
  background: #fff;
  border-radius: 18px;
  padding: 12px;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(0,0,0,0.1);
  font-size: 2.2rem;
}
.sort-token .shape-box { width: 100%; height: 100%; }
.sort-token .shape-circle,
.sort-token .shape-square { width: 44px; height: 44px; }
.sort-token .shape-triangle { border-left-width: 24px; border-right-width: 24px; border-bottom-width: 42px; }
.sort-token.correct { border-color: var(--green); background: #d3f9d8; opacity: 0.65; cursor: default; }
.sort-token.wrong-flash { animation: shake 0.4s ease; border-color: var(--red); }

/* ===== مخطط الصور (Pictograph) ===== */
.pictograph-rows { width: 100%; max-width: 420px; margin: 0 auto 18px; }
.pictograph-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border-radius: 16px;
  padding: 10px 16px;
  margin-bottom: 10px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.06);
}
.pictograph-row .cat-label { font-weight: 800; min-width: 90px; }
.pictograph-row .cat-icons { font-size: 1.4rem; letter-spacing: 3px; }

/* ===== خط الأعداد ===== */
.number-line {
  display: flex;
  direction: ltr;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 22px 0 14px;
}
.nl-cell {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #f1f3f5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  position: relative;
}
.nl-cell.nl-start { background: var(--orange); color: #fff; }
.nl-cell.nl-end { background: var(--green); color: #fff; }
.nl-cell.nl-hop::before {
  content: "↷";
  position: absolute;
  top: -22px;
  font-size: 1rem;
  color: var(--purple);
}

/* ===== الأطوال ===== */
.length-bar {
  display: flex;
  gap: 3px;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 320px;
}
.unit-block {
  width: 26px;
  height: 26px;
  border-radius: 6px;
}
.length-card {
  border: 3px solid transparent;
  background: #fff;
  border-radius: 20px;
  padding: 16px;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(0,0,0,0.1);
  margin: 8px 0;
}
.length-card.correct { border-color: var(--green); animation: pop 0.4s ease; }
.length-card.wrong { border-color: var(--red); animation: shake 0.4s ease; }

/* ===== شاشة البدء (Splash) ===== */
.splash-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  gap: 18px;
  width: 100%;
}
.splash-mascot { font-size: 6rem; animation: splashBounce 1s ease-in-out infinite; }
@keyframes splashBounce {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-22px) rotate(3deg); }
}
.splash-dots { display: flex; gap: 10px; }
.splash-dots span {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--purple);
  animation: dotPulse 1.2s ease infinite;
}
.splash-dots span:nth-child(2) { animation-delay: 0.2s; background: var(--orange); }
.splash-dots span:nth-child(3) { animation-delay: 0.4s; background: var(--green); }
@keyframes dotPulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.15); }
}
.splash-credit {
  position: fixed;
  bottom: 22px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  opacity: 0;
  animation: creditFadeIn 0.8s ease 0.6s forwards;
}
.splash-credit img { width: 54px; height: auto; margin-bottom: 4px; }
.splash-credit span { font-size: 0.8rem; color: #888; text-align: center; padding: 0 20px; }
.splash-credit-phone { direction: ltr; font-size: 0.75rem !important; color: #aaa !important; }
@keyframes creditFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
body.splash-active #star-bar,
body.splash-active #sound-toggle,
body.splash-active #mascot,
body.splash-active #mascot-bubble {
  display: none;
}

/* ===== مكعبات الآحاد والعشرات (Base-10 Blocks) ===== */
.base10-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.base10-tens {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: center;
}
.ten-rod {
  width: 16px;
  height: 64px;
  border-radius: 5px;
}
.base10-ones {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 90px;
}
.one-unit {
  width: 16px;
  height: 16px;
  border-radius: 4px;
}

/* ===== المتشابه والمختلف ===== */
.odd-one-row {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}
.odd-one-item {
  border: 3px solid transparent;
  background: #fff;
  border-radius: 20px;
  font-size: 2.8rem;
  width: 84px;
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(0,0,0,0.1);
}
.odd-one-item.correct { border-color: var(--green); animation: pop 0.4s ease; }
.odd-one-item.wrong { border-color: var(--red); animation: shake 0.4s ease; }

/* ===== المواقع (فوق/تحت) ===== */
.position-scene {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 10px 0 26px;
  font-size: 4rem;
}

/* ===== اليمين واليسار ===== */
.lr-row {
  direction: ltr;
  display: flex;
  justify-content: center;
  gap: 40px;
  margin: 14px 0 26px;
}
.lr-slot {
  width: 90px; height: 90px;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 6px 0 rgba(0,0,0,0.08);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.8rem;
}
.lr-options {
  display: flex;
  justify-content: center;
  gap: 16px;
}

/* ===== الأنماط ===== */
.pattern-row { font-size: 2.4rem; display: flex; gap: 10px; justify-content: center; margin-bottom: 22px; }
.pattern-row .blank {
  width: 52px; height: 52px; border-radius: 14px;
  border: 3px dashed #adb5bd;
  display: flex; align-items: center; justify-content: center;
}

/* ===== نشاط الكتابة (التتبّع بالإصبع) ===== */
.trace-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.trace-canvas {
  width: min(280px, 78vw);
  height: min(280px, 78vw);
  background: #fff;
  border-radius: 24px;
  border: 3px solid #e9ecef;
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
  touch-action: none;
  cursor: crosshair;
}
.trace-controls { display: flex; gap: 12px; }
.trace-picker-hint { font-size: 1.1rem; color: #888; margin-top: 6px; }

/* ===== لوحة متابعة الأهل ===== */
.parent-link {
  margin-top: 22px;
  background: none;
  border: none;
  color: #888;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 8px;
}
.parent-summary {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border-radius: 20px;
  padding: 16px 20px;
  box-shadow: 0 6px 0 rgba(0,0,0,0.08);
  width: 100%;
  max-width: 480px;
  margin-bottom: 18px;
}
.parent-summary .avatar { font-size: 2.6rem; }
.parent-summary .name { font-size: 1.3rem; font-weight: 800; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.edit-name-btn { background: none; border: none; cursor: pointer; font-size: 1rem; padding: 2px; opacity: 0.6; }
.edit-name-btn:hover { opacity: 1; }
.parent-summary .stars { color: #888; font-size: 1rem; }
.parent-track-card {
  background: #fff;
  border-radius: 20px;
  padding: 16px 20px;
  box-shadow: 0 6px 0 rgba(0,0,0,0.08);
  width: 100%;
  max-width: 480px;
  margin-bottom: 16px;
  text-align: right;
}
.parent-track-card .track-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--purple);
  margin-bottom: 10px;
}
.parent-progress-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.parent-progress-row .unit-name { flex: 1; font-size: 0.95rem; color: var(--ink); }
.parent-progress-row .frac { font-size: 0.85rem; color: #999; min-width: 44px; text-align: left; }
.parent-bar-bg { flex: 2; height: 10px; background: #eee; border-radius: 6px; overflow: hidden; }
.parent-bar-fill { height: 100%; border-radius: 6px; background: var(--green, #51cf66); }
.parent-tip-card {
  background: #fff8e1;
  border-radius: 20px;
  padding: 16px 20px;
  width: 100%;
  max-width: 480px;
  margin-bottom: 16px;
  text-align: right;
}
.parent-tip-card .tip-head { font-weight: 800; color: #e8590c; margin-bottom: 8px; }
.parent-tip-card ul { margin: 0; padding-inline-start: 20px; }
.parent-tip-card li { margin-bottom: 6px; line-height: 1.6; }
.parent-last-activity {
  background: #eef7ff;
  border-radius: 20px;
  padding: 14px 20px;
  width: 100%;
  max-width: 480px;
  margin-bottom: 16px;
  text-align: right;
}
.parent-contact-card {
  background: linear-gradient(160deg, #f3ecff, #eef7ff);
  border: 2px dashed var(--purple);
  border-radius: 20px;
  padding: 22px 20px;
  width: 100%;
  max-width: 480px;
  margin-bottom: 16px;
  text-align: center;
}
.parent-contact-card .contact-icon { font-size: 2.2rem; margin-bottom: 6px; }
.parent-contact-card .contact-title { font-size: 1.15rem; font-weight: 800; color: var(--purple); margin-bottom: 8px; }
.parent-contact-card .contact-text { font-size: 0.95rem; color: #555; line-height: 1.7; margin: 0 0 12px; }
.parent-contact-card .contact-team { font-weight: 700; color: var(--ink); }
.parent-contact-card .contact-phone {
  font-weight: 800;
  color: #fff;
  background: #25d366;
  font-size: 0.95rem;
  margin-top: 6px;
  display: inline-block;
  padding: 10px 18px;
  border-radius: 30px;
  text-decoration: none;
  box-shadow: 0 4px 0 rgba(0,0,0,0.1);
}
.parent-contact-card .contact-phone:active { transform: translateY(3px); box-shadow: none; }

/* ===== سويتش الوضع الهادئ ===== */
.calm-toggle-card {
  background: #fff;
  border-radius: 20px;
  padding: 16px 20px;
  box-shadow: 0 6px 0 rgba(0,0,0,0.08);
  width: 100%;
  max-width: 480px;
  margin-bottom: 16px;
  text-align: right;
}
.calm-toggle-row { display: flex; align-items: center; gap: 16px; }
.calm-toggle-text { flex: 1; }
.calm-toggle-title { font-weight: 800; color: var(--ink); font-size: 1.05rem; margin-bottom: 4px; }
.calm-toggle-desc { font-size: 0.85rem; color: #888; line-height: 1.6; }
.calm-info-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  background: #f3ecff;
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--purple);
  cursor: pointer;
  text-align: center;
}
.calm-info-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #ddd;
  font-size: 0.9rem;
  color: #555;
  line-height: 1.8;
}
.calm-info-panel p { margin: 0 0 10px; }
.calm-info-panel ul { margin: 0 0 10px; padding-inline-start: 20px; }
.calm-info-panel li { margin-bottom: 4px; }
.calm-info-note { background: #fff8e1; border-radius: 10px; padding: 8px 12px; font-size: 0.85rem; }
.calm-switch { position: relative; display: inline-block; width: 52px; height: 30px; flex-shrink: 0; }
.calm-switch input { opacity: 0; width: 0; height: 0; }
.calm-switch-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #ccc; border-radius: 30px; transition: background 0.2s;
}
.calm-switch-slider::before {
  content: ""; position: absolute; height: 24px; width: 24px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: transform 0.2s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.calm-switch input:checked + .calm-switch-slider { background: #6741d9; }
.calm-switch input:checked + .calm-switch-slider::before { transform: translateX(-22px); }

/* ===== زرّ الاستراحة ===== */
.pause-btn {
  position: fixed;
  bottom: 14px;
  inset-inline-start: 14px;
  background: #fff;
  border: 2px solid #8fa3c7;
  color: #5b6b8c;
  border-radius: 999px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  cursor: pointer;
  z-index: 60;
}

/* ===== الوضع الهادئ: تخفيف المثيرات الحسية فِي كُلّ التطبيق ===== */
body.calm .option-btn.wrong,
body.calm .match-card.wrong-flash,
body.calm .compare-card.wrong,
body.calm .ordinal-animal.wrong,
body.calm .sort-token.wrong-flash,
body.calm .length-card.wrong,
body.calm .odd-one-item.wrong {
  background: #8fa3c7 !important;
  border-color: #8fa3c7 !important;
  animation: none !important;
}
body.calm .option-btn.correct,
body.calm .compare-card.correct,
body.calm .ordinal-animal.correct,
body.calm .length-card.correct,
body.calm .odd-one-item.correct {
  animation: none !important;
}
body.calm .name-input.input-error { animation: none !important; border-color: #8fa3c7; }
body.calm #mascot { animation: none !important; }
body.calm #mascot.celebrate { animation: none !important; }
body.calm .splash-mascot { animation: none !important; }
body.calm .splash-dots span { animation: none !important; opacity: 0.7; }

/* ===== القصص التفاعلية ===== */
.story-card {
  background: #fff;
  border-radius: 28px;
  padding: 18px;
  max-width: 460px;
  width: 100%;
  text-align: center;
  box-shadow: 0 14px 30px rgba(0,0,0,0.12);
}
.story-image {
  width: 100%;
  border-radius: 18px;
  display: block;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}
.story-text {
  margin-top: 16px;
  font-size: 1.15rem;
  line-height: 2;
  color: var(--ink);
  cursor: pointer;
  padding: 6px 4px;
}
.story-choice-prompt {
  margin-top: 14px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--purple);
}
.story-choice-options {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.story-choice-options .option-btn { width: 100%; }

/* شاشات صغيرة */
@media (max-width: 420px) {
  #mascot { width: 84px; height: 84px; }
  .big-letter { font-size: 6rem; }
  .quiz-options { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .option-btn { font-size: 1.7rem; padding: 16px 4px; }
}
