/* ==========================================================================
   Math Adventure — واجهة v15 «مجرّة الأرقام»
   الفكرة: بنفسجي عميق + أصفر كهربائي فقط. أزرار «ملموسة» تُضغط للأسفل،
   حدود حبرية سميكة وظلال صلبة. كل الأصناف التي يستعملها JS محفوظة كما هي.
   قاعدة الاتساق: كل لون يأتي من المتغيّرات أدناه — لا ألوان حرّة في القوالب.
   ========================================================================== */

:root {
    /* البنفسجي */
    --violet-950: #1B0B45;
    --violet-800: #3B1A8C;
    --violet-700: #5B21B6;
    --violet-600: #7C3AED;
    --violet-500: #9D5CF5;
    --violet-300: #C9B4FB;
    --violet-200: #E2D6FD;
    --violet-100: #F0E9FF;
    --violet-50:  #F8F5FF;
    /* الأصفر */
    --yellow-500: #FFD23F;
    --yellow-400: #FFDC6B;
    --yellow-600: #F5B800;
    --yellow-100: #FFF3C2;
    --yellow-50:  #FFF9E0;

    --ink: var(--violet-950);
    --ink-soft: #5E4D8F;
    --paper: var(--violet-50);
    --card: #FFFFFF;
    --grid: var(--violet-200);
    --margin: var(--violet-600);
    --marker: var(--yellow-500);
    --marker-deep: var(--yellow-600);
    --violet: var(--violet-600);
    --sky: var(--violet-700);          /* الروابط والتركيز */
    --leaf: #12A474;                   /* دلالة «صحيح» فقط */
    --danger: #D41F5C;                 /* دلالة «خطأ» فقط */

    /* أسماء قديمة للتوافق */
    --primary: var(--ink);
    --primary-dark: var(--ink);
    --success: #0E7C58;
    --warning: #8A4B00;
    --text: var(--ink);
    --text-muted: var(--ink-soft);
    --border: #D2C4F3;
    --bg: var(--paper);
    --card-bg: var(--card);

    /* أزرار الإجابة الأربعة: بنفسجي داكن / بنفسجي فاتح / أصفر / لافندر */
    --k-red: var(--violet-700);
    --k-blue: #9333EA;
    --k-yellow: var(--yellow-500);
    --k-green: var(--violet-200);

    --r-sm: 12px;
    --r-md: 18px;
    --r-lg: 26px;
    --press: 0 4px 0 var(--ink);
    --font: "Cairo", "Tajawal", "Noto Sans Arabic", system-ui, "Segoe UI", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
[hidden] { display: none !important; }

body {
    font-family: var(--font);
    color: var(--ink);
    margin: 0;
    line-height: 1.7;
    background-color: var(--paper);
    background-image:
        radial-gradient(circle at 1px 1px, var(--violet-300) 1.2px, transparent 1.6px),
        radial-gradient(900px 420px at 85% -80px, rgba(255,210,63,.28), transparent 70%),
        radial-gradient(900px 520px at 5% -120px, rgba(124,58,237,.22), transparent 70%);
    background-size: 26px 26px, auto, auto;
    background-repeat: repeat, no-repeat, no-repeat;
    padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--sky); text-underline-offset: 3px; }
a, button, .topic-card, .choice-btn { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--violet-600); outline-offset: 3px; border-radius: 6px; }
.navbar :focus-visible, .footer :focus-visible, .consent-banner :focus-visible { outline-color: var(--marker); }

h1, h2, h3, h4 { line-height: 1.35; margin: 0 0 .5em; letter-spacing: 0; }
h2 { font-size: 1.7rem; }
h3 { font-size: 1.3rem; }

main { max-width: 1080px; margin: 0 auto; padding: 32px 20px 48px; position: relative; z-index: 1; }

/* ---------- الشريط العلوي ---------- */
.navbar {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 10px 28px; background: var(--violet-950);
    border-bottom: 4px solid var(--marker);
    position: sticky; top: 0; z-index: 10;
}
.brand {
    display: inline-flex; align-items: center; gap: 10px; min-height: 44px;
    font-weight: 800; font-size: 1.25rem; color: #fff; text-decoration: none;
}
.brand-mark {
    display: inline-grid; place-items: center; width: 36px; height: 36px;
    background: var(--marker); color: var(--ink); border: 2px solid var(--ink); border-radius: 11px;
    box-shadow: 0 3px 0 var(--violet-600); transform: rotate(-6deg);
    font-size: 1.35rem; font-weight: 800; line-height: 1; direction: ltr;
}
.navbar nav { display: flex; align-items: center; gap: 4px; }
.navbar nav a {
    margin: 0; padding: 8px 14px; min-height: 44px; display: inline-flex; align-items: center;
    text-decoration: none; color: #E9DEFF; font-weight: 600; border-radius: 999px;
}
.navbar nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.navbar nav a.btn-nav, .btn-nav {
    background: var(--marker); color: var(--ink) !important; border: 2px solid var(--ink);
    box-shadow: 0 3px 0 var(--violet-600); font-weight: 800; padding: 6px 18px; margin-inline-start: 6px;
}
.navbar nav a.btn-nav:hover { background: var(--marker); filter: brightness(1.04); }

/* ---------- الأزرار (ملموسة: تُضغط للأسفل) ---------- */
.btn-primary, .btn-secondary {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 48px; padding: 10px 28px; border-radius: 14px; text-decoration: none;
    font: inherit; font-weight: 800; font-size: 1.05rem; cursor: pointer;
    border: 2px solid var(--ink); box-shadow: var(--press);
    transition: transform .08s ease, box-shadow .08s ease;
}
.btn-primary { background: var(--marker); color: var(--ink); }
.btn-primary:hover { background: var(--yellow-400); }
.btn-secondary { background: var(--card); color: var(--violet-700); }
.btn-secondary:hover { background: var(--violet-100); }
.btn-primary:active, .btn-secondary:active, .btn-nav:active {
    transform: translateY(4px); box-shadow: 0 0 0 var(--ink);
}
.btn-primary.full { display: flex; width: 100%; margin-top: 8px; }
.btn-approve, .btn-reject {
    min-height: 44px; padding: 8px 16px; border: 2px solid var(--ink); border-radius: 12px;
    cursor: pointer; font: inherit; font-weight: 700; box-shadow: 0 3px 0 var(--ink);
}
.btn-approve { background: #BDF2DC; color: var(--ink); }
.btn-reject { background: #FFD3E0; color: var(--ink); }
.btn-approve:active, .btn-reject:active { transform: translateY(3px); box-shadow: none; }

/* ---------- البطاقات ---------- */
.feature-card, .plan-card, .child-card, .auth-form, .question-box, .contact-card, .legal {
    background: var(--card); border: 2px solid var(--ink); border-radius: var(--r-md);
}

/* ---------- الصفحة الرئيسية ---------- */
.hero {
    display: grid; grid-template-columns: 1.05fr .95fr; gap: 40px; align-items: center;
    padding: 36px 0 24px; text-align: start;
}
.hero h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); font-weight: 800; margin-bottom: 14px; }
.hero h1 .hl {
    background: linear-gradient(transparent 58%, var(--marker) 58%, var(--marker) 92%, transparent 92%);
    padding: 0 6px;
}
.tagline { font-size: 1.15rem; color: var(--ink-soft); margin: 0 0 26px; max-width: 34ch; }
.hero-note { margin: 14px 0 0; font-size: .95rem; color: var(--ink-soft); }

/* زخارف المجرّة: نجمة صفراء ودائرة بنفسجية خلف بطاقة العرض */
.hero > .demo-card { position: relative; }
.hero > .demo-card::before, .hero > .demo-card::after { content: ""; position: absolute; z-index: -1; pointer-events: none; }
.hero > .demo-card::before {
    width: 74px; height: 74px; top: -40px; inset-inline-end: -40px; background: var(--marker);
    clip-path: polygon(50% 0, 62% 36%, 100% 50%, 62% 64%, 50% 100%, 38% 64%, 0 50%, 38% 36%);
}
.hero > .demo-card::after {
    width: 96px; height: 96px; bottom: -62px; inset-inline-start: -56px; border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, var(--violet-500), var(--violet-800));
}
h2 { position: relative; }
.pricing h2::after, .dashboard-header h2::after {
    content: ""; display: block; width: 64px; height: 6px; border-radius: 6px; margin: 8px auto 0;
    background: linear-gradient(90deg, var(--violet-600) 60%, var(--marker) 60%);
}
.dashboard-header h2::after { margin-inline: 0; }

/* بطاقة «سؤال حيّ» في الصفحة الرئيسية */
.demo-card {
    background: var(--card); border: 2px solid var(--ink); border-radius: var(--r-lg);
    box-shadow: 6px 8px 0 var(--violet-600); padding: 18px; transform: rotate(-1.5deg);
}
.demo-head { display: flex; justify-content: space-between; font-weight: 700; font-size: .95rem; margin-bottom: 10px; }
.demo-head span:first-child { background: var(--violet-200); color: var(--violet-800); padding: 2px 12px; border-radius: 999px; }
.demo-timer { height: 14px; border-radius: 999px; background: var(--violet-100); border: 2px solid var(--ink); overflow: hidden; direction: ltr; margin-bottom: 14px; }
.demo-timer i { display: block; height: 100%; width: 68%; background: linear-gradient(90deg, var(--violet-600), var(--yellow-500)); border-radius: 999px; }
.demo-q {
    text-align: center; font-size: 2.2rem; font-weight: 800; padding: 14px 8px; margin-bottom: 12px;
    border-radius: var(--r-sm); border: 2px dashed var(--border); direction: ltr;
}
.demo-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.demo-choices b {
    display: flex; align-items: center; justify-content: center; min-height: 54px; border-radius: 12px;
    color: #fff; font-size: 1.35rem; box-shadow: 0 4px 0 rgba(0,0,0,.25); direction: ltr;
}
.demo-choices b:nth-child(1) { background: var(--k-red); }
.demo-choices b:nth-child(2) { background: var(--k-blue); }
.demo-choices b:nth-child(3) { background: var(--k-yellow); color: var(--ink); }
.demo-choices b:nth-child(4) { background: var(--k-green); color: var(--ink); }
.demo-choices b.ok { outline: 4px solid #fff; box-shadow: 0 0 0 7px var(--ink), 0 4px 0 rgba(0,0,0,.25); }
.demo-choices b.dim { opacity: .55; }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 22px; margin: 44px 0; }
.feature-card { padding: 24px; text-align: start; box-shadow: var(--press); }
.feature-card .icon {
    display: inline-grid; place-items: center; width: 56px; height: 56px; font-size: 1.7rem;
    border: 2px solid var(--ink); border-radius: 16px; margin-bottom: 12px;
}
.feature-card:nth-child(1) .icon { background: var(--violet-200); }
.feature-card:nth-child(2) .icon { background: var(--yellow-100); }
.feature-card:nth-child(3) .icon { background: var(--violet-300); }
.feature-card h3 { margin-bottom: 6px; }
.feature-card p { margin: 0; color: var(--ink-soft); }

.pricing { text-align: center; margin: 56px 0 24px; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 22px; margin-top: 24px; }
.plan-card { padding: 28px 20px; box-shadow: var(--press); }
.plan-card.trial { background: var(--yellow-50); box-shadow: 0 4px 0 var(--ink), 0 0 0 5px var(--yellow-500); }
.plan-card h3, .plan-card h4 { margin-bottom: 4px; }
.plan-card .price { font-size: 1.9rem; font-weight: 800; margin: 8px 0; }
.plan-card .price span { font-size: .95rem; color: var(--ink-soft); font-weight: 600; }
.plan-card p { margin: 6px 0; }
.plan-card .btn-secondary { margin-top: 10px; }

/* ---------- النماذج ---------- */
.auth-form { max-width: 440px; margin: 32px auto; padding: 32px; box-shadow: 6px 8px 0 var(--violet-600); }
.auth-form h2 { text-align: center; }
.auth-form .subtitle { text-align: center; color: var(--ink-soft); margin: -4px 0 20px; }
.auth-form input, .auth-form textarea, .auth-form select,
.add-child input, .add-child select {
    width: 100%; padding: 12px 14px; margin-bottom: 12px; min-height: 48px;
    border: 2px solid var(--border); border-radius: var(--r-sm); background: #fff;
    font: inherit; font-size: 16px; color: var(--ink);
}
.auth-form input:focus, .auth-form textarea:focus, .auth-form select:focus,
.add-child input:focus, .add-child select:focus { outline: none; border-color: var(--violet-600); box-shadow: 0 0 0 4px var(--violet-200); }
.auth-form .row { display: flex; gap: 10px; }
.auth-form .switch { text-align: center; margin: 16px 0 0; }
.error { color: var(--danger); text-align: center; font-weight: 700; }
.consent-note { font-size: .85rem; color: var(--ink-soft); margin: 8px 0 0; }

.banner { padding: 14px 18px; border-radius: var(--r-sm); margin-bottom: 20px; border: 2px solid var(--ink); font-weight: 600; }
.banner a { color: var(--ink); font-weight: 800; }
.banner-info { background: var(--violet-100); }
.banner-warning { background: var(--yellow-100); }
.banner-success { background: #CDF5E4; }

/* ---------- لوحة ولي الأمر ---------- */
.dashboard-header h2 { font-size: 2rem; }
.children-list > h3 { margin-top: 8px; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-top: 16px; }
.child-card { padding: 20px; text-align: start; box-shadow: var(--press); }
.child-card h4 { font-size: 1.2rem; margin: 0; }
.child-card p { margin: 2px 0; }
.child-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.child-head small { display: block; color: var(--ink-soft); font-weight: 600; }
.avatar {
    flex: none; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%;
    border: 2px solid var(--ink); font-size: 1.5rem; font-weight: 800; background: var(--marker);
}
.cards-grid > :nth-child(4n+2) .avatar { background: var(--violet-300); }
.cards-grid > :nth-child(4n+3) .avatar { background: var(--yellow-100); }
.cards-grid > :nth-child(4n+4) .avatar { background: var(--violet-200); }
.child-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 16px; }
.child-stats div { background: var(--paper); border: 2px solid var(--grid); border-radius: 12px; padding: 6px 4px; text-align: center; }
.child-stats strong { display: block; font-size: 1.2rem; line-height: 1.3; }
.child-stats span { font-size: .78rem; color: var(--ink-soft); font-weight: 600; }
.child-card .btn-secondary { width: 100%; background: var(--marker); }
.locked { color: var(--ink-soft); font-weight: 600; }

.add-child { margin-top: 28px; background: var(--card); border: 2px dashed var(--ink); border-radius: var(--r-md); padding: 6px 18px; }
.add-child summary { min-height: 48px; display: flex; align-items: center; cursor: pointer; font-weight: 800; }
.add-child form { display: flex; gap: 10px; margin: 8px 0 14px; flex-wrap: wrap; }
.add-child input, .add-child select { width: auto; flex: 1 1 180px; margin: 0; }

/* ---------- اختيار الموضوع ---------- */
.topic-card { cursor: pointer; text-align: center; transition: transform .12s ease, box-shadow .12s ease; padding: 22px 14px; }
.topic-card h4 { margin: 0; font-size: 1.1rem; }
.topic-card .icon {
    display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 10px;
    border: 2px solid var(--ink); border-radius: 50%; font-size: 1.9rem; background: var(--yellow-100);
}
.cards-grid > .topic-card:nth-child(4n+1) .icon { background: var(--violet-300); }
.cards-grid > .topic-card:nth-child(4n+2) .icon { background: var(--yellow-400); }
.cards-grid > .topic-card:nth-child(4n+3) .icon { background: var(--violet-200); }
.cards-grid > .topic-card:nth-child(4n+4) .icon { background: var(--yellow-100); }
.topic-card:hover { transform: translateY(-3px); box-shadow: 0 7px 0 var(--violet-600); border-color: var(--violet-700); }
.topic-card:active { transform: translateY(4px); box-shadow: 0 0 0 var(--ink); }

/* ---------- الجولة ---------- */
.quiz-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-weight: 800; margin-bottom: 14px; }
#quiz-topic-label { font-size: 1.1rem; }
.quiz-header #quiz-progress, .quiz-header #quiz-score {
    background: var(--violet-200); border: 2px solid var(--ink); padding: 2px 14px; border-radius: 999px; font-size: .95rem;
}
.quiz-header #quiz-score { background: var(--marker); }
.mute-btn {
    border: 2px solid var(--ink); background: var(--card); border-radius: 50%; width: 44px; height: 44px;
    font-size: 1.1rem; cursor: pointer; box-shadow: 0 3px 0 var(--ink);
}
.mute-btn:active { transform: translateY(3px); box-shadow: none; }

.timer-wrap { position: relative; height: 26px; background: var(--card); border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; margin-bottom: 16px; direction: ltr; }
.timer-bar { height: 100%; width: 100%; background: linear-gradient(90deg, var(--violet-600), var(--yellow-500)); border-radius: 999px; transition: width .1s linear; }
.timer-bar.danger { background: linear-gradient(90deg, #D41F5C, #FF6E96); }
.timer-num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--ink); font-size: .95rem; }
.timer-num.danger { animation: pulse .5s ease-in-out infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.25); } }

.question-box {
    padding: 28px 22px 18px; text-align: center; margin-bottom: 18px; box-shadow: var(--press);
    background-image: linear-gradient(var(--grid) 1px, transparent 1px); background-size: 100% 34px;
    border-top: 8px solid var(--violet-600);
}
#question-text { font-size: 1.8rem; font-weight: 800; margin: 0 0 8px; line-height: 1.9; }
.feedback { min-height: 1.7em; margin: 0; font-size: 1.1rem; font-weight: 700; }
.feedback-correct { color: var(--success); }
.feedback-wrong { color: var(--danger); }

.choices-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; max-width: 900px; margin: 0 auto; }
.choice-btn {
    display: flex; align-items: center; gap: 14px; min-height: 104px; padding: 14px 20px;
    border: 2px solid var(--ink); border-radius: var(--r-md); color: #fff; font: inherit; font-size: 1.5rem; font-weight: 800;
    cursor: pointer; text-align: start; box-shadow: 0 6px 0 var(--ink);
    transition: transform .1s, box-shadow .1s, opacity .2s, filter .2s;
}
.choice-btn .shape {
    flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
    background: rgba(255,255,255,.25); font-size: 1.2rem;
}
.choice-btn .label { flex: 1; text-align: center; word-break: break-word; }
.choice-c0 { background: var(--k-red); }
.choice-c1 { background: var(--k-blue); }
.choice-c2 { background: var(--k-yellow); color: var(--ink); }
.choice-c2 .shape { background: rgba(27,11,69,.15); }
.choice-c3 { background: var(--k-green); color: var(--ink); }
.choice-c3 .shape { background: rgba(27,11,69,.12); }
.choice-btn:hover:not(:disabled) { transform: translateY(-3px); filter: brightness(1.06); }
.choice-btn:active:not(:disabled) { transform: translateY(6px); box-shadow: 0 0 0 var(--ink); }
.choice-btn:disabled { cursor: default; }
.choice-btn.dimmed { opacity: .35; filter: grayscale(.4); }
.choice-btn.reveal-correct { outline: 5px solid #fff; box-shadow: 0 0 0 9px var(--leaf), 0 6px 0 var(--ink); animation: pop .4s ease; }
.choice-btn.reveal-wrong { opacity: 1; animation: shake .4s ease; }
@keyframes pop { 0% { transform: scale(1); } 50% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

#finish-btn { margin-top: 22px; min-height: 44px; font-size: .95rem; padding: 6px 20px; }

.level-badge {
    --lvl-color: #C9B4FB;
    display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 14px;
    margin: 10px auto 14px; padding: 8px 18px; max-width: 640px; font-weight: 700;
    border: 2px solid var(--ink); border-radius: 999px;
    background: color-mix(in srgb, var(--lvl-color) 22%, white);
    box-shadow: 0 3px 0 var(--ink);
}
.level-pips { color: var(--ink); letter-spacing: 2px; font-size: 1.1em; }
.level-next { font-size: .9em; color: var(--ink-soft); font-weight: 600; }
.level-badge.level-up { animation: lvlPop .9s ease; }
@keyframes lvlPop { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }

.fx-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; pointer-events: none; z-index: 50; }
.toast-area { position: fixed; bottom: calc(24px + env(safe-area-inset-bottom)); inset-inline: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 60; pointer-events: none; }
.toast { background: var(--violet-950); color: var(--marker); border: 2px solid var(--marker); padding: 12px 22px; border-radius: 999px; font-weight: 700; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 92vw; text-align: center; }

#result-area { text-align: center; background: var(--card); border: 2px solid var(--ink); border-radius: var(--r-lg); box-shadow: 6px 8px 0 var(--violet-600); padding: 32px 20px; max-width: 560px; margin: 16px auto; }
.result-stars { font-size: 3.4rem; letter-spacing: 8px; margin: 8px 0 16px; }
#result-summary { font-size: 1.1rem; }
#result-achievements { font-weight: 800; margin: 10px 0 18px; }

/* تعبيرات رياضية: دائماً LTR */
.math { direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.math.wrap { white-space: normal; }

/* ---------- التواصل والخصوصية ---------- */
.contact-card { max-width: 640px; margin: 32px auto; padding: 28px 20px; text-align: center; line-height: 2; box-shadow: 6px 8px 0 var(--violet-600); }
.contact-actions { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin: 24px 0; }
.contact-btn {
    display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 10px 24px;
    border-radius: 14px; border: 2px solid var(--ink); box-shadow: var(--press);
    color: #fff; text-decoration: none; font-weight: 800; font-size: 1.05rem;
}
.contact-btn.whatsapp { background: var(--violet-700); }
.contact-btn.facebook { background: var(--violet-600); }
.contact-btn.email { background: var(--ink); }
.contact-btn:active { transform: translateY(4px); box-shadow: none; }

.wa-float {
    position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); inset-inline-end: 20px; z-index: 900;
    background: var(--marker); color: var(--ink); text-decoration: none; font-weight: 800;
    padding: 10px 18px; min-height: 44px; display: inline-flex; align-items: center; gap: 6px;
    border: 2px solid var(--ink); border-radius: 999px; box-shadow: 0 4px 0 var(--violet-600);
}

.legal { max-width: 800px; margin: 32px auto; padding: 28px 24px; line-height: 2; }
.legal h2 { margin-top: 28px; font-size: 1.35rem; }
.legal .updated { color: var(--ink-soft); font-size: .9rem; }
.legal table { width: 100%; border-collapse: collapse; margin: 12px 0; display: block; overflow-x: auto; }
.legal th, .legal td { border: 1px solid var(--border); padding: 8px 10px; text-align: start; font-size: .92rem; }
.legal th { background: var(--violet-100); }

.consent-banner {
    position: fixed; bottom: 0; inset-inline: 0; z-index: 1000; background: var(--violet-950); color: #fff; border-top: 4px solid var(--marker);
    padding: 16px 24px calc(16px + env(safe-area-inset-bottom));
    display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
}
.consent-banner p { margin: 0; flex: 1 1 320px; }
.consent-banner a { color: var(--marker); }
.consent-actions { display: flex; gap: 10px; }

/* ---------- الدفع والإدارة ---------- */
.payment-instructions { background: var(--yellow-50); border: 2px solid var(--ink); border-radius: var(--r-sm); padding: 18px; margin-bottom: 20px; font-size: .95rem; }
.payment-instructions h3 { font-size: 1.1rem; }
.payment-instructions .note { color: var(--ink-soft); font-size: .85rem; }
.price-highlight { text-align: center; font-size: 1.6rem; font-weight: 800; margin: 0 0 16px; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 20px; border: 2px solid var(--ink); border-radius: var(--r-md); background: var(--card); }
.admin-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.admin-table th, .admin-table td { padding: 10px; text-align: center; font-size: .9rem; border-bottom: 1px solid var(--grid); }
.admin-table th { background: var(--violet-200); color: var(--violet-800); font-weight: 800; }
.admin-table tr:last-child td { border-bottom: 0; }

.footer { text-align: center; padding: 28px 20px; font-size: .92rem; position: relative; z-index: 1; border-top: 4px solid var(--marker); background: var(--violet-950); color: #CDBCF5; }
.footer a { color: #fff; }
.footer .btn-secondary { color: var(--violet-700); }
.footer p { margin: 4px 0; }
.footer a { display: inline-block; padding: 8px; }
.install-hint { font-size: .9rem; }

.offline-box { max-width: 420px; margin: 0 auto; padding: 56px 20px; text-align: center; }
.offline-icon { font-size: 3rem; margin: 0 0 8px; }

/* ---------- الهاتف واللمس ---------- */
@media (hover: none) {
    .topic-card:hover { transform: none; box-shadow: var(--press); }
    .choice-btn:hover:not(:disabled) { transform: none; filter: none; }
}

@media (max-width: 800px) {
    .hero { grid-template-columns: 1fr; gap: 28px; text-align: center; padding-top: 16px; }
    .tagline { margin-inline: auto; }
    .demo-card { max-width: 420px; margin: 0 auto; }
}

@media (max-width: 560px) {
    .navbar { position: static; flex-direction: column; gap: 2px; padding: 8px 12px; }
    .navbar nav { flex-wrap: wrap; justify-content: center; width: 100%; gap: 0 2px; }
    .navbar nav a { padding: 0 12px; white-space: nowrap; }
    .navbar nav a.btn-nav { min-height: 40px; }

    main { padding: 16px 12px 32px; }
    h2 { font-size: 1.45rem; }
    .auth-form { margin: 16px auto; padding: 22px 16px; box-shadow: 4px 6px 0 var(--ink); }
    .auth-form .row { flex-direction: column; gap: 0; }
    .add-child form > * { width: 100%; flex-basis: 100%; }

    .quiz-header { gap: 6px; flex-wrap: nowrap; }
    #quiz-topic-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1rem; }
    .quiz-header #quiz-progress, .quiz-header #quiz-score { font-size: .82rem; padding: 2px 10px; white-space: nowrap; }
    .mute-btn { width: 40px; height: 40px; flex: none; }
    .question-box { padding: 20px 14px 12px; }
    #question-text { font-size: 1.3rem; overflow-wrap: anywhere; }
    .choices-grid { grid-template-columns: 1fr; gap: 12px; }
    .choice-btn { min-height: 72px; padding: 10px 14px; font-size: 1.2rem; gap: 10px; box-shadow: 0 5px 0 var(--ink); }
    .choice-btn .shape { width: 34px; height: 34px; font-size: 1rem; }
    .level-badge { font-size: .9rem; padding: 6px 12px; }
    .result-stars { font-size: 2.6rem; letter-spacing: 4px; }

    .consent-banner { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); gap: 8px; }
    .consent-banner p { flex: 1 1 100%; font-size: .85rem; line-height: 1.5; }
    .consent-actions { width: 100%; }
    .consent-actions button { flex: 1; min-height: 44px; }

    .wa-float { padding: 8px 14px; font-size: .9rem; }
    .contact-btn { width: 100%; }

    /* صفحة اللعب: نخفي الشريط ونضغط الرأس لتظهر الاختيارات الأربعة دون تمرير */
    .play-page .navbar { display: none; }
    .play-page main { padding-top: 10px; padding-bottom: 12px; }
    .play-page .quiz-header { margin-bottom: 6px; }
    .play-page .timer-wrap { height: 22px; margin-bottom: 8px; }
    .play-page .level-badge { margin: 6px auto 8px; padding: 3px 10px; gap: 2px 10px; font-size: .85rem; box-shadow: none; }
    .play-page .level-next { font-size: .8rem; }
    .play-page .question-box { padding: 12px 12px 8px; margin-bottom: 10px; border-top-width: 6px; }
    .play-page #question-text { font-size: 1.2rem; line-height: 1.7; margin-bottom: 2px; }
    .play-page .feedback { font-size: 1rem; min-height: 1.4em; }
    .play-page .choices-grid { gap: 10px; }
    .play-page .choice-btn { min-height: 62px; padding: 6px 12px; }
    .play-page #finish-btn { margin-top: 14px; }
    .play-page .footer { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* v16: التصميم الجديد — زخارف بطاقة العرض على الصفحة الرئيسية كانت تخرج عن عرض الشاشة (≤ 320px) */
@media (max-width: 560px) {
    .hero { overflow-x: clip; }
    .hero > .demo-card::before { width: 56px; height: 56px; top: -30px; inset-inline-end: -6px; }
    .hero > .demo-card::after  { width: 72px; height: 72px; bottom: -44px; inset-inline-start: -6px; }
    .demo-card { box-shadow: 4px 6px 0 var(--violet-600); }
}

/* --- v17: استرجاع كلمة المرور وإدارة المستخدمين --- */
.notice { color: var(--violet-800); background: var(--violet-200); border: 2px solid var(--ink); border-radius: var(--r-md); padding: 10px 14px; text-align: center; font-weight: 700; }
.temp-password { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.5rem; font-weight: 800; letter-spacing: .08em; text-align: center; user-select: all; margin: 8px 0; }
.search-row { display: flex; gap: 10px; margin: 16px 0 0; }
.search-row input { flex: 1; padding: 10px 12px; border: 2px solid var(--ink); border-radius: var(--r-md); font: inherit; }

/* --- v18: موافقة التسجيل وصفحة الحساب --- */
.check-row { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0; font-size: .92rem; line-height: 1.6; cursor: pointer; }
.check-row input[type="checkbox"] { width: 20px; height: 20px; margin: 4px 0 0; flex: none; accent-color: var(--violet-600); }
.account-hub h3 { margin: 22px 0 6px; }
.account-hub .btn-secondary { text-align: center; text-decoration: none; }
.danger-link { color: var(--danger); border-color: var(--danger); }

/* ==========================================================================
   v20 — تصميم ناعم (مستوحى من تصميم Stitch): خلفية فاتحة، بطاقات بيضاء بظلال هادئة،
   أزرار بنفسجية. يغطي كل الصفحات عبر المكوّنات المشتركة. أزرار الإجابة في اللعبة لم تتغيّر.
   ========================================================================== */
:root { --press: 0 6px 18px rgba(91,33,182,.14); --soft: 0 6px 24px rgba(59,26,140,.08); --line: #E7DEFB; }
body { background-color: #F7F4FF; background-image:
    radial-gradient(900px 420px at 90% -100px, rgba(255,210,63,.18), transparent 70%),
    radial-gradient(900px 520px at 5% -140px, rgba(124,58,237,.14), transparent 70%); background-size: auto; }
.navbar { background: rgba(255,255,255,.93); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); box-shadow: 0 2px 14px rgba(59,26,140,.06); }
.brand { color: var(--violet-700); line-height: 1.15; }
.brand small { display: block; font-size: .68rem; font-weight: 600; color: var(--ink-soft); direction: ltr; text-align: start; }
.brand-mark { background: var(--violet-600); color: #fff; border: 0; box-shadow: none; transform: none; }
.navbar nav a { color: var(--ink-soft); }
.navbar nav a:hover { background: var(--violet-100); color: var(--violet-700); }
.navbar nav a.btn-nav, .btn-nav { background: var(--violet-600); color: #fff !important; border: 0; box-shadow: 0 4px 12px rgba(124,58,237,.35); }
.navbar nav a.btn-nav:hover { background: var(--violet-700); }

.btn-primary, .btn-secondary { border: 0; box-shadow: 0 6px 16px rgba(91,33,182,.22); transition: transform .15s, box-shadow .15s, background .15s; }
.btn-primary { background: var(--violet-600); color: #fff; }
.btn-primary:hover { background: var(--violet-700); transform: translateY(-1px); }
.btn-secondary { background: #fff; color: var(--violet-700); border: 1.5px solid var(--violet-300); box-shadow: none; }
.btn-secondary:hover { background: var(--violet-100); }
.btn-primary:active, .btn-secondary:active, .btn-nav:active { transform: translateY(1px); box-shadow: none; }
.btn-primary.btn-gold { background: var(--yellow-500); color: var(--ink); box-shadow: 0 6px 16px rgba(245,184,0,.35); }
.btn-primary.btn-gold:hover { background: var(--yellow-400); }
.child-card .btn-secondary { background: var(--violet-600); color: #fff; border: 0; }
.btn-approve, .btn-reject, .mute-btn { border-width: 1px; box-shadow: none; }

.feature-card, .plan-card, .child-card, .auth-form, .question-box, .contact-card, .legal {
    border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--soft); }
.question-box { border-top: 6px solid var(--violet-600); }
.auth-form { box-shadow: 0 14px 40px rgba(59,26,140,.12); }
.feature-card .icon, .avatar, .topic-card .icon { border: 0; }
.banner { border: 1px solid var(--line); }
.add-child { border: 2px dashed var(--violet-300); }
.topic-card:hover { box-shadow: 0 12px 28px rgba(91,33,182,.18); }

.hero-badge { display: inline-flex; background: var(--violet-100); color: var(--violet-700); font-weight: 700; font-size: .85rem; padding: 4px 14px; border-radius: 999px; margin-bottom: 14px; }
.hero h1 .hl { background: linear-gradient(90deg, var(--violet-600), #E5A800); -webkit-background-clip: text; background-clip: text; color: transparent; padding: 0; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.demo-card { border: 1px solid var(--line); box-shadow: 0 20px 50px rgba(59,26,140,.16); transform: none; }
.demo-timer { border: 0; height: 10px; }
.demo-choices b { box-shadow: none; border-radius: 14px; }
.demo-choices b.ok { outline: 0; box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--leaf); }

.section-head { text-align: center; margin: 56px 0 24px; }
.section-head h2 { margin-bottom: 6px; }
.section-head p { margin: 0; color: var(--ink-soft); }
.cta-banner { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; color: #fff;
    background: linear-gradient(135deg, var(--violet-700), var(--violet-600)); border-radius: 24px; padding: 28px 32px; margin: 40px 0; box-shadow: 0 14px 36px rgba(91,33,182,.3); }
.cta-banner h3 { margin: 0 0 4px; font-size: 1.4rem; }
.cta-banner p { margin: 0; opacity: .92; }
.levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.level-tile { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 18px 12px; text-align: center; text-decoration: none; color: var(--ink); font-weight: 800; box-shadow: var(--soft); transition: transform .15s, border-color .15s; }
.level-tile:hover { transform: translateY(-3px); border-color: var(--violet-500); }
.level-tile b { display: grid; place-items: center; width: 44px; height: 44px; margin: 0 auto 8px; border-radius: 50%; background: var(--violet-100); color: var(--violet-700); font-size: 1.2rem; }
.plan-card { position: relative; }
.plan-card.trial { background: #fff; border: 2px solid var(--yellow-500); }
.plan-card.featured { border: 2px solid var(--violet-600); box-shadow: 0 18px 44px rgba(91,33,182,.22); transform: translateY(-6px); }
.plan-card.featured .btn-secondary { background: var(--violet-600); color: #fff; border: 0; }
.plan-badge { position: absolute; top: -14px; left: 50%; transform: translateX(-50%); background: var(--violet-600); color: #fff; font-size: .8rem; font-weight: 800; padding: 3px 14px; border-radius: 999px; white-space: nowrap; }
.pay-note { text-align: center; color: var(--ink-soft); margin: 22px 0 0; font-size: .95rem; }
.faq { max-width: 760px; margin: 0 auto; display: grid; gap: 12px; }
.faq details { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 4px 18px; box-shadow: var(--soft); }
.faq summary { min-height: 52px; display: flex; align-items: center; cursor: pointer; font-weight: 800; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; margin-inline-start: auto; color: var(--violet-600); font-size: 1.5rem; }
.faq details[open] summary::after { content: "−"; }
.faq p { margin: 0 0 14px; color: var(--ink-soft); }
.final-cta { text-align: center; background: var(--yellow-50); border: 1px solid var(--yellow-400); border-radius: 28px; padding: 40px 20px; margin: 56px 0 8px; }
.final-cta h2 { margin-bottom: 8px; }
.final-cta p { color: var(--ink-soft); margin: 0 0 20px; }
@media (max-width: 720px) {
    .navbar { padding: 8px 12px; }
    .navbar nav a:not(.btn-nav) { padding: 8px 9px; }
    .hero { grid-template-columns: 1fr; }
    .cta-banner { justify-content: center; text-align: center; }
    .plan-card.featured { transform: none; }
}
.footer { background: #fff; border-top: 1px solid var(--line); color: var(--ink-soft); }
.footer a { color: var(--violet-700); }

/* ==========================================================================
   خطوط أصغر: الموقع 15px (بدل 16px)، لوحات الأدمين 13.5px، وصفحة اللعب تبقى 16px للأطفال.
   كل أحجام rem تتبع هذه القيم؛ تُبنى على :has() (يدعمها كروم/إيدج/سفاري/فايرفوكس الحديثة، ومن لا يدعمها يرى الحجم القديم).
   ========================================================================== */
html { font-size: 15px; }
html:has(body.admin-page) { font-size: 13.5px; }
html:has(body.play-page) { font-size: 16px; }

.admin-page main { padding-top: 22px; }
.admin-page h2 { font-size: 1.35rem; margin-bottom: .4em; }
.admin-page h2::after { height: 4px; margin-top: 6px; }
.admin-page .admin-table { min-width: 560px; }
.admin-page .admin-table th, .admin-page .admin-table td { padding: 7px 6px; font-size: .92rem; }
.admin-page .actions button, .admin-page td button, .admin-page td .btn-secondary {
    font-size: .85rem; padding: 4px 10px; min-height: 32px; border-radius: 8px; box-shadow: none; }
.admin-page .table-scroll { border: 1px solid var(--line); box-shadow: var(--soft); }
.admin-page input, .admin-page select { font-size: 14px; min-height: 36px; padding: 4px 10px; }

/* --- أيقونات التواصل: واتساب أخضر وفيسبوك أزرق (ألوان العلامتين الرسمية) --- */
.ico { width: 1.5em; height: 1.5em; flex: none; display: inline-block; vertical-align: middle; }
.ico-wa { fill: #25D366; }
.ico-fb { fill: #1877F2; }
.contact-btn.whatsapp, .contact-btn.facebook { background: #fff; color: var(--ink); gap: 10px; }
.contact-btn.whatsapp:hover, .contact-btn.facebook:hover { background: #f5f3ff; }
.wa-float { background: #fff; color: var(--ink); gap: 8px; }
.wa-float .ico { width: 1.7em; height: 1.7em; }

/* --- أزرار التواصل العائمة الصغيرة: واتساب أخضر + فيسبوك أزرق (أيقونة فقط) --- */
.float-contact {
    position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); inset-inline-end: 20px; z-index: 900;
    display: flex; align-items: center; gap: 10px;
}
.fc-btn {
    width: 44px; height: 44px; /* 44px هو الحد الأدنى المريح للمس على الهاتف */
    display: inline-flex; align-items: center; justify-content: center; border-radius: 50%;
    border: 2px solid var(--ink); box-shadow: 0 3px 0 var(--violet-600); text-decoration: none;
}
.fc-btn:active { transform: translateY(3px); box-shadow: none; }
.fc-btn .ico { width: 24px; height: 24px; fill: #fff; }
.fc-wa { background: #25D366; }
.fc-fb { background: #1877F2; }
@media (max-width: 640px) { .float-contact { inset-inline-end: 14px; gap: 8px; } }
