/* --- Base --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family: 'Segoe UI', sans-serif;
}

header,
footer {
    background: linear-gradient(135deg, #0984e3, #00b894);
    color: #fff;
    padding: 20px;
    text-align: center;
}

nav {
    background: #f4f4f4;
    padding: 10px;
    text-align: center;
}

nav ul li {
    display: inline;
    margin: 0 10px;
}

nav ul li a {
    color: #0984e3;
    text-decoration: none;
    font-weight: bold;
}

nav ul li a:hover {
    color: #f4f4f4;
    background: #0984e3;
    padding: 5px 15px;
    border-radius:50px;
    text-decoration: none;
    font-weight: bold;
}

section {
    display: grid;
    grid-template-columns: 1fr 3fr 1fr;
    flex: 1;
}

aside {
    background-color: #f4f4f4;
    padding: 20px;
    border: 1px solid #ddd;
}

/* --- Layout Main & Fond Bilou --- */
main {
    position: relative;
    padding: 20px;
    display: flex;
    justify-content: center;
    z-index: 1;
}

main::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("bilou.png");
    background-size: cover;
    background-position: center;
    opacity: 0.4;
    z-index: -1;
}

/* --- Conteneurs Jeux --- */
.game-wrapper {
    background: rgba(255, 255, 255, 0.9);
    padding: 25px;
    border-radius: 20px;
    width: 100%;
    max-width: 550px;
    text-align: center;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

h2, h3{
    font-family: 'Caveat', cursive;
    font-size: 2.2rem;
    color: #d52026;
    margin-bottom: 15px;
}
p {
    font-size: 1.1rem;
    color: #0984e3;
    margin-bottom: 20px;
}


/* --- Boites de texte --- */
.display-box {
    background: white;
    border: 4px solid #0984e3;
    border-radius: 25px;
    width: 180px;
    height: 180px;
    margin: 15px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Borel', cursive;
    font-size: 100px;
}

#number-display {
    font-family: 'Segoe UI', sans-serif;
    font-size: 80px;
    font-weight: bold;
    color: #00b894;
    border: none;
    background: transparent;
    text-align: center;
    width: 100%;
    outline: none;
}

/* --- Memory 3D --- */
#game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    perspective: 1000px;
    margin-bottom: 20px;
}

.card {
    aspect-ratio: 1/1;
    position: relative;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform .6s;
}

.card.reveal {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 8px;
    border: 2px solid #146c54;
}

.card-back {
    background: linear-gradient(135deg, #00ffff, #00ff80);
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-front {
    background: white;
    transform: rotateY(180deg);
}

.card-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

/* --- Stats & Boutons --- */
.stats-memory {
    background: #333;
    color: white;
    padding: 10px;
    border-radius: 8px;
    margin-top: 10px;
}

.main-btn {
    background: linear-gradient(135deg, #55efc4 0%, #00b894 100%);
    color: white;
    border: none;
    padding: 12px 35px;
    border-radius: 50px;
    font-weight: bold;
    cursor: pointer;
}

.menu-liste {
    list-style: none;
}

/*.menu-liste a {
    text-decoration: none;
    color: #0984e3;
    font-weight: bold;
    display: block;
    padding: 10px;
    border-bottom: 1px solid #ddd;
}*/


.menu-liste a {
    display: block;
    width:fit-content;
    padding: 10px;
    background: wheat;
    color: #0984e3;
    text-decoration: none;
    border-radius: 5px;
    border-left: 4px solid #d6bb0c;
    transition: 0.3s;
    margin-bottom: 8px;
}

.menu-liste a:hover {
    border-left-color: #00ffff;
    transform: translateX(5px);
}

/* --- RESPONSIVE DESIGN --- */

@media (max-width: 768px) {
    /* 1. On passe de 3 colonnes à 1 seule colonne verticale */
    section {
        display: flex;
        flex-direction: column;
    }

    /* 2. On change l'ordre : le jeu (main) passe en premier, les menus après */
    main {
        order: 1; 
        width: 100%;
        padding: 10px;
    }

    aside#sidebar-gauche {
        order: 2; /* Le menu des jeux passe sous le jeu */
        width: 100%;
    }

    aside#sidebar-droite {
        order: 3; /* La description passe en dernier */
        width: 100%;
    }

    /* 3. Ajustement des boîtes de jeu pour mobile */
    .game-wrapper {
        padding: 15px;
        max-width: 95%; /* On prend presque toute la largeur */
    }

    .display-box {
        width: 140px;
        height: 140px;
        font-size: 70px;
    }

    #number-display {
        font-size: 60px;
    }

    /* 4. Ajustement du Memory pour mobile (2 colonnes au lieu de 4) */
    #game-board {
        grid-template-columns: repeat(3, 1fr); /* 3 cartes par ligne sur mobile */
        gap: 8px;
    }

    /* 5. Menu de navigation du haut */
    nav ul li {
        display: block; /* Un lien par ligne */
        margin: 10px 0;
    }
}

/* Ajustement pour les très petits écrans (iPhone SE, etc.) */
@media (max-width: 400px) {
    #game-board {
        grid-template-columns: repeat(2, 1fr); /* 2 cartes par ligne seulement */
    }
    
    h2 {
        font-size: 1.8rem;
    }
}