/* ==========================================================================
   1. Variables & Styles de Base
   ========================================================================== */

:root {
    /* Palette de couleurs moderne et douce */
    --color-primary: #0a2540;      /* Bleu nuit profond pour le texte */
    --color-accent: #cd171a;       /* Bleu vif pour les interactions */
    --color-accent-hover: #0056b3; /* Bleu plus foncé pour le survol */
    --color-danger: #e63946;       /* Rouge pour les erreurs/mines */
    --color-success: #2a9d8f;      /* Vert pour la victoire */
    --color-background: #f8f9fa;   /* Fond gris très clair */
    --color-surface: #ffffff;      /* Fond des cartes (jeu, classement) */
    --color-border: #dee2e6;       /* Bordures subtiles */
    --font-sans-serif: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    /* Variables pour la grille (contrôlées par JS) */
    --board-size: 16;
    --cell-size: 30px;
}

body {
    font-family: var(--font-sans-serif);
    background-color: var(--color-background);
    color: var(--color-primary);
    margin: 0;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    box-sizing: border-box;
}

.titre {
    padding-top: 20px;
    padding-bottom: 20px;
}

/* Style bouton retour */
.back-btn {
    display: inline-flex
;
    align-items: center;
    gap: 0px;
    padding: 6px 6px;
    background: #ffffff;
    color: #8b0000;
    font-size: 13px;
    font-weight: 600;
    border-radius: 7px;
    border: none;
    text-decoration: none;
    transition: background 0.16s, color 0.13s, box-shadow 0.14s;
    box-shadow: 0 2px 8px #0001;
    margin-left: 10px;
}

.back-btn:hover,
.back-btn:focus {
    background: #911315;
    color: #fff;
}

.back-btn .arrow {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 2px;
}

.back-btn .arrow svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* ==========================================================================
   2. Conteneurs principaux
   ========================================================================== */

.game-container,
.leaderboard-container {
    background-color: var(--color-surface);
    border-radius: 16px;
    border: 1px solid var(--color-border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    width: 100%;
    max-width: 500px;
    padding: 24px;
    margin-bottom: 24px;
    box-sizing: border-box;
    text-align: center;
}

h8 {
       font-size: 30px;
    color: var(--color-primary);
    margin: 0 0 24px 0;
    font-weight: 900;
    font-family: roboto;
}

.boucherie-logo {
    margin-bottom: 16px;
}

.boucherie-logo img {
    height: 45px;
    
}



.bg-green-400 {
    --tw-bg-opacity: 1;
    background-color: rgb(139 0 0) !important;
}

.w-48 {
    width: 100px !important;
}

/* ==========================================================================
   3. Contrôles du jeu (Difficulté, Infos, Recommencer)
   ========================================================================== */

.game-difficulties {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
}

.difficulty-btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    background-color: var(--color-surface);
    color: var(--color-accent);
    font-weight: 600;
    font-size: 1em;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.difficulty-btn:hover {
    background-color: #e9ecef;
}

.difficulty-btn.active {
    background-color: var(--color-accent);
    color: var(--color-surface);
    border-color: var(--color-accent);
}

.game-info {
    display: flex;
    justify-content: space-around;
    font-size: 1.2em;
    font-weight: 500;
    margin-bottom: 20px;
    color: #495057;
}

#restart-button {
    padding: 12px 24px;
    font-size: 1em;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    background-color: #cd171a;
    color: var(--color-surface);
    cursor: pointer;
    transition: background-color 0.2s;
    margin-bottom: 30px;
}

#restart-button:hover {
    background-color: #911315;
}


/* ==========================================================================
   4. Grille de jeu (Responsive & Scrollable)
   ========================================================================== */

/*
 * C'est la section clé pour le responsive.
 * Le wrapper a une taille maximale et devient scrollable si la grille à l'intérieur
 * (dont la taille est calculée par JS) est plus grande.
 */
.board-wrapper {
    max-width: 100%;
    overflow: auto; /* Active le scroll si nécessaire */
    border: 1px solid var(--color-border);
    border-radius: 12px;
    margin: 0 auto 16px auto;
    background-color: #e9ecef;
    padding: 8px; /* Petit espace autour de la grille */
}

#game-board {
    display: grid;
    grid-template-columns: repeat(var(--board-size), var(--cell-size));
    grid-template-rows: repeat(var(--board-size), var(--cell-size));
    /* Pas de width/height fixes ici, on laisse le JS et le wrapper gérer */
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    background-color: #ced4da;
    border: 1px solid #adb5bd;
    border-radius: 4px;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: calc(var(--cell-size) * 0.6);
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s;
}

.cell:not(.revealed):hover {
    background-color: #dee2e6;
}

.cell.revealed {
    background-color: var(--color-background);
    border-color: var(--color-border);
    cursor: default;
}

.cell.flagged {
    font-size: calc(var(--cell-size) * 0.5);
}

.cell.mine {
    background-color: var(--color-danger);
    animation: shake 0.5s;
}

.cell span {
    display: inline-block;
    transform: scale(0);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cell.revealed span, .cell.flagged span {
    transform: scale(1);
}

/* Couleurs des chiffres */
.cell[data-count="1"] { color: #007bff; }
.cell[data-count="2"] { color: #28a745; }
.cell[data-count="3"] { color: #dc3545; }
.cell[data-count="4"] { color: #6f42c1; }
.cell[data-count="5"] { color: #fd7e14; }
.cell[data-count="6"] { color: #20c997; }
.cell[data-count="7"] { color: #17a2b8; }
.cell[data-count="8"] { color: #6c757d; }

@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-3px); }
  40%, 60% { transform: translateX(3px); }
}


/* ==========================================================================
   5. Classement
   ========================================================================== */


.leaderboard-container h2 {
    font-size: 1.5em;
    margin: 0 0 20px 0;
    color: var(--color-primary);
    font-family: roboto !important;
    font-weight: 800;
}

#leaderboard {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.leaderboard-difficulty h3 {
    text-transform: capitalize;
    font-size: 1.2em;
    color: var(--color-primary);
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 8px;
    margin: 0 0 12px 0;
    text-align: left;
}

.leaderboard-difficulty ol {
    padding-left: 0;
    margin: 0;
    list-style-type: none; /* Assurez-vous que cette ligne est présente pour cacher les numéros par défaut */
    display: flex;
    flex-direction: column;
    gap: 8px;
    counter-reset: score-counter; /* Initialise notre compteur */
}

.leaderboard-difficulty li {
    display: flex;
    align-items: center;
    position: relative;
    min-height: 56px;
    padding-left: 58px; /* place pour le cercle */
    background-color: var(--color-background);
    margin-bottom: 10px;
    border-radius: 12px;
    flex-direction: row;
}
.leaderboard-difficulty li.top-score {
    background-color: #fff3cd; /* Jaune pâle pour le premier */
    border: 1px solid #ffeeba;
}


/* Lignes podium = couleurs différentes */
.leaderboard-difficulty li.top-score   { background: #fff9e2; }
.leaderboard-difficulty li.second-place { background: #f6f6f7; }
.leaderboard-difficulty li.third-place  { background: #f6f1ea; }


.score-row {
    width: 95%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1em;
    font-weight: 600;
}

.player-name {
    text-align: left;
}

.player-time {
    color: var(--color-accent);
    font-variant-numeric: tabular-nums;
}

.score-date {
    font-size: 0.8em;
    color: #6c757d;
    margin-top: 0px;
}




/* ==========================================================================
   6. Fenêtre Modale
   ========================================================================== */

.hidden { display: none !important; }

#modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(10, 37, 64, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

#modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

#modal {
    background: var(--color-surface);
    padding: 24px;
    border-radius: 16px;
    width: 80%;
    max-width: 400px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#modal-overlay.visible #modal {
    transform: scale(1);
}

#modal h2 {
    margin: 0 0 12px 0;
    font-size: 1.4em;
}

#modal p {
    margin: 0 0 20px 0;
    line-height: 1.5;
    color: #495057;
}

#modal-input-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

#modal-input-container input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-family: var(--font-sans-serif);
    font-size: 1em;
    box-sizing: border-box;
}

#modal-input-container input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}

#modal-buttons button {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: none;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    background-color: var(--color-accent);
    color: var(--color-surface);
    transition: background-color 0.2s;
}

#modal-buttons button:hover {
    background-color: #970002;
}


/* ==========================================================================
   7. Responsive pour petits écrans
   ========================================================================== */

@media (max-width: 600px) {
    body {
        padding: 8px;
    }

    .game-container,
    .leaderboard-container {
        padding: 16px;
    }

    h1 {
        font-size: 1.8em;
    }
}




.leaderboard-difficulty li {
    /* ... conserve les autres propriétés ... */
    display: flex;
    align-items: center;
    position: relative;
    min-height: 42px;
    padding-left: 55px; /* Pour la médaille */
    padding-bottom: 20px;
}
/* Le cercle, déjà dans ton CSS */
.medal-circle, .rank-circle {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 25px;
    height: 25px;
    border-radius: 50%;
    box-shadow: 0 1px 6px #0001;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1em;
    font-weight: 700;
    z-index: 2;
}
.medal-circle.gold   { background: linear-gradient(135deg, #ffe066 65%, #ffd200 100%); color: #b08d22; border: 2px solid #f7c948; font-size: 25px;}
.medal-circle.silver { background: linear-gradient(135deg, #f0f1f6 65%, #b7b7b7 100%); color: #777; border: 2px solid #b7b7b7; font-size: 25px;}
.medal-circle.bronze { background: linear-gradient(135deg, #ffe3c7 60%, #d8a373 100%); color: #ad6f32; border: 2px solid #d8a373; font-size: 25px;}
.rank-circle         { background: #e9ecef; color: var(--color-primary); border: 2px solid #dee2e6; }

/* Main info (nom+temps) */
.score-main {
    display: flex;
    align-items: center;
    gap: 22px;
    flex: 1;
    font-size: 1.08em;
    font-weight: 700;
    min-height: 38px;
}

/* Nom aligné verticalement */
.player-name {
    text-align: left;
    font-size: 1.08em;
    font-weight: 700;
    color: var(--color-primary);
}

/* Score à droite, rouge */
.player-time {
    color: var(--color-danger);
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    font-size: 1.1em;
    margin-left: 20px;
}

/* Date toujours sous la ligne principale, aligné à la médaille */
.score-date {
    position: absolute;
    left: 55px;
    bottom: 5px;
    font-size: 0.94em;
    color: #7c818b;
    font-weight: 400;
}