body {
    margin: 0;
}

/* Conteneur principal qui englobe tout */
#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column; /* Force une disposition verticale (en colonne) */
    justify-content: flex-start; /* Aligne le canvas tout en haut de l'écran */
    align-items: center; /* Centre le canvas horizontalement */
    background-color: #000;
    overflow: hidden;
}

/* Le canvas */
canvas {
    aspect-ratio: 448 / 576;
    max-width: 100vw;
    max-height: 75vh; /* Sécurité : on limite la hauteur du jeu à 75% de l'écran maximum */
    object-fit: contain;
    margin-top: 10px; /* Petit espace esthétique par rapport au haut du téléphone */
}

#btn-back {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 45px;
    height: 45px;
    background: rgba(0, 0, 0, 0); /* Fond noir semi-transparent pour rester visible peu importe le fond du jeu */
    border: 0px solid rgba(255, 255, 255, 0.5);
/*    border-radius: 50%; /* Bouton bien rond */*/
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 100; /* Priorité maximale pour passer au-dessus du canvas */
    padding: 0;
    box-sizing: border-box;
    /* Supprime les comportements tactiles parasites */
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

/* Style de l'icône croix blanche */
.icon-back {
    width: 60%;
    height: 60%;
    fill: #ffffff;
    transition: transform 0.1s ease;
}

/* Effet visuel au clic ou au toucher */
#btn-back:active {
    background: rgba(255, 255, 255, 0.3);
}
#btn-back:active .icon-back {
    fill: #ff4d4d; /* La croix devient rouge quand on appuie dessus */
    transform: scale(0.9);
}
/* La manette virtuelle */
#virtual-joystick {
/*    display: none; */
}

/* Si l'appareil dispose d'un écran tactile (smartphone/tablette) */
/*@media (pointer: coarse) {*/
    #virtual-joystick {
        display: flex;
        position: absolute;
        
        /* Au lieu d'être calée à "bottom: 20px" par rapport au bas du canvas, 
           elle s'adapte à l'espace restant en bas de l'écran */
        bottom: 5vh; 
        left: 0;
        width: 100%;
        justify-content: space-between;
        padding: 0 30px;
        box-sizing: border-box;
        pointer-events: none;
        z-index: 10; /* Assure que la manette passe au-dessus si l'écran est vraiment minuscule */
    }

    .btn {
        pointer-events: auto;
        background: rgba(255, 255, 255, 0.2);
        color: white;
        border: 2px solid rgba(255, 255, 255, 0.4);
        border-radius: 50%;
        font-size: 24px;
        width: 65px; /* Légèrement agrandi pour le confort des pouces */
        height: 65px;
        display: flex;
        justify-content: center;
        align-items: center;
        user-select: none;
        -webkit-user-select: none;
        touch-action: manipulation;
    }

    .btn:active {
        background: rgba(255, 255, 255, 0.6);
    }

    .d-pad {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    .d-pad-horizontal {
        display: flex;
        align-items: center;
    }
    .d-pad-center {
        width: 55px; /* Aligné avec la nouvelle taille des boutons */
        height: 55px;
    }

    .action-buttons {
/*        display: flex;*/
/*        align-items: flex-end;*/
    }
    .btn-action {
        width: 85px;
        height: 85px;
        border-radius: 50%;
        font-size: 16px;
        font-weight: bold;
        background: rgba(231, 76, 60, 0.4);
        border-color: rgba(231, 76, 60, 0.6);
    }

/*}*/

