/* Variables et reset */
:root {
    --blue: #0055A4;
    --white: #FFFFFF;
    --red: #EF4135;
    --light-blue: #E8F0F8;
    --dark-blue: #003366;
    --success: #28A745;
    --error: #DC3545;
    --gray: #6C757D;
    --light-gray: #F8F9FA;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--light-gray);
    color: #333;
    min-height: 100vh;
}

/* Écrans */
.screen {
    display: none;
    min-height: 100vh;
    padding: 20px;
}

.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.container {
    max-width: 700px;
    width: 100%;
    margin: 0 auto;
}

/* Logo tricolore */
.logo {
    margin: 20px auto 30px;
}

.tricolor {
    display: flex;
    width: 120px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
    margin: 0 auto;
}

.tricolor .blue {
    flex: 1;
    background-color: var(--blue);
}

.tricolor .white {
    flex: 1;
    background-color: var(--white);
}

.tricolor .red {
    flex: 1;
    background-color: var(--red);
}

/* Titres */
h1 {
    font-size: 2rem;
    color: var(--dark-blue);
    text-align: center;
    margin-bottom: 10px;
}

.subtitle {
    text-align: center;
    color: var(--gray);
    font-size: 1.1rem;
    margin-bottom: 30px;
}

h2 {
    font-size: 1.3rem;
    color: var(--dark-blue);
    margin-bottom: 15px;
}

/* Boîte des règles */
.rules-box {
    background: var(--white);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--blue);
}

.rules-box ul {
    list-style: none;
    padding-left: 0;
}

.rules-box li {
    padding: 8px 0;
    padding-left: 25px;
    position: relative;
    font-size: 1rem;
}

.rules-box li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success);
    font-weight: bold;
}

/* Sélection du niveau */
.level-selection {
    margin-bottom: 30px;
}

.level-selection h2 {
    text-align: center;
}

.level-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.level-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 30px;
    border: 3px solid var(--light-blue);
    border-radius: 12px;
    background: var(--white);
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 200px;
}

.level-btn:hover {
    border-color: var(--blue);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.level-btn.selected {
    border-color: var(--blue);
    background: var(--light-blue);
}

.level-name {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--blue);
}

.level-desc {
    font-size: 0.85rem;
    color: var(--gray);
    margin: 5px 0;
}

.level-count {
    font-size: 0.9rem;
    color: var(--dark-blue);
    font-weight: 500;
}

/* Boutons */
.primary-btn {
    display: block;
    width: 100%;
    max-width: 400px;
    margin: 20px auto;
    padding: 18px 40px;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--white);
    background: linear-gradient(135deg, var(--blue), var(--dark-blue));
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
}

.primary-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.primary-btn:disabled {
    background: var(--gray);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Quiz Header */
.quiz-header {
    background: var(--white);
    padding: 20px;
    border-radius: 0 0 20px 20px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    max-width: 800px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

#question-counter {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark-blue);
}

.timer {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--blue);
    background: var(--light-blue);
    padding: 8px 16px;
    border-radius: 20px;
}

.timer.warning {
    color: var(--red);
    background: #FEE;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.progress-bar {
    height: 10px;
    background: var(--light-gray);
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--blue), var(--dark-blue));
    border-radius: 5px;
    transition: width 0.3s ease;
    width: 0%;
}

/* Quiz Content */
.quiz-content {
    background: var(--white);
    border-radius: 20px;
    padding: 30px;
    margin: 20px auto;
    max-width: 800px;
    box-shadow: var(--shadow);
}

.theme-badge {
    display: inline-block;
    background: var(--light-blue);
    color: var(--blue);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 20px;
}

.question-text {
    font-size: 1.3rem;
    line-height: 1.6;
    color: #333;
    margin-bottom: 30px;
}

/* Options */
.options-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-btn {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 18px 20px;
    font-size: 1.05rem;
    text-align: left;
    background: var(--light-gray);
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.option-btn:hover:not(:disabled) {
    background: var(--light-blue);
    border-color: var(--blue);
}

.option-btn .option-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 35px;
    height: 35px;
    background: var(--white);
    border-radius: 50%;
    font-weight: bold;
    color: var(--blue);
    margin-right: 15px;
    flex-shrink: 0;
}

.option-btn.selected {
    background: var(--light-blue);
    border-color: var(--blue);
}

.option-btn.selected .option-letter {
    background: var(--blue);
    color: var(--white);
}

.option-btn.correct {
    background: #D4EDDA;
    border-color: var(--success);
}

.option-btn.correct .option-letter {
    background: var(--success);
    color: var(--white);
}

.option-btn.incorrect {
    background: #F8D7DA;
    border-color: var(--error);
}

.option-btn.incorrect .option-letter {
    background: var(--error);
    color: var(--white);
}

.option-btn:disabled {
    cursor: not-allowed;
}

/* Quiz Footer */
.quiz-footer {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
}

/* Résultats */
#results-screen .container {
    padding-top: 30px;
}

.result-header {
    text-align: center;
    margin-bottom: 30px;
}

.result-icon {
    font-size: 5rem;
    margin-bottom: 10px;
}

.result-header.success .result-icon::before {
    content: "🎉";
}

.result-header.failure .result-icon::before {
    content: "😔";
}

.score-display {
    text-align: center;
    margin-bottom: 40px;
}

.score-circle {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: var(--white);
    box-shadow: var(--shadow-lg);
    margin-bottom: 20px;
}

.score-circle.success {
    border: 5px solid var(--success);
}

.score-circle.failure {
    border: 5px solid var(--error);
}

#score-number {
    font-size: 3.5rem;
    font-weight: bold;
    color: var(--dark-blue);
    line-height: 1;
}

.score-total {
    font-size: 1.5rem;
    color: var(--gray);
}

.score-percentage {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--dark-blue);
    margin-bottom: 10px;
}

.result-message {
    font-size: 1.2rem;
    color: var(--gray);
}

.result-message.success {
    color: var(--success);
}

.result-message.failure {
    color: var(--error);
}

/* Liste des réponses */
.results-details {
    background: var(--white);
    border-radius: 20px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.results-details h2 {
    text-align: center;
    margin-bottom: 20px;
}

.answers-list {
    max-height: 400px;
    overflow-y: auto;
}

.answer-item {
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 10px;
    border-left: 4px solid;
}

.answer-item.correct {
    background: #D4EDDA;
    border-left-color: var(--success);
}

.answer-item.incorrect {
    background: #F8D7DA;
    border-left-color: var(--error);
}

.answer-question {
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

.answer-detail {
    font-size: 0.9rem;
    color: var(--gray);
}

.answer-detail .your-answer {
    color: var(--error);
}

.answer-detail .correct-answer {
    color: var(--success);
    font-weight: 500;
}

/* Responsive */
@media (max-width: 600px) {
    .screen {
        padding: 10px;
    }

    h1 {
        font-size: 1.6rem;
    }

    .tricolor {
        width: 90px;
        height: 60px;
    }

    .level-buttons {
        flex-direction: column;
        align-items: center;
    }

    .level-btn {
        width: 100%;
        max-width: 280px;
    }

    .quiz-content {
        padding: 20px 15px;
    }

    .question-text {
        font-size: 1.1rem;
    }

    .option-btn {
        padding: 15px;
        font-size: 1rem;
    }

    .option-btn .option-letter {
        width: 30px;
        height: 30px;
        margin-right: 12px;
    }

    .score-circle {
        width: 120px;
        height: 120px;
    }

    #score-number {
        font-size: 2.8rem;
    }

    .primary-btn {
        padding: 15px 30px;
        font-size: 1.1rem;
    }
}

/* Scrollbar */
.answers-list::-webkit-scrollbar {
    width: 8px;
}

.answers-list::-webkit-scrollbar-track {
    background: var(--light-gray);
    border-radius: 4px;
}

.answers-list::-webkit-scrollbar-thumb {
    background: var(--blue);
    border-radius: 4px;
}

.answers-list::-webkit-scrollbar-thumb:hover {
    background: var(--dark-blue);
}

/* ===================== */
/* AD LAYOUT STYLES      */
/* ===================== */

/* Three-column layout */
.page-layout {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    gap: 20px;
}

/* Main content area */
.main-content {
    flex: 1;
    max-width: 800px;
    min-width: 0;
}

/* Sidebar ads */
.ad-sidebar {
    width: 160px;
    flex-shrink: 0;
}

.ad-container {
    width: 160px;
}

.ad-sticky {
    position: sticky;
    top: 20px;
}

/* Ad placeholder styling */
.ad-placeholder {
    background: linear-gradient(135deg, #f0f0f0, #e0e0e0);
    border: 2px dashed #ccc;
    border-radius: 8px;
    min-height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ad-placeholder.ad-horizontal {
    min-height: 100px;
    width: 100%;
}

/* Horizontal banner ads */
.ad-banner {
    margin: 20px 0;
}

/* Screen active state with layout */
.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 20px;
}

.screen.active .page-layout {
    width: 100%;
}

/* Responsive: hide sidebars on smaller screens */
@media (max-width: 1100px) {
    .ad-sidebar {
        width: 120px;
    }

    .ad-container {
        width: 120px;
    }

    .ad-placeholder {
        min-height: 400px;
    }
}

@media (max-width: 900px) {
    .page-layout {
        flex-direction: column;
        align-items: center;
    }

    .ad-sidebar {
        display: none;
    }

    .main-content {
        max-width: 100%;
        width: 100%;
    }

    /* Show horizontal ads on mobile instead */
    .ad-banner {
        display: block;
    }
}

@media (min-width: 901px) {
    /* On desktop, you can hide horizontal banners if sidebars are visible */
    /* Uncomment below if you only want sidebars on desktop */
    /* .ad-banner { display: none; } */
}
