/* =============================================================== */
/* ===== زِدْني - التصميم الاحترافي ===== */
/* =============================================================== */

:root {
    --bg: #F8F9FA;
    --surface: #ffffff;
    --text: #1E293B;
    --text-muted: #64748B;
    --text-light: #94A3B8;
    --primary: #800020;
    --primary-dark: #6B001B;
    --primary-glow: rgba(128, 0, 32, 0.2);
    --btn-bg: #E2E8F0;
    --btn-hover: #D1D5DB;
    --correct: #22C55E;
    --correct-bg: #F0FDF4;
    --wrong: #EF4444;
    --wrong-bg: #FEF2F2;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.1);
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    --font: 'Tajawal', 'Cairo', sans-serif;
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ===== إعلان Adsterra: Banner 728x90 ===== */

.ad-header {
    width: 100%;
    max-width: 728px;
    min-height: 90px;
    margin: 6px auto;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #e9ecef, #f1f3f5);
    border-radius: var(--radius-md);
    overflow: hidden;
}

/* ===== الحاوية الرئيسية ===== */

.game-wrapper {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-container {
    width: 100%;
    max-width: 700px;
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 32px 32px 40px;
    position: relative;
    min-height: 480px;
    transition: min-height 0.4s ease;
    border: 1px solid rgba(0,0,0,0.04);
}

/* ===== الشاشات ===== */

.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    animation: fadeIn 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.screen.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =============================================================== */
/* ===== شاشة البداية ===== */
/* =============================================================== */

.logo-area {
    text-align: center;
    margin-bottom: 24px;
    position: relative;
}

.logo-area::after {
    content: '';
    display: block;
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    margin: 16px auto 0;
    border-radius: 4px;
}

.logo-icon {
    font-size: 4rem;
    margin-bottom: 8px;
    line-height: 1;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
}

.game-title {
    font-size: 2rem;
    font-weight: 900;
    color: var(--text);
    margin-bottom: 6px;
    letter-spacing: -0.5px;
}

.game-subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ===== منتقي عدد الأسئلة ===== */

.section-label {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    text-align: center;
}

.count-section {
    width: 100%;
    margin-bottom: 20px;
}

.count-group {
    display: flex;
    gap: 8px;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
}

.count-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    min-width: 52px;
    background: var(--btn-bg);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 800;
    color: var(--text);
    transition: all 0.25s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.count-btn:hover {
    background: #D1D5DB;
    transform: translateY(-2px);
}

.count-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 4px 14px var(--primary-glow);
}

/* ===== أزرار التصنيفات ===== */

.categories-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
}

.category-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 20px 14px;
    background: var(--btn-bg);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    overflow: hidden;
}

.category-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 40%, rgba(128,0,32,0.03));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.category-btn:hover {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: 0 10px 28px var(--primary-glow);
}

.category-btn:hover::before {
    opacity: 1;
}

.category-btn:active {
    transform: translateY(-1px);
}

.cat-icon {
    font-size: 2rem;
    line-height: 1;
    transition: transform 0.3s ease;
}

.category-btn:hover .cat-icon {
    transform: scale(1.15);
}

.cat-name {
    font-size: 0.88rem;
    font-weight: 800;
}

.cat-badge {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-light);
    background: rgba(0,0,0,0.06);
    padding: 2px 10px;
    border-radius: 20px;
    transition: all 0.25s ease;
}

.category-btn:hover .cat-badge {
    color: #fff;
    background: rgba(255,255,255,0.2);
}

/* =============================================================== */
/* ===== شاشة اللعب ===== */
/* =============================================================== */

.game-header {
    width: 100%;
    margin-bottom: 18px;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.score-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
}

.score-label {
    font-size: 0.75rem;
    color: var(--text-light);
}

#scoreDisplay {
    color: var(--primary);
    font-weight: 900;
    font-size: 1.3rem;
    min-width: 24px;
    text-align: center;
    transition: all 0.3s ease;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--btn-bg);
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 6px;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), #B3364A);
    border-radius: 20px;
    transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.game-meta {
    display: flex;
    justify-content: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 600;
}

.question-count-label {
    color: var(--primary);
}

/* ===== صندوق الصورة ===== */

.image-container {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, #F1F5F9, #F8FAFC);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
    position: relative;
    border: 1px solid rgba(0,0,0,0.04);
}

#questionImage {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-sm);
    transition: opacity 0.4s ease;
}

.image-placeholder {
    font-size: 3.5rem;
    opacity: 0.4;
}

/* ===== نص السؤال ===== */

.question-text {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    text-align: center;
    margin-bottom: 18px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.6;
    padding: 0 4px;
}

/* ===== الخيارات ===== */

.options-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    margin-bottom: 18px;
}

.option-btn {
    padding: 14px 16px;
    background: var(--btn-bg);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    transition: all 0.2s ease;
    text-align: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.option-btn:hover:not(.disabled) {
    background: #D1D5DB;
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.option-btn:active:not(.disabled) {
    transform: translateY(0);
}

.option-btn.correct {
    background: var(--correct);
    color: #fff;
    border-color: var(--correct);
    animation: pulseCorrect 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 4px 16px rgba(34,197,94,0.3);
}

.option-btn.wrong {
    background: var(--wrong);
    color: #fff;
    border-color: var(--wrong);
    animation: shakeWrong 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 4px 16px rgba(239,68,68,0.3);
}

.option-btn.disabled {
    cursor: not-allowed;
    opacity: 0.8;
    pointer-events: none;
}

.option-btn.correct.disabled,
.option-btn.wrong.disabled {
    opacity: 1;
}

@keyframes pulseCorrect {
    0% { transform: scale(1); }
    50% { transform: scale(1.04); }
    100% { transform: scale(1); }
}

@keyframes shakeWrong {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

/* ===== النبذة التثقيفية ===== */

.explanation-area {
    width: 100%;
    margin-bottom: 14px;
}

.explanation-box {
    background: linear-gradient(135deg, #FFF7ED, #FFFBEB);
    border: 1px solid #FED7AA;
    border-radius: var(--radius-md);
    padding: 16px 18px;
    margin-bottom: 10px;
    animation: fadeIn 0.4s ease;
}

.explanation-header {
    font-weight: 800;
    font-size: 0.85rem;
    color: #9A3412;
    margin-bottom: 8px;
}

.explanation-content {
    font-size: 0.88rem;
    color: #431407;
    line-height: 1.7;
    font-weight: 500;
}

/* ===== إعلان Adsterra: Native Ad ===== */

.ad-native {
    width: 100%;
    min-height: 60px;
    background: linear-gradient(135deg, #F1F5F9, #F8FAFC);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    overflow: hidden;
}

/* ===== زر السؤال التالي ===== */

.next-btn {
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #ffffff;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font);
    font-size: 1.05rem;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.next-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px var(--primary-glow);
}

.next-btn:active {
    transform: translateY(0);
}

.next-arrow {
    font-size: 1.2rem;
    transition: transform 0.2s ease;
}

.next-btn:hover .next-arrow {
    transform: translateX(-4px);
}

/* =============================================================== */
/* ===== شاشة النتيجة ===== */
/* =============================================================== */

.result-box {
    text-align: center;
    padding: 16px 0 8px;
    width: 100%;
}

.result-header {
    margin-bottom: 20px;
}

.result-icon {
    font-size: 4rem;
    margin-bottom: 6px;
    line-height: 1;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.1));
}

.result-title {
    font-size: 1.7rem;
    font-weight: 900;
    color: var(--text);
}

/* ===== دائرة النتيجة ===== */

.result-score-ring {
    position: relative;
    width: 140px;
    height: 140px;
    margin: 0 auto 16px;
}

.score-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring-bg {
    fill: none;
    stroke: var(--btn-bg);
    stroke-width: 8;
}

.ring-fill {
    fill: none;
    stroke: var(--primary);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 326.7;
    stroke-dashoffset: 326.7;
    transition: stroke-dashoffset 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.score-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    font-weight: 900;
    color: var(--primary);
    direction: ltr;
}

.result-details {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 10px;
}

.result-details span {
    color: var(--primary);
    font-weight: 800;
}

.result-message {
    font-size: 1.05rem;
    color: var(--text-muted);
    margin-bottom: 22px;
    font-weight: 500;
    padding: 0 10px;
}

/* ===== إعلان Adsterra: Banner 300x250 ===== */

.ad-result {
    width: 100%;
    max-width: 300px;
    min-height: 250px;
    background: linear-gradient(135deg, #F1F5F9, #F8FAFC);
    border-radius: var(--radius-md);
    margin: 0 auto 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.play-again-btn {
    padding: 16px 36px;
    background: var(--text);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font);
    font-size: 1.05rem;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.play-again-btn:hover {
    background: #0F172A;
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(30,41,59,0.25);
}

.play-again-btn:active {
    transform: translateY(0);
}

.btn-icon {
    font-size: 1.1rem;
}

/* =============================================================== */
/* ===== شاشة التحميل ===== */
/* =============================================================== */

.loading-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(4px);
    border-radius: var(--radius-xl);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    gap: 18px;
}

.loading-overlay.active {
    display: flex;
}

.loading-overlay p {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
}

.spinner {
    width: 44px;
    height: 44px;
    border: 4px solid var(--btn-bg);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =============================================================== */
/* ===== التجاوب مع الجوال ===== */
/* =============================================================== */

@media (max-width: 640px) {
    body { padding: 6px; }

    .game-container {
        padding: 20px 14px 28px;
        border-radius: var(--radius-lg);
        min-height: 400px;
    }

    .game-title { font-size: 1.4rem; }
    .logo-icon { font-size: 3.2rem; }
    .logo-area::after { width: 40px; margin-top: 12px; }

    .count-group { gap: 6px; }
    .count-btn { padding: 8px 14px; min-width: 44px; font-size: 0.9rem; }

    .categories-grid { gap: 10px; }
    .category-btn { padding: 16px 10px; }
    .cat-icon { font-size: 1.6rem; }
    .cat-name { font-size: 0.8rem; }
    .cat-badge { font-size: 0.55rem; }

    .question-text { font-size: 1.05rem; min-height: 40px; }
    .options-container { gap: 8px; }
    .option-btn { padding: 12px 12px; font-size: 0.9rem; min-height: 44px; }
    .image-container { height: 150px; }

    .game-info { font-size: 0.8rem; }
    #scoreDisplay { font-size: 1.1rem; }

    .result-icon { font-size: 3.2rem; }
    .result-title { font-size: 1.3rem; }
    .result-score-ring { width: 110px; height: 110px; }
    .score-text { font-size: 1.5rem; }
    .result-message { font-size: 0.95rem; }

    .ad-header { min-height: 70px; }
    .next-btn { font-size: 0.95rem; padding: 14px 20px; }
    .play-again-btn { font-size: 0.95rem; padding: 14px 28px; }

    .section-label { font-size: 0.75rem; }
}

@media (max-width: 400px) {
    .game-container { padding: 16px 10px 22px; }
    .categories-grid { gap: 8px; }
    .category-btn { padding: 12px 8px; }
    .cat-icon { font-size: 1.4rem; }
    .options-container { gap: 6px; }
    .option-btn { padding: 10px 8px; font-size: 0.85rem; min-height: 40px; }
    .image-container { height: 120px; }
    .count-group { gap: 4px; }
    .count-btn { padding: 6px 10px; min-width: 38px; font-size: 0.85rem; }
}

@media (min-width: 1200px) {
    .game-container { padding: 40px 40px 50px; }
    .question-text { font-size: 1.3rem; }
    .image-container { height: 220px; }
}
