body {
    background: radial-gradient(circle at center, #001a33 0%, #000 100%);
    color: white; 
    direction: rtl; 
    display: flex; 
    margin: 0;
    font-family: 'Segoe UI', system-ui, sans-serif; 
    height: 100vh; 
    overflow: hidden;
    position: relative;
}

/* Sidebar (Gains List) */
#gains-liste-container { 
    width: 220px; 
    background: rgba(0, 15, 30, 0.95); 
    padding: 20px; 
    border-left: 2px solid #0099ff; 
    display: flex;
    flex-direction: column;
    justify-content: center;
    z-index: 500;
    transition: transform 0.3s ease;
}

#gains-liste {
    padding: 0;
    margin: 0;
}

#gains-liste li { 
    list-style: none; 
    padding: 6px; 
    color: #ffa500; 
    opacity: 0.5; 
    font-size: 0.95rem; 
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.active-gain { 
    opacity: 1 !important; 
    color: white !important; 
    background: #0099ff; 
    border-radius: 5px; 
    font-weight: bold; 
    transform: scale(1.05);
    padding-right: 10px !important;
}

/* Toggle Buttons for Mobile */
#toggle-gains-btn { display: none; }
.close-btn-mobile { display: none; }

/* Main Wrapper */
#main-wrapper { 
    flex-grow: 1; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    padding: 0 5%; 
    overflow-y: auto; /* Allow scrolling if vertical content overflows */
}

#jeu-container { 
    width: 100%; 
    max-width: 1000px; 
    text-align: center; 
    position: relative; 
}

/* Game Info Bar */
#info-barre { 
    background: rgba(255,255,255,0.08); 
    padding: 15px; 
    border-radius: 15px; 
    margin-bottom: 20px; 
    display: flex; 
    justify-content: space-around; 
    border: 1px solid rgba(0,153,255,0.3); 
    backdrop-filter: blur(5px);
}
#chrono-container { color: #ffcc00; font-weight: bold; }

/* Buttons */
.menu-btn, .reponse-btn {
    background: linear-gradient(145deg, #004d99, #003366);
    border: 2px solid #0099ff; 
    color: white; 
    padding: 18px;
    margin: 10px; 
    border-radius: 15px; 
    cursor: pointer; 
    font-size: 1.2rem;
    width: 45%; 
    transition: 0.2s;
    /* Ensure text wrapping */
    white-space: normal;
    line-height: 1.4;
}
.reponse-btn:active, .menu-btn:active { transform: scale(0.98); }
.reponse-btn:hover { 
    box-shadow: 0 0 20px rgba(0, 153, 255, 0.6); 
    transform: translateY(-2px); 
    border-color: white; 
}

/* Question Text */
#question-texte {
    font-size: 1.8rem;
    margin-bottom: 30px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    line-height: 1.4;
}

/* Jokers */
.joker-btn { 
    width: 60px; height: 60px; 
    border-radius: 50%; 
    background: #1a1a1a; 
    border: 2px solid #ffcc00; 
    color: #ffcc00; 
    margin: 0 10px; 
    cursor: pointer; 
    font-size: 1.4rem; 
    transition: 0.3s; 
    margin-bottom: 20px;
}
.joker-btn:hover { background: #ffcc00; color: black; box-shadow: 0 0 15px #ffcc00; }

/* Animations & Feedback */
.feedback-emoji { 
    display: none; position: absolute; top: 30%; left: 45%; 
    font-size: 120px; z-index: 100; pointer-events: none; 
}
.show-fade { display: block !important; animation: popAndFade 1.2s forwards; }

@keyframes popAndFade { 
    0% { transform: scale(0.5); opacity: 0; } 
    50% { transform: scale(1.2); opacity: 1; } 
    100% { transform: scale(1.5); opacity: 0; } 
}

/* Overlays */
.overlay { 
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0,0,0,0.9); z-index: 1000; 
    justify-content: center; align-items: center; 
    backdrop-filter: blur(8px); 
}
.fade-in { animation: fadeIn 0.5s forwards; }
.fade-out { animation: fadeOut 0.5s forwards; }
@keyframes fadeIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
@keyframes fadeOut { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(0.9); } }

.overlay-content { 
    background: #001a33; padding: 40px; border-radius: 30px; 
    border: 3px solid #0099ff; text-align: center; 
    width: 90%; max-width: 500px; 
    box-shadow: 0 20px 50px rgba(0,0,0,0.5); 
}
.win-box { border-color: #ffcc00; box-shadow: 0 0 40px rgba(255, 204, 0, 0.4); }
.menu-btn-small { 
    background: #004d99; color: white; 
    border: 1px solid #0099ff; padding: 10px 30px; 
    border-radius: 10px; cursor: pointer; margin-top: 20px;
}

/* ================= MOBILE RESPONSIVENESS ================= */
@media (max-width: 768px) {
    /* Switch to Column Layout */
    body { flex-direction: column; overflow-y: auto; }
    
    /* Hide Sidebar by default (Slide-in Drawer) */
    #gains-liste-container {
        position: fixed;
        top: 0; right: 0;
        height: 100%;
        width: 250px;
        transform: translateX(100%); /* Hidden to the right (RTL) */
        border-left: 2px solid #0099ff;
        box-shadow: -5px 0 20px rgba(0,0,0,0.5);
    }
    #gains-liste-container.show-drawer {
        transform: translateX(0);
    }

    /* Mobile Toggle Button */
    #toggle-gains-btn {
        display: block;
        position: absolute;
        top: 15px; left: 15px;
        z-index: 600;
        background: transparent;
        border: 1px solid #0099ff;
        color: #0099ff;
        padding: 5px 10px;
        border-radius: 5px;
        cursor: pointer;
    }

    .close-btn-mobile {
        display: block;
        background: none; border: none;
        color: white; font-size: 30px;
        position: absolute; top: 10px; left: 15px;
        cursor: pointer;
    }

    /* Main Area Adjustments */
    #main-wrapper { 
        padding: 60px 15px 20px; /* Top padding for toggle button */
        align-items: flex-start; /* Start from top on mobile */
    }

    /* Buttons Stack Vertically */
    .menu-btn, .reponse-btn {
        width: 100%;
        margin: 8px 0;
        padding: 15px;
        font-size: 1rem;
    }

    /* Joker Bar */
    .joker-btn { width: 50px; height: 50px; font-size: 1.2rem; }

    /* Typography */
    h1#menu-title { font-size: 1.5rem; }
    #question-texte { font-size: 1.3rem; margin-bottom: 20px; }
    
    /* Overlay Adjustment */
    .overlay-content { padding: 20px; width: 85%; }
    
    /* Feedback Icon */
    .feedback-emoji { left: 35%; font-size: 80px; }
}