        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        :root {
            --primary: #667eea;
            --secondary: #764ba2;
            --success: #4caf50;
            --danger: #f44336;
            --warning: #ff9800;
            --bg: #ffffff;
            --bg-secondary: #f5f5f5;
            --text: #333333;
            --text-light: #666666;
            --border: #e0e0e0;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
            min-height: 100vh;
            padding: 20px;
            color: var(--text);
            transition: all 0.3s ease;
        }

        .container {
            max-width: 1000px;
            margin: 0 auto;
        }

        /* ===== الصفحة الرئيسية ===== */
        .home-page {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            min-height: 100vh;
        }

        .home-header {
            text-align: center;
            color: white;
            margin-bottom: 40px;
        }

        .home-header h1 {
            font-size: 3em;
            margin-bottom: 10px;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
        }

        .home-header p {
            font-size: 1.1em;
            opacity: 0.9;
        }

        .theme-toggle-btn {
            position: fixed;
            top: 20px;
            right: 20px;
            background: rgba(255, 255, 255, 0.2);
            border: 2px solid white;
            color: white;
            width: 50px;
            height: 50px;
            border-radius: 50%;
            font-size: 1.5em;
            cursor: pointer;
            transition: all 0.3s ease;
            z-index: 1000;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .theme-toggle-btn:hover {
            background: rgba(255, 255, 255, 0.3);
            transform: scale(1.1);
        }

        .theme-menu {
            position: fixed;
            top: 80px;
            right: 20px;
            background: var(--bg);
            border-radius: 15px;
            padding: 20px;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
            z-index: 999;
            display: none;
            max-height: 80vh;
            overflow-y: auto;
            min-width: 250px;
        }

        .theme-menu.show {
            display: block;
            animation: slideIn 0.3s ease;
        }

        @keyframes slideIn {
            from {
                opacity: 0;
                transform: translateY(-10px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .theme-menu h3 {
            color: var(--primary);
            margin-bottom: 15px;
            text-align: center;
        }

        .theme-item {
            padding: 12px;
            margin-bottom: 10px;
            border-radius: 8px;
            cursor: pointer;
            background: var(--bg-secondary);
            transition: all 0.3s ease;
            text-align: center;
            border: 2px solid transparent;
        }

        .theme-item:hover {
            background: var(--primary);
            color: white;
            transform: translateX(-5px);
        }

        .theme-item.active {
            border-color: var(--primary);
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            color: white;
        }

        .quizzes-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 25px;
            width: 100%;
        }

        .quiz-card {
            background: var(--bg);
            border-radius: 15px;
            padding: 30px;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
            border-left: 5px solid var(--primary);
        }

        .quiz-card:hover {
            transform: translateY(-10px);
            box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
        }

        .quiz-card h3 {
            color: var(--primary);
            margin-bottom: 15px;
            font-size: 1.5em;
        }

        .quiz-card p {
            color: var(--text-light);
            margin-bottom: 20px;
        }

        .quiz-info {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
        }

        .question-count {
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            color: white;
            padding: 8px 15px;
            border-radius: 20px;
            font-weight: bold;
            font-size: 0.9em;
        }

        .timer-option {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 10px;
        }

        .timer-option input[type="radio"] {
            cursor: pointer;
        }

        .timer-option label {
            cursor: pointer;
            margin: 0;
        }

        .timer-config {
            background: var(--bg-secondary);
            padding: 10px;
            border-radius: 8px;
            margin-top: 10px;
            margin-left: 25px;
            display: none;
        }

        .timer-config.show {
            display: block;
        }

        .timer-config input {
            width: 100%;
            padding: 8px;
            border: 1px solid var(--border);
            border-radius: 5px;
            margin-top: 5px;
        }

        /* ===== صفحة الكويز ===== */
        .quiz-page {
            display: none;
        }

        /* 1. الحاوية الرئيسية */
        .quiz-header {
            background: var(--bg);
            padding: 20px 25px; /* تقليل البادينج العلوي قليلاً */
            border-radius: 15px;
            margin-bottom: 30px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
            
            display: flex;
            flex-wrap: wrap; /* أهم تعديل: يسمح للعناصر بالنزول لسطر جديد */
            justify-content: space-between; /* يبعد العنوان عن التايمر */
            align-items: center;
            gap: 15px;
        }

        /* 2. العنوان */
        .quiz-title {
            color: var(--primary);
            font-size: 1.4em;
            font-weight: bold;
            /* نلغي flex: 1 القديمة عشان ماياخدش مساحة زيادة */
        }

        /* 3. التايمر */
        .timer {
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            color: white;
            padding: 8px 20px; /* تصغير الحجم قليلاً ليكون أشيك */
            border-radius: 20px; /* شكل كبسولة */
            text-align: center;
            font-weight: bold;
            font-size: 1.1em;
            min-width: 80px; /* عرض ثابت عشان الأرقام ماترقصش */
            box-shadow: 0 2px 5px rgba(0,0,0,0.2);
        }

        .timer.hidden {
            display: none;
        }

        /* 4. حاوية شريط التقدم (الجديد) */
        .progress-container {
            width: 100%; /* ياخد العرض بالكامل */
            margin-top: 10px; /* مسافة بينه وبين العنوان */
        }

        .progress-track {
            display: flex;
            gap: 0; /* إلغاء المسافات نهائياً ليصبح متصلاً */
            height: 10px; /* سمك الخط */
            width: 100%;
            background-color: #e0e0e0; /* لون الخلفية للخط كله */
            border-radius: 10px; /* التدوير للحاوية الخارجية فقط */
            overflow: hidden; /* عشان القطع اللي جوه ماتخرجش بره التدوير */
            direction: rtl; 
        }

        .progress-segment {
            flex: 1; 
            /* شيلنا اللون الرمادي من هنا عشان الخلفية الأساسية هتبان */
            /* شيلنا border-radius من هنا عشان يبانوا لازقين في بعض */
            transition: background-color 0.3s ease;
            border-right: 1px solid rgba(255,255,255,0.2); /* اختياري: خط رفيع جداً شفاف يفصل بينهم شكلياً فقط */
        }

        .progress-segment:last-child {
            border-right: none;
        }

        /* الألوان زي ما هي */
        .progress-segment.correct { background-color: #4caf50 !important; }
        .progress-segment.wrong { background-color: #f44336 !important; }
        .progress-segment.skipped { background-color: #ffc107 !important; }
        .progress-segment.current { background-color: var(--primary); opacity: 0.5; }
        .question-container {
            background: var(--bg);
            border-radius: 15px;
            padding: 40px;
            margin-bottom: 30px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }

        .question-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 25px;
            padding-bottom: 15px;
            border-bottom: 2px solid var(--border);
            flex-wrap: wrap;
            gap: 10px;
        }

        .question-number {
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            color: white;
            padding: 8px 16px;
            border-radius: 20px;
            font-weight: bold;
        }

        .question-type {
            background: var(--bg-secondary);
            padding: 8px 16px;
            border-radius: 20px;
            font-size: 0.9em;
            color: var(--text-light);
        }

        .translate-btn {
            background: var(--bg-secondary);
            border: 2px solid var(--primary);
            color: var(--primary);
            padding: 8px 16px;
            border-radius: 8px;
            cursor: pointer;
            font-weight: bold;
            transition: all 0.3s ease;
        }

        .translate-btn:hover {
            background: var(--primary);
            color: white;
        }

        .question-text {
            font-size: 1.3em;
            color: var(--text);
            margin-bottom: 30px;
            line-height: 1.8;
            font-weight: 500;
        }

        .question-image {
            max-width: 100%;
            height: auto;
            border-radius: 10px;
            margin-bottom: 30px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }

        .options {
            display: flex;
            flex-direction: column;
            gap: 15px;
            margin-bottom: 30px;
        }

        .option {
            display: flex;
            align-items: center;
            padding: 15px;
            border: 2px solid var(--border);
            border-radius: 10px;
            cursor: pointer;
            transition: all 0.3s ease;
            background: var(--bg-secondary);
        }

        .option:hover:not(.disabled) {
            border-color: var(--primary);
            background: var(--bg);
        }

        .option.disabled {
            cursor: not-allowed;
            opacity: 0.7;
        }

        .option input[type="radio"],
        .option input[type="checkbox"] {
            margin-right: 15px;
            width: 20px;
            height: 20px;
            cursor: pointer;
            accent-color: var(--primary);
        }

        .option.disabled input {
            cursor: not-allowed;
        }

        .option label {
            flex: 1;
            cursor: pointer;
            font-size: 1.1em;
        }

        .option.disabled label {
            cursor: not-allowed; /* تغيير المؤشر للنص المعطل */
        }

        .option.selected {
            border-color: var(--primary);
            background: var(--bg);
            border-width: 2px;
        }

        .option.correct {
            border-color: var(--success);
            background: linear-gradient(135deg, rgba(76, 175, 80, 0.1), rgba(76, 175, 80, 0.05));
        }

        .option.incorrect {
            border-color: var(--danger);
            background: linear-gradient(135deg, rgba(244, 67, 54, 0.1), rgba(244, 67, 54, 0.05));
        }

        .feedback {
            margin-top: 25px;
            padding: 20px;
            border-radius: 10px;
            display: none;
        }

        .feedback.show {
            display: block;
        }

        .feedback.correct {
            background: linear-gradient(135deg, rgba(76, 175, 80, 0.1), rgba(76, 175, 80, 0.05));
            border-left: 5px solid var(--success);
            color: var(--success);
        }

        .feedback.incorrect {
            background: linear-gradient(135deg, rgba(244, 67, 54, 0.1), rgba(244, 67, 54, 0.05));
            border-left: 5px solid var(--danger);
            color: var(--danger);
        }

        .feedback-title {
            font-weight: bold;
            margin-bottom: 10px;
            font-size: 1.1em;
        }

        .feedback-text {
            line-height: 1.6;
            color: var(--text);
        }

        .controls {
            display: flex;
            gap: 15px;
            justify-content: center;
            flex-wrap: wrap;
            margin-top: 30px;
        }

        button {
            padding: 12px 30px;
            font-size: 1em;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.3s ease;
            font-weight: bold;
            min-width: 120px;
        }

        button:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        .btn-primary {
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            color: white;
        }

        .btn-primary:hover:not(:disabled) {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
        }

        .btn-secondary {
            background: var(--bg-secondary);
            color: var(--primary);
            border: 2px solid var(--primary);
        }

        .btn-secondary:hover:not(:disabled) {
            background: var(--primary);
            color: white;
        }

        .btn-back {
            background: var(--bg-secondary);
            color: var(--text);
            border: 2px solid var(--border);
        }

        .btn-back:hover {
            background: var(--border);
        }

        /* ===== صفحة النتائج ===== */
        .results-page {
            display: none;
        }

        .results-container {
            background: var(--bg);
            border-radius: 15px;
            padding: 50px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
            text-align: center;
        }

        .results-title {
            font-size: 2.5em;
            color: var(--primary);
            margin-bottom: 30px;
        }

        .score-display {
            font-size: 4em;
            font-weight: bold;
            color: var(--primary);
            margin: 30px 0;
        }

        .percentage {
            font-size: 0.5em;
            color: var(--text-light);
        }

        .results-summary {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin: 40px 0;
        }

        .summary-item {
            padding: 20px;
            border-radius: 10px;
            background: var(--bg-secondary);
        }

        .summary-item.correct {
            background: linear-gradient(135deg, rgba(76, 175, 80, 0.1), rgba(76, 175, 80, 0.05));
            border-left: 5px solid var(--success);
        }

        .summary-item.incorrect {
            background: linear-gradient(135deg, rgba(244, 67, 54, 0.1), rgba(244, 67, 54, 0.05));
            border-left: 5px solid var(--danger);
        }

        .summary-item.skipped {
            background: linear-gradient(135deg, rgba(255, 152, 0, 0.1), rgba(255, 152, 0, 0.05));
            border-left: 5px solid var(--warning);
        }

        .summary-item label {
            display: block;
            color: var(--text-light);
            font-size: 0.9em;
            margin-bottom: 10px;
        }

        .summary-item .value {
            font-size: 2em;
            font-weight: bold;
            color: var(--primary);
        }

        /* الحاوية */
        .lang-switch-container {
            position: fixed;
            top: 20px;
            left: 20px;
            z-index: 9999;
            display: flex;
            align-items: center;
            justify-content: center;
            background-color: rgba(255, 255, 255, 0.8); 
            padding: 4px; 
            border-radius: 34px;
            backdrop-filter: blur(5px);
        }

        .switch {
            position: relative;
            display: inline-block;
            width: 60px;
            height: 30px;
            margin: 0;
        }

        .switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }

        /* === السلايدر (الوضع الافتراضي = إنجليزي = ملون) === */
        .slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            
            /* 1. اللون الافتراضي: ملون */
            background-color: var(--primary); 
            
            transition: .4s;
            border-radius: 34px;
            border: 2px solid #fff; 
        }

        /* === الدائرة (الوضع الافتراضي = يمين) === */
        .slider:before {
            position: absolute;
            content: "";
            height: 24px;
            width: 24px;
            left: 1px; 
            bottom: 1px;
            background-color: white;
            transition: .4s;
            border-radius: 50%;
            box-shadow: 0 2px 5px rgba(0,0,0,0.3);
            z-index: 2;
            
            /* 2. المكان الافتراضي: يمين (30 بكسل) */
            transform: translateX(30px); 
        }

        /* تنسيق النصوص */
        .lang-label {
            position: absolute;
            top: 50%;
            transform: translateY(-50%);
            color: white;
            font-size: 11px;
            font-weight: bold;
            z-index: 1;
            user-select: none;
            transition: opacity 0.3s ease;
        }

        /* كلمة AR (مكانها يمين، وافتراضياً مخفية) */
        .lang-label.ar {
            right: 8px; 
            opacity: 0; /* مخفي */
        }

        /* كلمة EN (مكانها شمال، وافتراضياً ظاهرة) */
        .lang-label.en {
            left: 8px; 
            opacity: 1; /* ظاهر */
        }

        /* ====== حالة الضغط (Checked = عربي) ====== */

        /* لما يبقى Checked يقلب رمادي */
        input:checked + .slider {
            background-color: #ccc; 
        }

        /* لما يبقى Checked يرجع الدائرة لليسار */
        input:checked + .slider:before {
            transform: translateX(0); 
        }

        /* إظهار العربي */
        input:checked + .slider .lang-label.ar {
            opacity: 1;
        }

        /* إخفاء الإنجليزي */
        input:checked + .slider .lang-label.en {
            opacity: 0;
        }

        .wrong-answers {
            margin-top: 50px;
            padding-top: 30px;
            border-top: 2px solid var(--border);
        }

        .wrong-answers h3 {
            color: var(--danger);
            margin-bottom: 25px;
            font-size: 1.5em;
            text-align: right;
        }

        .skipped-answers h3 {
            color: var(--warning);
            margin-bottom: 25px;
            font-size: 1.5em;
            text-align: right;
        }

        .answer-item {
            background: linear-gradient(135deg, rgba(244, 67, 54, 0.1), rgba(244, 67, 54, 0.05));
            border-right: 5px solid var(--danger);
            padding: 20px;
            margin-bottom: 15px;
            border-radius: 8px;
        }

        .skipped-item {
            background: linear-gradient(135deg, rgba(255, 152, 0, 0.1), rgba(255, 152, 0, 0.05));
            border-right: 5px solid var(--warning);
            padding: 20px;
            margin-bottom: 15px;
            border-radius: 8px;
        }

        .answer-item .question,
        .skipped-item .question {
            font-weight: bold;
            margin-bottom: 10px;
            color: var(--text);
        }

        .answer-item .your-answer,
        .skipped-item .your-answer {
            color: var(--danger);
            margin-bottom: 8px;
        }

        .answer-item .correct-answer,
        .skipped-item .correct-answer {
            color: var(--success);
            font-weight: bold;
        }
        
        .no-answer {
            animation: noAnswerFlash 1.8s ease;
        }

        @keyframes noAnswerFlash {
            0%, 100% {
                box-shadow: 0 0 10px var(--primary);
            }
            50% {
                box-shadow: 0 0 20px var(--primary);
            }
        }
        
        .warning-text {
            color: var(--primary);
            font-weight: bold;
            text-align: center;
        }


        .explanation {
            margin-top: 10px;
            color: var(--text);
            font-style: italic;
        }

        /* ===== الاستجابة للأجهزة الصغيرة ===== */
        @media (max-width: 768px) {
            .home-header h1 {
                font-size: 1.8em;
            }

            .quizzes-grid {
                grid-template-columns: 1fr;
            }

            .quiz-header {
                grid-template-columns: 1fr;
            }

            .question-container {
                padding: 20px;
            }

            .results-container {
                padding: 25px;
            }

            .controls {
                flex-direction: column;
            }

            button {
                width: 100%;
            }

            .quiz-stats {
                flex-wrap: wrap;
            }

            .question-header {
                flex-direction: column;
                align-items: flex-start;
            }

            .theme-menu {
                right: 10px;
                top: 70px;
                min-width: 200px;
            }
        }

        .empty-state {
            text-align: center;
            padding: 60px 20px;
            color: white;
        }

        .empty-state h2 {
            font-size: 2em;
            margin-bottom: 10px;
        }

        .empty-state p {
            font-size: 1.1em;
            opacity: 0.9;
        }

        .btn-download {
            background: #ff9800;
            color: white;
            border: none;
            padding: 12px 25px;
            border-radius: 10px;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4px 15px rgba(255, 152, 0, 0.3);
        }   

        .btn-download:hover {
            background: #f57c00;
            transform: translateY(-2px);
        }