/* # Ajuste extra para móvil: botón de menú siempre visible y en la esquina */
@media only screen and (max-width: 900px) {
    #back-to-menu-btn {
        top: 10px;
        left: 10px;
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
        z-index: 300;
    }
}
#back-to-menu-btn {
    position: absolute;
    top: 18px;
    left: 18px;
    z-index: 100;
    background: rgba(34,34,34,0.85);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    transition: background 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
#back-to-menu-btn:hover {
    background: #444;
}
body {
    background: #222;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    min-height: 100vh;
    width: 100vw;
}
/* Centrado y ajuste para el contenedor del juego */
#game-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100vw;
    height: 100vh;
    background: #222;
}

canvas {
    border: 2px solid #fff;
    background: #444;
    display: block;
    /* Por defecto, tamaño fijo para escritorio */
    width: 640px;
    height: 480px;
    max-width: 100vw;
    max-height: 100vh;
    aspect-ratio: 4/3;
    box-sizing: border-box;
}

/* Estilos para Controles Móviles */
/* Controles móviles siempre visibles sobre el canvas */
#game-container {
    position: relative !important;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100vw;
    height: 100vh;
    background: #222;
    z-index: 50;
}

/* Refuerzo: ocultar controles móviles en desktop por media query */
@media (hover: hover) and (pointer: fine) {
    #mobile-controls {
        display: none !important;
    }
    .utility-controls {
        display: none !important;
    }
}

.move-controls {
    display: flex;
    gap: 15px;
}

.left-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.right-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.crouch-controls {
    display: flex;
    justify-content: center;
}

.action-controls {
    display: flex;
    gap: 15px;
}

.utility-controls {
    display: flex;
    gap: 15px;
}

.mobile-btn {
    width: 50px;
    height: 50px;
    background-color: rgba(255, 255, 255, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    color: white;
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    pointer-events: auto; /* Los botones sí responden a clics/toques */
    user-select: none; /* Evitar selección de texto en el icono */
}

.mobile-btn:active {
    background-color: rgba(255, 255, 255, 0.5);
}

/* Estilos específicos para botones de utilidad */
.utility-controls .mobile-btn {
    background-color: rgba(100, 150, 255, 0.3);
    border-color: rgba(100, 150, 255, 0.5);
    width: 45px;
    height: 45px;
    font-size: 18px;
}

.utility-controls .mobile-btn:active {
    background-color: rgba(100, 150, 255, 0.5);
}

/* Estilos para botones de herramientas (ej. pantalla completa) */
.game-tool-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    background-color: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 5px;
    color: white;
    font-size: 18px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-tool-btn:hover {
    background-color: rgba(0, 0, 0, 0.6);
}

/* === ESTILOS ADICIONALES PARA MÓVIL === */

/* Previene el zoom y scroll en la página */
html, body {
    touch-action: none;
    overflow: hidden;
}

/* Estilos para el mensaje de rotación */
#rotate-device-overlay {
    display: none; /* Oculto por defecto */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    color: #fff;
    font-family: Arial, sans-serif;
    font-size: 20px;
    text-align: center;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

/* Media query para mostrar el mensaje en modo vertical */
@media only screen and (max-width: 900px) and (orientation: portrait) {
    #game-container {
        display: none;
    }
    #rotate-device-overlay {
        display: flex;
    }
}

/* Centrado y bandas negras laterales en móviles (horizontal) */
@media only screen and (max-width: 900px) and (orientation: landscape) {
    body, html {
        width: 100vw;
        height: 100vh;
        min-height: 100vh;
        min-width: 100vw;
        margin: 0;
        padding: 0;
        overflow: hidden;
        background: #222;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    #game-container {
        width: 100vw;
        height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
        background: #222;
    }
    canvas {
        width: 100vh;
        height: 75vh;
        max-width: calc(100vw - 0px);
        max-height: 100vh;
        aspect-ratio: 4/3;
        display: block;
        margin: 0 auto;
        background: #444;
        box-sizing: border-box;
    }
    #mobile-controls {
        position: absolute;
        bottom: 20px;
        left: 0;
        width: 100vw;
        height: auto;
        display: flex;
        justify-content: space-between;
        align-items: flex-end;
        padding: 0 20px;
        pointer-events: none;
        z-index: 50;
        box-sizing: border-box;
    }
    
    /* Contenedor izquierdo: movimiento y agacharse */
    .left-controls {
        display: flex;
        flex-direction: column;
        gap: 15px;
        align-items: center;
    }
    
    /* Contenedor derecho: ataque */
    .right-controls {
        display: flex;
        flex-direction: column;
        gap: 15px;
        align-items: center;
    }
    
    /* Botones de movimiento (izquierda y derecha) */
    .move-controls {
        display: flex;
        gap: 15px;
        justify-content: center;
    }
    
    /* Botón de agacharse - debajo de los botones de movimiento */
    .crouch-controls {
        display: flex;
        justify-content: center;
    }
    
    /* Botón de ataque - derecha inferior */
    .action-controls {
        display: flex;
        align-items: center;
        margin-bottom: 0;
    }
    
    /* Botones de utilidad - arriba a la derecha (debajo del botón de pantalla completa) */
    .utility-controls {
        position: absolute;
        top: 60px;
        right: 10px;
        display: flex;
        flex-direction: column;
        gap: 10px;
        justify-content: flex-start;
        align-items: center;
        pointer-events: auto;
    }
}

/* Estilos para desktop (testing) */
#mobile-controls {
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100vw;
    height: auto;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 20px;
    pointer-events: none;
    z-index: 50;
    box-sizing: border-box;
}

/* Contenedor izquierdo: movimiento y agacharse */
.left-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

/* Contenedor derecho: ataque */
.right-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

/* Botones de movimiento (izquierda y derecha) */
.move-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* Botón de agacharse - debajo de los botones de movimiento */
.crouch-controls {
    display: flex;
    justify-content: center;
}

/* Botón de ataque - derecha inferior */
.action-controls {
    display: flex;
    align-items: center;
    margin-bottom: 0;
}

/* Botones de utilidad - arriba a la derecha (debajo del botón de pantalla completa) */
.utility-controls {
    position: absolute;
    top: 60px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-content: flex-start;
    align-items: center;
    pointer-events: auto;
}