:root {
    --font-family-serif: 'Playfair Display', 'Georgia', serif;
    --font-family-sans: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    /* Light Theme */
    --color-background-light: #f8f9fa;
    --color-paper-light: #ffffff;
    --color-text-light: #212529;
    --color-primary-light: #6a11cb;
    --color-accent-start-light: #fc5c7d;
    --color-accent-end-light: #f7797d;
    --color-border-light: #e9ecef;
    --color-success-light: #198754;
    --color-error-light: #dc3545;
    
    /* Dark Theme */
    --color-background-dark: #121212;
    --color-paper-dark: #1e1e1e;
    --color-text-dark: #e0e0e0;
    --color-primary-dark: #00c9ff;
    --color-accent-start-dark: #00c9ff;
    --color-accent-end-dark: #92fe9d;
    --color-border-dark: #333;
    --color-success-dark: #20c997;
    --color-error-dark: #ff5252;
    
    --color-background: var(--color-background-light);
    --color-paper: var(--color-paper-light);
    --color-text: var(--color-text-light);
    --color-primary: var(--color-primary-light);
    --color-accent-start: var(--color-accent-start-light);
    --color-accent-end: var(--color-accent-end-light);
    --color-border: var(--color-border-light);
    --color-success: var(--color-success-light);
    --color-error: var(--color-error-light);

    --border-radius: 12px;
    --box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    --container-width: 1200px;
    --gradient-accent: linear-gradient(45deg, var(--color-accent-start), var(--color-accent-end));
}

:root[data-theme="dark"] {
    --color-background: var(--color-background-dark);
    --color-paper: var(--color-paper-dark);
    --color-text: var(--color-text-dark);
    --color-primary: var(--color-primary-dark);
    --color-accent-start: var(--color-accent-start-dark);
    --color-accent-end: var(--color-accent-end-dark);
    --color-border: var(--color-border-dark);
    --color-success: var(--color-success-dark);
    --color-error: var(--color-error-dark);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family-sans);
    background-color: var(--color-background);
    color: var(--color-text);
    line-height: 1.7;
    padding: 0.5rem; /* Mobile padding */
    transition: background-color 0.3s, color 0.3s;
    overflow-x: hidden;
}

main {
    width: 100%;
    max-width: var(--container-width);
    margin: 0 auto;
    padding-bottom: 6rem; /* More space for footer on mobile */
}

h1, h2, h3, h4 {
    line-height: 1.2;
    font-weight: 700;
    text-align: center;
}
/* Adjusted for mobile */
h1 { font-family: var(--font-family-serif); font-size: clamp(2.5rem, 12vw, 3.5rem); margin-bottom: 0.5rem; color: var(--color-text); background: var(--gradient-accent); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
h2 { font-size: 1.75rem; color: var(--color-primary); margin-bottom: 1rem; }
h3 { display: flex; align-items: center; justify-content: center; gap: 0.5rem; font-size: 1.25rem; margin-bottom: 1rem; color: var(--color-text)}
h4 { font-size: 1.1rem; margin-bottom: 0.75rem; color: var(--color-primary); }


.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.8rem 1.8rem;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    border: none;
    border-radius: var(--border-radius);
    background: var(--gradient-accent);
    color: white;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    -webkit-tap-highlight-color: transparent; /* Better mobile tap experience */
}
.btn:hover, .btn:focus-visible {
    transform: translateY(-3px);
    box-shadow: 0 7px 20px rgba(0,0,0,0.2);
    outline: none;
}
.btn:active { transform: translateY(-1px); }
.btn:disabled { background: #ccc; cursor: not-allowed; transform: none; box-shadow: none; opacity: 0.6; }

.btn-secondary {
    background: transparent;
    color: var(--color-text);
    box-shadow: none;
    border: 2px solid var(--color-border);
}
.btn-secondary:hover, .btn-secondary:focus-visible {
    background-color: var(--color-paper);
    color: var(--color-primary);
    border-color: var(--color-primary);
    box-shadow: none;
}
.btn svg { width: 1.2em; height: 1.2em; }

.hidden { display: none !important; }

.screen { animation: fadeIn 0.6s cubic-bezier(0.165, 0.84, 0.44, 1); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.card {
    background-color: var(--color-paper);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    padding: 1rem; /* Mobile padding */
    margin-bottom: 1.5rem;
    box-shadow: var(--box-shadow);
    transition: background-color 0.3s, border-color 0.3s;
}
:root[data-theme="dark"] .card {
    border: 1px solid transparent;
    background: linear-gradient(var(--color-paper), var(--color-paper)) padding-box,
                linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0)) border-box;
}

/* --- Écran d'accueil --- */
#accueil-screen { text-align: center; }
#accueil-screen .card,
#recap-screen .card {
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    padding: 1.5rem; /* More padding for these main cards */
}
#accueil-screen h2 { color: var(--color-text); }
#accueil-screen p { margin-bottom: 1.5rem; max-width: 500px; margin-left: auto; margin-right: auto;}
#score-rule-display { font-family: monospace; font-size: 0.9em; padding: 0.2em 0.5em; border-radius: 4px; display: inline-block; background: var(--color-background); border: 1px solid var(--color-border); }
#start-game-btn { font-size: 1.1rem; padding: 0.9rem 2rem; }
.rgpd-notice { font-size: 0.8rem; color: #777; }
:root[data-theme="dark"] .rgpd-notice { color: #aaa; }


#difficulty-selector, #city-selector-container { margin: 2rem 0; }
.difficulty-options { display: flex; justify-content: center; gap: 0.5rem; /* smaller gap on mobile */ flex-wrap: wrap; margin-top: 1rem;}
.difficulty-options label {
    padding: 0.5rem 1rem;
    border: 2px solid var(--color-border);
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
}
.difficulty-options input[type="radio"] { display: none; }
.difficulty-options input[type="radio"]:checked + label {
    background: var(--gradient-accent);
    color: white;
    border-color: transparent;
}
.difficulty-options label:hover { border-color: var(--color-primary); }

.select-wrapper {
    position: relative;
    width: 100%;
    max-width: 300px;
    margin: 1rem auto 0;
}
.select-wrapper::after {
    content: '▼';
    font-size: 1rem;
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--color-text);
    opacity: 0.5;
}
#city-selector {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    font-size: 1rem;
    font-family: var(--font-family-sans);
    border: 2px solid var(--color-border);
    border-radius: var(--border-radius);
    background-color: var(--color-paper);
    color: var(--color-text);
    cursor: pointer;
    transition: border-color 0.2s ease;
}
#city-selector:hover, #city-selector:focus {
    border-color: var(--color-primary);
    outline: none;
}
#city-selector:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* --- Écran de jeu --- */
#jeu-screen { display: flex; flex-direction: column; height: 100%;}
#jeu-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; font-weight: 600; font-size: 1.1rem; padding: 0 0.5rem; }
#score-indicator { transition: all 0.3s ease; }
#score-value.updating { transform: scale(1.3); color: var(--color-primary); }

.game-area { display: flex; flex-direction: column; gap: 1rem; }

#postcard-container { padding: 1rem; }
#postcard-image {
    display: block;
    width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    cursor: zoom-in;
    transition: transform 0.3s ease;
}
#postcard-image:hover { transform: scale(1.02); }
.image-loading { min-height: 40vh; background-color: var(--color-border); display: flex; align-items: center; justify-content: center; font-style: italic; border-radius: var(--border-radius); }
#credits { font-size: 0.8rem; color: #777; margin-top: 1rem; text-align: center; }
:root[data-theme="dark"] #credits { color: #aaa; }


#controls-deck { /* Not sticky on mobile */ }
#indices-container { margin-bottom: 1.5rem; display: flex; flex-direction: column; align-items: center;}
#indices-list { list-style: none; padding-left: 0; width: 100%; }
#indices-list li { margin-bottom: 0.5rem; background-color: var(--color-background); padding: 0.75rem; border-left: 4px solid var(--color-primary); border-radius: 4px; animation: fadeIn 0.4s ease forwards; }

#answer-form { display: flex; flex-direction: column; gap: 1.5rem; text-align: center;}
.form-group label { font-weight: 600; font-size: 1.1rem; margin-bottom: 1rem; display: block;}

.slider-wrapper { position: relative; }
.slider-tooltip {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gradient-accent);
    color: white;
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: bold;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    will-change: left;
}
#annee-slider:active ~ .slider-tooltip,
#annee-slider:focus ~ .slider-tooltip,
#annee-slider:hover ~ .slider-tooltip {
    opacity: 1;
}

#annee-guess {
    font-size: 2rem;
    font-weight: 700;
    font-family: var(--font-family-sans);
    color: var(--color-text);
    background: transparent;
    border: none;
    text-align: center;
    width: 100%;
    margin-bottom: 0.5rem;
    pointer-events: none; /* Can't be typed in, only slider controls it */
}
#annee-slider { width: 100%; -webkit-appearance: none; appearance: none; height: 10px; background: var(--color-border); border-radius: 5px; outline: none; transition: opacity .2s; }
#annee-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 25px; height: 25px; background: var(--gradient-accent); border-radius: 50%; cursor: pointer; border: 3px solid var(--color-paper); }
#annee-slider::-moz-range-thumb { width: 25px; height: 25px; background: var(--gradient-accent); border-radius: 50%; cursor: pointer; border: 3px solid var(--color-paper); }


#feedback-container { margin-top: 1rem; padding: 1rem; border-radius: var(--border-radius); text-align: center; display: flex; align-items: center; justify-content: center; gap: 1rem; animation: fadeInScale 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes fadeInScale { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
#feedback-container.correct { background-color: var(--color-success); color: white; }
#feedback-container.incorrect { background-color: var(--color-error); color: white; }
#feedback-container p { margin: 0; font-weight: 600; font-size: 1.1rem; }
#feedback-container svg { width: 2em; height: 2em; flex-shrink: 0;}

#next-card-controls { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1rem; }

#discovery-panel {
    margin-top: 1.5rem;
    padding: 1rem;
    background-color: var(--color-background);
    border-radius: var(--border-radius);
    border-left: 4px solid var(--color-accent-end);
    animation: fadeIn 0.5s ease;
}
#discovery-panel h4 {
    text-align: left;
}
#discovery-panel p {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}
#discovery-panel p strong {
    color: var(--color-text);
}


/* --- Responsive Tables (Mobile First) --- */
.responsive-table {
    display: block;
    width: 100%;
    margin: 2rem 0;
}
.responsive-table thead {
    display: none;
}
.responsive-table tbody {
    display: block;
    width: 100%;
}
.responsive-table tr {
    display: block;
    width: 100%;
    margin-bottom: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    padding: 1rem;
    background-color: var(--color-background);
}
.responsive-table tr:nth-child(even) { background-color: var(--color-paper); }

.responsive-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: right !important;
    border: none !important;
    padding: 0.5rem 0 !important;
}
.responsive-table td::before {
    content: attr(data-label);
    font-weight: bold;
    text-align: left;
    margin-right: 1rem;
    color: var(--color-primary);
}
#recap-table {
    border-collapse: separate;
    border-spacing: 0;
}
/* Total row specific style */
.responsive-table .total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    font-size: 1.1rem;
    border: none;
    border-top: 2px solid var(--color-text);
    padding: 1rem 0 0;
    margin-top: 1rem;
    border-radius: 0;
    background: transparent;
}
.responsive-table .total-row td {
    display: inline;
    padding: 0 !important;
    background: transparent !important;
}
.responsive-table .total-row td::before { display: none; }


.donation-box {
    margin: 2.5rem 0;
    padding: 2rem;
    text-align: center;
    border-radius: var(--border-radius);
    background-color: var(--color-background);
    border: 2px dashed var(--color-border);
    transition: border-color 0.3s ease, background-color 0.3s ease;
}

.donation-box:hover {
    border-color: var(--color-primary);
    background-color: var(--color-paper);
}

.donation-box .coffee-icon {
    width: 48px;
    height: 48px;
    color: var(--color-primary);
    margin-bottom: 1rem;
    opacity: 0.8;
}

.donation-box h3 {
    color: var(--color-primary);
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}
.donation-box p {
    margin-bottom: 1.5rem;
    max-width: 450px;
    margin-left: auto;
    margin-right: auto;
    opacity: 0.9;
}

.recap-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

#leaderboard-section { margin-top: 2rem; }
.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.leaderboard-header h3 {
    margin-bottom: 0;
}
.leaderboard-header .btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    gap: 0.5rem;
}

#pseudo-form { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
#pseudo-input { flex-grow: 1; padding: 0.75rem; border: 2px solid var(--color-border); border-radius: var(--border-radius); font-size: 1rem; background-color: var(--color-paper); color: var(--color-text);}

#score-submission-feedback {
    padding: 0.75rem;
    background-color: var(--color-background);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-success);
    border-radius: var(--border-radius);
    margin: 1rem 0;
    text-align: center;
}

/* --- Lightbox & Modals --- */
.lightbox { position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0, 0, 0, 0.9); display: flex; align-items: center; justify-content: center; padding: 1rem; animation: fadeIn 0.3s ease; }
.lightbox-content { margin: auto; display: block; max-width: 90%; max-height: 90vh; animation: zoomIn 0.3s ease-out; border-radius: var(--border-radius); }
#about-modal .modal-content, #legal-modal .modal-content { max-width: 600px; text-align: left; position: relative; }
#about-modal h3, #legal-modal h3 { text-align: left; }
#about-modal p, #legal-modal p { margin-bottom: 1rem; }
#legal-modal h4 { text-align: left; margin-top: 1rem; }

@keyframes zoomIn { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.lightbox-close { position: absolute; top: 1rem; right: 1.5rem; color: var(--color-text); opacity: 0.6; font-size: 40px; font-weight: bold; transition: 0.3s; cursor: pointer; z-index: 1001; }
.lightbox-close:hover, .lightbox-close:focus { color: var(--color-primary); text-decoration: none; opacity: 1; }
#lightbox .lightbox-close { color: #f1f1f1; } /* Specific close for image lightbox */

/* --- Utilitaires --- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0; }
.demo-banner { background: var(--gradient-accent); color: white; text-align: center; padding: 0.5rem; font-weight: bold; position: sticky; top: 0; z-index: 100; }

/* --- Footer --- */
#app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background-color: var(--color-paper);
    border-top: 1px solid var(--color-border);
    box-shadow: 0 -4px 15px rgba(0,0,0,0.05);
    z-index: 999;
}
.logo-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--color-text);
    text-decoration: none;
    transition: color 0.2s ease;
}
.logo-link:hover {
    color: var(--color-primary);
}
.logo-svg {
    color: var(--color-primary);
}

.footer-nav {
    display: flex;
    gap: 1rem;
}
.footer-nav a {
    color: var(--color-text);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
    opacity: 0.8;
}
.footer-nav a:hover {
    color: var(--color-primary);
    opacity: 1;
}

#theme-toggle {
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
    box-shadow: none;
}
#theme-toggle svg { width: 24px; height: 24px; }


@media (max-width: 991px) {
    .game-area {
        /* Add space at the bottom so content isn't hidden by the fixed controls */
        padding-bottom: 24rem; 
    }

    #controls-deck {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 990; /* Below modals */
        
        /* Override .card styles for a 'bar' look */
        margin-bottom: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        box-shadow: 0 -4px 15px rgba(0,0,0,0.1);
        max-width: none;
        
        /* Make it scrollable if its content overflows on very small screens */
        max-height: 45vh; /* Limit height */
        overflow-y: auto;
    }
}


@media (max-width: 600px) {
    .logo-link span, .footer-nav {
        display: none;
    }
    #app-footer {
        justify-content: space-around;
    }
}

/* Tablet and up */
@media (min-width: 768px) {
    body {
        padding: 1rem;
    }
    main {
        padding-bottom: 5rem;
    }
    h1 { font-size: clamp(3rem, 10vw, 5rem); }
    h2 { font-size: 2rem; }
    .card {
        padding: 1.5rem;
    }
    .difficulty-options { gap: 1rem; }
    .footer-nav { gap: 1.5rem; }
    #start-game-btn { font-size: 1.2rem; padding: 1rem 2.5rem; }

    /* Restore table layout */
    .responsive-table {
        display: table;
        border-collapse: collapse;
        border-spacing: 0;
    }
    .responsive-table thead {
        display: table-header-group;
    }
    .responsive-table tbody {
        display: table-row-group;
    }
    .responsive-table tr {
        display: table-row;
        border: none;
        padding: 0;
        margin: 0;
        background: transparent !important; /* Override mobile styles */
    }
    .responsive-table td {
        display: table-cell;
        padding: 0.75rem !important; /* Override mobile styles */
        text-align: left !important;
        border-bottom: 1px solid var(--color-border) !important;
    }
    .responsive-table td::before {
        display: none;
    }
    #recap-table { border-collapse: collapse; }
    #recap-table .total-row { font-weight: bold; border-top: 2px solid var(--color-text); font-size: 1.1rem; }
    .responsive-table .total-row {
        display: table-row; /* Restore display */
        border: none;
        padding: 0;
        margin: 0;
    }
     .responsive-table .total-row td {
         display: table-cell;
     }

    #leaderboard-table th, #leaderboard-table td { padding: 0.5rem; }
    #leaderboard-table tr:nth-child(even) { background-color: var(--color-background); }
}

@media (min-width: 992px) {
    .card { padding: 2rem; }
    .game-area {
        flex-direction: row;
        align-items: flex-start;
        gap: 2rem;
    }
    #postcard-container { flex: 2; }
    #controls-deck {
        flex: 1;
        position: sticky;
        top: 6rem;
        max-width: 400px;
    }
}