@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&display=swap');

:root {
    --neon-cyan: #00f2ff;
    --neon-magenta: #ff00ff;
    --neon-yellow: #fbff00;
    --bg-color: #000000;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    background-color: var(--bg-color);
    color: white;
    font-family: 'Orbitron', sans-serif;
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100dvh;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: env(safe-area-inset-top) 10px env(safe-area-inset-bottom) 10px;
    background: radial-gradient(circle at center, #111 0%, #000 100%);
}

#hud {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    font-size: 14px;
    color: var(--neon-cyan);
    text-shadow: 0 0 10px var(--neon-cyan), 0 0 20px var(--neon-cyan);
    padding: 0 10px;
}

#game-title {
    font-weight: 700;
    font-size: 18px;
    color: var(--neon-magenta);
    text-shadow: 0 0 15px var(--neon-magenta), 0 0 30px var(--neon-magenta);
    letter-spacing: 1px;
}

canvas {
    max-width: 100%;
    max-height: calc(100dvh - 120px);
    aspect-ratio: 19 / 21;
    background: #000;
    border: 3px solid var(--neon-cyan);
    box-shadow: 0 0 30px rgba(0, 242, 255, 0.4), inset 0 0 20px rgba(0, 242, 255, 0.2);
    border-radius: 12px;
    touch-action: none;
}

#overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    background: rgba(0, 0, 0, 0.8);
    width: 80%;
    padding: 40px;
    border-radius: 15px;
    border: 1px solid var(--neon-magenta);
    box-shadow: 0 0 30px var(--neon-magenta);
    z-index: 10;
}

#overlay-title {
    font-size: 28px;
    margin-bottom: 20px;
    color: var(--neon-magenta);
    text-shadow: 0 0 20px var(--neon-magenta);
}

#hero-logo {
    width: 120px;
    height: 120px;
    margin-bottom: 10px;
    border-radius: 24px;
    box-shadow: 0 0 25px var(--neon-magenta);
    border: 2px solid var(--neon-magenta);
    animation: logo-pulse 2.5s infinite ease-in-out;
}

@keyframes logo-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 20px var(--neon-magenta); }
    50% { transform: scale(1.05); box-shadow: 0 0 40px var(--neon-magenta); }
}

#overlay-msg {
    color: var(--neon-cyan);
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Botón de activación en la esquina (Fuera del flujo del juego) */
#toggle-controls {
    position: fixed;
    top: 15px;
    right: 15px;
    width: 45px;
    height: 45px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid var(--neon-cyan);
    border-radius: 50%;
    color: var(--neon-cyan);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    z-index: 1000;
    cursor: pointer;
    box-shadow: 0 0 15px var(--neon-cyan);
    transition: all 0.3s ease;
}

#toggle-controls.active {
    background: var(--neon-cyan);
    color: black;
    box-shadow: 0 0 25px var(--neon-cyan);
}

/* Modales y Registro */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5000;
}

.modal-content {
    background: #000;
    padding: 30px;
    border: 2px solid var(--neon-magenta);
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 0 40px var(--neon-magenta);
}

.mini-logo {
    width: 80px;
    margin-bottom: 20px;
    border-radius: 15px;
    box-shadow: 0 0 15px var(--neon-magenta);
}

#username-input {
    width: 100%;
    padding: 12px;
    background: #111;
    border: 1px solid var(--neon-cyan);
    color: #fff;
    font-family: 'Orbitron', sans-serif;
    margin-top: 20px;
    border-radius: 8px;
    text-align: center;
}

#btn-register {
    margin-top: 20px;
    width: 100%;
    height: 50px;
}

.error-msg {
    color: #ff4444;
    margin-top: 10px;
    font-size: 12px;
}

#leaderboard {
    margin-top: 30px;
    border-top: 1px solid #333;
    padding-top: 15px;
    text-align: left;
}

#leaderboard h3 {
    font-size: 14px;
    color: var(--neon-yellow);
    margin-bottom: 10px;
    text-align: center;
}

#global-list {
    list-style: none;
    font-size: 12px;
    color: #aaa;
}

#global-list li {
    padding: 5px 0;
    border-bottom: 1px solid #111;
    display: flex;
    justify-content: space-between;
}

.modal-hidden {
    display: none !important;
}

/* Controles para Móviles (Invisibles pero funcionales) */
#mobile-controls {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none; /* Se activa con JS */
    pointer-events: none;
    z-index: 50;
}

#mobile-controls.visible {
    display: block;
}

#btn-pause {
    position: absolute;
    top: 15px;
    left: 15px;
    width: 45px;
    height: 45px;
    opacity: 0.2; /* Apenas visible para pausar */
    background: transparent;
    border: 1px solid var(--neon-cyan);
    color: var(--neon-cyan);
    border-radius: 50%;
    pointer-events: auto;
}

#dpad {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.dpad-btn {
    position: absolute;
    background: transparent;
    border: none;
    color: transparent; /* TOTALMENTE INVISIBLE */
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
}

/* Zonas táctiles gigantes e invisibles */
#btn-up { top: 0; left: 0; width: 100%; height: 35%; } 
#btn-down { bottom: 0; left: 0; width: 100%; height: 35%; } 
#btn-left { top: 35%; left: 0; width: 50%; height: 30%; } 
#btn-right { top: 35%; right: 0; width: 50%; height: 30%; } 

.dpad-horizontal { display: none; }
