/* =========================================
   1. المتغيرات الجذرية (CSS Variables)
   ========================================= */
:root {
    --primary: #4a90e2;
    --primary-light: #ebf4ff;
    --primary-dark: #2c5282;
    --secondary: #6366f1;
    --accent: #ff8a5c;
    --success: #48bb78;
    --warning: #ed8936;
    --danger: #f56565;

    /* درجات الرمادي */
    --gray-50: #f7fafc;
    --gray-100: #edf2f7;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e0;
    --gray-400: #a0aec0;
    --gray-500: #718096;
    --gray-600: #4a5568;
    --gray-700: #2d3748;
    --gray-800: #1a202c;
    --gray-900: #171923;

    /* خلفيات ونصوص */
    --bg-main: var(--gray-50);
    --bg-card: #ffffff;
    --text-title: var(--gray-900);
    --text-body: var(--gray-700);
    --text-muted: var(--gray-500);

    /* تأثيرات الزجاج والظلال */
    --glass: rgba(255, 255, 255, 0.85);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.1);

    /* انحناءات الحواف */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 30px;

    --transition-base: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* تحسينات الوضع الليلي - إعادة الألوان الأصلية (أسود مزرق) */
body.dark-mode {
    --bg-main: #0b0f19;
    --bg-card: #161e2e;
    --text-title: #f8fafc;
    --text-body: #cbd5e0;
    --text-muted: #718096;
    --glass: rgba(17, 24, 39, 0.9);
    --gray-100: #1f2937;
    --gray-200: #374151;
}
/* تنسيق القائمة بالكامل */
.custom-lang-select {
    font-family: 'Cairo', sans-serif;
    transition: all 0.3s ease;
    /* ربط الخلفية والنص بالوضع الحالي */
    background-color: var(--gray-100, rgba(0,0,0,0.1)); 
    color: var(--text-title, inherit);
}

/* لون الخيارات عند فتح القائمة */
.custom-lang-select option {
    /* هنا الربط الذكي: سيأخذ لون الكارد الليلي في الليل ولون أبيض بالنهار */
    background-color: var(--bg-card, #ffffff); 
    color: var(--text-body, #000000);
    padding: 12px;
}

/* الخيار المختار - يظل أصفر دائماً لتمييزه */
.custom-lang-select option:checked {
    background-color: #facc15 !important;
    color: #0b0f19 !important; /* لون النص أسود ليظهر بوضوح فوق الأصفر */
}

/* التفاعل عند تمرير الماوس (Hover) */
.custom-lang-select option:hover {
    background-color: var(--gray-200, #f0f0f0);
}

/* تأثير الإطار عند التركيز */
.custom-lang-select:focus {
    border-color: #facc15;
    box-shadow: 0 0 8px rgba(250, 204, 21, 0.3);
}

/* [تحديث]: تصميم زر التبديل الجديد (أيقونة حرة تماماً) */
.theme-toggle {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    cursor: pointer;
    padding: 0;
    margin-left: 25px; /* المسافة عن زر ابدأ الآن */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
    outline: none;
}

.theme-toggle:hover {
    transform: scale(1.15);
}

#theme-icon {
    font-size: 1.6rem;
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    filter: drop-shadow(0 0 5px rgba(0,0,0,0.1));
}

/* ألوان الأيقونات عالية الجودة مع وهج ملون */
.fa-sun { 
    color: #ffce54; 
    filter: drop-shadow(0 0 8px rgba(255, 206, 84, 0.5)) !important;
}

.fa-moon { 
    color: #a29bfe; 
    filter: drop-shadow(0 0 8px rgba(162, 155, 254, 0.4)) !important;
}

/* أنيميشن الدوران والقفزة */
.rotate-pop { 
    transform: rotate(360deg) scale(1.3); 
}

/* ضمان عدم وجود حدود بيضاء في أي عنصر بالوضع الليلي */
body.dark-mode * {
    border-color: rgba(255, 255, 255, 0.05);
}


/* =========================================
   3. إعادة الضبط الشامل (Global Reset)
   ========================================= */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-body);
    font-family: 'Poppins', 'Cairo', sans-serif;
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color var(--transition-base);
}
/* =========================================
   4. الهيدر (Header & Navigation)
   ========================================= */
.top-header {
    background: var(--glass);
    backdrop-filter: blur(15px);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 2000;
    padding: 1rem 0;
    border-bottom: 1px solid var(--gray-200);
    transition: all var(--transition-base);
}
.viewer-header {
    max-width: 800px;
    margin: 0 auto 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 10;
}


.header-scrolled {
    padding: 0.6rem 0;
    box-shadow: var(--shadow-lg);
}

.header-container {
    max-width: 1300px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 1.5rem;
    font-weight: 900;
    cursor: pointer;
}

.logo-icon {
    font-size: 2rem;
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-links a {
    font-weight: 600;
    color: var(--text-body);
    font-size: 0.95rem;
    transition: var(--transition-base);
}

.nav-links a:hover, .nav-links a.active {
    color: var(--primary);
}

/* =========================================
   5. قسم الـ Hero (Hero Section)
   ========================================= */
.hero-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10rem 2rem 5rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero-content {
    max-width: 850px;
    z-index: 10;
}

.highlight-text {
    color: var(--primary);
    background: linear-gradient(to right, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-btns {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin-top: 2.5rem;
}

/* الأشكال العائمة في الخلفية */
.floating-elements .float-item {
    position: absolute;
    width: 50px;
    height: 50px;
    background: var(--bg-card);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    color: var(--primary);
    font-size: 1.5rem;
    animation: float 6s infinite ease-in-out;
}

.item-1 { top: 20%; left: 10%; }
.item-2 { bottom: 20%; right: 10%; animation-delay: 2s; }
.item-3 { top: 40%; right: 15%; animation-delay: 4s; }
/* =========================================
   6. شريط الإحصائيات (Stats Bar)
   ========================================= */
.stats-bar {
    max-width: 1100px;
    margin: -50px auto 50px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 2rem;
    position: relative;
    z-index: 100;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--gray-200);
}

.stat-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-item i {
    font-size: 2rem;
    color: var(--primary);
}

.stat-info strong {
    display: block;
    font-size: 1.4rem;
    color: var(--text-title);
}

/* =========================================
   7. منطقة الألعاب التفاعلية (Games Section)
   ========================================= */
.games-menu-box {
    margin-bottom: 4rem !important;
    transition: all 0.5s ease;
}

/* زر اللعبة عند التفعيل */
.game-tab-btn {
    position: relative;
    overflow: hidden;
}

.game-tab-btn.active-game {
    background: var(--primary) !important;
    color: white !important;
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(74, 144, 226, 0.4);
    border-color: var(--primary) !important;
}

/* تنسيق الكلمات داخل لعبة الترتيب */
.word-pill {
    display: inline-block;
    padding: 10px 20px;
    margin: 5px;
    background: var(--gray-100);
    border: 2px solid var(--gray-300);
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    user-select: none;
}

.word-pill:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

.word-pill.selected {
    opacity: 0.5;
    pointer-events: none;
}

/* منطقة النتيجة (Result Area) */
.drop-zone {
    min-height: 60px;
    padding: 15px;
    background: rgba(0,0,0,0.03);
    border-radius: 12px;
    border: 2px dashed var(--gray-300);
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

body.dark-mode .drop-zone {
    background: rgba(255,255,255,0.03);
}
/* =========================================
   8. مكتبة القصص (Story Grid & Cards)
   ========================================= */
.filter-container {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 3rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    border: 1px solid var(--gray-300);
    background: var(--bg-card);
    color: var(--text-body);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-btn.active, .filter-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 5px 15px rgba(74, 144, 226, 0.3);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2.5rem;
    padding: 2rem 0;
}
.grid {
    max-width: 1300px !important; /* يحافظ على حجم الكراسات الأصلي */
    margin: 0 auto !important;    /* يوسط الشبكة بالكامل */
}

/*===========================================================
                  تصميم الكراسة (Story Card) 
=============================================================*/

.story-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
}

.story-card:hover {
    transform: translateY(-12px);
    box-shadow: var(--shadow-xl);
}

.card-image-wrapper {
    position: relative;
    height: 200px;
    overflow: hidden;
}

.card-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
}

.story-card:hover .card-image-wrapper img {
    transform: scale(1.1);
}

.level-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: white;
    z-index: 2;
}

.badge-beginner { background: var(--success); }
.badge-intermediate { background: var(--warning); }
.badge-advanced { background: var(--danger); }

.card-content {
    padding: 1.5rem;
    flex-grow: 1;
}

.card-content h3 {
    margin-bottom: 0.8rem;
    font-size: 1.25rem;
    color: var(--text-title);
}

.card-content p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-100);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
/* =========================================
   9. الفوتر (Footer)
   ========================================= */
.main-footer {
    background: var(--gray-900);
    color: white;
    padding: 4rem 5% 2rem;
    margin-top: 5rem;
}

.footer-top-area {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 3rem;
    margin-bottom: 3rem;
}

.footer-brand .logo-area.light {
    color: white;
    margin-bottom: 1.5rem;
}

.link-group h3 {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    color: var(--primary);
}

.link-group ul {
    list-style: none;
}

.link-group ul li {
    margin-bottom: 0.8rem;
}

.link-group ul li a {
    color: #cbd5e0;
    text-decoration: none;
    transition: 0.3s;
}

.link-group ul li a:hover {
    color: white;
    padding-right: 5px;
}

.footer-bottom-strip {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.9rem;
    color: #a0aec0;
}

/* =========================================
   10. التجاوب مع الجوال (Responsive)
   ========================================= */
@media (max-width: 768px) {
    .nav-links {
        display: none; /* يمكن إضافة قائمة هامبرغر لاحقاً */
    }
    
    .hero-section h1 {
        font-size: 2.2rem;
    }
    
    .stats-bar {
        margin: -30px 15px 30px;
    }
    
    .grid {
        grid-template-columns: 1fr;
        padding: 1rem;
    }

    .game-nav-buttons {
        flex-direction: column;
    }

    .game-tab-btn {
        width: 100%;
    }
}

/* =========================================
   11. تأثيرات إضافية (Utility & Animations)
   ========================================= */
.adventure-btn-glow {
    background: var(--primary);
    color: white;
    padding: 0.8rem 1.8rem;
    border-radius: 50px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(74, 144, 226, 0.4);
    transition: 0.3s;
}

.adventure-btn-glow:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(74, 144, 226, 0.6);
}

.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-4 { margin-top: 1.5rem; }

/* تأثير النبض للأيقونات */
@keyframes pulse-icon {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}
.pulse-icon { animation: pulse-icon 2s infinite; }
/* =========================================
   12. نافذة القراءة والترجمة (Story Viewer)
   ========================================= */
.story-viewer-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-main);
    z-index: 3000;
    display: none; /* تظهر عبر JS */
    overflow-y: auto;
    padding: 2rem;
}

.viewer-header {
    max-width: 800px;
    margin: 0 auto 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--gray-200);
}

.content-container {
    max-width: 800px;
    margin: 0 auto;
}

/* تنسيق الجمل التفاعلية */
/* تنسيق الجمل التفاعلية داخل الفقرة */
.story-sentence {
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0 4px;
    border-radius: 4px;
    display: inline; /* لجعل الجمل تظهر بجانب بعضها كفقرة */
}

.story-sentence:hover {
    background-color: rgba(74, 144, 226, 0.15);
    color: var(--primary);
}

/* تنسيق صندوق القصة الطويلة */
.story-full-text-box {
    line-height: 2.3; /* مسافة مريحة للعين */
    font-size: 1.35rem;
    padding: 35px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    text-align: left;
    direction: ltr;
    font-family: 'Poppins', sans-serif;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-200);
}

body.dark-mode .story-full-text-box {
    border-color: var(--gray-700);
}


.sentence-box:hover {
    transform: translateX(-5px);
    background: var(--primary-light);
}

.en-text {
    display: block;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-title);
    margin-bottom: 8px;
    font-family: 'Poppins', sans-serif;
}

.ar-text {
    display: none; /* تظهر عند الضغط */
    font-size: 1.1rem;
    color: var(--secondary);
    font-weight: 600;
}

/* شريط التحكم (Control Bar) */
.story-controls {
    position: sticky;
    bottom: 20px;
    background: var(--glass);
    backdrop-filter: blur(10px);
    padding: 15px;
    border-radius: 50px;
    display: flex;
    gap: 15px;
    justify-content: center;
    box-shadow: var(--shadow-xl);
    width: fit-content;
    margin: 30px auto;
    border: 1px solid var(--gray-300);
}

.control-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: none;
    background: white;
    color: var(--primary);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: 0.3s;
}

.control-btn:hover {
    background: var(--primary);
    color: white;
}
/* =========================================
   13. نظام المحادثة الذكي (Chat Game UI)
   ========================================= */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 450px;
    background: var(--bg-card);
    border-radius: 15px;
    overflow: hidden;
    border: 1px solid var(--gray-200);
}

.chat-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    max-width: 80% ;
    padding: 12px 18px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    animation: fadeInUp 0.3s ease;
}

.bot-message {
    align-self: flex-start;
    background: var(--gray-100);
    color: var(--text-title);
    border-bottom-left-radius: 2px;
}

.user-message {
    align-self: flex-end;
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 2px;
}

.chat-input-area {
    padding: 15px;
    display: flex;
    gap: 10px;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
}

.chat-input-area input {
    flex-grow: 1;
    padding: 10px 15px;
    border-radius: 25px;
    border: 1px solid var(--gray-300);
    outline: none;
}

/* =========================================
   14. نظام الجوائز والنتائج (Result Overlays)
   ========================================= */
.quiz-result-card {
    text-align: center;
    padding: 30px;
    animation: zoomIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.result-score {
    font-size: 3rem;
    font-weight: 900;
    color: var(--primary);
    margin: 15px 0;
}

.star-rating {
    color: #f1c40f;
    font-size: 1.8rem;
    margin-bottom: 20px;
}

@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

/* =========================================
   15. تنسيقات شريط التمرير (Custom Scrollbar)
   ========================================= */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* =========================================
   16. تأثيرات الكراسات عند التحميل (Skeleton Loader)
   ========================================= */
.skeleton {
    background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
/* =========================================
   17. تأثيرات الأزرار المتقدمة (Button Feedbacks)
   ========================================= */
button:active {
    transform: scale(0.95);
}

.cta-primary-large {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 1.2rem 2.5rem;
    border-radius: 50px;
    border: none;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
    transition: all 0.3s ease;
}

.cta-outline-large {
    background: transparent;
    color: var(--text-title);
    padding: 1.2rem 2.5rem;
    border-radius: 50px;
    border: 2px solid var(--gray-300);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    margin-left: 1rem;
    transition: 0.3s;
}

/* =========================================
   18. نظام التنبيهات المنبثقة (Toast Notifications)
   ========================================= */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--bg-card);
    color: var(--text-title);
    padding: 15px 25px;
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    border-right: 5px solid var(--success);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 5000;
    animation: slideInRight 0.5s ease-out;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* =========================================
   19. تحسينات القراءة (Typography Focus)
   ========================================= */
.reading-mode-active .sentence-box {
    margin-bottom: 25px;
    padding: 25px;
}

.reading-mode-active .en-text {
    font-size: 1.5rem;
    line-height: 1.8;
}

/* =========================================
   20. خلفية الصفحة المتحركة (Mesh Gradient)
   ========================================= */
.main-page::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(at 0% 0%, rgba(74, 144, 226, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(99, 102, 241, 0.05) 0px, transparent 50%);
    z-index: -1;
    pointer-events: none;
}
/* --- تحديثات إيما الجديدة (تضاف للنهاية) --- */

/* 1. تمركز صندوق تحدي الترجمة */
.centered-game-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    text-align: center;
    min-height: 200px;
}

/* 2. ستايل الإدخال الموحد للألعاب */
.modern-input {
    width: 100%;
    max-width: 400px;
    padding: 15px;
    border-radius: 15px;
    border: 2px solid var(--primary-color);
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 1.1rem;
    text-align: center;
    margin: 20px 0;
}

/* 3. تأثير عداد الماراثون عند اقتراب الوقت */
.timer-warning {
    color: #e74c3c !important;
    animation: shake 0.5s infinite;
    font-weight: bold;
}

/* 4. أنيميشن الوميض الأخضر عند الفوز */
@keyframes success-glow {
    0% { box-shadow: 0 0 0px var(--success-color); }
    50% { box-shadow: 0 0 20px var(--success-color); }
    100% { box-shadow: 0 0 0px var(--success-color); }
}

.success-celebrate {
    animation: success-glow 0.8s ease-in-out;
    border-color: var(--success-color) !important;
}

/* 5. أيقونة الثيم (نصف الدائرة) */
#theme-icon {
    transition: transform 0.5s ease;
}
/* تنسيق أساسي لإظهار النافذة المنبثقة فوق كل شيء */
.story-viewer-modal {
    display: none; 
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 99999; /* رقم كبير جداً لضمان ظهوره فوق الهيدر والبطاقات */
    overflow-y: auto;
}

.viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
}
/* تأثير عند وضع الماوس (Hover) */
.nav-links li a:hover {
    color: #ffce54 !important; /* اللون الأصفر */
    text-shadow: 0 0 10px rgba(255, 206, 84, 0.6);
}

/* الكلاس الذي سيتم إضافته عند الضغط (Active) */
.nav-links li a.clicked-active {
    color: #ffce54 !important;
    font-weight: bold;
    border-bottom: 2px solid #ffce54; /* خط سفلي بسيط للإشارة */
    text-shadow: 0 0 15px rgba(255, 206, 84, 0.8);
}

/* لإضافة توهج للأيقونة أيضاً */
.nav-links li a:hover i,
.nav-links li a.clicked-active i {
    color: #ffce54;
    filter: drop-shadow(0 0 5px rgba(255, 206, 84, 0.5));
}
/* تأثيرات زر "كيف نتعلم" الاحترافية */
.cta-outline-large {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 30px;
    border: 2px solid #7ba2bf; /* لون الحدود الأصلي */
    background: transparent;
    color: white;
    border-radius: 50px;
    font-family: 'Cairo', sans-serif;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* أنيميشن مرن وسلس */
    position: relative;
    overflow: hidden;
}

/* تأثيرات زر "كيف نتعلم" الاحترافية - النسخة المتوافقة مع الوضعين */
.cta-outline-large {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 30px;
    border: 2px solid #7ba2bf;
    background: transparent;
    
    /* التعديل هنا: استخدام متغير اللون الأساسي للنص في موقعك */
    /* إذا لم يكن لديك متغير، استخدم currentColor ليتبع لون النص في الهيرو */
    color: inherit; 
    
    border-radius: 50px;
    font-family: 'Cairo', sans-serif;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}
/* 1. التنسيق الأساسي (نهاري/ليلي) */
.cta-outline-large {
    padding: 12px 30px;
    border-radius: 50px;
    background-color: transparent !important; /* شفاف في الحالة العادية */
    border: 2px solid #7ba2bf;
    color: #161e2e;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* النص أبيض في الليل قبل الهوفر */
body.dark-mode .cta-outline-large {
    color: white !important;
}

/* 2. الحل النهائي: إجبار التلون بالأصفر عند الهوفر في الوضعين */
/* وضعنا body.dark-mode هنا لنلغي أي كود ليلي يمنع اللون الأصفر */
.cta-outline-large:hover,
body.dark-mode .cta-outline-large:hover {
    transform: scale(1.1);
    background-color: #ffce54 !important; /* صبغ جسم الزر بالأصفر */
    background: #ffce54 !important;      /* تأكيد إضافي للمتصفح */
    border-color: #ffce54 !important;
    color: #161e2e !important;           /* النص غامق فوق الأصفر */
    box-shadow: 0 0 25px rgba(255, 206, 84, 0.7);
}

/* الأيقونة عند الهوفر */
.cta-outline-large:hover i,
body.dark-mode .cta-outline-large:hover i {
    color: #161e2e !important;
    transform: rotate(360deg);
}

.cta-outline-large:active {
    transform: scale(0.95);
}

/* تأكد من أن الحاوية تعطي مساحة كافية وتتوسط الصفحة */
#how-it-works .container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center; /* توسيط المحتوى داخلياً */
}

/* شبكة الخطوات: التوزيع من المنتصف */
.steps-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center; /* هذا هو السر في وضع البطاقات بالوسط */
    gap: 25px;
    margin-top: 40px;
    width: 100%;
}
.step-card {
    background: var(--bg-card, #ffffff); 
    padding: 30px;
    border-radius: 20px;
    width: 100%;
    max-width: 350px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    transition: all 0.4s ease;
    border: 1px solid rgba(123, 162, 191, 0.1);
    overflow: hidden;
    /* لجعل البطاقة حاوية للطبقات */
    z-index: 1; 
}

/* التوهج الأصفر عند وضع الماوس */
.step-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 0 30px rgba(255, 206, 84, 0.3); 
    border-color: #ffce54;
}

/* رفع النصوص للطبقة الأمامية */
.step-card h3, .step-card p {
    color: var(--text-title, #1a202c);
    position: relative;
    z-index: 2; /* أعلى من الرقم */
}

.step-card p {
    color: var(--text-body, #718096);
    font-size: 0.95rem;
}

/* الرقم في مكانه المعتاد لكن في طبقة خلفية */
.step-num {
    font-size: 2.8rem;
    font-weight: 900;
    color: #ffce54;
    opacity: 0.15;
    position: absolute;
    top: 10px;
    right: 15px;
    transition: 0.3s;
    
    /* السر هنا */
    z-index: 0; 
    pointer-events: none; /* لا يعترض الماوس */
}

.step-card:hover .step-num {
    opacity: 0.6;
    transform: scale(1.1);
}
/* أنيميشن النبض للإطار المقطع */
@keyframes border-pulse {
    0% { border-color: #7ba2bf; box-shadow: 0 0 5px rgba(123, 162, 191, 0.2); }
    50% { border-color: #ffce54; box-shadow: 0 0 15px rgba(255, 206, 84, 0.3); }
    100% { border-color: #7ba2bf; box-shadow: 0 0 5px rgba(123, 162, 191, 0.2); }
}
.games-menu-box h4 {
    text-shadow: 0 0 10px rgba(123, 162, 191, 0.2);
    letter-spacing: 1px;
}
/* 1. تنسيق النص المشع الأصفر (طور مهاراتك) */
.game-hint {
    color: #ffce54 !important; /* لون أصفر */
    font-weight: bold;
    text-align: center;
    margin-bottom: 25px;
    text-shadow: 0 0 10px rgba(255, 206, 84, 0.6); 
    animation: glow-text 2s infinite alternate;
}

@keyframes glow-text {
    from { opacity: 0.8; text-shadow: 0 0 5px rgba(255, 206, 84, 0.4); }
    to { opacity: 1; text-shadow: 0 0 15px rgba(255, 206, 84, 0.9); }
}

/* 2. تحديث أزرار الألعاب (الحالة العادية) */
.game-tab-btn {
    background: rgba(123, 162, 191, 0.1); 
    border: 2px solid #7ba2bf;
    color: var(--text-title, #2d3748);
    padding: 12px 20px;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    text-decoration: none;
}

/* 3. حركة الأزرار عند وضع الماوس (Hover) */
.game-tab-btn:hover {
    transform: translateY(-8px); /* الزر يصعد للأعلى */
    background: #4a90e2 !important; /* يتحول للأزرق */
    color: white !important; /* النص يصير أبيض */
    border-color: #4a90e2;
    box-shadow: 0 10px 25px rgba(74, 144, 226, 0.5); /* توهج أزرق */
}

/* تحريك الأيقونة داخل الزر عند اللمس */
.game-tab-btn:hover i {
    transform: scale(1.2) rotate(10deg);
}
/* أنيميشن النبض للوقت الحرج */
.timer-pulse {
    animation: pulse-red 0.5s infinite alternate;
}

@keyframes pulse-red {
    from { transform: scale(1); text-shadow: 0 0 5px rgba(255, 77, 77, 0.5); }
    to { transform: scale(1.2); text-shadow: 0 0 15px rgba(255, 77, 77, 0.8); }
}

/* أنيميشن الاهتزاز عند الخسارة */
@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}
/* ضمان توسيع منطقة اللعب */
#quiz-area {
    width: 100%;
    min-width: 320px; /* للـ mobile */
    max-width: 800px; /* أقصى عرض مريح للعين */
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* إصلاح بنك الكلمات ومنطقة الإسقاط */
.drop-zone, #word-bank {
    width: 100% !important; /* تأكيد أخذ العرض الكامل */
    min-height: 80px;
}
/* توسيع منطقة اللعب ومنع انكماشها */
#quiz-area {
    width: 100% !important;
    min-height: 200px; /* يعطي مساحة كافية للكلمات */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    transition: all 0.5s ease;
    margin-top: 20px;
}

/* لضمان أن بنك الكلمات ومنطقة الإسقاط لا يتقلصان */
.drop-zone, #word-bank {
    width: 90% !important; /* لترك مسافة بسيطة عن الحواف */
    max-width: 700px;
    margin: 10px auto;
}
#quiz-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100% !important;
    min-width: 300px;
}

.word-pill {
    transition: all 0.3s ease;
    border: 2px solid #7ba2bf;
    padding: 10px 15px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    color: white;
}
/* تنسيق الكلمات في الوضع النهاري */
.word-pill {
    color: #1a1a1a !important; /* لون نص غامق جداً للرؤية الواضحة */
    background: #ffffff;
    border: 2px solid #4a90e2;
    transition: all 0.3s ease; /* لتكون الحركة ناعمة */
    font-weight: bold;
}

/* تأثير الإضاءة عند وضع الماوس (Hover) */
/* تنسيق الكلمات الأساسي */
.word-pill {
    color: #1a1a1a !important; 
    background: #ffffff;
    border: 2px solid #4a90e2;
    transition: background 0.3s ease, box-shadow 0.3s ease; /* أزلنا الـ transform لمنع الاهتزاز */
    font-weight: bold;
    display: inline-block;
}

/* تأثير الإضاءة عند وضع الماوس بدون اهتزاز */
.word-pill:hover {
    background: #4a90e2 !important;
    color: #ffffff !important; /* النص يصبح أبيض عند التأشير */
    box-shadow: 0 0 15px rgba(74, 144, 226, 0.5);
    transform: none !important; /* نمنع أي حركة أو اهتزاز */
}

/* زر "حاول مجدداً" وزر "التحقق" - نثبت لون النص أبيض */
.btn-fixed-text:hover {
    color: #ffffff !important; /* إجبار النص على البقاء أبيض */
    background: #2ecc71 !important; /* لون أخضر أو أزرق حسب رغبتك */
}

/* في الوضع الليلي */
body.dark-mode .word-pill {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.1);
    border-color: #7ba2bf;
}

body.dark-mode .sentence-box {
    color: #ffce54 !important;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}/* منطقة وضع الكلمات (الحل) */
#drop-zone {
    min-height: 120px !important; /* ارتفاع كافٍ لسطرين من الكلمات */
    height: auto;
    display: flex;
    align-content: flex-start; /* لتبدأ الكلمات من الأعلى دائماً */
    background: rgba(74, 144, 226, 0.05);
    transition: none !important; /* منع أي اهتزاز أثناء النقل */
}

/* بنك الكلمات (المكان السفلي) */
#word-bank {
    min-height: 150px !important; /* ارتفاع ثابت يضمن عدم تقلص الحاوية */
    display: flex;
    align-content: flex-start;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 15px;
    padding: 20px;
}

/* تأمين الكلمات نفسها */
.word-pill {
    flex-shrink: 0; /* منع الكلمات من الانضغاط */
    margin: 5px;
}
/* الألوان في الوضع النهاري */
:root {
    --emma-main-bg: rgba(255, 255, 255, 0.8); /* خلفية فاتحة */
    --emma-text: #333333; /* نص غامق */
    --emma-chat-inner: rgba(0, 0, 0, 0.05); /* إطار الشات الداخلي */
}

/* الألوان في الوضع الليلي */
[data-theme='dark'] { /* أو الكلاس اللي تستخدمه للوضع الليلي */
    --emma-main-bg: rgba(30, 39, 46, 0.9); /* خلفية غامقة */
    --emma-text: #ffffff; /* نص أبيض */
    --emma-chat-inner: rgba(255, 255, 255, 0.05);
}
.timer-pulse {
    animation: timerPulse 0.5s infinite alternate;
}
@keyframes timerPulse {
    from { transform: scale(1); }
    to { transform: scale(1.15); }
}
@keyframes successPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.success-celebrate {
    animation: successPulse 0.4s ease-in-out;
}
/* توسيط عنوان المكتبة والخط اللي تحته والوصف */
.library-title {
    text-align: center !important;
    margin-top: 30px !important;
    margin-bottom: 10px !important;
    font-size: 2.2rem !important; /* تكبير العنوان */
    color: var(--game-text-main) !important;
}

.underline {
    margin: 0 auto 20px auto !important; /* هذا السطر هو اللي يوسط الخط */
    width: 80px !important; /* طول الخط */
    height: 4px !important;
    background: #4a90e2 !important; /* لون الخط */
    border-radius: 2px !important;
}

.library-title + .underline + p {
    text-align: center !important;
    margin-bottom: 25px !important;
    color: var(--game-text-main) !important;
    opacity: 0.8;
    font-size: 1.1rem !important;
}

/* التأكد من أن شريط البحث يتبعهم في الوسط */
#story-search {
    display: block !important;
    margin: 0 auto 40px auto !important;
    width: 90% !important;
    max-width: 500px !important;
    padding: 15px 25px !important;
    border-radius: 30px !important;
    border: 2px solid #7ba2bf !important;
    text-align: center !important; /* جعل نص الكتابة يبدأ من الوسط */
}
.clickable-sentence {
    display: inline;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 4px;
    padding: 2px 4px;
}

.clickable-sentence:hover {
    background: rgba(74, 144, 226, 0.2); /* لون أزرق خفيف خلف السطر */
    box-shadow: 0 0 10px rgba(74, 144, 226, 0.5); /* توهج أزرق */
    color: #fff; /* تفتيح لون الخط */
}
.clickable-sentence {
    display: inline;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 4px;
    padding: 2px 4px;
    color: #eee;
}

/* حالة التوهج أثناء القراءة */
.active-reading {
    background: rgba(46, 204, 113, 0.3) !important; /* لون أخضر خفيف */
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.6);
    color: #fff !important;
    transform: scale(1.02);
    display: inline-block;
}
.active-reading {
    background: rgba(46, 204, 113, 0.4) !important; /* أخضر مضيء */
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.7);
    color: #fff !important;
    border-radius: 4px;
    transition: all 0.2s ease;
}
/* تنسيق الأزرار العلوية */
.nav-btn {
    padding: 8px 18px;
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.nav-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.2);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

/* تأثير الإضاءة عند القراءة (Highlight) - لون سماءي بدون خط */
.active-reading {
    background: rgba(52, 152, 219, 0.25) !important;
    color: #fff !important;
    box-shadow: 0 0 20px rgba(52, 152, 219, 0.5);
    border-radius: 4px;
    padding: 2px 6px;
    transition: all 0.3s ease;
    /* تم حذف الخط الجانبي من هنا */
}


/* تأثير احترافي عند مرور الماوس (Hover) يدعم الوضعين */
.clickable-sentence:hover {
    cursor: pointer;
    /* خلفية سماءية شفافة تتناسب مع أي خلفية تحتها */
    background: rgba(52, 152, 219, 0.15) !important;
    
    /* جعل لون النص أبيض في الوضع الليلي وواضح في النهاري */
    color: var(--text-title) !important; 
    
    /* توهج سماءي ناعم */
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.3);
    
    /* حواف ناعمة تمنع الشكل "المقطوم" */
    border-radius: 6px;
    padding: 2px 8px;
    
    /* سرعة استجابة سريعة للموس */
    transition: all 0.2s ease-in-out;
}

/* تنسيق شريط التمرير الاحترافي للمودال */
.story-viewer-modal::-webkit-scrollbar {
    width: 10px; /* عرض الشريط */
}

.story-viewer-modal::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02); /* لون المسار خلف الشريط */
    border-radius: 10px;
}

.story-viewer-modal::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #4a90e2, #2ecc71); /* لون متدرج للشريط */
    border-radius: 10px;
    border: 2px solid #1a1a2e; /* يعطي مسافة جمالية حول الشريط */
}

.story-viewer-modal::-webkit-scrollbar-thumb:hover {
    background: #4a90e2; /* لون أفتح عند وضع الماوس */
    box-shadow: 0 0 10px #4a90e2; /* تأثير توهج */
}

/* تحسين شكل صندوق العبرة (The Moral) */
.moral-box {
    margin-top: 40px;
    padding: 25px;
    background: rgba(74, 144, 226, 0.08); /* خلفية زرقاء خفيفة جداً */
    border-right: 4px solid #2ecc71; /* خط جانبي أخضر بدلاً من الأزرق ليعطي تباين */
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.moral-box h4 {
    color: #2ecc71;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 15px;
    font-size: 1rem;
}

.moral-box p {
    font-style: italic;
    color: #eee !important;
    font-size: 1.1rem;
    line-height: 1.6;
}
#main-grid {
    display: grid;
    /* تأكد من إضافة padding يمين ويسار */
    padding: 20px 50px; 
    /* الفراغ بين البطاقات */
    gap: 30px; 
    /* عشان تضمن إنها في النص */
    justify-content: center; 
    max-width: 1200px;
    margin: 0 auto;
}


/*
.adventure-btn-glow {
    background: linear-gradient(45deg, #4a90e2, #9013fe); 
    color: white;
    padding: 12px 35px;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease; 
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.3); 
    display: flex;
    align-items: center;
    gap: 10px; 
}

.adventure-btn-glow:hover {
    transform: translateY(-3px); 
    box-shadow: 0 8px 25px rgba(144, 19, 254, 0.5); 
    filter: brightness(1.1); 
}
*/



/* التأثير عند الضغط */
.adventure-btn-glow:active {
    transform: scale(0.95); /* يصغر قليلاً عند الضغط */
}
/* 1. التحكم في عرض شريط التمرير ككل */
::-webkit-scrollbar {
    width: 10px; /* جعل الشريط نحيفاً وأنيقاً */
}

/* 2. خلفية المسار الذي يمشي فيه الشريط */
::-webkit-scrollbar-track {
    background: #1a1a2e; /* نفس لون خلفية موقعك لكي يختفي تقريباً */
}
/* 3. الجزء المتحرك الذي تمسكه بالماوس (المقبض) */
::-webkit-scrollbar-thumb {
    /* تم استبدال التدرج الأزرق بلون بنفسجي ثابت وجميل */
    background: #9b59b6; 
    border-radius: 10px; /* جعل الحواف دائرية تماماً */
    /* الحافة تجعله يبدو منفصلاً عن المسار بشكل أنيق */
    border: 2px solid #1a1a2e; 
}

/* 4. تغيير اللون عند مرور الماوس عليه */
::-webkit-scrollbar-thumb:hover {
    /* يصبح البنفسجي أفتح قليلاً عند وضع الماوس ليعطي إيحاء بالتفاعل */
    background: #af7ac5; 
}

/* 5. عند الضغط المطول على السكرولر */
::-webkit-scrollbar-thumb:active {
    /* يصبح أغمق قليلاً عند السحب ليعطيك شعوراً بالتحكم */
    background: #8e44ad;
}

/* تحسينات الوضع النهاري (Light Mode) */
body.light-mode {
    --bg-main: #f0f2f5;      /* خلفية الصفحة فاتحة */
    --bg-card: #ffffff;      /* خلفية البطاقة والنافذة بيضاء صافية */
    --text-title: #1e293b;   /* نصوص العناوين غامقة جداً */
    --text-body: #334155;    /* نصوص المحتوى رمادي غامق مريح */
    --text-muted: #64748b;   /* نصوص ثانوية هادئة */
}

/* 1. تنسيق الوضع النهاري الشامل للنافذة والهيدر */
body.light-mode .viewer-container {
    background-color: #ffffff !important; /* خلفية بيضاء للقصة */
    border: 1px solid #ddd !important;
    box-shadow: 0 20px 50px rgba(0,0,0,0.1) !important;
}

body.light-mode .viewer-header {
    background-color: #ffffff !important;
    border-bottom: 1px solid #eee !important;
}

body.light-mode .viewer-header h2 {
    color: #1e293b !important; /* عنوان القصة أسود */
}

body.light-mode .story-body {
    color: #334155 !important; /* نص القصة غامق للوضوح */
}

body.light-mode .moral-section {
    background: #f8fafc !important; /* صندوق العبرة رمادي فاتح */
    color: #1e293b !important;
}

/* 2. كود تحريك الزر (وزنه مع البحث) */
#filter-btn {
    margin-top: -40px; /* هذا الرقم يرفعه لفوق، غيره حتى يضبط معك تماماً */
}

/* 3. الهيدر واللوغو في الوضع النهاري */
body.light-mode .top-header { 
    background: #ffffff !important; 
    border-bottom: 1px solid #eee; 
}

body.light-mode .nav-links a, 
body.light-mode .logo-area { 
    color: #1e293b !important; 
}
/* تأثير الزر الكبير */
.cta-primary-large {
    /* أساسيات الزر */
    padding: 15px 35px;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 50px;
    border: none;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    
    /* أهم سطر للأنيميشن: يجعل أي تغيير يحدث بنعومة */
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ماذا يحدث عندما يمر الماوس (Hover) */
.cta-primary-large:hover {
    transform: scale(1.1) translateY(-3px); /* يكبر ويرتفع قليلاً للأعلى */
    box-shadow: 0 15px 25px rgba(37, 99, 235, 0.4); /* ظل أزرق ناعم */
    filter: brightness(1.1); /* تفتيح بسيط للون */
}

/* حركة السهم عند الحوم */
.cta-primary-large:hover i {
    transform: translateX(-5px); /* السهم يتحرك لليسار قليلاً */
    transition: 0.3s;
}

/* تأثير الضغطة (عند النقر) */
.cta-primary-large:active {
    transform: scale(0.95); /* يصغر قليلاً ليعطي إيحاء بالضغط */
}
.timer-pulse {
    animation: pulse-red 0.5s infinite;
}

@keyframes pulse-red {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); text-shadow: 0 0 10px rgba(255, 71, 87, 0.7); }
    100% { transform: scale(1); }
}
/* تنسيق نص القصة والقاموس للوضع النهاري - أسود فاحم */
.story-text-fix, 
.force-color, 
#modal-content, 
.clickable-sentence {
    color: #000000 !important; /* أسود صريح */
    opacity: 1 !important;
}

/* تنسيق معاني الكلمات العربية في الوضع النهاري */
.word-card .force-color {
    color: #1a1a1a !important; /* أسود غامق جداً */
}

/* --- الوضع الليلي (Dark Mode) --- */
/* إذا كان موقعك يستخدم كلاس dark أو dark-mode في الـ body */
body.dark .story-text-fix,
body.dark .force-color,
body.dark #modal-content,
body.dark .clickable-sentence,
body.dark-mode .story-text-fix,
body.dark-mode .force-color,
body.dark-mode #modal-content,
body.dark-mode .clickable-sentence {
    color: #ffffff !important; /* أبيض ناصع */
}
.control-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.3rem;
    padding: 8px;
    transition: 0.3s;
    color: #4a90e2; 
    
    /* التعديلات الجديدة */
    position: relative;
    top: -5px;          /* صعدناه فوق شوي (كل ما زاد الرقم بالسالب صعد أكثر) */
    margin-right: 15px; /* بعدناه عن العناصر اللي على يمينه */
    margin-left: 15px;  /* بعدناه عن العناصر اللي على يساره */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* في الوضع النهاري (Light Mode) */
body.light-mode .control-btn {
    color: #2563eb;
}
.control-btn:active i {
    transform: scale(0.9); /* تأثير ضغطة بسيطة عند النقر بالماوس */
}
/* الحاوية الأساسية للرسائل */
#toast-box-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 10000;
    display: flex;
    flex-direction: column-reverse; 
    align-items: flex-end;
    gap: 12px;
}

/* التنسيق المشترك للرسالة */
.custom-toast-msg {
    padding: 12px 20px;
    border-radius: 12px; /* زوايا أنعم */
    font-size: 0.95rem;
    min-width: 250px;
    font-weight: 500;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    border-right: 6px solid; /* الخط الجانبي */
    transition: all 0.3s ease;
    animation: slideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* --- الوضع الليلي (Dark Mode) --- */
body.dark-mode .custom-toast-msg, 
body.dark .custom-toast-msg {
    background: #1e293b; /* كحلي غامق جداً */
    color: #f8fafc;
    border-right-color: #38bdf8; /* أزرق سماوي مضيء */
    box-shadow: 0 4px 15px rgba(56, 189, 248, 0.2); /* توهج أزرق خفيف */
}

/* --- الوضع النهاري (Light Mode) --- */
body.light-mode .custom-toast-msg {
    background: #ffffff;
    color: #1e293b;
    border-right-color: #2563eb; /* أزرق صريح */
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.1);
}

/* أنيميشن الدخول والخروج */
@keyframes slideIn {
    from { 
        transform: translateX(120%) scale(0.9); 
        opacity: 0; 
    }
    to { 
        transform: translateX(0) scale(1); 
        opacity: 1; 
    }
}

@keyframes fadeOut {
    to { 
        opacity: 0; 
        transform: scale(0.8) translateX(20px); 
    }
}

/* لمسة تفاعلية للزر */
.control-btn:active i {
    transform: scale(0.8);
    transition: 0.1s;
}
/* منع النسخ في جميع محتويات الكروت */
.story-card, 
.story-card * {
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    -webkit-user-drag: none !important; /* يمنع سحب الصور والنصوص أيضاً */
}

/* منع النسخ في نافذة القصة بالكامل (العنوان، اللفل، المتن، المورال) */
.story-viewer-modal,
.viewer-container,
.viewer-container * {
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

/* إذا أردت منع النسخ في كامل الموقع (اختياري لكنه الأضمن) */
body {
    -webkit-touch-callout: none; /* يمنع القائمة المنبثقة في الموبايل */
}
/* 1. منع النسخ في قسم المختبر التعليمي التفاعلي بالكامل */
.interactive-lab, 
.interactive-lab *, 
.lab-section, 
.lab-section * {
    user-select: none !important;
    -webkit-user-select: none !important;
}

/* 2. منع النسخ في عنوان "مكتبة القصص الذكية" والوصف اللي تحته */
.library-header, 
.library-header h2, 
.library-header p {
    user-select: none !important;
    -webkit-user-select: none !important;
}

/* 3. منع النسخ في أزرار الألعاب (ترتيب الجمل، تحدي الترجمة، إلخ) */
.lab-btn, 
.lab-btn span, 
.lab-btn i {
    user-select: none !important;
    -webkit-user-select: none !important;
}

/* 4. كود احتياطي وشامل لأي نص داخل الموقع ما تبيه يتحدد */
h1, h2, h3, h4, .title, .description {
    user-select: none !important;
    -webkit-user-select: none !important;
}
html, body {
    /* يمنع المتصفح من مط الصفحة لأسفل أو لأعلى عند الوصول للنهاية */
    overscroll-behavior-y: none; 
    
    /* لضمان عدم وجود أي مساحة مخفية */
    margin: 0;
    padding: 0;
}

/* --- الفوتر الاحترافي المطور: نحيف، عصري، ومنسق --- */

.main-footer {
    display: block;
    position: relative;
    z-index: 10;
    /* نهار: خلفية رمادية ناعمة جداً تبرز المحتوى */
    background-color: #f8fafc !important; 
    color: #334155 !important;
    
    /* جعل الخط العلوي نحيف جداً وأنيق 1.5 بيكسل */
    border-top: 1.5px solid;
    border-image-source: linear-gradient(90deg, transparent, #3b82f6, transparent);
    border-image-slice: 1;
    
    padding: 70px 0 0 0;
    width: 100%;
    overflow: hidden; 
}

/* شريط الحقوق السفلي - تصميم Flat عصري */
.footer-bottom-strip {
    margin: 0 !important;
    padding: 20px 0;
    text-align: center;
    margin-top: 60px !important;
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.3px;
    background-color: #0f172a !important; /* نهار: كحلي داكن */
    color: #94a3b8 !important;
}

/* تثبيت الحاوية وحل الاهتزاز نهائياً */
.footer-top-area {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 40px;
}

/* تثبيت الأعمدة */
.footer-links-grid > div {
    flex: 0 0 180px; 
    min-width: 180px;
}

/* البراند: تصميم Logo Area */
.footer-brand h2, 
.footer-brand .logo-area span {
    color: #0f172a !important; /* لون أسود فحمي فخم */
    font-weight: 900 !important;
    font-size: 1.4rem;
    letter-spacing: -0.5px;
}

.footer-brand p {
    color: #64748b !important; 
    line-height: 1.7;
    font-size: 0.95rem;
    margin-top: 15px;
}

/* العناوين: تصميم ناعم بدون خطوط غبية */
.main-footer h3 {
    color: #1e40af !important; /* أزرق ملكي */
    font-weight: 800;
    font-size: 1.05rem;
    margin-bottom: 25px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* الروابط: تباين عالي وتفاعل ناعم */
.main-footer a {
    color: #475569 !important; 
    font-weight: 600;
    text-decoration: none;
    margin-bottom: 14px;
    display: table !important; 
    font-size: 0.95rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.main-footer a:hover {
    color: #3b82f6 !important;
    transform: translateX(-6px); /* إزاحة خفيفة بدلاً من القفز */
}

/* --- الوضع الليلي: Midnight Pro --- */
.dark-mode .main-footer {
    background-color: #020617 !important; /* ليل: أسود عميق جداً */
    color: #cbd5e1 !important;
    /* خط علوي نيون نحيف جداً */
    border-image-source: linear-gradient(90deg, transparent, #0ea5e9, transparent);
}

.dark-mode .footer-brand h2,
.dark-mode .footer-brand .logo-area span {
    color: #f1f5f9 !important;
}

.dark-mode .main-footer h3 {
    color: #38bdf8 !important; /* سماوي نيون */
}

.dark-mode .main-footer a {
    color: #94a3b8 !important;
}

.dark-mode .main-footer a:hover {
    color: #38bdf8 !important;
}

.dark-mode .footer-bottom-strip {
    background-color: #000000 !important; /* ليل: أسود خالص */
    color: #475569 !important;
    border-top: 1px solid #1e293b;
}
/* منع النسخ نهائياً في شريط الإحصائيات وكل ما يحتويه */
.stats-bar, 
.stats-bar *, 
.stat-info, 
.stat-info * {
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    -webkit-touch-callout: none !important; /* لمنع القائمة المنبثقة في الموبايل */
}

/* إلغاء ظهور مؤشر التحديد عند مرور الماوس */
.stats-bar {
    cursor: default !important;
}
/* منع النسخ في شريط الإحصائيات وشبكة الخطوات وكل محتوياتها */
.stats-bar, .stats-bar *, 
.steps-grid, .steps-grid * {
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    -webkit-touch-callout: none !important;
    cursor: default !important;
}
/* منع النسخ في شريط الإحصائيات، الخطوات، مؤقت الماراثون، والتلميحات */
.stats-bar, .stats-bar *, 
.steps-grid, .steps-grid *,
.marathon-timer, .marathon-timer *,
.game-hint {
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    -webkit-touch-callout: none !important;
    cursor: default !important;
}

/* لمسة جمالية للمؤقت في الوضع الليلي والنهاري */
.marathon-timer {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 15px;
    background: rgba(255, 206, 84, 0.1); /* خلفية صفراء خفيفة جداً */
    border-radius: 12px;
    color: var(--primary);
    font-weight: bold;
    border: 1px solid rgba(255, 206, 84, 0.2);
}

.game-hint {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 10px;
    font-style: italic;
}
/* حاوية المختبر يجب أن تكون relative ليعمل التموضع المطلق */
.interactive-lab-container { /* تأكد من اسم الكلاس الخاص بحاوية المختبر عندك */
    position: relative;
}

.lab-header-controls {
    position: absolute;
    top: 20px;
    right: 25px; /* يضعه في الزاوية اليمنى التي حددتها */
    z-index: 100;
}

.lab-reset-btn {
    padding: 8px 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(74, 144, 226, 0.3);
    color: #4a90e2;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

.lab-reset-btn i {
    font-size: 0.9rem;
    transition: transform 0.4s ease;
}

.lab-reset-btn:hover {
    background: #ffce54 !important;
    color: #1a1a1a !important;
    border-color: #ffce54 !important;
    box-shadow: 0 4px 15px rgba(255, 206, 84, 0.3);
}

.lab-reset-btn:hover i {
    transform: rotate(180deg); /* حركة دوران للأيقونة عند الهوفر */
}

/* التوافق مع الوضع الليلي */
body.dark-mode .lab-reset-btn {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.1);
    color: #eee;
}
/* تأثير عندما يكون الزر في حالة الانتظار */
.lab-reset-btn:disabled, 
.lab-reset-btn[style*="not-allowed"] {
    filter: grayscale(1);
    transform: none !important;
    box-shadow: none !important;
}
/* --- التنسيق النهائي لموقع القائمة --- */
.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-direction: row-reverse; /* لضمان ترتيب العناصر من الطرف المختار */
}

/* حاوية القائمة المنسدلة */
.user-menu-wrapper {
    position: relative;
    order: 10; /* يعطيها الأولوية في الترتيب لتكون في الطرف */
}

/* شكل الزر الخارجي (السهم والصورة) */
.user-account-trigger {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 45px; /* جعلناه دائري ليناسب أزرار الثيم */
    height: 45px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(123, 162, 191, 0.3);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.user-account-trigger:hover {
    background: rgba(123, 162, 191, 0.2);
    border-color: #7ba2bf;
    box-shadow: 0 0 15px rgba(123, 162, 191, 0.2);
}

.mini-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1.5px solid #7ba2bf;
}

/* صندوق القائمة (Dropdown) */
.auth-dropdown-box {
    display: none; 
    position: absolute;
    top: 60px;
    right: 0; /* لجعلها تفتح تحت الزر مباشرة في الطرف */
    width: 250px;
    background: #161e2e; /* لون البطاقات في موقعك */
    border: 1px solid rgba(123, 162, 191, 0.4);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    z-index: 9999;
    animation: fadeInUp 0.4s ease-out; /* نفس أنيميشن موقعك */
}

/* محتوى القائمة الداخلي */
.user-meta-info {
    text-align: center;
    margin-bottom: 15px;
}

#drop-user-img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid #7ba2bf;
    margin-bottom: 10px;
}

.user-id-text {
    display: block;
    font-size: 0.85rem;
    color: #f8fafc;
    font-family: 'Cairo', sans-serif;
}

/* أزرار الأكشن */
.login-google-btn {
    width: 100%;
    padding: 12px;
    background: #4285F4;
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-family: 'Cairo';
}

.logout-btn-style {
    width: 100%;
    padding: 10px;
    background: transparent;
    color: #ff4d4d;
    border: 1px solid rgba(255, 77, 77, 0.3);
    border-radius: 8px;
    margin-top: 10px;
    cursor: pointer;
}
#user-energy-count {
    transition: all 0.3s ease;
    display: inline-block;
}

/* تأثير عند زيادة النقاط */
.energy-gain-animation {
    animation: bounce 0.5s ease;
    color: #2ecc71 !important;
}

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.4); }
}
.flying-bolt {
    position: fixed;
    color: #ffce54;
    font-size: 1.8rem;
    z-index: 99999;
    pointer-events: none;
    transition: all 1s cubic-bezier(0.19, 1, 0.22, 1);
    filter: drop-shadow(0 0 10px #ffce54);
}
.story-locked {
    position: relative;
}

.lock-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    color: white;
    text-shadow: 0 0 20px rgba(0,0,0,0.5);
    z-index: 10;
}

.purchase-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px #f1c40f !important;
}
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85); display: flex; align-items: center;
    justify-content: center; z-index: 10000; backdrop-filter: blur(5px);
}
.modal-content {
    background: #2c3e50; padding: 40px; border-radius: 20px;
    text-align: center; border: 2px solid #f1c40f; color: white;
    max-width: 400px; width: 90%; animation: zoomIn 0.3s ease;
}
.modal-buttons { display: flex; gap: 15px; justify-content: center; margin-top: 25px; }
.modal-btn {
    padding: 12px 30px; border: none; border-radius: 50px;
    font-weight: bold; cursor: pointer; transition: 0.3s;
}
.modal-btn.confirm { background: #2ecc71; color: white; }
.modal-btn.cancel { background: #e74c3c; color: white; }
.modal-btn:hover { transform: scale(1.1); filter: brightness(1.2); }

@keyframes zoomIn {
    from { transform: scale(0.7); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.central-alert {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    background: rgba(44, 62, 80, 0.95);
    color: white;
    padding: 30px 50px;
    border-radius: 20px;
    z-index: 20000;
    text-align: center;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid transparent;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    pointer-events: none;
}

.central-alert.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.central-alert i {
    font-size: 3.5rem;
    margin-bottom: 15px;
    display: block;
}

.central-alert.success { border-color: #2ecc71; }
.central-alert.success i { color: #2ecc71; }

.central-alert.error { border-color: #e74c3c; }
.central-alert.error i { color: #e74c3c; }

.central-alert p {
    font-size: 1.2rem;
    margin: 0;
    font-weight: bold;
}

/* واجهة الدخول المطورة */
.auth-dropdown-box {
    display: none; 
    position: fixed; /* تغيير إلى fixed لضمان التمركز */
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%); /* وضعها في منتصف الشاشة بالضبط */
    width: 350px; 
    background: #161e2e; 
    border: 2px solid #7ba2bf; 
    border-radius: 20px; 
    padding: 30px; 
    z-index: 100000; 
    box-shadow: 0 25px 50px rgba(0,0,0,0.6);
    font-family: 'Cairo', sans-serif;
    animation: fadeIn 0.3s ease-out; /* تأثير ظهور ناعم */
}

/* طبقة التشويش الخلفية */
#auth-overlay {
    display: none; 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(0, 0, 0, 0.7); 
    backdrop-filter: blur(12px); /* تشويش قوي وفخم */
    -webkit-backdrop-filter: blur(12px);
    z-index: 99999;
}

/* حركة ظهور النافذة */
@keyframes fadeIn {
    from { opacity: 0; transform: translate(-50%, -45%); }
    to { opacity: 1; transform: translate(-50%, -50%); }
}

/* تنسيق المدخلات */
.auth-dropdown-box input {
    width: 100%; 
    padding: 12px; 
    margin-bottom: 15px; 
    border-radius: 10px; 
    border: 1px solid #2d3748; 
    background: #0f172a; 
    color: white; 
    font-family: 'Cairo';
    box-sizing: border-box;
}

/* تنسيق الأزرار */
.auth-btn {
    width: 100%; 
    padding: 12px; 
    border-radius: 10px; 
    border: none; 
    cursor: pointer; 
    font-weight: bold; 
    font-family: 'Cairo';
    transition: 0.3s;
}

.auth-btn-login { background: #3b82f6; color: white; margin-bottom: 10px; }
.auth-btn-signup { background: #10b981; color: white; }
.auth-btn:hover { opacity: 0.9; transform: scale(1.02); }
/* أضيفي هذا في ملف الستايل أو داخل وسم style */
/* الحاوية الأساسية لكل الألعاب لضمان الثبات */
/* تثبيت حاوية اللعبة داخل البوكس الأصلي */
#quiz-area {
    position: relative !important; /* يمنع اللعبة من الهروب للخارج */
    width: 100% !important;
    min-height: 450px;
    display: block !important;
    margin: 0 auto;
    overflow: hidden; /* أي شيء يحاول يخرج برا البوكس يختفي */
    opacity: 1;
}

/* حركة الظهور الناعمة داخل البوكس */
.game-fade-in {
    animation: fadeInContainer 0.5s ease-out forwards;
}

@keyframes fadeInContainer {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* تنسيق كلمات ترتيب الجمل لضمان عدم تداخلها */
.word-pill {
    cursor: pointer;
    padding: 10px 20px;
    background: #1e293b;
    color: white;
    border-radius: 12px;
    border: 1px solid #334155;
    font-weight: bold;
    transition: 0.3s;
    user-select: none;
    display: inline-block;
}

.word-pill:hover {
    background: #3b82f6;
    transform: scale(1.05);
}
/* الوضع الافتراضي: مخفي وشفاف */
#quiz-area {
    background: transparent;
    border: none;
    transition: all 0.3s ease;
}

/* عندما تفتح أي لعبة، نضيف هذا الكلاس برمجياً أو نعدل الستايل */
#quiz-area.game-on {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(123, 162, 191, 0.3);
}
@keyframes pulse-red-timer { 
    from { transform: scale(1); } 
    to { transform: scale(1.2); text-shadow: 0 0 10px rgba(255, 77, 77, 0.8); } 
}
.pulse-timer { animation: pulse-red-timer 0.5s infinite alternate; }
#game-toast {
    visibility: hidden;
    min-width: 250px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 50px;
    padding: 16px;
    position: fixed;
    z-index: 9999;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

#game-toast.show-toast {
    visibility: visible;
    animation: fadeInOut 3s; /* الأنيميشن مدته 3 ثوانٍ */
}

@keyframes fadeInOut {
    0% { opacity: 0; bottom: 0; }
    15% { opacity: 1; bottom: 30px; }
    85% { opacity: 1; bottom: 30px; }
    100% { opacity: 0; bottom: 0; }
}
/* الحل السحري */
.custom-toast-msg {
    /* بنخلي الأنميشن مدته 3 ثواني */
    animation: fadeAndHide 3s forwards !important;
}

@keyframes fadeAndHide {
    0% { opacity: 1; transform: translateY(0); }
    80% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-20px); display: none; }
}

/* تعديل أخير لضمان وضوح الكلمات عند الضغط باللمس */
.word-pill:active {
    background: #3b82f6 !important;
    transform: scale(0.95) !important; /* تأثير ارتداد عند اللمس بالإصبع */
}
/* إضافة تأثير الإضاءة عند تمرير الماوس */
.lang-option-item {
    padding: 12px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(123,162,191,0.1);
}

.lang-option-item:hover {
    background: rgba(59, 130, 246, 0.2) !important; /* إضاءة زرقاء خفيفة */
    color: #ffce54 !important; /* النص يقلب ذهبي */
    padding-left: 15px; /* حركة بسيطة */
}


/* واجهة الدخول - وضعية المنتصف لضمان الثبات */
.auth-dropdown-box {
    display: none; 
    position: fixed; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%); 
    width: 350px; 
    background: #161e2e; 
    border: 2px solid #7ba2bf; 
    border-radius: 20px; 
    padding: 30px; 
    z-index: 1000001 !important; /* أعلى من أي شيء آخر */
    box-shadow: 0 25px 50px rgba(0,0,0,0.8);
    font-family: 'Cairo', sans-serif;
}

/* طبقة التشويش - ضرورية لمنع الضغط بالخلف */
#auth-overlay {
    display: none; 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(0, 0, 0, 0.7); 
    backdrop-filter: blur(8px);
    z-index: 1000000 !important;
}

/* علامة الإغلاق X */
.close-dropdown {
    position: absolute;
    top: 15px;
    left: 15px;
    color: #7ba2bf;
    cursor: pointer;
    font-size: 1.5rem;
    transition: 0.3s;
}
.close-dropdown:hover { color: #ef4444; }
#shop-icon {
    display: inline-block !important; /* لضمان الظهور */
    z-index: 1000;
    position: relative;
}
/* أضيفي هذا لملف الـ CSS لضمان ظهور السلة في اللابتوب */
#shop-icon {
    visibility: visible !important;
    opacity: 1 !important;
    cursor: pointer !important;
}

/* لمنع تداخل القلم مع عناصر أخرى في الشاشات الكبيرة */
#edit-avatar-icon {
    z-index: 1000 !important;
}

/* منع النسخ في قائمة اللغات والأزرار */
.language-wrapper, #lang-dropdown, .lang-option-item {
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

/* تنسيق الحاوية لدمج الزر مع البحث */
.search-filter-wrapper {
    display: flex !important;
    flex-direction: row-reverse !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0px !important; /* إلغاء الفجوة تماماً */
}

#story-search {
    width: 350px !important;
    height: 45px !important;
    border-radius: 0 25px 25px 0 !important; /* حواف دائرية من اليمين فقط */
    border-left: 1px solid #7ba2bf !important;
}
/* 1. تعريف الألوان الذكية (مريحة للعين) */
:root {
    --filter-text-color: #333333; /* أسود هادئ للوضع الفاتح */
    --filter-border-color: #333333;
}

/* الوضع الليلي بألوان مطفية */
body.dark-mode {
    --filter-text-color: #e0e0e0; /* أبيض هادئ/رمادي فاتح جداً (وليس ناصعاً) */
    --filter-border-color: #555555; /* إطار رمادي متوسط لكي لا يبرز بشكل حاد */
}

/* 2. تنسيق الزر */
#filter-btn {
    height: 45px !important;
    border-radius: 25px 0 0 25px !important; 
    border: 1px solid var(--filter-border-color) !important;
    border-right: none !important; 
    display: flex;
    align-items: center;
    justify-content: center;
    background: none !important;
    outline: none !important;
    box-shadow: none !important;
    color: var(--filter-text-color) !important;
    transition: all 0.3s ease;
    cursor: pointer;
    transform: none !important; 
}

/* 3. عند التمرير أو الضغط: يتحول للأزرق السماوي */
#filter-btn:hover, #filter-btn:active {
    color: #3b82f6 !important; /* اللون السماوي النشط */
    background: none !important;
    transform: none !important;
}

/* القائمة المنسدلة */
#filter-options {
    text-align: right;
}

.filter-item {
    padding: 8px 15px;
    cursor: pointer;
    transition: 0.2s;
}

.filter-item:hover {
    background: rgba(123, 162, 191, 0.1);
}
#story-search {
    /* تكبير الخط الأساسي والنص المكتوب */
    font-size: 1.15rem !important; 
    font-weight: 500;
    font-family: 'Cairo', sans-serif; /* لضمان جمال الخط العربي */
}

/* تكبير وتنسيق جملة "ابحث عن قصة بالاسم..." */
#story-search::placeholder {
    font-size: 1.05rem !important;
    opacity: 0.8;
    color: var(--text-muted);
}
#story-search {
    /* الخط والتنسيق الأساسي */
    font-size: 1.15rem !important;
    transition: all 0.3s ease-in-out; /* لجعل الضوء يظهر بنعومة */
    border: 1px solid #7ba2bf; /* لون الإطار العادي */
}

/* التغيير الذي يحدث عند الضغط داخل المربع (Focus) */
#story-search:focus {
    outline: none; /* إزالة إطار المتصفح الافتراضي البشع */
    border-color: #87ceeb !important; /* تغيير لون الإطار للون السماوي */
    
    /* تأثير الضوء السماوي (Glow) */
    box-shadow: 0 0 15px rgba(135, 206, 235, 0.6), 
                0 0 5px rgba(135, 206, 235, 0.4) !important;
    
    background-color: rgba(135, 206, 235, 0.05); /* لمسة خفيفة جداً من اللون داخل المربع */
}
/* تأكدي أن النوافذ مخفية تماماً ولا تأخذ مساحة عند الإغلاق */
/* الخلفية المعتمة */
.sp-overlay {
    display: none;
    position: fixed !important;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 999999 !important;
    align-items: center;
    justify-content: center;
}

/* تكبير حجم البطاقة وتعديل التصميم */
.sp-card {
    background: #1a202c;
    width: 95%; /* تكبير العرض */
    max-width: 600px; /* زيادة الحد الأقصى للعرض */
    min-height: 450px; /* زيادة الارتفاع */
    border-radius: 28px;
    padding: 40px; /* زيادة المسافات الداخلية */
    position: relative;
    box-shadow: 0 30px 60px rgba(0,0,0,0.7);
    color: #e2e8f0;
    direction: ltr;
    animation: sp-pop 0.3s cubic-bezier(0.17, 0.89, 0.32, 1.27);
}

@keyframes sp-pop {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ديزاين زر الـ X المطور */
.sp-close-top {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #2d3748;
    border: none;
    color: #a0aec0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 22px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* تأثير الـ X عند مرور الماوس: يكبر وينير أحمر */
.sp-close-top:hover {
    background: #e53e3e; /* أحمر */
    color: white;
    transform: scale(1.2) rotate(90deg); /* يكبر ويدور */
    box-shadow: 0 0 15px rgba(229, 62, 62, 0.6);
}

/* ديزاين جديد لزر "فهمت ذلك" */
.sp-btn-confirm {
    background: linear-gradient(135deg, #3182ce 0%, #2c5282 100%);
    color: white;
    border: none;
    padding: 16px;
    width: 100%;
    border-radius: 15px;
    font-size: 18px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 20px;
    box-shadow: 0 4px 15px rgba(49, 130, 206, 0.3);
}

.sp-btn-confirm:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(49, 130, 206, 0.5);
    filter: brightness(1.2);
}

/* تحسين شكل القائمة والخطوط */
.sp-title { color: #f6ad55; font-size: 32px; margin-bottom: 25px; text-align: center; }
.sp-feature-list li { font-size: 18px; margin-bottom: 18px; color: #cbd5e0; }



/* منع النسخ عن واجهة ما الجديد */
#whats-new-wrap .sp-card, 
#whats-new-wrap .sp-title, 
#whats-new-wrap .sp-btn-confirm {
    user-select: none !important;
    -webkit-user-select: none !important;
}

/* تصحيح لون أيقونة تيك توك في الوضع الليلي */
body.dark-mode .social-dark-fix {
    color: #ffffff !important;
}

/* تأثير التكبير لأيقونات السوشيال ميديا */
.sp-highlight-box a {
    transition: transform 0.3s ease;
    display: inline-block;
}

.sp-highlight-box a:hover {
    transform: scale(1.3);
}
/* منع النسخ في واجهة الشروط */
#site-terms-wrap .sp-card {
    user-select: none !important;
    -webkit-user-select: none !important;
}

/* دعم الوضعين */
body.dark-mode #site-terms-wrap .sp-card {
    background: #1a202c !important;
    color: #e2e8f0 !important;
}

body.light-mode #site-terms-wrap .sp-card {
    background: #ffffff !important;
    color: #2d3748 !important;
    border: 1px solid #e2e8f0 !important;
}


/* حل مشكلة الالتصاق بالهيدر */
.main-content-wrapper {
    padding-top: 100px; /* مساحة كافية تحت الهيدر الثابت */
    min-height: 25vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ================ تنسيق المبدل المدمج (كبسولة واحدة) ================ */

/* الحاوية أصبحت ملتصقة بالبحث الآن */
.view-switcher {
    margin: 0 !important; /* إلغاء المسافات القديمة تماماً ليلتصق بالبحث */
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid #7ba2bf;
    border-left: none; /* إلغاء الحد الأيسر للالتصاق بالبحث */
    border-radius: 0 25px 25px 0; /* انحناء جهة اليمين فقط */
    height: 45px; /* نفس ارتفاع حقل البحث والفلتر */
    padding: 0 8px;
    gap: 4px;
}

/* تنسيق الأزرار الدائرية الصغيرة داخل المبدل */
.view-switcher button {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
}
/* حالة الزر النشط (تم تغيير اللون من البنفسجي إلى الأزرق السماوي) */
.view-switcher button.active {
    background: #3b82f6 !important; /* اللون الأزرق السماوي الاحترافي */
    color: #ffffff !important;
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.4); /* ظل أزرق خفيف ليعطي عمق */
}

/* تأثير التمرير للزر غير النشط (أزرق خفيف جداً) */
.view-switcher button:hover:not(.active) {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

/* تعديل إطار الحاوية ليتناسب مع لون الزر */
.view-switcher {
    margin: 0 !important;
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid #3b82f6; /* توحيد لون الإطار مع البحث */
    border-left: none;
    border-radius: 0 25px 25px 0;
    height: 45px;
    padding: 0 8px;
    gap: 4px;
}


/* ================ تنسيق البحث والفلتر المدمج ================ */





/* أضف هذا لملف الـ CSS الخاص بك */
#games-grid-container {
    display: none; /* مخفي افتراضياً */
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); /* يتكيف مع الشاشة */
    gap: 40px 35px;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

/* في الشاشات الكبيرة نثبت الـ 4 أعمدة مثل القصص */
@media (min-width: 1200px) {
    #games-grid-container {
        grid-template-columns: repeat(4, 1fr);
    }
}
/* إزالة أي مساحة زائدة بين الحاويتين */
#main-grid, #games-grid-container {
    margin-top: 0 !important;
    padding-top: 0 !important;
    margin-bottom: 20px;
}

/* تأكد من أن الحاوية الأم لا تملك padding علوي كبير */
.library-container {
    padding-top: 10px !important;
}
/* استخدم كلاس موحد للحاويتين لضمان تطابق الزوايا */
.stories-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr) !important; /* إجبار الـ 4 أعمدة */
    gap: 40px 35px;
    width: 100% !important;
    max-width: 1600px !important;
    margin: 0 auto !important;
    padding: 50px !important; /* هذه هي المسافة التي تضبط الزاوية */
    box-sizing: border-box !important;
    justify-content: center;
}

/* لضمان أن الكروت داخل الألعاب تأخذ كامل العرض المتاح لها */
.stories-grid > div {
    width: 100%;
}




/* دعم الوضع الليلي والنهاري وتكبير الكروت */
.game-card-new {
    padding: 20px 15px !important; /* تكبير الحجم */
    font-size: 1.2rem !important;
    border-radius: 15px !important;
    margin-bottom: 5px;
    width: 100%;
    /* ألوان متغيرة حسب ثيم الصفحة */
    background: var(--card-bg, #ffffff); 
    color: var(--text-color, #1e293b);
    border: 2px solid var(--border-color, #e2e8f0);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
}

/* في حالة الوضع الليلي (تأكد أن موقعك يضيف class dark للجسم أو الـ container) */
body.dark-mode .game-card-new {
    background: #1e293b;
    color: #f8fafc;
    border-color: #334155;
}

.selected-active {
    background: #0ea5e9 !important;
    color: white !important;
    border-color: #38bdf8 !important;
    transform: scale(1.05);
}
/* منع التمرير في الحاوية وكل ما بداخلها */
/* --- 1. تعريف المتغيرات حسب الثيم --- */
:root {
    /* ألوان الوضع النهاري (هادئة وعصرية) */
    --memory-card-bg: #ffffff;
    --memory-card-text: #1e293b;
    --memory-card-border: #e2e8f0;
    --memory-timer-label: #64748b;
}

body.dark-mode {
    /* ألوان الوضع الليلي (فخمة وواضحة) */
    --memory-card-bg: rgba(255, 255, 255, 0.08);
    --memory-card-text: #f8fafc;
    --memory-card-border: rgba(255, 255, 255, 0.1);
    --memory-timer-label: #94a3b8;
}
/* --- 1. تنسيق البطاقة الأساسي (ستايل دولينجو) --- */
.game-card-new {
    min-height: 65px;
    padding: 15px 10px;
    font-size: 1.2rem;
    font-weight: 700; /* خط أسمك ليناسب ستايل الألعاب */
    border-radius: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: all 0.1s ease; /* سرعة استجابة مثل الأزرار الحقيقية */
    width: 100%;
    user-select: none;
    position: relative;
    
    /* المتغيرات الافتراضية */
    background: var(--memory-card-bg);
    color: var(--memory-card-text);
    /* حدود سفلية سميكة لتعطي تأثير الـ 3D */
    border: 2px solid var(--memory-card-border);
    border-bottom-width: 5px; 
    box-shadow: none;
}

/* --- 2. تأثير الماوس (Hover) - تم إزالة التكبير --- */
.game-card-new:hover:not(.matched-correct):not(.matched-wrong) {
    background: #f1f5f9 !important; /* لون خفيف جداً عند الحوم */
    border-color: #cbd5e1 !important;
    border-bottom-width: 5px !important;
    transform: none !important; /* إلغاء التكبير تماماً */
}

/* --- 3. حالة الاختيار (الأزرق - مثل دولينجو) --- */
.selected-active {
    background: #e0f2fe !important; /* أزرق فاتح جداً من الداخل */
    color: #0369a1 !important;      /* نص أزرق غامق */
    border: 2px solid #7dd3fc !important; /* أطراف سماوية */
    border-bottom-width: 5px !important;  /* عمق سماوي */
    transform: translateY(2px); /* كأن الزر انضغط قليلاً */
}

/* --- 4. حالة الإجابة الصحيحة (الأخضر - ستايل دولينجو) --- */
.matched-correct {
    background: #dcfce7 !important; /* أخضر فاتح جداً من الداخل */
    color: #15803d !important;      /* نص أخضر غامق */
    border: 2px solid #4ade80 !important; /* أطراف خضراء */
    border-bottom-width: 5px !important;  /* عمق أخضر غامق */
    transform: none !important;
}

/* --- 5. حالة الخطأ (الأحمر - ستايل دولينجو) --- */
.matched-wrong {
    background: #fee2e2 !important; /* أحمر فاتح جداً من الداخل */
    color: #b91c1c !important;      /* نص أحمر غامق */
    border: 2px solid #f87171 !important; /* أطراف حمراء */
    border-bottom-width: 5px !important;  /* عمق أحمر غامق */
    transform: none !important;
}

/* تأثير الضغط الفعلي بالماوس (Active) */
.game-card-new:active {
    border-bottom-width: 2px !important; /* يختفي العمق ليعطي إيحاء الضغط */
    transform: translateY(3px) !important;
}

/* تعديلات الوضع الليلي لتناسب الألوان الفاتحة */
body.dark-mode .selected-active { background: #0c4a6e !important; color: #e0f2fe !important; }
body.dark-mode .matched-correct { background: #064e3b !important; color: #dcfce7 !important; }
body.dark-mode .matched-wrong { background: #7f1d1d !important; color: #fee2e2 !important; }

/* تأثير الاهتزاز عند الخطأ */
@keyframes shakeError {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-7px); }
    40%, 80% { transform: translateX(7px); }
}

/* تأثير القفزة عند الصح */
@keyframes popSuccess {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.matched-wrong {
    animation: shakeError 0.4s ease-in-out !important;
}

.matched-correct {
    animation: popSuccess 0.4s ease-out !important;
}
/* اللون الأحمر والنبض للتايمر */
.timer-danger {
    color: #ef4444 !important; /* أحمر فاقع */
    text-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
    display: inline-block;
    animation: timerPulse 0.5s ease-in-out infinite alternate;
}

@keyframes timerPulse {
    from { transform: scale(1); }
    to { transform: scale(1.3); }
}
/* مناطق السكرامبل */
.scramble-drop-zone {
    min-height: 100px;
    border: 3px dashed var(--mem-border);
    border-radius: 20px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    padding: 20px;
    background: rgba(0,0,0,0.05);
}

.scramble-bank-zone {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    padding: 10px;
}

/* الكلمات (تستخدم نفس ستايل كروت الميموري اللي سويناه) */
.word-tile-btn {
    width: auto !important;
    min-width: 80px;
    padding: 10px 20px !important;
    min-height: 50px !important;
}

/* صندوق الترتيب الصحيح عند الخسارة */
.correct-sentence-box {
    background: #dcfce7;
    color: #15803d;
    padding: 15px;
    border-radius: 12px;
    font-weight: bold;
    margin: 15px 0;
}
body.dark-mode .correct-sentence-box {
    background: #064e3b;
    color: #dcfce7;
}

/* أنيميشن الظهور */
.animate-pop {
    animation: popSuccess 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
/* الحاوية الكبرى لضمان التوسط */
.result-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 400px; /* ليملأ مساحة اللعبة */
    text-align: center;
}

.final-result-container {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* أيقونة النتيجة */
.result-icon {
    font-size: 5rem;
    margin-bottom: 15px;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.1));
}

/* النصوص */
.win-text { color: #22c55e; font-size: 2rem; font-weight: 800; margin: 10px 0; }
.loss-text { color: #ef4444; font-size: 2rem; font-weight: 800; margin: 10px 0; }

/* الإحصائيات */
.result-stats {
    display: flex;
    gap: 40px;
    background: rgba(0,0,0,0.04);
    padding: 20px 40px;
    border-radius: 20px;
    margin: 20px 0;
}
body.dark-mode .result-stats { background: rgba(255,255,255,0.05); }

.stat-item { display: flex; flex-direction: column; align-items: center; }
.stat-item span { font-size: 0.85rem; opacity: 0.7; margin-bottom: 5px; }
.stat-item strong { font-size: 1.6rem; }

/* صندوق الجملة الصحيحة عند الخسارة */
.correct-order-box {
    width: 100%;
    background: rgba(239, 68, 68, 0.08);
    border: 2px dashed #ef4444;
    padding: 20px;
    border-radius: 20px;
    margin: 20px 0;
}
.correct-order-box .sentence-text {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--mem-text);
    margin-top: 10px;
    direction: ltr; /* للجمل الإنجليزية */
}

/* الأزرار */
.result-actions {
    display: flex;
    gap: 15px;
    margin-top: 25px;
}
/* تكبير حجم التايمر */
.game-timer-style {
    font-size: 2.5rem !important; /* حجم كبير وواضح */
    font-weight: 800;
    transition: color 0.3s ease;
}

/* تحسينات الوضع الليلي للواجهة */
body.dark-mode .final-result-container {
    background-color: #1e293b; /* لون خلفية داكن مريح */
    color: #f8fafc;
}

body.dark-mode .scramble-drop-zone {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: #334155;
}

body.dark-mode .correct-order-box {
    background: rgba(239, 68, 68, 0.15); /* لون أحمر خفيف للنتائج الخاطئة في الوضع الليلي */
    border-color: #f87171;
}

body.dark-mode .correct-order-box .sentence-text {
    color: #fca5a5; /* نص واضح للجملة الصحيحة */
}

/* تنسيق إضافي للأزرار في الوضع الليلي */
body.dark-mode .action-btn-gray {
    background-color: #334155;
    color: #e2e8f0;
}
/* تنسيق التايمر الأساسي (أصفر وحجم كبير) */
#timerUI {
    font-size: 3.5rem; /* تكبير الخط جداً */
    font-weight: 900;
    color: #facc15; /* أصفر فاقع */
    text-shadow: 0 4px 10px rgba(0,0,0,0.2);
    display: block;
    margin: 10px 0;
    transition: all 0.3s ease;
}

/* وضع الخطر (أحمر + اهتزاز) */
.timer-danger {
    color: #ef4444 !important; /* تحويل للأحمر */
    animation: dangerShake 0.2s infinite alternate;
}

/* أنيميشن الاهتزاز مع الصوت */
@keyframes dangerShake {
    from { transform: scale(1) rotate(-2deg); }
    to { transform: scale(1.1) rotate(2deg); }
}

/* تحسينات الوضع الليلي لبيئة اللعب */
body.dark-mode .game-timer-style {
    text-shadow: 0 0 15px rgba(250, 204, 21, 0.4);
}

body.dark-mode .scramble-drop-zone {
    background: rgba(255, 255, 255, 0.03);
    border: 2px dashed #475569;
}
/* تأثير الاهتزاز عند كتابة إجابة خاطئة */
@keyframes shake-anim {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}
.shake-anim { animation: shake-anim 0.2s ease-in-out 0s 2; }

/* تحسين شكل الإدخال في الوضع الليلي */
body.dark-mode #transInput {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}

body.dark-mode #transInput::placeholder {
    color: #64748b;
}
.chat-container { display: flex; flex-direction: column; height: 400px; overflow-y: auto; padding: 10px; gap: 10px; background: var(--mem-bg); }
.msg { max-width: 80%; padding: 12px 16px; border-radius: 20px; font-size: 1rem; line-height: 1.4; position: relative; }
.msg-system { align-self: flex-start; background: #e4e6eb; color: #050505; border-bottom-left-radius: 4px; }
.msg-user { align-self: flex-end; background: #3797f0; color: white; border-bottom-right-radius: 4px; }
body.dark-mode .msg-system { background: #303030; color: #f5f5f5; }
.chat-input-area { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--mem-border); }
/* تحسين فقاعة النظام في الوضع الليلي */
body.dark-mode .msg-system {
    background-color: #303030 !important;
    color: #f5f5f5 !important;
    border: 1px solid #444 !important;
}

/* زر الإرسال التفاعلي */
#sendBtn {
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
}

/* تكبير الزر عند النقر */
#sendBtn:active {
    transform: scale(1.3) !important;
}
/* وضع النهار الافتراضي */
.msg-system {
    background-color: #f0f0f0 !important;
    color: #000 !important;
    align-self: flex-start;
}

.msg-user {
    background-color: #3797f0 !important;
    color: #fff !important;
    align-self: flex-end;
}

/* --- حل مشكلة الوضع الليلي للشات حصراً --- */
body.dark-mode .msg-system {
    background-color: #303030 !important; /* لون غامق للفقاعة */
    color: #f5f5f5 !important;           /* لون فاتح للنص */
    border: 1px solid #444 !important;
}

body.dark-mode .msg-user {
    background-color: #1a73e8 !important; /* لون أزرق مناسب لليل */
    color: #ffffff !important;
}

/* تحسين شكل حقل الكتابة في الوضع الليلي */
body.dark-mode #chatInput {
    background-color: #2d2d2d !important;
    color: #fff !important;
    border: 1px solid #444 !important;
}
/* --- الوضع الفاتح (النهار) --- */
.filter-item.selected-level {
    background-color: rgba(59, 130, 246, 0.1) !important; /* خلفية زرقاء شفافة */
    color: #3b82f6 !important; /* نص أزرق سماوي */
    font-weight: bold;
}

/* --- الوضع الليلي (Dark Mode) --- */
/* افترضنا أن الكلاس هو .dark-mode */
body.dark-mode .filter-item.selected-level {
    background-color: rgba(255, 255, 255, 0.1) !important; /* خلفية رمادية مطفية */
    color: #f1c40f !important; /* أصفر ذهبي هادئ (غير ناصع) */
    border-radius: 8px;
}

/* تحسينات عامة للقائمة */
.filter-item {
    transition: all 0.3s ease;
    margin: 2px 5px;
    border-radius: 5px;
}
/* الحاوية الأساسية */
.settings-wrapper {
    position: relative;
    display: inline-block;
}

/* زر الترس */
.settings-trigger {
    background: none !important;
    border: none !important;
    color: inherit;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 10px;
    display: flex;
    align-items: center;
    transition: transform 0.3s ease;
}

.settings-trigger:hover {
    transform: rotate(45deg);
}

/* القائمة المنسدلة النيلية */
.settings-dropdown {
    display: none;
    position: absolute;
    top: 110%; /* تظهر أسفل الزر مباشرة */
    right: 0;   /* محاذاة لليمين لكي لا تخرج عن الشاشة في الموبايل */
    min-width: 200px;
    background: #111827 !important; /* لون نيلي عميق (نفس الهيدر) */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    overflow: hidden;
}

/* الهيدر داخل القائمة */
.settings-header {
    padding: 10px 15px;
    background: #1f2937 !important; /* أفتح قليلاً من الخلفية */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.8rem;
    color: #9ca3af;
    text-align: right;
}

/* العناصر داخل القائمة */
.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between; /* النص يمين والزر يسار */
    padding: 12px 15px;
    color: #f3f4f6;
    gap: 20px;
}

/* زر المود الدائري */
.theme-toggle-inline {
    background: #374151 !important;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    color: #f1c40f; /* لون القمر الذهبي */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.3s;
}

.theme-toggle-inline:hover {
    background: #4b5563 !important;
    transform: scale(1.05);
}
/* الوضع النيلي للقائمة */
body.dark-mode .settings-dropdown {
    background: #111827 !important; /* اللون النيلي المفضل لديك */
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05); /* خط فاصل بسيط */
}

.settings-item:last-child {
    border-bottom: none; /* إزالة الخط من الخيار الأخير */
}

/* لون الأيقونات في الوضع الليلي */
body.dark-mode .theme-toggle-inline {
    background: #1f2937 !important;
    color: #f1c40f; /* اللون الذهبي */
}
/* 1. تعريف الألوان الأساسية للوضع النهاري (Default) */
.settings-dropdown {
    background: #ffffff !important; /* خلفية بيضاء في النهار */
    border: 1px solid #dddddd;
    color: #333333;
}

.settings-header {
    background: #f9f9f9 !important;
    color: #666666;
    border-bottom: 1px solid #eeeeee;
}

.settings-item {
    color: #333333;
}

.theme-toggle-inline {
    background: #f0f0f0 !important;
    color: #333333;
}

/* 2. الألوان المخصصة للوضع الليلي (تطبق فقط عندما يكون body.dark-mode) */
body.dark-mode .settings-dropdown {
    background: #111827 !important; /* اللون النيلي العميق */
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

body.dark-mode .settings-header {
    background: #1f2937 !important; /* نيلي أفتح قليلاً */
    color: #9ca3af;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .settings-item {
    color: #e5e7eb;
}

body.dark-mode .theme-toggle-inline {
    background: #374151 !important;
    color: #f1c40f; /* أيقونة ذهبية */
}

/* تحسين شكل الترس ليتناسب مع الوضعين */
.settings-trigger {
    color: inherit; /* سيأخذ لون النص الخاص بالهيدر تلقائياً */
}






#orientation-blocker {
    position: fixed !important;
    top: 0 !important; left: 0 !important;
    width: 100vw !important; height: 100vh !important;
    background: #0b0e14 !important;
    z-index: 99999999 !important;
    overflow: hidden !important;
    display: block !important; /* نستخدم البلوك هنا لأننا سنوسط المحتوى داخلياً */
}

/* هذه الحاوية هي التي ستكون في منتصف الشاشة بالضبط */
.central-wrapper {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important; /* هذا السطر هو سر التوسط الحقيقي */
    text-align: center !important;
    width: 100% !important;
}

/* حاوية المربعات */
.loader-boxes {
    position: relative !important;
    height: 100px !important; /* ارتفاع كافي للدوران */
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    margin-bottom: 20px !important;
}

.loader-box {
    position: absolute !important;
    width: 30px !important;
    height: 30px !important;
    border-radius: 8px !important;
    animation: orbit-merge 2.5s infinite ease-in-out !important;
}

/* الألوان مع التوهج */
.purple { background: #9c27b0 !important; box-shadow: 0 0 20px #9c27b0 !important; animation-delay: 0s !important; }
.blue   { background: #448aff !important; box-shadow: 0 0 20px #448aff !important; animation-delay: -0.83s !important; }
.yellow { background: #ffcc00 !important; box-shadow: 0 0 20px #ffcc00 !important; animation-delay: -1.66s !important; }

/* أنيميشن الدوران والاندماج */
@keyframes orbit-merge {
    0% { transform: rotate(0deg) translateX(55px) rotate(0deg); }
    45%, 55% { transform: rotate(180deg) translateX(0px) rotate(-180deg) scale(1.3); border-radius: 50%; }
    100% { transform: rotate(360deg) translateX(55px) rotate(-360deg); }
}

#blocker-text {
    color: white !important;
    font-family: 'Rajdhani', sans-serif !important;
    font-size: 24px !important;
    font-weight: bold !important;
    margin: 10px 0 5px 0 !important;
    letter-spacing: 1px !important;
}

#blocker-subtext {
    color: #8a8e94 !important;
    font-size: 14px !important;
}
/* تنسيق حاوية الروابط للسماح بالسحب على الهاتف */
.nav-links {
    display: flex !important;
    flex-wrap: nowrap !important; /* منع العناصر من النزول لسطر جديد */
    overflow-x: auto !important;  /* تفعيل السحب الأفقي */
    overflow-y: hidden !important;
    white-space: nowrap !important; /* إجبار النصوص على البقاء في سطر واحد */
    -webkit-overflow-scrolling: touch; /* سحب ناعم على أجهزة آيفون */
    gap: 15px; /* المسافة بين الروابط */
    padding: 10px 5px;
    scrollbar-width: none; /* إخفاء شريط التمرير المتصفحات الحديثة */
}

/* إخفاء شريط التمرير لمتصفحات Chrome و Safari لجعل المظهر احترافياً */
.nav-links::-webkit-scrollbar {
    display: none;
}

/* التأكد من أن عناصر القائمة لا تتقلص */
.nav-links li {
    flex: 0 0 auto !important;
    list-style: none;
}


:root {
    --nav-bg: rgba(15, 23, 42, 0.8);
    --nav-border: rgba(123, 162, 191, 0.2);
    --nav-text: #7ba2bf;
}

/* إذا كان الموقع في الوضع الفاتح (Light Mode) */
body.light-mode {
    --nav-bg: rgba(255, 255, 255, 0.8);
    --nav-border: rgba(0, 0, 0, 0.1);
    --nav-text: #4a5568;
}

.bottom-navbar {
    position: fixed;
    bottom: 20px; /* جعلته يطفو قليلاً لمظهر عصري */
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 450px;
    height: 70px;
    background: var(--nav-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--nav-border);
    border-radius: 25px; /* حواف دائرية كاملة */
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 10000;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), bottom 0.4s ease;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

/* أنميشن الاختفاء نحو الأسفل */
.bottom-navbar.hidden {
    bottom: -100px;
    transform: translateX(-50%) translateY(20px);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--nav-text);
    gap: 4px;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item i { font-size: 1.2rem; }
.nav-item span { font-size: 0.7rem; font-weight: 600; }

.nav-item.active {
    color: #f1c40f;
    transform: translateY(-5px); /* رفع الأيقونة النشطة قليلاً */
}






.mode-btn {
    background: transparent;
    color: #7ba2bf;
    font-weight: bold;
}
.mode-btn.active {
    background: #f1c40f !important;
    color: #0f172a !important;
    box-shadow: 0 4px 15px rgba(241, 196, 15, 0.4);
}

.cat-pill {
    background: rgba(123, 162, 191, 0.1);
    color: #7ba2bf;
    padding: 8px 20px;
    border-radius: 20px;
    white-space: nowrap;
    cursor: pointer;
    font-size: 0.9rem;
    transition: 0.3s;
    border: 1px solid transparent;
}
.cat-pill.active {
    background: #7ba2bf;
    color: white;
}

/* لمنع النسخ */
.hub-container {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}




/* إزالة المساحة البيضاء الزائدة */
body {
    padding-bottom: 0 !important;
}

.bottom-navbar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    /* لضمان التمركز والحركة للأسفل */
    transform: translateX(-50%) translateY(0); 
    width: 90%;
    max-width: 450px;
    height: 65px;
    z-index: 999999;
    pointer-events: auto;
    
    /* حركة ناعمة جداً للإخفاء والظهور واللون */
    transition: 
        transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), 
        background 0.4s ease, 
        opacity 0.4s ease;
        
    /* التصميم العام */
    border-radius: 20px;
    display: flex;
    justify-content: space-around;
    align-items: center;
}

/* كلاس الإخفاء (سيضاف بالجافا سكريبت) */
.bottom-navbar.nav-hidden {
    transform: translateX(-50%) translateY(120px); /* ينزل تحت الشاشة */
    opacity: 0; /* يختفي تدريجياً */
}

/* وضع النهار والليل */
body.dark-mode .bottom-navbar {
    background: rgba(15, 23, 42, 0.95);
    border-color: rgba(123, 162, 191, 0.3);
}

body:not(.dark-mode) .bottom-navbar {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.1);
}
/* كل واجهة عبارة عن شاشة كاملة */
.app-screen {
    width: 100%;
    min-height: 100vh;
    padding-bottom: 80px; /* عشان ما تتغطى بالشريط السفلي */
}

.app-screen.hidden {
    display: none !important;
}

/* حركة تنقل ناعمة بين الواجهات */
.app-screen:not(.hidden) {
    animation: screen-fade 0.3s ease-in-out;
}

@keyframes screen-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}
/* كلاس الإخفاء - ضروري جداً */
.hidden {
    display: none !important;
}

/* لجعل التنقل ناعم (اختياري) */
.app-screen, .app-view {
    animation: fadeInPage 0.3s ease-in-out;
}

@keyframes fadeInPage {
    from { opacity: 0; }
    to { opacity: 1; }
}
.app-view.hidden {
    display: none !important;
}
/* إخفاء الواجهة وكل محتوياتها بقوة !important */
.app-view.hidden {
    display: none !important;
}

/* تأكيد إخفاء العناصر الداخلية الحساسة */
.app-view.hidden #main-grid, 
.app-view.hidden .search-filter-wrapper,
.app-view.hidden .section-header {
    display: none !important;
}
/* إخفاء غلاف البحث بالكامل مع كل ما بداخله */
#view-search.hidden {
    display: none !important;
    height: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* حل مشكلة الفراغ السفلي ومنع ظهور شريط البحث فوق الصفحات الأخرى */
.app-view.hidden .search-filter-wrapper,
.app-view.hidden .section-header,
.app-view.hidden #main-grid,
.app-view.hidden #stories-grid-container {
    display: none !important;
    visibility: hidden !important;
}

/* تأكد أن الحاوية الرئيسية لكل صفحة تأخذ مساحة نظيفة */
.app-view {
    width: 100%;
    min-height: calc(100vh - 70px); /* يملأ الشاشة ما عدا مكان الشريط السفلي */
    position: relative;
}
/* إخفاء واجهة البحث تماماً عند البداية */
#view-search.hidden {
    display: none !important;
    height: 0 !important;
    overflow: hidden !important;
    visibility: hidden !important;
}

/* تأكيد إخفاء العناصر المتمردة */
.app-view.hidden * {
    display: none !important;
}
/* تنسيق منطقة العنوان لضمان التوسيط الكامل */
.section-header {
    display: flex;
    flex-direction: column; /* ترتيب العناصر عمودياً فوق بعضها */
    align-items: center;    /* توسيط العناصر أفقياً في المنتصف */
    justify-content: center;
    text-align: center;     /* توسيط النص نفسه */
    width: 100%;
    margin-bottom: 30px;    /* مسافة تحت العنوان قبل شريط البحث */
    padding: 0 20px;
}

/* تنسيق العنوان الرئيسي */
.library-title {
    font-size: 2.2rem;
    font-weight: 800;
    margin: 0;
    color: var(--text-main); /* سيأخذ لون الخط الأساسي عندك */
}

/* تنسيق الخط اللي تحت العنوان ليكون في الوسط */
.underline {
    width: 80px;
    height: 4px;
    background: #3b82f6;   /* لون أزرق جميل */
    margin: 12px auto;     /* auto هنا هي اللي تخليه بالنص بالضبط */
    border-radius: 10px;
}

/* تنسيق الوصف الفرعي */
.library-subtitle {
    font-size: 1.1rem;
    opacity: 0.8;
    margin: 0;
}




/* تنسيق القسم الواحد */
.home-category-section {
    margin-bottom: 30px;
    padding: 0 15px;
}

.category-title {
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-right: 4px solid #3b82f6; /* خط جمالي بجانب العنوان */
    padding-right: 10px;
}

/* حاوية التمرير الأفقي */
.stories-scroll-row {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding: 10px 5px;
    scroll-behavior: smooth;
    scrollbar-width: none; /* إخفاء السكرول في فايرفوكس */
}

.stories-scroll-row::-webkit-scrollbar {
    display: none; /* إخفاء السكرول في كروم وسفاري */
}

/* تصغير الكروت قليلاً في الصفحة الرئيسية لتناسب الصف */
.home-category-section .story-card {
    min-width: 200px;
    max-width: 200px;
    flex-shrink: 0; /* منع انكماش الكرت */
}
.stories-scroll-row {
    display: flex;
    gap: 15px;
    overflow-x: auto; /* يسمح بالسحب يميناً ويساراً */
    padding: 10px 20px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none; /* إخفاء السكرول */
}

.stories-scroll-row::-webkit-scrollbar {
    display: none;
}

.home-category-section .story-card {
    min-width: 160px; /* عرض الكرت في الرئيسية */
    flex-shrink: 0;
    scroll-snap-align: start;
}
.stories-scroll-row {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding: 20px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* إخفاء شريط التمرير */
}

.stories-scroll-row::-webkit-scrollbar {
    display: none;
}

/* التأكد من بقاء الكرت بحجمه الأصلي في الصف الأفقي */
.stories-scroll-row .story-card {
    flex: 0 0 300px; /* عرض ثابت 300 بكسل وعدم الانكماش */
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}





.active-switch {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 8px 25px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.inactive-switch {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-body);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 25px;
    border-radius: 20px;
    cursor: pointer;
}
.switch-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-body);
    padding: 10px 25px;
    border-radius: 30px;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.switch-btn.active {
    background: #3b82f6;
    color: white;
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.4);
    transform: translateY(-2px);
    border-color: #3b82f6;
}

.switch-btn i {
    font-size: 1.1rem;
}



/* لون اللايك الأخضر عند التفعيل */
.active-like {
    background-color: #22c55e !important; /* أخضر */
    color: white !important;
}

/* لون الديسلايك الأحمر عند التفعيل */
.active-dislike {
    background-color: #ef4444 !important; /* أحمر */
    color: white !important;
}

/* تنسيق عام للأزرار لضمان سلاسة الحركة */
.react-btn {
    transition: all 0.3s ease;
    cursor: pointer;
}
/* الأخضر للايك */
.active-like {
    background-color: #22c55e !important;
    color: white !important;
    transform: scale(1.05); /* تكبير بسيط للزر المختار */
}

/* الأحمر للديسلايك */
.active-dislike {
    background-color: #ef4444 !important;
    color: white !important;
    transform: scale(1.05);
}
#auth-dropdown {
    background-color: var(--bg-card); /* ليأخذ لون البطاقة حسب الوضع الحالي */
    color: var(--text-main);
    transition: background 0.3s ease;
}
/* الألوان الافتراضية (وضع النهار) */
.dynamic-auth-bg {
    background: #ffffff !important;
    color: #1e293b !important;
    border-color: #e2e8f0 !important;
}
.dynamic-text-color { color: #1e293b; }

/* الألوان عند تفعيل وضع الليل */
body.dark-mode .dynamic-auth-bg {
    background: #161e2e !important;
    color: #ffffff !important;
    border-color: #3b82f6 !important;
}
body.dark-mode .dynamic-text-color { color: #ffffff; }

/* انيميشن تبديل الوضع */
.rotate-pop {
    animation: rotatePop 0.5s ease;
}
@keyframes rotatePop {
    0% { transform: scale(1) rotate(0); }
    50% { transform: scale(1.3) rotate(180deg); }
    100% { transform: scale(1) rotate(360deg); }
}
@keyframes authTransition {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.auth-fade-in {
    animation: authTransition 0.4s ease forwards;
}
