:root {
    --bg-base: #f4efe7;
    --bg-wash: #f9f5ef;
    --card-bg: #ffffff;
    --ink: #1f1b16;
    --muted: #6b645d;
    --accent: #1f8a70;
    --accent-strong: #0f3d3e;
    --accent-warm: #f26b3a;
    --success: #1f7a4f;
    --error: #c13b2a;
    --warning: #d8812b;
    --line: #e6ded2;
    --shadow-sm: 0 6px 16px rgba(31, 27, 22, 0.08);
    --shadow-md: 0 16px 28px rgba(31, 27, 22, 0.14);
    --shadow-lg: 0 24px 40px rgba(31, 27, 22, 0.18);
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 26px;
    --radius-pill: 999px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    color: var(--ink);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 48px 20px 64px;
    line-height: 1.6;
    background:
        radial-gradient(900px 500px at 5% 5%, rgba(31, 138, 112, 0.16), transparent 60%),
        radial-gradient(700px 420px at 95% 10%, rgba(242, 107, 58, 0.18), transparent 55%),
        radial-gradient(800px 600px at 40% 95%, rgba(15, 61, 62, 0.12), transparent 60%),
        var(--bg-base);
    position: relative;
    overflow-x: hidden;
}

body::before,
body::after {
    content: "";
    position: absolute;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    filter: blur(30px);
    z-index: -1;
    opacity: 0.5;
}

body::before {
    top: -140px;
    left: -120px;
    background: linear-gradient(135deg, rgba(31, 138, 112, 0.3), rgba(15, 61, 62, 0.1));
}

body::after {
    bottom: -160px;
    right: -80px;
    background: linear-gradient(135deg, rgba(242, 107, 58, 0.25), rgba(242, 107, 58, 0.05));
}

.container {
    width: 100%;
    max-width: 980px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

/* Header */
.quiz-header {
    background: linear-gradient(150deg, #ffffff 0%, #f8f3ea 100%);
    padding: 32px 36px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(31, 27, 22, 0.06);
    position: relative;
    overflow: hidden;
    animation: riseIn 0.7s ease both;
}

.quiz-header::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 220px;
    height: 100%;
    background: linear-gradient(150deg, rgba(31, 138, 112, 0.18), transparent 70%);
    transform: skewX(-12deg) translateX(60px);
    pointer-events: none;
}

.title-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quiz-title {
    font-family: "Fraunces", "Times New Roman", serif;
    font-size: clamp(2rem, 4vw, 2.8rem);
    font-weight: 700;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--accent-strong);
}

.quiz-title i {
    color: var(--accent-warm);
}

.quiz-subtitle {
    color: var(--muted);
    font-size: 1.05rem;
    max-width: 560px;
}

.meta-row {
    margin-top: 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
}

.progress-block {
    flex: 1 1 320px;
    background: var(--bg-wash);
    padding: 14px 18px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(31, 27, 22, 0.08);
}

.progress-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    margin-bottom: 8px;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: rgba(31, 27, 22, 0.08);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(120deg, var(--accent) 0%, var(--accent-warm) 100%);
    width: 0%;
    transition: width 0.5s ease;
}

.score-display {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--accent-strong);
    color: #fff;
    padding: 12px 22px;
    border-radius: var(--radius-pill);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.score-label {
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.7;
}

.score-value {
    font-size: 1.6rem;
    font-weight: 700;
}

.score-total {
    opacity: 0.7;
}

/* Banner */
.quiz-banner-container {
    text-align: center;
    animation: riseIn 0.7s ease both;
    animation-delay: 0.08s;
}

.quiz-banner {
    max-width: 100%;
    height: auto;
    max-height: 260px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    object-fit: cover;
    border: 1px solid rgba(31, 27, 22, 0.08);
}

/* Etapes */
.etape {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    margin-bottom: 18px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: riseIn 0.6s ease both;
}

.etape:nth-child(1) { animation-delay: 0.05s; }
.etape:nth-child(2) { animation-delay: 0.1s; }
.etape:nth-child(3) { animation-delay: 0.15s; }
.etape:nth-child(4) { animation-delay: 0.2s; }
.etape:nth-child(5) { animation-delay: 0.25s; }
.etape:nth-child(6) { animation-delay: 0.3s; }

.etape:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.etape.completed {
    border-left: 6px solid var(--success);
}

.etape.unlocked {
    border-left: 6px solid var(--accent);
}

.etape.locked {
    opacity: 0.5;
    background: #f0ebe2;
    pointer-events: none;
}

.etape-header {
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    background: #fbf7f1;
    transition: background 0.2s;
}

.etape.unlocked .etape-header:hover {
    background: #f3ede2;
}

.etape-title {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--ink);
}

.etape-icon {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(31, 138, 112, 0.12);
    color: var(--accent-strong);
    transition: all 0.3s ease;
}

.etape.completed .etape-icon {
    background: rgba(31, 122, 79, 0.2);
    color: var(--success);
}

.etape.unlocked .etape-icon {
    background: rgba(31, 138, 112, 0.15);
    color: var(--accent);
}

.etape-toggle {
    color: var(--muted);
    transition: transform 0.3s ease, color 0.3s ease;
}

.etape.expanded .etape-toggle {
    transform: rotate(180deg);
    color: var(--accent);
}

/* Questions */
.etape-questions {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease-out;
    background: #fffdf8;
}

.etape.expanded .etape-questions {
    max-height: 5000px;
}

.question {
    padding: 26px;
    border-top: 1px solid var(--line);
}

.question.locked {
    filter: blur(2px);
    opacity: 0.5;
    pointer-events: none;
    user-select: none;
}

.question-header {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 18px;
}

.question-objectif {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(242, 107, 58, 0.15);
    color: var(--accent-warm);
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    font-weight: 600;
    width: fit-content;
}

.question-enonce {
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--ink);
}

.answer-count {
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(31, 138, 112, 0.14);
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    margin-left: 10px;
    vertical-align: middle;
}

.question-choix {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.choix-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: #fff;
    border: 2px solid rgba(31, 27, 22, 0.08);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.choix-item:hover {
    border-color: rgba(31, 138, 112, 0.5);
    background: rgba(31, 138, 112, 0.06);
    transform: translateY(-2px);
}

.choix-item.selected {
    border-color: var(--accent);
    background: rgba(31, 138, 112, 0.12);
}

.choix-item.correct {
    border-color: var(--success);
    background: rgba(31, 122, 79, 0.12);
}

.choix-item.incorrect {
    border-color: var(--error);
    background: rgba(193, 59, 42, 0.12);
    animation: shake 0.4s ease-in-out;
}

.choix-item.disabled {
    cursor: default;
    opacity: 0.7;
}

.choix-radio,
.choix-checkbox {
    width: 22px;
    height: 22px;
    border: 2px solid rgba(31, 27, 22, 0.2);
    position: relative;
    flex-shrink: 0;
    transition: all 0.2s;
    background: #fff;
}

.choix-radio {
    border-radius: 50%;
}

.choix-checkbox {
    border-radius: 6px;
}

.choix-item.selected .choix-radio,
.choix-item.selected .choix-checkbox {
    border-color: var(--accent);
    background: var(--accent);
}

.choix-item.correct .choix-radio,
.choix-item.correct .choix-checkbox {
    border-color: var(--success);
    background: var(--success);
}

.choix-item.incorrect .choix-radio,
.choix-item.incorrect .choix-checkbox {
    border-color: var(--error);
    background: var(--error);
}

.choix-item.selected .choix-radio::after {
    content: "";
    position: absolute;
    width: 8px;
    height: 8px;
    background: #fff;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.choix-item.selected .choix-checkbox::after,
.choix-item.correct .choix-checkbox::after,
.choix-item.correct .choix-radio::after {
    content: "\2713";
    position: absolute;
    color: #fff;
    font-size: 13px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 700;
}

.choix-item.incorrect .choix-checkbox::after,
.choix-item.incorrect .choix-radio::after {
    content: "\2715";
    position: absolute;
    color: #fff;
    font-size: 12px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 700;
}

.choix-text {
    font-size: 1.05rem;
    font-weight: 500;
    color: #3a3430;
}

/* Feedback */
.question-feedback {
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    font-weight: 500;
    display: none;
    align-items: center;
    gap: 10px;
    animation: slideDown 0.3s ease-out;
}

.question-feedback.show {
    display: flex;
}

.question-feedback.success {
    background: rgba(31, 122, 79, 0.12);
    color: var(--success);
    border: 1px solid rgba(31, 122, 79, 0.2);
}

.question-feedback.error {
    background: rgba(193, 59, 42, 0.12);
    color: var(--error);
    border: 1px solid rgba(193, 59, 42, 0.2);
}

/* Footer */
.app-footer {
    margin-top: 40px;
    padding: 22px;
    text-align: center;
    border-top: 1px solid rgba(31, 27, 22, 0.08);
    color: var(--muted);
}

.footer-text {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.95rem;
}

.creator-name {
    color: var(--accent-strong);
    font-weight: 600;
    padding: 2px 8px;
    background: rgba(31, 138, 112, 0.12);
    border-radius: 12px;
    transition: 0.2s;
}

.creator-name:hover {
    background: var(--accent-strong);
    color: #fff;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--muted);
}

.loading.hidden {
    display: none;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 4px solid rgba(31, 27, 22, 0.1);
    border-top: 4px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 61, 62, 0.35);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(6px);
}

.modal.show {
    display: flex;
    animation: fadeIn 0.3s;
}

.modal-content {
    background: #fff;
    padding: 38px;
    border-radius: var(--radius-lg);
    text-align: center;
    max-width: 520px;
    width: 92%;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.modal-content::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: linear-gradient(120deg, var(--accent) 0%, var(--accent-warm) 100%);
}

.modal-icon {
    font-size: 3.6rem;
    color: var(--accent-warm);
    margin-bottom: 14px;
    display: block;
}

.modal h2 {
    color: var(--accent-strong);
    margin-bottom: 10px;
    font-size: 2rem;
}

.modal p {
    color: var(--muted);
    margin-bottom: 26px;
    font-size: 1.05rem;
}

.btn-continue {
    background: linear-gradient(120deg, var(--accent) 0%, var(--accent-warm) 100%);
    color: white;
    border: none;
    padding: 14px 40px;
    border-radius: var(--radius-pill);
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 18px rgba(31, 27, 22, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-continue:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 22px rgba(31, 27, 22, 0.18);
}

/* Animations */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes riseIn {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 720px) {
    body {
        padding: 32px 16px 48px;
    }

    .quiz-header {
        padding: 26px 22px;
    }

    .quiz-title {
        flex-direction: column;
        align-items: flex-start;
    }

    .meta-row {
        flex-direction: column;
        align-items: stretch;
    }

    .score-display {
        justify-content: center;
    }
}

@media (max-width: 520px) {
    .quiz-title {
        font-size: 1.9rem;
    }

    .question {
        padding: 20px;
    }

    .etape-header {
        padding: 16px 18px;
    }
}