/* =========================================
   RESET
========================================= */

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


:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;

    --background: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;

    --text: #172033;
    --text-secondary: #64748b;
    --text-light: #94a3b8;

    --border: #e2e8f0;

    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #ef4444;

    --radius: 16px;
    --radius-small: 10px;

    --shadow:
        0 4px 20px rgba(15, 23, 42, 0.06);

    --shadow-hover:
        0 8px 30px rgba(15, 23, 42, 0.10);
}


html {
    min-height: 100%;
}


body {
    min-height: 100vh;

    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    color: var(--text);
    background: var(--background);
}

input,
textarea,
select {
    font-size: 16px;
}

/* =========================================
   APP LAYOUT
========================================= */

#app {
    width: min(1400px, 100%);
    margin: 0 auto;

    padding: 40px 32px 60px;

    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 28px;

    align-items: start;
}


#game-area {
    min-width: 0;
}


/* =========================================
   HEADER
========================================= */

.game-header {
    width: 100%;

    margin-bottom: 28px;
    padding: 28px 36px;

    background: #ffffff;

    border: 1px solid #e2e8f0;
    border-radius: 16px;

    box-shadow:
        0 4px 18px rgba(15, 23, 42, 0.05);

    position: relative;
    overflow: hidden;
}

.game-header::before {
    content: "";

    position: absolute;

    top: 0;
    left: 0;

    width: 5px;
    height: 100%;

    background: #2563eb;
}

.game-header > div {
    display: flex;
    align-items: center;
    gap: 18px;
}

.game-header .eyebrow {
    display: inline-flex;
    align-items: center;

    height: 28px;

    padding: 0 10px;

    margin: 0;

    color: #2563eb;
    background: #eff6ff;

    border-radius: 7px;

    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;

    white-space: nowrap;
}

.game-header h1 {
    margin: 0;

    font-size: 26px;
    line-height: 1;

    letter-spacing: -0.025em;

    white-space: nowrap;
}

.game-header .subtitle {
    margin: 0;

    padding-left: 18px;

    border-left: 1px solid #e2e8f0;

    color: #64748b;

    font-size: 14px;

    line-height: 1.4;
}


/* =========================================
   COMMON CARDS
========================================= */

.setup-card,
.game-card,
.parameters-card {
    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: var(--radius);

    box-shadow: var(--shadow);
}


/* =========================================
   SETUP
========================================= */

.setup-card {
    padding: 28px;
    margin-bottom: 28px;
}


.section-title,
.parameters-header {
    display: flex;
    align-items: center;
    gap: 14px;

    margin-bottom: 24px;
}


.section-icon {
    width: 42px;
    height: 42px;

    display: grid;
    place-items: center;

    border-radius: 12px;

    background: var(--primary-light);
    color: var(--primary);

    font-size: 19px;
}


.section-title h2,
.parameters-header h2 {
    font-size: 19px;
    margin-bottom: 3px;
}


.section-title p,
.parameters-header p {
    color: var(--text-secondary);
    font-size: 13px;
}


.setup-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}


/* =========================================
   FIELDSETS
========================================= */

fieldset {
    border: 0;
}


.option-group legend {
    font-size: 14px;
    font-weight: 700;

    margin-bottom: 12px;
}


.radio-option {
    display: flex;
    align-items: center;
    gap: 12px;

    padding: 14px;

    border: 1px solid var(--border);
    border-radius: var(--radius-small);

    cursor: pointer;

    transition:
        border-color 0.2s ease,
        background 0.2s ease;

    margin-bottom: 8px;
}


.radio-option:hover {
    background: var(--surface-soft);
    border-color: #cbd5e1;
}


.radio-option input,
.difficulty-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}


.custom-radio {
    width: 19px;
    height: 19px;

    flex: 0 0 19px;

    border: 2px solid #cbd5e1;
    border-radius: 50%;

    position: relative;
}


.radio-option input:checked + .custom-radio {
    border-color: var(--primary);
}


.radio-option input:checked + .custom-radio::after {
    content: "";

    position: absolute;

    width: 9px;
    height: 9px;

    top: 3px;
    left: 3px;

    background: var(--primary);

    border-radius: 50%;
}


.option-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}


.option-text strong {
    font-size: 14px;
}


.option-text small {
    color: var(--text-secondary);
    font-size: 12px;
}


/* =========================================
   BUTTONS
========================================= */

.primary-btn,
.secondary-btn {
    border: 0;

    font-family: inherit;
    font-weight: 700;

    cursor: pointer;

    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease,
        background 0.2s ease;
}


.primary-btn {
    width: 100%;

    min-height: 52px;

    padding: 0 18px;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;

    color: white;
    background: var(--primary);

    border-radius: 12px;

    box-shadow:
        0 4px 12px rgba(37, 99, 235, 0.20);
}


.primary-btn:hover {
    background: var(--primary-dark);

    transform: translateY(-1px);

    box-shadow:
        0 8px 18px rgba(37, 99, 235, 0.25);
}


.btn-arrow {
    font-size: 20px;
}


/* =========================================
   GAME CARD
========================================= */

.game-card {
    padding: 22px;
}


/* =========================================
   STATISTICS
========================================= */

.game-stats {
    display: grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap: 12px;

    margin-bottom: 20px;
}


.stat-card {
    min-height: 82px;

    display: flex;
    align-items: center;
    gap: 12px;

    padding: 15px;

    background: var(--surface-soft);

    border: 1px solid var(--border);
    border-radius: 12px;
}


.stat-icon {
    width: 42px;
    height: 42px;

    flex: 0 0 42px;

    display: grid;
    place-items: center;

    border-radius: 11px;

    background: var(--primary-light);

    font-size: 18px;
}


.stat-card > div {
    display: flex;
    flex-direction: column;
    gap: 3px;
}


.stat-label {
    color: var(--text-secondary);

    font-size: 11px;
    font-weight: 600;

    text-transform: uppercase;
    letter-spacing: 0.05em;
}


.stat-card strong {
    font-size: 21px;
}


.timer-card .stat-icon {
    background: #fff7ed;
}


/* =========================================
   GAME BOARD
========================================= */

.game-board {
    overflow: hidden;

    border: 1px solid var(--border);
    border-radius: 14px;

    background: white;
}

.eyebrow {
    display: inline-block;

    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.12em;

    margin-bottom: 6px;
}


.board-header {
    display: flex;
    justify-content: space-between;
    align-items: center;

    gap: 20px;

    padding: 18px 20px;

    border-bottom: 1px solid var(--border);
}


.board-header h2 {
    font-size: 17px;
    margin-top: 2px;
}


.hint-badge {
    padding: 7px 10px;

    color: var(--primary);

    background: var(--primary-light);

    border-radius: 999px;

    font-size: 11px;
    font-weight: 700;

    white-space: nowrap;
}


#game-display-div {
    width: 100%;

    padding: 10px;

    overflow-x: auto;

    background:
        radial-gradient(
            circle at center,
            #ffffff 0%,
            #f8fafc 100%
        );
}


#game-canvas {
    display: block;

    margin: 0 auto;
}


/* =========================================
   INPUT
========================================= */

#game-input {
    margin-top: 18px;
}


.input-wrapper {
    width: 100%;
}


.input-wrapper label {
    display: block;

    margin-bottom: 8px;

    font-size: 13px;
    font-weight: 700;
}


.input-row {
    display: flex;
    gap: 10px;
}


#given-city-field {
    width: 100%;
    min-width: 0;

    height: 52px;

    padding: 0 16px;

    border: 2px solid var(--border);
    border-radius: 11px;

    outline: none;

    font-family: inherit;
    font-size: 16px;

    color: var(--text);

    background: white;

    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}


#given-city-field::placeholder {
    color: var(--text-light);
}


#given-city-field:focus {
    border-color: var(--primary);

    box-shadow:
        0 0 0 4px rgba(37, 99, 235, 0.10);
}


.secondary-btn {
    height: 52px;

    padding: 0 20px;

    flex: 0 0 auto;

    color: #475569;

    background: #f1f5f9;

    border-radius: 11px;
}


.secondary-btn:hover {
    color: var(--danger);
    background: #fef2f2;
}


.input-help {
    margin-top: 7px;

    color: var(--text-light);

    font-size: 12px;
}


/* =========================================
   PARAMETERS
========================================= */

#params-div {
    position: sticky;
    top: 24px;
}


.parameters-card {
    padding: 22px;
}


.parameters-header {
    margin-bottom: 20px;
}


/* Checkbox */

.checkbox-option {
    padding: 14px;

    background: var(--surface-soft);

    border: 1px solid var(--border);
    border-radius: 11px;

    margin-bottom: 24px;
}


.checkbox-option > input {
    position: absolute;
    opacity: 0;
}


.checkbox-option label {
    display: flex;
    align-items: center;
    gap: 11px;

    cursor: pointer;
}


.checkmark {
    width: 20px;
    height: 20px;

    flex: 0 0 20px;

    border: 2px solid #cbd5e1;
    border-radius: 5px;

    position: relative;
}


.checkbox-option input:checked + label .checkmark {
    background: var(--primary);
    border-color: var(--primary);
}


.checkbox-option input:checked + label .checkmark::after {
    content: "✓";

    position: absolute;

    left: 3px;
    top: -2px;

    color: white;

    font-size: 14px;
    font-weight: 800;
}


.checkbox-option label > span:last-child {
    display: flex;
    flex-direction: column;
    gap: 3px;
}


.checkbox-option strong {
    font-size: 13px;
}


.checkbox-option small {
    color: var(--text-secondary);
    font-size: 11px;
}


/* Difficulty */

.difficulty-group legend {
    margin-bottom: 5px;
}


.fieldset-description {
    color: var(--text-secondary);

    font-size: 12px;
    line-height: 1.5;

    margin-bottom: 12px;
}


.difficulty-option {
    display: grid;

    grid-template-columns: 1fr auto;
    align-items: center;

    gap: 10px;

    padding: 13px;

    margin-bottom: 8px;

    border: 1px solid var(--border);
    border-radius: 10px;

    cursor: pointer;

    transition: 0.2s ease;
}


.difficulty-option:hover {
    background: var(--surface-soft);
}


.difficulty-option:has(input:checked) {
    border-color: var(--primary);

    background: var(--primary-light);
}


.difficulty-content {
    display: flex;
    flex-direction: column;
    gap: 3px;
}


.difficulty-content strong {
    font-size: 13px;
}


.difficulty-content small {
    color: var(--text-secondary);
    font-size: 11px;
}


.difficulty-indicator {
    padding: 4px 7px;

    border-radius: 6px;

    font-size: 10px;
    font-weight: 800;
}


.easy-indicator {
    color: #15803d;
    background: #dcfce7;
}


.medium-indicator {
    color: #b45309;
    background: #fef3c7;
}


.hard-indicator {
    color: #b91c1c;
    background: #fee2e2;
}


/* =========================================
   UTILITIES
========================================= */

.hide-div {
    display: none;
}


#game-map {
    width: 100%;
    height: 600px;
}

.city-label {
    font-family: Arial, sans-serif;
    font-size: 14px;
    font-weight: normal;
}


/* =========================================
   ACCOUNT BANNER
========================================= */

.account-banner {
    width: 100%;

    margin-bottom: 28px;
    padding: 16px 24px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 20px;

    background: linear-gradient(
        135deg,
        #ffffff 0%,
        #f8fbff 100%
    );

    border: 1px solid var(--border);
    border-radius: var(--radius);

    box-shadow: var(--shadow);

    position: relative;
    overflow: hidden;
}


/* Petite barre bleue sur le côté */

.account-banner::before {
    content: "";

    position: absolute;

    left: 0;
    top: 0;

    width: 4px;
    height: 100%;

    background: var(--primary);
}


/* Informations du compte */

.account-info {
    display: flex;
    align-items: center;

    gap: 12px;

    min-width: 0;
}


.account-avatar {
    width: 42px;
    height: 42px;

    flex: 0 0 42px;

    display: grid;
    place-items: center;

    background: var(--primary-light);

    border-radius: 12px;

    font-size: 18px;
}


.account-info > div:last-child {
    display: flex;
    flex-direction: column;

    gap: 2px;
}


.account-title {
    font-size: 13px;
    font-weight: 800;

    color: var(--text);
}


.account-subtitle {
    color: var(--text-secondary);

    font-size: 12px;
}


/* Boutons */

.account-actions {
    display: flex;
    align-items: center;

    gap: 8px;

    flex: 0 0 auto;
}


.account-btn {
    height: 42px;

    padding: 0 15px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    gap: 8px;

    border: 0;
    border-radius: 10px;

    font-family: inherit;
    font-size: 13px;
    font-weight: 700;

    cursor: pointer;

    transition:
        box-shadow 0.2s ease,
        background 0.2s ease;
}


/* Connexion */

.login-btn {
    color: white;

    background: var(--primary);

    box-shadow:
        0 4px 12px rgba(37, 99, 235, 0.20);
}


.login-btn:hover {
    background: var(--primary-dark);

    box-shadow:
        0 7px 16px rgba(37, 99, 235, 0.25);
}


.account-arrow {
    font-size: 17px;
}


/* Déconnexion */

.logout-btn {
    color: #64748b;

    background: #f1f5f9;
}


.logout-btn:hover {
    color: var(--danger);

    background: #fef2f2;
}



/* =========================
   DAILY SCORES
   ========================= */

.scores-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
}

.scores-card .section-title {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.scores-card .section-title h2 {
    margin: 0;
}

.scores-card .section-title p {
    margin: 4px 0 0;
    color: #6b7280;
}


/* Liste */

.scores-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}


/* Ligne */

.score-row {
    display: grid;
    grid-template-columns: 50px 1fr auto;
    align-items: center;

    padding: 12px 16px;

    border-radius: 12px;
    background: #f8fafc;

    transition: background 0.15s ease;
}

.score-row:hover {
    background: #f1f5f9;
}


/* Top 3 */

.score-row.top-score {
    background: #fefce8;
}


/* Position */

.score-rank {
    font-size: 20px;
    font-weight: 700;
}


/* Joueur */

.score-player {
    min-width: 0;
}

.score-player strong {
    display: block;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* Temps */

.score-time {
    font-weight: 700;
    font-size: 17px;
    white-space: nowrap;
}


/* États */

.scores-loading,
.scores-empty,
.scores-error {
    padding: 20px;
    text-align: center;
    color: #6b7280;
}

.scores-error {
    color: #dc2626;
}




/* =========================================
   RESPONSIVE
========================================= */

@media (max-width: 1000px) {

    #app {
        grid-template-columns: 1fr;
    }

    #params-div {
        position: static;
    }

    .parameters-card {
        max-width: none;
    }
}


@media (max-width: 700px) {

    #app {
        padding: 20px 12px 40px;
    }

    .setup-card,
    .game-card {
        padding: 14px;
    }

    .game-stats {
        grid-template-columns: 1fr;
    }

    .board-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .hint-badge {
        white-space: normal;
    }

    .input-row {
        flex-direction: column;
    }

    .secondary-btn {
        width: 100%;
    }

    .game-header {
        padding: 20px 22px;

        margin-bottom: 18px;
    }

    .game-header > div {
        display: flex;
        flex-wrap: wrap;

        gap: 8px 12px;
    }

    .game-header .eyebrow {
        width: 100%;

        height: auto;

        padding: 0;

        background: transparent;

        font-size: 10px;
    }

    .game-header h1 {
        font-size: 25px;
    }

    .game-header .subtitle {
        width: 100%;

        padding-left: 0;

        border-left: 0;

        font-size: 12px;
    }


    /* ================================
       CANVAS MOBILE
    ================================= */

    #game-display-div {
        width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 10px;
        -webkit-overflow-scrolling: touch;
    }

    #game-canvas {
        display: block;
        width: 175%;
        height: auto;
    }
    
    .account-banner {
        align-items: stretch;

        flex-direction: column;

        gap: 14px;

        padding: 15px;
    }


    .account-actions {
        width: 100%;
    }


    .account-btn {
        flex: 1;
    }


    .account-info {
        width: 100%;
    }
}