:root {
    --neon-cyan: #00f0ff;
    --neon-pink: #ff007f;
    --neon-orange: #ff9900;
    --neon-green: #39ff14;
    --dark-bg: #03030d;
    --hud-bg: rgba(6, 6, 20, 0.65);
    --hud-border: rgba(0, 240, 255, 0.25);
    --font-primary: 'Rajdhani', sans-serif;
    --font-cyber: 'Orbitron', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--dark-bg);
    color: #fff;
    font-family: var(--font-primary);
    position: relative;
}

/* Canvas ocupa todo el viewport */
#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    display: block;
}

/* Overlay principal (pantalla de inicio, calibración) */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, rgba(10, 10, 30, 0.9) 0%, rgba(3, 3, 13, 0.98) 100%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    padding: 20px;
}

.overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Tarjeta de Glassmorphism */
.glass-card {
    background: var(--hud-bg);
    border: 1px solid var(--hud-border);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 0 40px rgba(0, 240, 255, 0.15), inset 0 0 20px rgba(0, 240, 255, 0.05);
    animation: card-appear 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes card-appear {
    0% { transform: scale(0.9) translateY(20px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

.glow-text {
    font-family: var(--font-cyber);
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: 4px;
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5), 0 0 20px var(--neon-cyan), 0 0 40px var(--neon-cyan);
    margin-bottom: 2px;
}

.glow-text span {
    color: var(--neon-pink);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5), 0 0 20px var(--neon-pink), 0 0 40px var(--neon-pink);
}

.subtitle {
    font-family: var(--font-cyber);
    font-size: 0.95rem;
    letter-spacing: 8px;
    color: var(--neon-cyan);
    margin-bottom: 30px;
    text-transform: uppercase;
}

.instructions {
    font-size: 1.1rem;
    line-height: 1.6;
    color: #b0b0d0;
    margin-bottom: 30px;
}

.connection-tip {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 12px;
    margin-top: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 0.95rem;
    border: 1px dashed rgba(0, 240, 255, 0.2);
}

.pulse-icon {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}

#ip-text {
    font-weight: bold;
    color: var(--neon-cyan);
    word-break: break-all;
}

/* Botones */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.btn {
    font-family: var(--font-cyber);
    font-size: 1.1rem;
    font-weight: bold;
    padding: 16px 30px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    letter-spacing: 2px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn.primary {
    background: var(--neon-cyan);
    color: #000;
    box-shadow: 0 0 15px var(--neon-cyan);
}

.btn.primary:active {
    transform: scale(0.95);
    box-shadow: 0 0 5px var(--neon-cyan);
}

.btn.secondary {
    background: transparent;
    border: 1px solid var(--neon-pink);
    color: var(--neon-pink);
    box-shadow: 0 0 5px rgba(255, 0, 127, 0.2);
}

.btn.secondary:active {
    transform: scale(0.95);
    background: rgba(255, 0, 127, 0.1);
}

.hidden {
    display: none !important;
}

.status-msg {
    font-size: 0.9rem;
    color: #8888aa;
    margin-top: 15px;
}

.fallback-info {
    font-size: 0.95rem;
    color: var(--neon-orange);
    margin-top: 15px;
    background: rgba(255, 153, 0, 0.1);
    padding: 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 153, 0, 0.2);
}

/* --- HUD de Juego --- */
.hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none; /* Permite disparar a través del HUD */
    padding: env(safe-area-inset-top, 20px) env(safe-area-inset-right, 20px) env(safe-area-inset-bottom, 20px) env(safe-area-inset-left, 20px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Contenedores Superior e Inferior del HUD */
.hud-top, .hud-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.hud-item {
    background: var(--hud-bg);
    border: 1px solid var(--hud-border);
    padding: 8px 18px;
    border-radius: 6px;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hud-item .label {
    font-size: 0.75rem;
    letter-spacing: 2px;
    color: #8888aa;
    margin-bottom: 2px;
}

.hud-item .value {
    font-family: var(--font-cyber);
    font-size: 1.5rem;
    font-weight: bold;
}

.glow-cyan {
    color: var(--neon-cyan);
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}

.glow-orange {
    color: var(--neon-orange);
    text-shadow: 0 0 10px rgba(255, 153, 0, 0.4);
}

.multiplier-container {
    justify-content: center;
    border-color: var(--neon-pink);
    padding: 10px 15px;
}

.multiplier-container .value {
    color: var(--neon-pink);
    font-size: 1.6rem;
    text-shadow: 0 0 10px rgba(255, 0, 127, 0.4);
}

/* Barras de Estado (Escudo, Armadura, Calor) */
.hud-bar-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 40%;
    max-width: 250px;
    pointer-events: auto; /* Permite interactuar con botones si los hubiera */
}

.hud-bar-group.right-align {
    align-items: flex-end;
}

.hud-bar-container {
    width: 100%;
    background: var(--hud-bg);
    border: 1px solid var(--hud-border);
    padding: 6px 12px;
    border-radius: 6px;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.hud-bar-container .label {
    font-size: 0.7rem;
    letter-spacing: 1px;
    color: #8888aa;
    display: block;
    margin-bottom: 4px;
}

.bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.2s ease-out;
}

.shield-fill {
    background: linear-gradient(90deg, #0099ff, var(--neon-cyan));
    box-shadow: 0 0 8px var(--neon-cyan);
}

.armor-fill {
    background: linear-gradient(90deg, #dd3300, var(--neon-green));
    box-shadow: 0 0 8px var(--neon-green);
}

.heat-fill {
    background: linear-gradient(90deg, var(--neon-green), var(--neon-orange), var(--neon-pink));
    box-shadow: 0 0 8px var(--neon-orange);
}

.heat-container {
    position: relative;
    border-color: rgba(255, 153, 0, 0.25);
}

.overheat-text {
    position: absolute;
    right: 12px;
    top: 5px;
    font-family: var(--font-cyber);
    font-size: 0.75rem;
    color: var(--neon-pink);
    font-weight: bold;
    animation: flash 0.5s infinite alternate;
}

@keyframes flash {
    0% { opacity: 0.3; }
    100% { opacity: 1; }
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--hud-border);
    background: var(--hud-bg);
    color: #fff;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    transition: all 0.2s;
    margin-top: 8px;
}

.btn-icon:active {
    transform: scale(0.9);
    border-color: var(--neon-cyan);
    box-shadow: 0 0 10px var(--neon-cyan);
}

/* Alertas de Juego del Centro */
.game-alert {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-cyber);
    font-size: 2.2rem;
    font-weight: 900;
    letter-spacing: 4px;
    color: #fff;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.8), 0 0 30px var(--neon-pink);
    animation: alert-banner 1.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    text-align: center;
    white-space: nowrap;
}

@keyframes alert-banner {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; filter: blur(10px); }
    15% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; filter: blur(0); }
    30% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    80% { transform: translate(-50%, -50%) scale(1); opacity: 1; filter: blur(0); }
    100% { transform: translate(-50%, -50%) scale(1.3); opacity: 0; filter: blur(15px); }
}

/* Soporte para modo horizontal en móviles */
@media (orientation: landscape) {
    .overlay {
        padding: 10px;
    }
    
    .glass-card {
        max-width: 600px;
        padding: 20px 30px;
    }
    
    .glow-text {
        font-size: 2.4rem;
    }
    
    .subtitle {
        margin-bottom: 15px;
    }
    
    .instructions {
        font-size: 0.95rem;
        margin-bottom: 15px;
    }
    
    .instructions p {
        margin-bottom: 5px;
    }
    
    .connection-tip {
        margin-top: 10px;
        padding: 8px;
    }
    
    .action-buttons {
        flex-direction: row;
        justify-content: center;
    }
    
    .btn {
        padding: 12px 24px;
        font-size: 0.95rem;
    }
    
    .hud-bar-group {
        width: 30%;
    }
}

/* Panel de Diagnóstico de Sensores (Cyberpunk Style) - Ocultado para producción */
.sensor-debug-panel {
    display: none !important; /* Ocultado por solicitud de usuario */
    position: absolute;
    bottom: 80px;
    left: 20px;
    background: rgba(6, 6, 20, 0.85);
    border: 1px dashed rgba(0, 240, 255, 0.4);
    font-family: 'Orbitron', monospace;
    font-size: 11px;
    padding: 10px 14px;
    border-radius: 6px;
    z-index: 100;
    pointer-events: none;
    color: var(--neon-cyan);
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-shadow: 0 0 2px var(--neon-cyan);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.1);
}

.sensor-debug-panel span {
    color: #fff;
    font-weight: bold;
}

