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

body {
    font-family: 'Courier New', monospace;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    touch-action: none; /* Prevenir gestos del navegador en móviles */
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
}

#game-canvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-crisp-edges;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    touch-action: none; /* Prevenir zoom y scroll en el canvas */
}

/* Controles virtuales */
.virtual-controls {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999999; /* Valor muy alto para asegurar visibilidad en fullscreen */
    display: none; /* Oculto por defecto, se mostrará solo en móviles */
}

/* Joystick */
.joystick-container {
    position: absolute;
    bottom: 30px;
    left: 5px;
    pointer-events: auto;
}

.joystick-base {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.5);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

.joystick-handle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid rgba(255, 255, 255, 1);
    position: absolute;
    transition: transform 0.1s ease-out;
    touch-action: none;
}

/* Botones de acción */
.action-buttons {
    position: absolute;
    bottom: 30px;
    right: 30px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    pointer-events: auto;
    align-items: flex-end;
}

.action-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.8);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 24px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.action-btn:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.3);
}

.jump-btn {
    background: rgba(0, 150, 255, 0.7);
}

.punch-btn {
    background: rgba(255, 100, 100, 0.7);
}

.kick-btn {
    background: rgba(255, 200, 0, 0.7);
}

.special-btn {
    background: rgba(150, 0, 255, 0.7);
}

/* Botones de navegación (esquina superior izquierda) */
.nav-buttons {
    position: absolute;
    top: 15px;
    left: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: auto;
    align-items: flex-start;
    z-index: 1000000; /* Asegurar que esté por encima de todo en fullscreen */
    max-width: 180px;
}

/* Contenedores de línea para organizar botones en 2 filas */
.nav-buttons > div {
    display: flex;
    gap: 8px;
}

.nav-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.8);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 20px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.nav-btn:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.3);
}

.enter-btn {
    background: rgba(0, 255, 0, 0.7);
}

.esc-btn {
    background: rgba(255, 0, 0, 0.7);
}

.help-btn {
    background: rgba(0, 200, 255, 0.7);
}

.sound-btn {
    background: rgba(0, 200, 255, 0.7);
    font-size: 18px;
}

.fullscreen-btn {
    /* Destacar el botón de fullscreen cuando no está en fullscreen */
    transition: all 0.3s ease;
}

.fullscreen-btn:not(.in-fullscreen) {
    /* Animación sutil para llamar la atención cuando no está en fullscreen */
    animation: pulse-fullscreen 2s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(0, 200, 255, 0.5);
}

@keyframes pulse-fullscreen {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 10px rgba(0, 200, 255, 0.5);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 15px rgba(0, 200, 255, 0.8);
    }
}

/* Mostrar controles solo en móviles */
@media (max-width: 768px) {
    .virtual-controls {
        display: block;
    }
}

/* También mostrar si no hay hover (dispositivos táctiles) */
@media (hover: none) {
    .virtual-controls {
        display: block;
    }
}

/* Ajustes para pantallas muy pequeñas */
@media (max-width: 480px) {
    .joystick-base {
        width: 100px;
        height: 100px;
    }
    
    .joystick-handle {
        width: 40px;
        height: 40px;
    }
    
    .action-btn {
        width: 60px;
        height: 60px;
        font-size: 20px;
    }
    
    .nav-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .sound-btn {
        font-size: 16px;
    }
    
    .joystick-container {
        bottom: 20px;
        left: 5px;
    }
    
    .action-buttons {
        bottom: 20px;
        right: 20px;
        gap: 12px;
    }
    
    .nav-buttons {
        top: 15px;
        left: 15px;
        gap: 10px;
        max-width: 180px;
    }
}

/* Mensaje de orientación para móviles */
.orientation-message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    color: white;
    font-family: 'Courier New', monospace;
    text-align: center;
    padding: 20px;
}

.orientation-message.show {
    display: flex;
}

.orientation-message-icon {
    font-size: 80px;
    margin-bottom: 30px;
    animation: rotate 2s ease-in-out infinite;
}

@keyframes rotate {
    0%, 100% {
        transform: rotate(0deg);
    }
    50% {
        transform: rotate(90deg);
    }
}

.orientation-message-text {
    font-size: 24px;
    margin-bottom: 15px;
    font-weight: bold;
}

.orientation-message-subtext {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.8);
}

/* Estilos para pantalla completa */
:fullscreen {
    width: 100%;
    height: 100%;
}

:-webkit-full-screen {
    width: 100%;
    height: 100%;
}

:-moz-full-screen {
    width: 100%;
    height: 100%;
}

:-ms-fullscreen {
    width: 100%;
    height: 100%;
}

/* Asegurar que los controles virtuales se mantengan visibles en fullscreen */
:fullscreen .virtual-controls,
:-webkit-full-screen .virtual-controls,
:-moz-full-screen .virtual-controls,
:-ms-fullscreen .virtual-controls {
    position: fixed !important;
    z-index: 999999 !important;
    pointer-events: none !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: block !important;
}

/* Asegurar que los botones dentro de los controles sean clickeables en fullscreen */
:fullscreen .virtual-controls *,
:-webkit-full-screen .virtual-controls *,
:-moz-full-screen .virtual-controls *,
:-ms-fullscreen .virtual-controls * {
    pointer-events: auto !important;
}

/* También aplicar estilos cuando el body o documentElement está en fullscreen */
body:fullscreen .virtual-controls,
body:-webkit-full-screen .virtual-controls,
body:-moz-full-screen .virtual-controls,
body:-ms-fullscreen .virtual-controls,
html:fullscreen .virtual-controls,
html:-webkit-full-screen .virtual-controls,
html:-moz-full-screen .virtual-controls,
html:-ms-fullscreen .virtual-controls {
    position: fixed !important;
    z-index: 999999 !important;
    pointer-events: none !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: block !important;
}

/* Mensaje de solicitud de pantalla completa */
.fullscreen-prompt {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    padding: 15px 20px;
    color: white;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    text-align: center;
    z-index: 1000001; /* Por encima de los controles */
    display: none;
    pointer-events: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease-out;
}

.fullscreen-prompt.show {
    display: block;
}

.fullscreen-prompt-icon {
    font-size: 24px;
    margin-right: 10px;
    vertical-align: middle;
}

.fullscreen-prompt-text {
    display: inline-block;
    vertical-align: middle;
}

.fullscreen-prompt-button {
    display: inline-block;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.8);
    background: rgba(0, 200, 255, 0.7);
    color: white;
    font-size: 18px;
    line-height: 31px;
    text-align: center;
    margin-left: 10px;
    vertical-align: middle;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Asegurar que el juego se vea bien en modo horizontal */
@media (orientation: portrait) and (max-width: 768px) {
    .orientation-message {
        display: flex;
    }
    
    #game-container {
        display: none;
    }
}

/* Optimizaciones para modo horizontal en móviles */
@media (orientation: landscape) and (max-width: 1024px) {
    body {
        overflow: hidden;
    }
    
    #game-container {
        width: 100vw;
        height: 100vh;
    }
}

/* Modo pantalla completa simulado para iOS */
/* iOS no soporta la API de Fullscreen para elementos HTML, así que usamos CSS */
body.ios-fullscreen,
html.ios-fullscreen {
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
    /* Ocultar barras de navegación del navegador */
    -webkit-overflow-scrolling: touch;
}

body.ios-fullscreen {
    /* Asegurar que ocupe toda la pantalla disponible */
    min-height: 100vh;
    min-height: -webkit-fill-available;
    /* Prevenir scroll */
    overscroll-behavior: none;
}

html.ios-fullscreen {
    /* Asegurar que ocupe toda la pantalla disponible */
    height: 100%;
    height: -webkit-fill-available;
}

/* En iOS fullscreen, asegurar que el contenedor del juego ocupe toda la pantalla */
body.ios-fullscreen #game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: -webkit-fill-available;
    z-index: 1;
}

/* Asegurar que los controles virtuales sean visibles en iOS fullscreen */
body.ios-fullscreen .virtual-controls {
    position: fixed !important;
    z-index: 999999 !important;
    pointer-events: none !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    height: -webkit-fill-available !important;
    display: block !important;
}

body.ios-fullscreen .virtual-controls * {
    pointer-events: auto !important;
}

