/* --- 1. إعدادات الصفحة العامة --- */
body {
    font-family: system-ui, sans-serif;
    color: #1D2128;
    background-color: #EEEEEE;
    background: linear-gradient(to bottom, #DDDDDD, #ffffff);
    margin: 0;         /* حل مشكلة الفراغ فوق الهيدر وسقفه */
    padding: 0;
    direction: rtl;    /* ضبط اتجاه الموقع بالكامل للعربية */
}

/* التنسيق الافتراضي العام للأزرار */
button {
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid #DDDDDD;
    cursor: pointer;
    background-color: #0fb86c;
}

/* --- 2. تنسيقات الهيدر (Header) --- */
.header {
    background-color: #0fb86c;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); 
    width: 100%;
    color: white;
    font-size: 16px;
    position: relative;
    z-index: 1000;
}

.hcontainer {
    display: flex;
    justify-content: space-between; 
    align-items: center;           
    max-width: 1200px;             
    margin: 0 auto;                
    padding: 15px 20px; /* مسافة داخلية متوازنة تعطي حماية للهيدر */
    box-sizing: border-box;
}

.navlist {
    display: flex;
    list-style: none; 
    padding: 0;
    margin: 0;
    gap: 25px; 
}

.navlist a {
    color: #ffffff;
    text-decoration: none;
    font-size: 18px;
    font-weight: 500;
}

/* تنسيق اسم الموقع في الهيدر */
.icon {
    color: #ffffff;
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    display: flex;
    align-items: center;
}

/* حل مشكلة التحكم بحجم الأيقونة */
.icon img {
    height: 30px;  /* يمكنك الآن تكبيرها وتصغيرها بحرية من هنا وسيتحرك الهيدر معها */
    width: 150px;        
    display: block;
}

/* --- 3. قسم شريط البحث (Search Section) --- */
.sbar {
    text-align: center;
    border: 1px solid #DDDDDD;
    border-radius: 20px;
    padding: 30px;
    background-color: #ffffff;
    margin: auto;
    margin-top: 25px;
    max-width: 1000px;
    min-height: 180px; /* استخدام min-height أفضل هندسياً من height الثابتة */
    box-sizing: border-box;
}

/* الحاوية المتلاحمة التي تجمع الحقل والزر معاً */
.sbox {
    display: flex;
    align-items: center;
    background-color: #ffffff; 
    border: 2px solid #12cf7a; 
    border-radius: 50px;       
    padding: 3px; /* حشو داخلي خفيف يعطي مساحة تنفس للزر بالداخل */
    max-width: 500px;          
    margin: 25px auto;   
    height: 50px; /* تثبيت ارتفاع شريط البحث ليصبح متناسقاً وعصرياً */
    box-sizing: border-box;
    overflow: hidden; /* لمنع بروز حواف الزر الحادة */
}

/* تنسيق حقل الإدخال النصي */
.sbox input[type="search"] {
    border: none; 
    background: transparent;   
    padding: 0 20px;        
    font-size: 16px;
    flex: 1;                   
    outline: none;             
    color: #333;
    height: 100%;
}

/* حل مشكلة نص زر البحث النازل لأسفل */
.sbox button {
    display: inline-flex;  /* استخدام الفليكس لضمان توسيط النص بشكل كامل */
    justify-content: center;
    align-items: center;
    background-color: #12cf7a; 
    color: white;
    border: none;
    padding: 0 25px;       /* إلغاء الـ padding العلوي والاعتماد على الارتفاع الكامل */
    height: 100%;          /* جعل الزر يملأ ارتفاع الـ sbox تماماً */
    border-radius: 50px;       
    cursor: pointer;
    font-size: 16px;       /* حجم خط متناسق مع ارتفاع الـ 50px */
    font-weight: bold;
    transition: background 0.2s ease;
}

.sbox button:hover {
    background-color: #0fb86c; 
}

/* --- 4. قسم أحدث الألعاب --- */
.news {
    text-align: right;
    border: 1px solid #DDDDDD;
    border-radius: 20px;
    padding: 30px;
    background-color: #ffffff;
    margin: auto;
    margin-top: 20px;
    margin-bottom: 40px; /* إضافة هامش سفلي لمنع الالتصاق بنهاية الشاشة */
    max-width: 1000px;
    box-sizing: border-box;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
}

.section-head h2 {
    margin: 0;
    font-size: 22px;
}

.show-more-btn {
    background-color: #12cf7a;
    color: white;
    border: none;
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(70px, 1fr));
    gap: 12px;
    align-items: stretch;
}

.game-card {
    background: #f9f9f9;
    border: 1px solid #e5e5e5;
    border-radius: 14px;
    padding: 10px 8px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    min-width: 0;
    display: block;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}

.game-icon {
    width: 100%;
    max-width: 62px;
    height: 62px;
    object-fit: cover;
    border-radius: 14px;
    margin-bottom: 8px;
}

.game-title {
    font-size: 13px;
    margin: 0 0 8px;
    color: #1D2128;
}

.download-btn {
    display: inline-block;
    background-color: #0fb86c;
    color: white;
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.download-btn:hover {
    background-color: #0aa55d;
}

/* --- التنسيق العادي للحاسوب --- */
.hamburger {
    display: none; /* إخفاء الزر تماماً في الشاشات الكبيرة */
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
}

/* ==================== [ 5. تنسيق شاشات الهاتف المحسن ] ==================== */
@media (max-width: 768px) {
    .header {
        position: relative;
    }

    .hcontainer {
        position: relative;
        padding: 12px 16px;
    }

    .hamburger {
        display: block; /* إظهار زر القائمة في الجوال */
    }

    /* القائمة المنسدلة الاحترافية بعرض الشاشة الكامل */
    nav#nav-menu {
        display: none; /* مخفية افتراضياً */
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        width: 100%;
        background-color: #0fb86c;
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
        border-radius: 0 0 16px 16px;
        z-index: 9999;
        padding: 10px 0;
    }

    /* عندما تفعيل القائمة عبر الجافاسكربت */
    nav#nav-menu.active {
        display: block !important;
    }

    .navlist {
        flex-direction: column;
        gap: 0;
        padding: 0;
        margin: 0;
        background-color: transparent;
    }

    .navlist li {
        width: 100%;
        text-align: center;
    }

    .navlist a {
        display: block;
        padding: 12px 20px;
        color: #ffffff;
        font-size: 16px;
        font-weight: 600;
        border-bottom: 1px solid rgba(255, 255, 255, 0.15);
        box-sizing: border-box;
    }

    .navlist li:last-child a {
        border-bottom: none;
    }

    .navlist a:hover {
        background-color: rgba(255, 255, 255, 0.1);
    }

    /* باقي تعديلات الجوال */
    .sbar {
        padding: 20px 16px;
        margin-top: 15px;
    }

    .sbox {
        width: 100%;
        max-width: none;
        height: 48px;
        margin: 20px auto 0;
    }

    .sbox input[type="search"] {
        padding: 0 15px;
        font-size: 14px;
    }

    .sbox button {
        padding: 0 18px;
        font-size: 14px;
    }

    .news {
        padding: 20px 16px;
    }

    .games-grid {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        padding-bottom: 6px;
        gap: 12px;
    }

    .game-card {
        flex: 0 0 calc(33.333% - 8px);
        min-width: calc(33.333% - 8px);
        scroll-snap-align: start;
    }

    .game-icon {
        max-width: 56px;
        height: 56px;
    }

    .game-title {
        font-size: 12px;
    }

    .download-btn {
        padding: 5px 8px;
        font-size: 11px;
    }
}