/* =====================================================
   QUIZ SCREEN - SAFE CENTERING FIX (NO CLIP)
   ===================================================== */

#quiz-screen.active {
    display: flex !important;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* התאמה למובייל */
    overflow: hidden; /* חוסם גלילה חיצונית */
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
    font-family: 'Heebo', sans-serif;
    z-index: 9999;
}

/* === 1. Header (למעלה) === */
#quiz-screen .quiz-header {
    flex-shrink: 0;
    order: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    height: 55px;
    background: rgba(15, 23, 42, 0.98);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    z-index: 20;
}

/* === 2. Progress Bar === */
#quiz-screen .quiz-progress-bar {
    flex-shrink: 0;
    order: 2;
    height: 4px;
    background: rgba(255,255,255,0.1);
}

/* === 3. Content (התיקון הגדול - מרכוז בטוח) === */
#quiz-screen .quiz-content {
    flex: 1; /* תופס את כל הגובה הפנוי */
    order: 3;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    
    padding: 10px 15px;
    
    /* קריטי: מתחילים מלמעלה כדי למנוע חיתוך! */
    justify-content: flex-start; 
    
    overflow-y: auto; 
    overflow-x: hidden;
    
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* === 4. Footer Buttons (מעל הפרסומת) === */
#quiz-screen .quiz-footer {
    flex-shrink: 0;
    order: 10 !important; 
    position: relative !important;
    padding: 10px 15px;
    background: #0f172a;
    border-top: 1px solid rgba(255,255,255,0.05);
    display: flex;
    gap: 12px;
    z-index: 100;
}

#quiz-screen .quiz-footer .btn {
    height: 48px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    flex: 1;
    display: flex; align-items: center; justify-content: center;
}

/* === 5. Ad Container (הכי למטה) === */
#sticky-ad-container {
    flex-shrink: 0;
    order: 20 !important;
    position: relative !important;
    width: 100% !important;
    min-height: 55px;
    background: #000;
    display: flex !important;
    justify-content: center;
    align-items: center;
    z-index: 200;
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

/* =========================================
   רכיבים פנימיים - מרכוז באמצעות Margins
   ========================================= */

/* שאלה */
#quiz-screen .question-card { 
    flex-shrink: 0;
    text-align: center;
    padding: 0 5px;
    
    /* דוחף את התוכן למטה אם יש מקום (מרכוז) */
    margin-top: auto; 
}

#quiz-screen .question-text {
    font-size: clamp(1.1rem, 2.5vh, 1.4rem); 
    font-weight: 700;
    line-height: 1.35;
    color: #fff;
    margin: 0;
}

/* === תמונה חכמה === */
#quiz-screen .question-image-wrap {
    display: none;
    width: 100%;
    border-radius: 12px;
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.05);
    position: relative;
    overflow: hidden;
}

/* כשיש תמונה - היא גמישה אך מוגבלת */
#quiz-screen .question-image-wrap.visible {
    display: flex;
    /* שיניתי ל-flex: 0 כדי לא "לדרוס" את המרכוז */
    flex: 0 1 auto; 
    min-height: 120px;
    max-height: 35vh; /* מקסימום 35% מהמסך */
    margin: 5px 0;
    justify-content: center;
    align-items: center;
}

#quiz-screen .question-image-wrap img {
    object-fit: contain;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
}

/* תשובות */
#quiz-screen .answers-area {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    
    /* דוחף את התוכן למעלה אם יש מקום (מרכוז) */
    margin-bottom: auto; 
}

#quiz-screen .answer-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    min-height: 50px;
    transition: background 0.2s;
}

#quiz-screen .answer-btn:active { background: rgba(255,255,255,0.1); transform: scale(0.98); }

#quiz-screen .answer-letter {
    width: 28px; height: 28px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem;
    color: var(--primary-light); flex-shrink: 0;
}

#quiz-screen .answer-text {
    flex: 1;
    font-size: 1rem;
    color: #e2e8f0;
    line-height: 1.25;
}

/* צבעים */
#quiz-screen .answer-btn.correct { border-color: #10b981; background: rgba(16,185,129,0.15); }
#quiz-screen .answer-btn.correct .answer-letter { background: #10b981; color: white; }
#quiz-screen .answer-btn.wrong { border-color: #ef4444; background: rgba(239,68,68,0.15); }
#quiz-screen .answer-btn.wrong .answer-letter { background: #ef4444; color: white; }

/* זכוכית מגדלת */
#quiz-screen .btn-zoom {
    position: absolute; bottom: 8px; left: 8px; width: 34px; height: 34px;
    background: rgba(0,0,0,0.6); border-radius: 50%; border: 1px solid rgba(255,255,255,0.3);
    color: #fff; display: flex; align-items: center; justify-content: center; z-index: 10;
}

/* התאמות למסכים קטנים */
@media (max-height: 650px) {
    #quiz-screen .question-text { font-size: 1rem; }
    #quiz-screen .answer-btn { min-height: 42px; padding: 8px 12px; }
    #quiz-screen .quiz-footer { padding: 8px 15px; }
    #quiz-screen .question-image-wrap.visible { max-height: 28vh; }
}