/* ============================================================
   automatismes.css — Fichier CSS unique pour les automatismes
   Fusion de : automatismes-v3_18-FIX8, STYLE-DROPDOWN,
               STYLE-FLASHCARDS, automatismes-print, 6-automatismes,
               CSS-FRACTIONS-PARFAIT, quiz-5e-hierarchique,
               automatismes-diff
   ============================================================ */

/* ═══════════════════════════════════════════════════════════
   1. VARIABLES & RESET
   ═══════════════════════════════════════════════════════════ */
:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --flashcard-color: #667eea;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --error-color: #ef4444;
    --text-color: #2c3e50;
    --bg-light: #f8f9fa;
    --border-color: #e1e8ed;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --card-shadow: 0 4px 6px rgba(0,0,0,0.1);
    --gradient-purple: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

/* ═══════════════════════════════════════════════════════════
   2. CONTAINER & LAYOUT
   ═══════════════════════════════════════════════════════════ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    background: rgb(127, 171, 238);
    border-radius: 15px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

/* ═══════════════════════════════════════════════════════════
   3. HEADER & NAVIGATION
   ═══════════════════════════════════════════════════════════ */
header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 3px solid var(--primary-color);
}

h1 {
    color: var(--primary-color);
    font-size: 2.5em;
    margin-bottom: 10px;
}

.subtitle {
    color: #7f8c8d;
    font-size: 1.2em;
}

.back-link {
    display: inline-block;
    margin-bottom: 20px;
    color: rgb(56, 11, 11);
    text-decoration: none;
    font-weight: bold;
    background: rgba(255,255,255,0.2);
    padding: 10px 20px;
    border-radius: 25px;
    transition: all 0.3s;
}

/* ═══════════════════════════════════════════════════════════
   4. FORMULAIRE IDENTITÉ (impression)
   ═══════════════════════════════════════════════════════════ */
.identity-form {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-light);
    border-radius: 10px;
}

.identity-form > div { flex: 1; }

.identity-form label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
    color: var(--text-color);
}

.identity-form input {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    font-size: 1em;
}

/* ═══════════════════════════════════════════════════════════
   5. SÉLECTION CHAPITRES & ITEMS — Structure hiérarchique
   ═══════════════════════════════════════════════════════════ */

/* Masquer anciennes sections HTML */
.chapter-selection,
#chapter-selection,
.chapters-section {
    display: none !important;
}

/* Section principale */
.selection-section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: var(--card-shadow);
}

.section-title {
    font-size: 1.3em;
    font-weight: bold;
    color: var(--text-color);
    margin-bottom: 20px;
    text-align: center;
}

/* En-tête sélection (titre + boutons) */
.selection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Boutons Tous / Aucun / Déplier / Replier */
.selection-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.select-all-btn,
.unselect-all-btn,
.expand-all-btn,
.collapse-all-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.select-all-btn { background: #27ae60; color: white; }
.select-all-btn:hover { background: #229954; transform: translateY(-1px); box-shadow: 0 2px 6px rgba(39,174,96,0.3); }

.unselect-all-btn { background: #e74c3c; color: white; }
.unselect-all-btn:hover { background: #c0392b; transform: translateY(-1px); box-shadow: 0 2px 6px rgba(231,76,60,0.3); }

.expand-all-btn { background: #3498db; color: white; }
.expand-all-btn:hover { background: #2980b9; transform: translateY(-1px); box-shadow: 0 2px 6px rgba(52,152,219,0.3); }

.collapse-all-btn { background: #95a5a6; color: white; }
.collapse-all-btn:hover { background: #7f8c8d; transform: translateY(-1px); box-shadow: 0 2px 6px rgba(149,165,166,0.3); }

/* Menu dépliant global */
.all-chapters-details {
    background: white;
    border: 2px solid #3498db;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.all-chapters-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    cursor: pointer;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    font-weight: 700;
    font-size: 1.1rem;
    color: #1976d2;
    user-select: none;
    transition: background 0.2s ease;
}

.all-chapters-summary:hover { background: linear-gradient(135deg, #bbdefb 0%, #90caf9 100%); }
.all-chapters-details[open] .all-chapters-summary { background: linear-gradient(135deg, #90caf9 0%, #64b5f6 100%); }
.all-chapters-summary::marker { color: #1976d2; font-size: 1.3em; }

.chapters-count {
    background: #1976d2;
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Grille des chapitres */
.chapters-items-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

/* Chapitre (details) */
.chapter-details {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.chapter-details:hover { border-color: #3498db; box-shadow: 0 2px 8px rgba(52,152,219,0.1); }
.chapter-details[open] { border-color: #3498db; }

.chapter-summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    cursor: pointer;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    transition: all 0.2s ease;
    user-select: none;
}

.chapter-summary:hover { background: linear-gradient(135deg, #e8f4f8 0%, #f0f7fa 100%); }
.chapter-details[open] .chapter-summary { background: linear-gradient(135deg, #d5e8f3 0%, #e3f2fd 100%); border-bottom: 2px solid #3498db; }
.chapter-summary::marker { color: #95a5a6; font-size: 1.2em; }
.chapter-details[open] .chapter-summary::marker { color: #2980b9; }

.chapter-checkbox-input {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #3498db;
    flex-shrink: 0;
}

.chapter-label {
    flex: 1;
    font-weight: 600;
    font-size: 1rem;
    color: #2c3e50;
    cursor: pointer;
}

.question-count {
    background: #3498db;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
}

/* Items */
.items-container {
    padding: 1rem;
    background: #fafbfc;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.75rem;
}

.no-items {
    grid-column: 1 / -1;
    text-align: center;
    color: #95a5a6;
    font-style: italic;
    padding: 1rem;
}

.item-checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.item-checkbox-wrapper:hover {
    border-color: #3498db;
    background: #f8fbfd;
    box-shadow: 0 1px 4px rgba(52,152,219,0.1);
}

.item-checkbox-input {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #3498db;
    flex-shrink: 0;
}

.item-label {
    flex: 1;
    font-size: 0.9rem;
    color: #34495e;
    cursor: pointer;
    line-height: 1.3;
}

.item-question-count {
    background: #e3f2fd;
    color: #1976d2;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

/* Info nombre de questions disponibles */
.chapter-info {
    text-align: center;
    padding: 12px;
    background: white;
    border-radius: 5px;
    color: var(--primary-color);
    font-weight: bold;
}

#available-questions {
    color: var(--secondary-color);
    font-size: 1.2em;
}

/* Animation ouverture */
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.chapter-details[open] .items-container { animation: slideDown 0.3s ease-out; }

/* ═══════════════════════════════════════════════════════════
   6. DIFFICULTÉ
   ═══════════════════════════════════════════════════════════ */
.difficulty-selector {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 16px 0;
}

.diff-btn { cursor: pointer; user-select: none; }
.diff-btn input[type="radio"] { display: none; }

.diff-btn span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 10px 22px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.95em;
    border: 2px solid transparent;
    transition: all 0.18s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.diff-facile span    { background: #e8f5e9; color: #1e7e34; border-color: #a5d6a7; }
.diff-moyen span     { background: #fff3e0; color: #e65100; border-color: #ffcc80; }
.diff-difficile span { background: #fce4ec; color: #b71c1c; border-color: #f48fb1; }
.diff-mixte span     { background: #f3e5f5; color: #6a1b9a; border-color: #ce93d8; }

.diff-facile    input:checked + span { background: #27ae60; color: white; border-color: #1e8449; box-shadow: 0 4px 12px rgba(39,174,96,.35); transform: translateY(-2px); }
.diff-moyen     input:checked + span { background: #f39c12; color: white; border-color: #c87f0a; box-shadow: 0 4px 12px rgba(243,156,18,.35); transform: translateY(-2px); }
.diff-difficile input:checked + span { background: #e74c3c; color: white; border-color: #c0392b; box-shadow: 0 4px 12px rgba(231,76,60,.35); transform: translateY(-2px); }
.diff-mixte     input:checked + span { background: #8e44ad; color: white; border-color: #6c3483; box-shadow: 0 4px 12px rgba(142,68,173,.35); transform: translateY(-2px); }

.diff-btn:hover span { filter: brightness(0.93); }

/* ═══════════════════════════════════════════════════════════
   7. ZONE DE LANCEMENT (mode, nb questions, timer, bouton)
   ═══════════════════════════════════════════════════════════ */
.launch-zone {
    background: #f8f9ff;
    border: 1px solid #dde3ff;
    border-radius: 14px;
    padding: 18px 20px;
    margin: 16px 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Nombre de questions + chrono sur la même ligne */
.num-questions-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-weight: 600;
    color: #444;
}

.num-questions-row input[type="number"] {
    width: 80px;
    padding: 8px 10px;
    border: 2px solid #c3d0ff;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    text-align: center;
}

.num-questions-row select {
    padding: 8px 12px;
    border: 2px solid #c3d0ff;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
}

.num-questions-row select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Sélecteur de mode */
.mode-selector {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.mode-choice-btn {
    cursor: pointer;
    user-select: none;
    position: relative;
}

.mode-choice-btn input[type="radio"] { display: none; }

.mode-choice-btn span {
    display: block;
    padding: 10px 18px 6px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.95em;
    background: white;
    border: 2px solid #dde;
    color: #555;
    transition: all 0.15s ease;
}

.mode-choice-btn small {
    display: block;
    font-size: 0.72em;
    font-weight: 400;
    color: #888;
    margin-top: 2px;
}

.mode-choice-btn[data-mode="normal"] span   { background: #e3f2fd; color: #1565c0; border-color: #90caf9; }
.mode-choice-btn[data-mode="flash"] span    { background: #e8f5e9; color: #2e7d32; border-color: #a5d6a7; }
.mode-choice-btn[data-mode="defi"] span     { background: #fff3e0; color: #e65100; border-color: #ffcc80; }
.mode-choice-btn[data-mode="revision"] span { background: #f3e5f5; color: #6a1b9a; border-color: #ce93d8; }

.mode-choice-btn[data-mode="normal"].active span   { background: #1976d2; color: white; border-color: #1565c0; box-shadow: 0 4px 12px rgba(25,118,210,.4); transform: translateY(-2px); }
.mode-choice-btn[data-mode="flash"].active span    { background: #388e3c; color: white; border-color: #2e7d32; box-shadow: 0 4px 12px rgba(56,142,60,.4); transform: translateY(-2px); }
.mode-choice-btn[data-mode="defi"].active span     { background: #f57c00; color: white; border-color: #e65100; box-shadow: 0 4px 12px rgba(245,124,0,.4); transform: translateY(-2px); }
.mode-choice-btn[data-mode="revision"].active span { background: #8e44ad; color: white; border-color: #6c3483; box-shadow: 0 4px 12px rgba(142,68,173,.4); transform: translateY(-2px); }

.mode-choice-btn.active small { color: rgba(255,255,255,0.85); }

/* Bouton lancer */
.btn-launch {
    align-self: flex-start;
    padding: 13px 40px;
    font-size: 1.1em;
    font-weight: bold;
    background: var(--gradient-purple);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    letter-spacing: 0.03em;
    box-shadow: 0 4px 15px rgba(102,126,234,.4);
    transition: all 0.2s ease;
}

.btn-launch:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(102,126,234,.5); }
.btn-launch:active { transform: translateY(0); }

/* Bandeau timer */
#timer-info-banner { margin: 8px 0 12px 0; }

/* ═══════════════════════════════════════════════════════════
   8. BOUTONS GÉNÉRAUX
   ═══════════════════════════════════════════════════════════ */
.btn {
    padding: 15px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.btn-primary {
    background: var(--gradient-purple);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102,126,234,0.4);
}

.btn-success { background: var(--success-color); color: white; }
.btn-success:hover { background: #059669; transform: translateY(-2px); }

.btn-secondary { background: #6c757d; color: white; }
.btn-secondary:hover { background: #5a6268; }

.btn-revision { background: linear-gradient(135deg, #8e44ad, #6c3483); color: white; border: none; }
.btn-revision:hover { background: linear-gradient(135deg, #6c3483, #4a235a); }

/* ═══════════════════════════════════════════════════════════
   9. QUESTIONS & RÉPONSES
   ═══════════════════════════════════════════════════════════ */
.questions-container {
    display: grid;
    gap: 20px;
    margin-bottom: 30px;
}

/* Mode une par une (normal) */
.question-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
    padding: 40px;
    background: white;
    border: 3px solid var(--border-color);
    border-radius: 15px;
    transition: all 0.3s ease;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    min-height: 300px;
}

.question-item:hover { box-shadow: 0 15px 50px rgba(0,0,0,0.15); }

.question-number { display: none; }

.question-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 25px;
    align-items: center;
    text-align: center;
}

.question-text {
    font-size: 24px;
    font-weight: bold;
    color: var(--text-color);
    line-height: 1.5;
    max-width: 800px;
}

.answer-input {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.answer-input input {
    width: 100%;
    padding: 20px;
    border: 3px solid var(--border-color);
    border-radius: 8px;
    font-size: 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.answer-input input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102,126,234,0.1);
}

/* Mode correction (liste) */
.questions-container.correction-mode .question-item {
    display: grid;
    grid-template-columns: 60px 1fr;
    gap: 20px;
    align-items: start;
    padding: 20px;
    min-height: auto;
}

.questions-container.correction-mode .question-number {
    display: block;
    font-size: 1.5em;
    font-weight: bold;
    color: var(--primary-color);
    text-align: center;
    padding-top: 5px;
}

.questions-container.correction-mode .question-content {
    text-align: left;
    align-items: flex-start;
    gap: 15px;
}

.questions-container.correction-mode .question-text {
    font-size: 1.1em;
    font-weight: normal;
    text-align: left;
}

.questions-container.correction-mode .answer-input { max-width: 100%; }
.questions-container.correction-mode .answer-input input { padding: 12px; font-size: 1em; text-align: left; }

/* Bordures colorées après correction */
.answer-input input.correct-input { border-color: var(--success-color) !important; background: #f0fdf4; }
.answer-input input.incorrect-input { border-color: var(--error-color) !important; background: #fef2f2; }

/* ═══════════════════════════════════════════════════════════
   10. BOUTONS MATHÉMATIQUES
   ═══════════════════════════════════════════════════════════ */
.math-buttons {
    display: flex;
    gap: 5px;
    margin-top: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.math-btn {
    padding: 8px 14px;
    border: 2px solid var(--border-color);
    background: white;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
    font-weight: 500;
}

.math-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ═══════════════════════════════════════════════════════════
   11. CORRECTION
   ═══════════════════════════════════════════════════════════ */
.correction {
    margin-top: 15px;
    padding: 15px;
    border-radius: 8px;
    font-size: 0.95em;
}

.correction.correct { background: #d4edda; border-left: 4px solid var(--success-color); }
.correction.incorrect { background: #f8d7da; border-left: 4px solid var(--error-color); }

.correction-header { font-weight: bold; margin-bottom: 8px; }
.correction-details { margin-top: 8px; }
.correct-answer { color: var(--success-color); font-weight: bold; }
.user-answer { color: var(--error-color); font-weight: bold; }

/* ═══════════════════════════════════════════════════════════
   12. SCORE
   ═══════════════════════════════════════════════════════════ */
.score-container {
    margin: 25px 0;
    padding: 0;
    border-radius: 16px;
    background: transparent;
    position: relative;
}

.score-display {
    padding: 25px;
    border-radius: 16px;
    color: white;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    margin-bottom: 15px;
}

.score-display h3 { font-size: 2em; margin-bottom: 10px; }
.score-display .score { font-size: 36px !important; font-weight: bold !important; margin: 15px 0 !important; }
.score-percentage { font-size: 3em; font-weight: bold; }

#scoreContainerTop {
    position: sticky;
    top: 20px;
    z-index: 100;
    animation: slideDown 0.5s ease;
}

/* ═══════════════════════════════════════════════════════════
   13. MODES FLASH, GAMING & DÉFI
   ═══════════════════════════════════════════════════════════ */
.flash-mode, .gaming-mode {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 25px;
    border-radius: 16px;
    margin: 20px 0;
    box-shadow: 0 8px 32px rgba(240,147,251,0.4);
}

.flash-mode h3, .gaming-mode h3 {
    margin: 0 0 15px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.4em;
}

.flash-mode h3 span:first-child,
.gaming-mode h3 span:first-child { font-size: 32px; }

.timer-container { margin: 20px 0; text-align: center; }

.timer-bar {
    width: 100%;
    height: 8px;
    background: rgba(255,255,255,0.3);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 10px;
}

.timer-fill { height: 100%; background: white; transition: width 0.1s linear; }
.timer-text { font-size: 48px; font-weight: bold; margin: 15px 0; }

/* Mode défi */
.defi-mode {
    background: var(--gradient-purple);
    color: white;
    padding: 25px;
    margin: 25px 0;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(102,126,234,0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.defi-mode:hover { transform: translateY(-2px); box-shadow: 0 12px 40px rgba(102,126,234,0.5); }

.defi-mode h3 {
    margin: 0 0 15px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.4em;
}

.defi-mode h3 span:first-child { font-size: 32px; animation: pulse 2s ease-in-out infinite; }

@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }

.defi-mode p { margin: 12px 0; font-size: 1em; opacity: 0.95; line-height: 1.6; }

.defi-buttons { display: flex; gap: 12px; margin-top: 20px; flex-wrap: wrap; }

.defi-buttons button {
    flex: 1;
    min-width: 150px;
    background: white;
    color: #667eea;
    padding: 14px 20px;
    border: none;
    border-radius: 10px;
    font-weight: bold;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.defi-buttons button:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.15); }

#defiStreak {
    margin-top: 20px;
    padding: 20px;
    background: rgba(255,255,255,0.15);
    border-radius: 12px;
    text-align: center;
    backdrop-filter: blur(10px);
}

#defiStreak > div:first-child { font-size: 0.9em; opacity: 0.9; text-transform: uppercase; letter-spacing: 1px; }
#defiStreak > div:nth-child(2) { font-size: 48px; font-weight: bold; margin: 10px 0; text-shadow: 0 2px 10px rgba(0,0,0,0.2); }

/* Récapitulatif défi */
.defi-recap-container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 30px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

.defi-victory {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, #f39c12 0%, #f1c40f 100%);
    border-radius: 16px;
    color: white;
    margin-bottom: 30px;
}

.trophy-icon { font-size: 80px; animation: bounce 1s infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

.defi-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.stat-item { text-align: center; padding: 20px; background: #ecf0f1; border-radius: 12px; }
.stat-value { font-size: 28px; font-weight: bold; color: #2c3e50; }

/* ═══════════════════════════════════════════════════════════
   14. FRACTIONS HTML
   ═══════════════════════════════════════════════════════════ */
.fraction {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    margin: 0 0.15em;
    line-height: 1;
    font-size: 1em;
    position: relative;
}

.fraction .numerator,
.fraction .denominator {
    padding: 0 0.2em;
    font-size: 0.85em;
    line-height: 1.2;
    position: relative;
    z-index: 1;
}

.fraction::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background-color: currentColor;
    transform: translateY(-50%);
    z-index: 0;
}

.fraction .fraction-line {
    position: absolute;
    top: 50%;
    left: 0.2em;
    right: 0.2em;
    height: 1px;
    background-color: currentColor;
    transform: translateY(-50%);
    z-index: 0;
    display: none;
}

/* ═══════════════════════════════════════════════════════════
   15. CONTRÔLES ANCIENS (compatibilité)
   ═══════════════════════════════════════════════════════════ */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: end;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-light);
    border-radius: 10px;
}

.controls > * { flex: 1; min-width: 150px; }
.controls label { display: block; font-weight: bold; margin-bottom: 5px; }
.controls input { width: 100%; padding: 12px; border: 2px solid var(--border-color); border-radius: 5px; font-size: 1em; }

/* ═══════════════════════════════════════════════════════════
   16. RESPONSIVE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .container { padding: 20px; }
    h1 { font-size: 1.8em; }

    .question-item { padding: 25px; min-height: 250px; }
    .question-text { font-size: 20px; }
    .answer-input input { padding: 15px; font-size: 18px; }
    .questions-container.correction-mode .question-item { grid-template-columns: 50px 1fr; padding: 15px; }

    .math-buttons { gap: 3px; }
    .math-btn { padding: 6px 10px; font-size: 0.9em; }

    .selection-header { flex-direction: column; align-items: stretch; }
    .selection-actions { width: 100%; }
    .select-all-btn, .unselect-all-btn, .expand-all-btn, .collapse-all-btn { flex: 1; min-width: 100px; }

    .chapters-items-container { grid-template-columns: repeat(2, 1fr); }
    .items-container { grid-template-columns: 1fr; }
    .chapter-summary { padding: 0.75rem; gap: 0.5rem; }
    .chapter-label { font-size: 0.95rem; }
    .question-count { font-size: 0.8rem; padding: 0.2rem 0.6rem; }

    .defi-buttons { flex-direction: column; }
    .defi-buttons button { width: 100%; min-width: 0; }
    .defi-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .selection-actions { flex-direction: column; }
    .select-all-btn, .unselect-all-btn, .expand-all-btn, .collapse-all-btn { width: 100%; }
    .chapters-items-container { grid-template-columns: 1fr; }
    .chapter-checkbox-input { width: 18px; height: 18px; }
    .item-checkbox-input { width: 14px; height: 14px; }
    .item-label { font-size: 0.85rem; }
}

/* ═══════════════════════════════════════════════════════════
   17. IMPRESSION
   ═══════════════════════════════════════════════════════════ */
@media print {
    @page { size: A4; margin: 0.7cm 0.4cm; }

    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; box-sizing: border-box; }

    body { margin: 0; padding: 0; background: white !important; font-family: Arial, sans-serif; font-size: 9pt; line-height: 1.15; color: #000 !important; }

    .no-print, button, .btn, nav, header, footer,
    .notions-toggle-btn, .notions-content, .selection-section,
    .math-toolbar, #prevBtn, #nextBtn, #validateBtn,
    #nextQuestionBtn, #scoreBtn, #print-buttons-container,
    .leaderboard-panel { display: none !important; }

    .container { box-shadow: none; padding: 20px; background: white !important; }

    /* En-tête élève */
    .print-header {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 12px;
        border: 2px solid #000;
        border-radius: 6px;
        margin-bottom: 12px;
        background: #f5f5f5 !important;
        page-break-after: avoid;
        page-break-inside: avoid;
    }

    .print-field { font-size: 10pt; font-weight: bold; color: #000 !important; white-space: nowrap; }

    .print-title {
        text-align: center;
        font-size: 13pt;
        font-weight: bold;
        margin: 8px 0;
        color: #000 !important;
        page-break-after: avoid;
    }

    .print-subtitle { text-align: center; font-size: 10pt; margin: 5px 0 12px 0; color: #333 !important; }

    /* 2 colonnes */
    .questions-container, .corrections-container { columns: 2; column-gap: 10px; column-rule: 1px solid #bbb; margin: 0; padding: 0; }

    .question-item {
        break-inside: avoid;
        page-break-inside: avoid;
        margin: 0 0 7px 0;
        padding: 6px;
        border: 1px solid #333;
        border-radius: 3px;
        background: white !important;
        box-shadow: none;
        min-height: auto;
    }

    .question-number {
        display: inline-block;
        background: #555 !important;
        color: white !important;
        width: 20px; height: 20px;
        border-radius: 50%;
        text-align: center;
        line-height: 20px;
        font-size: 10px;
        font-weight: bold;
        margin-right: 6px;
    }

    .question-text { font-size: 9pt !important; line-height: 1.2 !important; margin: 4px 0 !important; color: #000 !important; display: inline; }

    .answer-line { border-bottom: 1px solid #000; height: 18px; margin-top: 5px; }

    .corrections-page-break { page-break-before: always !important; display: block !important; height: 0; margin: 0; }

    .corrections-title { text-align: center; font-size: 14pt; font-weight: bold; margin: 15px 0; color: #000 !important; page-break-after: avoid; }

    .answer-box {
        background: #e8f5e9 !important;
        border-left: 3px solid #4caf50 !important;
        padding: 4px;
        margin-top: 4px;
        font-size: 8pt !important;
        color: #000 !important;
    }

    .answer-box strong { color: #2e7d32 !important; }

    h1, h2, h3 { margin: 5px 0 !important; padding: 0 !important; page-break-after: avoid; color: #000 !important; }
    p { margin: 3px 0 !important; page-break-inside: avoid; }

    .questions-container.correction-mode .question-item { display: grid; grid-template-columns: 50px 1fr; }

    /* Fractions à l'impression */
    .fraction { display: inline-table !important; text-align: center; vertical-align: middle; margin: 0 0.2em !important; border-collapse: collapse; page-break-inside: avoid; }
    .fraction::after { display: none; }
    .fraction .numerator { display: table-row !important; padding: 0 0.3em 0.1em !important; border-bottom: 1.5px solid #000 !important; font-size: 0.9em !important; color: #000 !important; }
    .fraction .denominator { display: table-row !important; padding: 0.1em 0.3em 0 !important; font-size: 0.9em !important; color: #000 !important; }

    .chapter-details { border: 1px solid #ddd; page-break-inside: avoid; }
    .chapter-summary::marker { display: none; }
    .items-container { grid-template-columns: repeat(2, 1fr); }
}

@media screen {
    .print-header, .print-title, .print-subtitle,
    .corrections-page-break, .corrections-title,
    .answer-line { display: none !important; }
}

/* ═══════════════════════════════════════════════════════════
   18. UTILITAIRES
   ═══════════════════════════════════════════════════════════ */
.print-optimized { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
.no-break { white-space: nowrap; page-break-inside: avoid; break-inside: avoid; }
.avoid-page-break { page-break-inside: avoid; break-inside: avoid; }
