/* =====================================================
   Quiz Game - Styles CSS
   Mobile-first responsive design
   ===================================================== */

:root {
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --secondary: #764ba2;
    --success: #48bb78;
    --danger: #f56565;
    --warning: #ed8936;
    --info: #4299e1;
    --dark: #1a202c;
    --light: #f7fafc;
    --gray: #718096;
    --gradient: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
    --radius-lg: 20px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--gradient);
    min-height: 100vh;
    color: var(--dark);
    font-size: 16px;
    line-height: 1.5;
}

/* App Container - Fullscreen mobile */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    user-select: none;
    -webkit-user-select: none;
}

.header-photo-heart {
    flex-shrink: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Le nom du compte connecté cède la place au titre sur un téléphone : l'écran du profil le donne */
.user-name {
    max-width: 30vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-logo > span {
    white-space: nowrap;
}

@media (max-width: 479.98px) {
    .user-name {
        display: none;
    }
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--light);
    color: var(--gray);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-icon:hover, .btn-icon:active {
    background: var(--primary);
    color: white;
}

/* Main Content */
.app-content {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Cards */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px;
    margin-bottom: 10px;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
}

/* Quiz Categories Grid */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.category-card {
    background: white;
    border-radius: var(--radius);
    padding: 10px 6px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    text-decoration: none;
    color: inherit;
}

.category-card:hover, .category-card:active {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.category-card.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
}

.category-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 6px;
    font-size: 1.1rem;
    color: white;
}

.category-name {
    font-weight: 600;
    font-size: 0.7rem;
    line-height: 1.2;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border-radius: var(--radius);
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    width: 100%;
}

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

.btn-primary:hover, .btn-primary:active {
    opacity: 0.9;
    transform: scale(0.98);
}

.btn-secondary {
    background: var(--light);
    color: var(--dark);
}

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

/* Rouge foncé : le texte blanc garde un contraste de 5,5 pour 1 */
.btn-danger {
    background: #c53030;
    color: white;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
    cursor: pointer;
}

.btn-outline:hover, .btn-outline:active {
    background: var(--primary);
    color: white;
}

.btn-lg {
    padding: 18px 32px;
    font-size: 1.1rem;
}

.btn-sm {
    padding: 10px 16px;
    font-size: 0.9rem;
}

/* Form Elements */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

/* Liste déroulante : la flèche signale le choix, le texte ne passe pas dessous */
select.form-control {
    appearance: none;
    padding-right: 44px;
    background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%234a5568' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 16px center / 16px 12px;
    text-overflow: ellipsis;
}

/* Options/Settings */
.option-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.option-btn {
    flex: 1;
    min-width: 80px;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius);
    background: white;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.option-btn.active {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    color: var(--primary);
}

.option-btn:disabled,
.option-btn.disabled {
    cursor: not-allowed;
    opacity: 0.7;
    background: #f1f5f9;
    border-color: var(--primary);
    color: var(--primary);
}

/* Toggle Switch */
.toggle-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
}

.toggle-container.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.toggle-label {
    font-weight: 500;
}

.toggle {
    position: relative;
    width: 52px;
    height: 28px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e0;
    transition: 0.3s;
    border-radius: 28px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: var(--shadow);
}

.toggle input:checked + .toggle-slider {
    background: var(--gradient);
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

/* Quiz Game Screen */
.quiz-screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: white;
}

.quiz-header {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e2e8f0;
}

.quiz-progress {
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-bar {
    width: 120px;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--gradient);
    transition: width 0.3s;
}

.progress-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray);
}

/* Timer */
.timer {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.25rem;
    font-weight: 700;
}

.timer-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: conic-gradient(var(--primary) var(--progress, 100%), #e2e8f0 0);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.timer-circle::before {
    content: '';
    position: absolute;
    width: 38px;
    height: 38px;
    background: white;
    border-radius: 50%;
}

.timer-value {
    position: relative;
    z-index: 1;
    font-size: 1rem;
}

.timer.warning .timer-value {
    color: var(--warning);
}

.timer.danger .timer-value {
    color: var(--danger);
    animation: pulse 0.5s infinite;
}

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

/* Question Area */
.quiz-content {
    flex: 1;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 0;
    overflow: hidden;
}

/* En mode carte, ne pas centrer verticalement */
.quiz-content:has(.quiz-map) {
    justify-content: flex-start;
}

.question-card {
    text-align: center;
    margin-bottom: 32px;
}

.question-number {
    font-size: 0.85rem;
    color: var(--gray);
    margin-bottom: 8px;
}

.question-text {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--dark);
}

.question-flag {
    font-size: 6rem;
    margin: 20px 0;
    line-height: 1;
}

/* Answer Input */
.answer-input-container {
    position: relative;
}

.answer-input-container.with-unit {
    display: flex;
    align-items: center;
    gap: 12px;
}

.answer-input-container.with-unit .answer-input {
    flex: 1;
}

.input-unit {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--dark);
    white-space: nowrap;
}

.answer-input {
    width: 100%;
    padding: 18px 20px;
    border: 3px solid #e2e8f0;
    border-radius: var(--radius-lg);
    font-size: 1.25rem;
    text-align: center;
    transition: all 0.3s;
}

.answer-input:focus {
    outline: none;
    border-color: var(--primary);
}

.answer-input.correct {
    border-color: var(--success);
    background: rgba(72, 187, 120, 0.1);
}

.answer-input.incorrect {
    border-color: var(--danger);
    background: rgba(245, 101, 101, 0.1);
}

/* QCM Choices */
.choices-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.choice-btn {
    padding: 18px 20px;
    border: 3px solid #e2e8f0;
    border-radius: var(--radius);
    background: white;
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

@media (hover: hover) and (pointer: fine) {
    .choice-btn:hover {
        border-color: var(--primary);
        background: rgba(102, 126, 234, 0.05);
    }
}

.choice-btn:active {
    border-color: var(--primary);
    background: rgba(102, 126, 234, 0.05);
}

.choice-btn:focus,
.choice-btn:focus-visible {
    outline: none;
    box-shadow: none;
    -webkit-tap-highlight-color: transparent;
}

.choice-btn.selected {
    border-color: var(--primary);
    background: rgba(102, 126, 234, 0.1);
}

.choice-btn.correct {
    border-color: var(--success);
    background: rgba(72, 187, 120, 0.15);
}

.choice-btn.incorrect {
    border-color: var(--danger);
    background: rgba(245, 101, 101, 0.15);
}

.choice-btn.disabled {
    pointer-events: none;
    opacity: 0.7;
}

/* Révélation progressive des réponses */
.choice-btn.progressive-reveal,
.flag-choice.progressive-reveal {
    --reveal-blur: 15px;
}

.choice-btn.progressive-reveal > span {
    filter: blur(var(--reveal-blur));
    transition: filter 0.15s linear;
}

.flag-choice.progressive-reveal .flag {
    filter: blur(var(--reveal-blur));
    transition: filter 0.15s linear;
}

/* Quand révélé complètement */
.choice-btn.progressive-reveal.revealed > span,
.flag-choice.progressive-reveal.revealed .flag {
    filter: none;
}

/* Flag Choices */
.flag-choices {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.flag-choice {
    padding: 20px;
    border: 3px solid #e2e8f0;
    border-radius: var(--radius);
    background: white;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

@media (hover: hover) and (pointer: fine) {
    .flag-choice:hover {
        border-color: var(--primary);
    }
}

.flag-choice:active {
    border-color: var(--primary);
}

.flag-choice:focus,
.flag-choice:focus-visible {
    outline: none;
    box-shadow: none;
    -webkit-tap-highlight-color: transparent;
}

.flag-choice .flag {
    font-size: 4rem;
    line-height: 1;
}

.flag-choice.correct {
    border-color: var(--success);
    background: rgba(72, 187, 120, 0.15);
}

.flag-choice.incorrect {
    border-color: var(--danger);
    background: rgba(245, 101, 101, 0.15);
}

.flag-choice.disabled {
    pointer-events: none;
    opacity: 0.7;
}

/* Flag Images (pour compatibilité Windows/Edge) */
.flag-img {
    display: inline-block;
    vertical-align: middle;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.flag-img-sm {
    width: 24px;
    height: auto;
}

.flag-img-md {
    width: 80px;
    height: auto;
}

.flag-img-lg {
    width: 160px;
    height: auto;
}

.question-flag .flag-img {
    max-width: 200px;
    height: auto;
}

.flag-choice .flag-img {
    width: 100%;
    max-width: 100px;
    height: auto;
}

/* Feedback Animation */
.feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: 5rem;
    z-index: 200;
    animation: feedbackPop 0.5s ease-out forwards;
}

@keyframes feedbackPop {
    0% { transform: translate(-50%, -50%) scale(0); }
    50% { transform: translate(-50%, -50%) scale(1.2); }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

/* Score Display */
.score-display {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.score-value {
    font-size: 1.25rem;
    color: var(--primary);
}

/* Results Screen */
.results-screen {
    min-height: 100vh;
    background: white;
    display: flex;
    flex-direction: column;
}

.results-header {
    background: var(--gradient);
    padding: 40px 20px;
    text-align: center;
    color: white;
}

.results-emoji {
    font-size: 4rem;
    margin-bottom: 16px;
}

.results-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.results-score {
    font-size: 3rem;
    font-weight: 800;
}

.results-percentage {
    font-size: 1.25rem;
    opacity: 0.9;
}

.results-content {
    flex: 1;
    padding: 20px;
}

.results-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--light);
    padding: 16px;
    border-radius: var(--radius);
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--gray);
}

/* Stats inline (résultats) */
.results-stats-inline {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
}

.stat-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--light);
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
}

.stat-inline i {
    font-size: 1.1rem;
}

/* Multiplayer */
.players-list {
    margin: 16px 0;
}

.player-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--light);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.player-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

.player-name {
    font-weight: 600;
}

.player-status {
    font-size: 0.85rem;
    color: var(--gray);
}

.player-score {
    font-weight: 700;
    font-size: 1.25rem;
}

.player-item.winner {
    background: linear-gradient(135deg, rgba(72, 187, 120, 0.15) 0%, rgba(72, 187, 120, 0.05) 100%);
    border: 2px solid var(--success);
}

/* Session Code */
.session-code {
    background: var(--light);
    padding: 20px;
    border-radius: var(--radius-lg);
    text-align: center;
    margin: 20px 0;
}

.session-code-label {
    font-size: 0.9rem;
    color: var(--gray);
    margin-bottom: 8px;
}

.session-code-value {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: 8px;
    color: var(--primary);
    font-family: monospace;
}

/* QR Code */
.qr-code-container {
    text-align: center;
    margin: 16px 0;
}

.qr-code-img {
    width: 150px;
    height: 150px;
    border-radius: var(--radius);
    border: 2px solid var(--light);
}

.login-qr-code {
    width: 120px;
    height: 120px;
    border-radius: var(--radius);
    border: 2px solid var(--light);
    display: block;
    margin: 0 auto;
}

/* Share Buttons */
.share-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 16px 0;
}

.share-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 0.9rem;
}

.share-btn i {
    font-size: 1.1rem;
}

/* Pause Overlay */
.pause-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1100; /* Au-dessus de Leaflet (max ~1000) */
    color: white;
}

.pause-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.pause-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 30px;
}

.pause-overlay .btn {
    min-width: 180px;
    max-width: 250px;
}

/* Map Container */
.map-container {
    width: 100%;
    height: 300px;
    border-radius: var(--radius);
    overflow: hidden;
    margin: 16px 0;
}

/* Custom Modal Overlay (pour éviter conflit avec Bootstrap) */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

/* Loading overlay - z-index légèrement inférieur */
#loading-overlay {
    z-index: 9998;
}

/* Modal Rejoindre - Custom */
.join-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 20px;
}

.join-modal-box {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.join-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.join-modal-header h5 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}

.btn-close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    line-height: 1;
}

.btn-close-modal:hover {
    color: #000;
}

.join-modal-body {
    padding: 20px;
}

.join-modal-body label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.join-modal-body input {
    width: 100%;
    padding: 16px;
    font-size: 1.5rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 8px;
    font-weight: bold;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    outline: none;
}

.join-modal-body input:focus {
    border-color: var(--primary);
}

.join-modal-footer {
    padding: 16px 20px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Modal de confirmation Bootstrap */
#confirmModal .modal-dialog {
    max-width: 360px;
}

#confirmModal .modal-content {
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

#confirmModal .modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
}

#confirmModal .modal-title {
    font-size: 1.1rem;
    font-weight: 600;
}

#confirmModal .modal-body {
    padding: 20px;
    font-size: 0.95rem;
    color: var(--text-muted);
}

#confirmModal .modal-footer {
    padding: 12px 20px;
    border-top: 1px solid #e2e8f0;
    justify-content: flex-end;
}

#confirmModal .modal-footer .btn {
    padding: 8px 20px;
    font-size: 0.9rem;
}

/* Leaderboard */
.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #e2e8f0;
}

.leaderboard-rank {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin-right: 12px;
}

.leaderboard-rank.gold {
    background: #ffd700;
    color: white;
}

.leaderboard-rank.silver {
    background: #c0c0c0;
    color: white;
}

.leaderboard-rank.bronze {
    background: #cd7f32;
    color: white;
}

.leaderboard-info {
    flex: 1;
}

.leaderboard-name {
    font-weight: 600;
}

.leaderboard-stats {
    font-size: 0.85rem;
    color: #4a5568;
}

.leaderboard-score {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
}

/* Administration : ajout replié sous son en-tête, lignes du classement suivies de leur formulaire replié */
.comptes-entete {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.comptes-chevron {
    transition: transform 0.2s;
}

[aria-expanded="true"] > .comptes-chevron {
    transform: rotate(180deg);
}


.comptes-formulaire {
    padding-top: 16px;
}

.comptes-modification {
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
}

.comptes-facultatif,
.comptes-nombre {
    font-weight: 400;
    color: #4a5568;
}

.comptes-pastille {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--light);
    color: #4a5568;
    font-size: 0.75rem;
    font-weight: 600;
    vertical-align: middle;
}

.comptes-pastille-desactive {
    background: #fed7d7;
    color: #9b2c2c;
}

.comptes-desactive .leaderboard-name {
    color: #4a5568;
}

/* Photo d'accueil : une forme par bouton d'option, la case reste lisible au clavier */
.photo-formes {
    border: 0;
    padding: 0;
    margin: 0 0 16px;
    min-width: 0;
}

.photo-forme {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.photo-forme input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.photo-forme:has(input:checked) {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    color: var(--primary);
}

.photo-forme:has(input:focus-visible),
.photo-fichier:focus-visible + .photo-choisir {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.photo-fichier {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.photo-choisir {
    width: auto;
}

.photo-nom {
    display: block;
    margin-top: 8px;
    color: #4a5568;
    overflow-wrap: anywhere;
}

.photo-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

.photo-actions .btn {
    width: auto;
}

/* Accès à l'administration depuis l'en-tête : l'icône seule sur un téléphone */
.btn-administration {
    width: auto;
    padding: 8px 14px;
    font-size: 0.9rem;
}

@media (max-width: 479.98px) {
    .photo-actions .btn {
        flex: 1 1 100%;
    }

    .btn-administration {
        padding: 8px 10px;
    }

    .btn-administration span {
        display: none;
    }
}

.toggle input:focus-visible + .toggle-slider {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* Bottom Navigation */
.bottom-nav {
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    padding: 8px 0;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    position: sticky;
    bottom: 0;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
    text-decoration: none;
    color: var(--gray);
    font-size: 0.75rem;
    transition: color 0.2s;
}

.nav-item i {
    font-size: 1.25rem;
    margin-bottom: 4px;
}

.nav-item.active {
    color: var(--primary);
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Photo Viewer */
.photo-viewer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: photoFadeIn 0.3s ease;
}

.photo-viewer.hidden {
    display: none !important;
}

.photo-viewer-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    cursor: pointer;
}

.photo-viewer-container {
    position: relative;
    z-index: 1;
    max-width: 90%;
    max-height: 90%;
    overflow: hidden;
    touch-action: none;
    border-radius: var(--radius-lg);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
}

.photo-viewer-img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    display: block;
    animation: photoZoomIn 0.3s ease;
    transform-origin: center center;
    transition: transform 0.1s ease-out;
    cursor: grab;
    user-select: none;
    -webkit-user-drag: none;
}

.photo-viewer-img.dragging {
    cursor: grabbing;
    transition: none;
}

.photo-viewer-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.5rem;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.photo-viewer-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.photo-viewer-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
    z-index: 2;
    pointer-events: none;
}

@keyframes photoFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes photoZoomIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* Responsive adjustments */
@media (min-width: 480px) {
    .choices-grid {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .category-icon {
        width: 48px;
        height: 48px;
        font-size: 1.3rem;
    }

    .category-name {
        font-size: 0.8rem;
    }
}

@media (min-width: 768px) {
    .app-content {
        max-width: 600px;
        margin: 0 auto;
    }

    .quiz-content {
        max-width: 700px;
        margin: 0 auto;
    }

    .categories-grid {
        gap: 12px;
    }

    .category-card {
        padding: 16px 12px;
    }

    .category-icon {
        width: 56px;
        height: 56px;
        font-size: 1.5rem;
    }

    .category-name {
        font-size: 0.9rem;
    }
}

/* Safe areas for notched phones */
@supports (padding: env(safe-area-inset-top)) {
    .app-header {
        padding-top: calc(12px + env(safe-area-inset-top));
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    body.dark-mode {
        --dark: #f7fafc;
        --light: #1a202c;
        background: #0f0f1a;
    }

    body.dark-mode .card,
    body.dark-mode .quiz-screen,
    body.dark-mode .results-screen,
    body.dark-mode .modal {
        background: #1a1a2e;
        color: #f7fafc;
    }
}

/* Affichage de la bonne réponse */
.correct-answer-display {
    margin-top: 20px;
    animation: slideUp 0.3s ease;
}

.correct-answer-box {
    background: linear-gradient(135deg, rgba(72, 187, 120, 0.15) 0%, rgba(72, 187, 120, 0.05) 100%);
    border: 2px solid var(--success);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 1.2rem;
}

.correct-answer-box i {
    color: var(--success);
    font-size: 1.5rem;
}

.correct-answer-box strong {
    color: var(--success);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Correction inline pour input texte */
.input-correction {
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(72, 187, 120, 0.15);
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--success);
    text-align: center;
}

/* Amélioration input numérique */
.answer-input[inputmode="numeric"] {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 2px;
}

/* Animation slide in pour les toasts */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== MAP QUIZ ==================== */

/* Question area en mode carte : utiliser flex pour remplir l'espace */
#question-area:has(.quiz-map) {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

#question-area:has(.quiz-map) .question-card {
    flex-shrink: 0;
    margin-bottom: 16px;
}

#question-area:has(.quiz-map) .text-center.text-muted {
    flex-shrink: 0;
}

/* Container de la carte du quiz */
.quiz-map {
    width: 100%;
    flex: 1;
    min-height: 200px;
    max-height: 70vh;
    border-radius: var(--radius);
    overflow: hidden;
    border: 3px solid #e2e8f0;
    cursor: crosshair;
}

/* Sur PC, limiter la hauteur et centrer */
@media (min-width: 768px) {
    .quiz-map {
        max-height: min(60vh, 500px);
        aspect-ratio: 16 / 9;
        margin: 0 auto;
    }
}

@media (min-width: 1024px) {
    .quiz-map {
        max-height: min(65vh, 600px);
        max-width: 900px;
    }
}

/* Override Leaflet pour mobile */
.quiz-map .leaflet-control-zoom {
    border: none;
    box-shadow: var(--shadow);
}

.quiz-map .leaflet-control-zoom a {
    width: 32px;
    height: 32px;
    line-height: 32px;
    font-size: 18px;
    color: var(--dark);
    background: white;
}

.quiz-map .leaflet-control-zoom a:hover {
    background: var(--light);
}

/* Marqueurs personnalisés */
.marker-pin {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.marker-pin.correct {
    background: var(--success);
}

.marker-pin.wrong {
    background: var(--danger);
}

/* Popup Leaflet amélioré */
.quiz-map .leaflet-popup-content-wrapper {
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.quiz-map .leaflet-popup-content {
    margin: 12px 16px;
    font-size: 1rem;
    font-family: 'Segoe UI', system-ui, sans-serif;
}

/* Popups de feedback carte */
.map-popup-correct .leaflet-popup-content-wrapper,
.map-popup-wrong .leaflet-popup-content-wrapper {
    background: transparent;
    box-shadow: none;
    padding: 0;
}

.map-popup-correct .leaflet-popup-content,
.map-popup-wrong .leaflet-popup-content {
    margin: 0;
}

.map-popup-correct .leaflet-popup-tip,
.map-popup-wrong .leaflet-popup-tip {
    display: none;
}

/* Instruction sur la carte */
.map-instruction {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    z-index: 1000;
    pointer-events: none;
}

/* =====================================================
   CARTE DE FRANCE (Départements et Régions)
   ===================================================== */

/* Container de la carte France */
.france-map-container {
    width: 100%;
    max-width: 600px;
    height: 50vh;
    min-height: 300px;
    max-height: 500px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.france-map-container svg {
    width: auto;
    height: 100%;
    max-width: 100%;
}

/* Styles des départements (dans le SVG) */
.france-map-container .dept {
    fill: #e2e8f0;
    stroke: #64748b;
    stroke-width: 0.5;
    cursor: pointer;
    transition: fill 0.2s ease;
}

.france-map-container .dept:hover {
    fill: #cbd5e1;
}

.france-map-container .dept.highlighted {
    fill: #667eea;
    stroke: #4f46e5;
    stroke-width: 2;
    filter: drop-shadow(0 2px 4px rgba(102, 126, 234, 0.4));
}

.france-map-container .dept.correct {
    fill: #22c55e;
    stroke: #16a34a;
    stroke-width: 2;
}

.france-map-container .dept.wrong {
    fill: #ef4444;
    stroke: #dc2626;
    stroke-width: 2;
}

.france-map-container .dept.selected {
    fill: #3b82f6;
    stroke: #2563eb;
    stroke-width: 2;
}

/* Styles des régions (dans le SVG) */
.france-map-container .region {
    fill: #e2e8f0;
    stroke: #475569;
    stroke-width: 1;
    cursor: pointer;
    transition: fill 0.2s ease;
}

.france-map-container .region:hover {
    fill: #cbd5e1;
}

.france-map-container .region.highlighted {
    fill: #667eea;
    stroke: #4f46e5;
    stroke-width: 2;
    filter: drop-shadow(0 2px 4px rgba(102, 126, 234, 0.4));
}

.france-map-container .region.correct {
    fill: #22c55e;
    stroke: #16a34a;
    stroke-width: 2;
}

.france-map-container .region.wrong {
    fill: #ef4444;
    stroke: #dc2626;
    stroke-width: 2;
}

.france-map-container .region.selected {
    fill: #3b82f6;
    stroke: #2563eb;
    stroke-width: 2;
}

/* Responsive carte France */
@media (min-width: 768px) {
    .france-map-container {
        max-width: 500px;
        height: 55vh;
        max-height: 450px;
    }
}

@media (min-width: 1024px) {
    .france-map-container {
        max-width: 550px;
        height: 60vh;
        max-height: 500px;
    }
}

/* Question area en mode carte France */
#question-area:has(.france-map-container) {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

#question-area:has(.france-map-container) .question-card {
    flex-shrink: 0;
    margin-bottom: 16px;
}

.quiz-content:has(.france-map-container) {
    justify-content: flex-start;
}
