:root {
    /* --- تم تعديل الألوان لتناسب الثيم الخشبي --- */
    --primary: #8b4513;       /* بني خشبي أساسي */
    --primary-dark: #5d4037;  /* بني غامق للظلال */
    --secondary: #d7ccc8;     /* لون ورقي/بيج فاتح للنصوص الثانوية */
    --bg-color: #1e1e1e;      /* خلفية داكنة لإبراز الخشب */
    --text-color: #fff8e1;    /* أبيض كريمي */
    --accent: #2e7d32;        /* أخضر عشبي (للإجابة الصحيحة والتقدم) */
    --danger: #c62828;        /* أحمر قرميدي (للخطأ) */
    --card-bg: rgba(62, 39, 35, 0.9); /* خلفية البطاقات بنية نصف شفافة */
    --studio-color: #ffb74d;  /* برتقالي ذهبي للشعارات */
    
    /* متغير جديد لظلال النصوص والأيقونات لتعطي طابع الحفر عالخشب */
    --wood-shadow: 1px 1px 0px #000; 
}

* { box-sizing: border-box; font-family: 'Tajawal', sans-serif; -webkit-tap-highlight-color: transparent; }

body { 
    margin: 0; 
    background-color: var(--bg-color); 
    color: var(--text-color); 
    height: 100vh; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    overflow: hidden; 
    user-select: none; 
}

/* --- إضافة دعم وتنسيق للأيقونات الجديدة (FontAwesome) --- */
i, .fa-solid, .fa-regular, .fa-brands {
    margin: 0 5px;
    filter: drop-shadow(var(--wood-shadow)); /* ظل للأيقونة */
}

/* تنسيق القلوب (الأرواح) */
.fa-heart {
    font-size: 1.3rem;
    color: #d32f2f; /* لون القلب أحمر */
    transition: transform 0.2s;
}
.heart-lost {
    color: #555 !important; /* لون القلب المفقود رمادي */
    opacity: 0.5;
}

.app-container { 
    width: 100%; 
    height: 100%; 
    max-width: 500px; 
    /* خلفية متدرجة بنية غامقة */
    background: linear-gradient(180deg, #3e2723 0%, #1a1a1d 100%); 
    position: relative; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
}

/* نمط خفيف فوق الخلفية */
.bg-pattern { 
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; 
    background-image: radial-gradient(rgba(255,255,255,0.03) 1px, transparent 1px); 
    background-size: 20px 20px; 
    pointer-events: none; z-index: 0; 
}

/* --- ✅ إصلاح الفيديو (كما هو في الكود الأصلي) --- */
#video-container { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background-color: black; z-index: 9999; 
    display: flex; align-items: center; justify-content: center; 
}
#intro-video { width: 100%; height: 100%; object-fit: contain; }

/* --- الشاشات --- */
.screen { 
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; 
    display: none; flex-direction: column; align-items: center; justify-content: center; 
    padding: 20px; z-index: 1; 
}
.screen.active { display: flex; z-index: 2; animation: fadeIn 0.4s ease-in-out; }
@keyframes fadeIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

/* --- استرجاع الخلفيات (مع الحفاظ على الكود القديم) --- */
#screen-home { 
    background-image: url('bg.jpg'); 
    background-size: cover; 
    background-position: center; 
    background-repeat: no-repeat; 
}

#screen-game { 
    background-image: url('game_bg.webp'); 
    background-size: cover; 
    background-position: center; 
    background-repeat: no-repeat; 
}

.logo-area { text-align: center; margin-bottom: 30px; }
.hero-title { 
    font-size: 2.5rem; margin: 0; 
    /* تدرج ذهبي/خشبي للعنوان */
    background: linear-gradient(45deg, #ffca28, #ff6f00); 
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; 
    font-weight: 900; 
    text-shadow: 0 0 20px rgba(0,0,0,0.8); 
}

/* --- الأزرار (تعديل الألوان لتصبح خشبية) --- */
.menu-grid { width: 100%; display: grid; gap: 8px; /* تم تقليل المسافة من 10px */ }

.btn { 
    padding: 10px; /* تم تصغير البادينغ من 12px */
    border-radius: 12px; 
    border: 2px solid #5d4037; /* حدود بنية */
    font-size: 1rem; /* تصغير الخط قليلاً */
    font-weight: bold; 
    color: white; 
    cursor: pointer; 
    transition: 0.2s; 
    width: 100%; 
    display: flex; align-items: center; justify-content: center; gap: 10px; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.6); 
    position: relative; 
    text-shadow: 1px 1px 0 #000;
}
.btn:active { transform: scale(0.97); }

/* أزرار القائمة الرئيسية - تدرج بني */
.btn-primary { background: linear-gradient(180deg, #8d6e63, #5d4037); }
.btn-secondary { background: rgba(62, 39, 35, 0.8); border: 1px solid rgba(255,255,255,0.2); backdrop-filter: blur(5px); }
.btn-danger { background: linear-gradient(180deg, #ef5350, #b71c1c); color: white; border: 1px solid var(--danger); }
.btn-locked { background: rgba(0,0,0,0.5); color: #999; cursor: not-allowed; border: 1px dashed #666; }

/* أيقونات SVG القديمة (تم الإبقاء عليها كاحتياط، لكن سنستخدم FontAwesome) */
.btn svg { width: 20px; height: 20px; fill: currentColor; } /* تصغير الأيقونات */

.lock-badge { background: #444; color: #fff; font-size: 0.7rem; padding: 2px 8px; border-radius: 10px; position: absolute; top: -8px; right: 10px; }

/* --- تنسيقات العملات في الشاشة الرئيسية (جديد) --- */
.home-currency-container {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
}

.currency-badge {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #8D6E63;
    border-radius: 20px;
    padding: 4px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 100px;
    height: 35px;
    color: #FFD700;
    font-weight: bold;
    font-size: 0.9rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
    position: relative;
    padding-left: 30px; /* مسافة للزر */
}

.currency-badge img {
    width: 20px;
    height: 20px;
    margin-right: 5px;
    filter: drop-shadow(1px 1px 1px black);
}

.add-btn-small {
    background: linear-gradient(180deg, #4CAF50, #2E7D32);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #fff;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    left: -8px; /* ملزقة بالأيقونة من اليسار */
    box-shadow: 0 2px 2px rgba(0,0,0,0.3);
    transition: transform 0.2s;
}

.add-btn-small:active { transform: scale(0.9); }

/* --- الهيدر والبطاقات --- */
.sub-screen-header { width: 100%; display: flex; align-items: center; margin-bottom: 20px; }
.back-btn { background: none; border: none; font-size: 1.5rem; color: white; cursor: pointer; z-index: 50; text-shadow: 0 0 5px black; transition: transform 0.2s; }
.back-btn:hover { transform: scale(1.1); color: var(--studio-color); }

.screen-title { flex: 1; text-align: center; font-size: 1.5rem; font-weight: bold; margin: 0; text-shadow: 0 0 10px black; }

.settings-card {
    background-color: var(--card-bg) !important;
    backdrop-filter: blur(15px); 
    -webkit-backdrop-filter: blur(15px); 
    border: 2px solid rgba(141, 110, 99, 0.5); /* حدود خشبية فاتحة */
    border-radius: 20px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
}
.setting-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
input[type=range] { width: 120px; accent-color: var(--primary); }
.stat-item { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.1); }
.stat-value { color: var(--studio-color); font-weight: bold; font-family: monospace; font-size: 1.2rem; }

/* --- اللعبة --- */
.top-nav { position: absolute; top: 0; left: 0; right: 0; padding: 20px; display: flex; justify-content: space-between; z-index: 10; align-items: center; }
.lives-display { color: var(--danger); font-size: 1.2rem; background: rgba(0,0,0,0.6); padding: 5px 10px; border-radius: 15px; display: flex; gap: 5px; border: 1px solid #5d4037; }
.game-content { width: 100%; margin-top: 60px; display: flex; flex-direction: column; gap: 20px; flex: 1; justify-content: center; }
.question-card { 
    background: var(--card-bg); padding: 30px 20px; border-radius: 20px; text-align: center; 
    font-size: 1.3rem; font-weight: bold; min-height: 150px; display: flex; align-items: center; justify-content: center; 
    border: 2px solid rgba(141, 110, 99, 0.5); backdrop-filter: blur(5px); 
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}
.options-grid { display: flex; flex-direction: column; gap: 12px; }
.option-btn { 
    background: linear-gradient(180deg, #5d4037, #3e2723); /* خلفية خشبية غامقة للخيارات */
    padding: 18px; border-radius: 12px; color: white; 
    font-size: 1.1rem; text-align: center; border: 1px solid rgba(255,255,255,0.1); backdrop-filter: blur(5px); 
    box-shadow: 0 4px 0 #271c19; /* ظل صلب ليعطي إحساس الزر */
    transition: transform 0.1s;
    cursor: pointer;
}
.option-btn:active { transform: translateY(4px); box-shadow: none; }

.correct { background: linear-gradient(180deg, #43a047, #2e7d32) !important; color: white !important; font-weight: bold; border-color: #1b5e20; }
.wrong { background: linear-gradient(180deg, #e53935, #c62828) !important; border-color: #b71c1c; }

.progress-track { position: absolute; top: 80px; left: 20px; right: 20px; height: 10px; background: rgba(0,0,0,0.5); border-radius: 10px; overflow: hidden; border: 1px solid #5d4037; }
.progress-fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.5s; box-shadow: 0 0 10px var(--accent); }

/* --- الجوكر والنتائج --- */
.powerups-bar { display: flex; gap: 15px; margin-bottom: 20px; width: 100%; justify-content: center; }
.powerup-btn { 
    width: 50px; height: 50px; border-radius: 50%; 
    background: linear-gradient(135deg, #ffca28, #ff6f00); 
    border: 2px solid #fff; 
    font-size: 1.2rem; cursor: pointer; display: flex; align-items: center; justify-content: center; 
    box-shadow: 0 0 10px rgba(255, 111, 0, 0.5); 
    color: #3e2723;
}
.powerup-btn:disabled { filter: grayscale(1); opacity: 0.5; }

.score-circle { 
    width: 160px; height: 160px; border-radius: 50%; 
    background: conic-gradient(var(--accent) 0%, transparent 0%); 
    display: flex; align-items: center; justify-content: center; 
    font-size: 3rem; font-weight: 900; margin-bottom: 20px; position: relative; 
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}
.score-circle::before { content: ''; position: absolute; width: 140px; height: 140px; background: var(--bg-color); border-radius: 50%; }
.score-circle span { position: relative; z-index: 2; color: var(--text-color); }

/* --- القوائم المنبثقة وصفحة المطور --- */
.overlay { 
    position: fixed; 
    top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0,0,0,0.9); 
    backdrop-filter: blur(10px); 
    z-index: 9999; 
    display: none; 
    flex-direction: column; align-items: center; justify-content: center; 
    animation: fadeIn 0.2s; 
}

.pause-menu-box { 
    width: 80%; max-width: 300px; 
    background: var(--card-bg); /* خلفية خشبية */
    border: 2px solid #8d6e63;
    padding: 20px; border-radius: 20px;
    display: flex; flex-direction: column; gap: 15px; text-align: center; 
}
.pause-btn { position: absolute; top: 20px; left: 20px; background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.2); color: white; font-size: 1.2rem; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; z-index: 20; display: flex; align-items: center; justify-content: center; }

/* تنسيق صفحة المطور */
.about-content { text-align: center; color: white; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; }
.studio-logo-modal { width: 120px; height: auto; margin-bottom: 20px; border-radius: 15px; box-shadow: 0 5px 20px rgba(255, 111, 0, 0.3); object-fit: contain;}
.studio-name { color: var(--studio-color); font-size: 1.5rem; font-weight: 900; margin: 0 0 5px 0; letter-spacing: 1px; text-shadow: 1px 1px 0 #000; }
.dev-name { color: #aaa; margin: 0 0 20px 0; font-size: 0.9rem; }
.social-links { display: flex; justify-content: center; gap: 20px; margin: 20px 0; }
.social-btn { width: 50px; height: 50px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; color: white; text-decoration: none; background: rgba(255,255,255,0.1); transition: 0.3s; }
.social-btn:hover { transform: translateY(-5px); background: var(--primary); }
.studio-footer { position: absolute; bottom: 15px; width: 100%; text-align: center; font-size: 0.75rem; color: #3E2723; /* لون غامق للخلفية الفاتحة */ letter-spacing: 1px; font-weight: bold; }
.studio-footer span { color: #000; font-weight: 900; }

/* --- خلفية شاشة الإعدادات --- */
#screen-settings {
    background-image: url('settings_bg.jpg') !important; 
    background-size: cover; background-position: center; background-repeat: no-repeat;
}

/* تنسيق الجمل والشعارات */
.logo-area p {
    color: #ffd700 !important; font-weight: 900; font-size: 1.2rem; margin-top: 5px;
    text-shadow: 2px 2px 0 #000; background-color: rgba(0, 0, 0, 0.3);
    padding: 5px 15px; border-radius: 20px; display: inline-block; 
}

/* --- تنسيق شاشة الأنماط (Modes) --- */
.modes-container { display: flex; flex-direction: column; gap: 15px; padding: 10px; margin-top: 10px; }
.mode-card {
    background: linear-gradient(90deg, rgba(93, 64, 55, 0.8) 0%, rgba(62, 39, 35, 0.9) 100%);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 15px; padding: 15px; display: flex; align-items: center; gap: 15px;
    cursor: pointer; transition: transform 0.2s, background 0.2s; position: relative; overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}
.mode-card:active { transform: scale(0.98); }
.mode-card:hover { border-color: #ffd700; background: rgba(93, 64, 55, 1); }

/* ألوان خاصة لحدود الكروت */
.mode-time { border-right: 5px solid #ef5350; }
.mode-cats { border-right: 5px solid #8b4513; }
.mode-perfect { border-right: 5px solid #ffd700; }

.mode-img { width: 60px; height: 60px; object-fit: contain; filter: drop-shadow(0 0 5px rgba(0,0,0,0.5)); }
.mode-info h3 { margin: 0; font-size: 1.2rem; color: var(--text-color); text-shadow: 1px 1px 0 #000; }
.mode-info p { margin: 5px 0 0; font-size: 0.8rem; color: #d7ccc8; }

/* --- تنسيق شاشة التصنيفات (Topics Grid) --- */
.topics-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; padding: 15px; }
.topic-item {
    background: rgba(62, 39, 35, 0.9);
    border-radius: 15px; padding: 20px 10px; text-align: center; cursor: pointer;
    border: 1px solid rgba(255,255,255,0.1); transition: 0.2s;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}
.topic-item:hover {
    background: linear-gradient(180deg, #5d4037, #4e342e);
    transform: translateY(-5px); border-color: #fff;
}
.topic-item img { width: 50px; height: 50px; object-fit: contain; }
.topic-item span { font-weight: bold; font-size: 1rem; color: var(--text-color); }

/* --- تنسيقات نمط صراع الوقت (جديد) --- */
.timer-display {
    font-size: 1.8rem;
    font-weight: 900;
    color: #fff;
    background: rgba(0,0,0,0.6);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid #ffca28;
    box-shadow: 0 0 15px rgba(255, 202, 40, 0.3);
    text-shadow: 2px 2px 0 #000;
    font-family: 'Montserrat', sans-serif;
}

/* حركة عند الخطر (الوقت أقل من 10) */
.timer-danger {
    color: #ff5252;
    border-color: #ff5252;
    animation: dangerPulse 0.5s infinite alternate;
}
@keyframes dangerPulse {
    from { transform: scale(1); box-shadow: 0 0 10px #ff5252; }
    to { transform: scale(1.1); box-shadow: 0 0 25px #ff5252; }
}

/* حركة عند إضافة وقت */
.anim-add-time { animation: popGreen 0.3s ease-out; color: #4CAF50 !important; border-color: #4CAF50 !important; }
@keyframes popGreen { 50% { transform: scale(1.3); } }

/* حركة عند خصم وقت */
.anim-sub-time { animation: shakeRed 0.3s ease-out; color: #f44336 !important; border-color: #f44336 !important; }
@keyframes shakeRed { 
    0%, 100% { transform: translateX(0); } 
    25% { transform: translateX(-5px); } 
    75% { transform: translateX(5px); } 
}