:root {
    --neon-pink: #ff007f;
    --neon-cyan: #00f0ff;
    --neon-green: #39ff14;
    --neon-red: #ff3131;
    --neon-purple: #bd00ff;
    --bg-dark: #050510;
    --bg-panel: rgba(13, 13, 35, 0.8);
    --font-header: 'Press Start 2P', monospace;
    --font-body: 'Orbitron', sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    background-image: 
        linear-gradient(rgba(189, 0, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(189, 0, 255, 0.05) 1px, transparent 1px);
    background-size: 40px 40px;
    color: #ffffff;
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    padding: 20px;
}

/* CRT Scanline Effect Overlay */
.crt::after {
    content: " ";
    display: block;
    position: fixed;
    top: 0; left: 0; bottom: 0; right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    aspect-ratio: auto;
    background-size: 100% 4px, 6px 100%;
    pointer-events: none;
    z-index: 999;
}

/* Contenedor Principal del Juego */
.game-container {
    max-width: 1100px;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    z-index: 10;
}

@media (min-width: 900px) {
    .game-container {
        grid-template-columns: 2.2fr 1fr;
    }
}

/* Título de Cabecera */
.header-title {
    grid-column: 1 / -1;
    text-align: center;
    margin-bottom: 10px;
}

.header-title h1 {
    font-family: var(--font-header);
    font-size: 2.2rem;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 4px;
    text-shadow: 
        0 0 5px #fff,
        0 0 10px var(--neon-pink),
        0 0 20px var(--neon-pink),
        0 0 40px var(--neon-purple);
    animation: neon-flicker 3s infinite alternate;
}

.header-title p {
    font-family: var(--font-body);
    color: var(--neon-cyan);
    font-size: 0.95rem;
    letter-spacing: 2px;
    text-shadow: 0 0 5px rgba(0, 240, 255, 0.5);
    margin-top: 8px;
}

/* Sección de la Pantalla del Juego */
.canvas-section {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 3px solid var(--neon-cyan);
    border-radius: 8px;
    background: #000;
    box-shadow: 
        0 0 15px rgba(0, 240, 255, 0.3),
        inset 0 0 20px rgba(0, 240, 255, 0.2);
    overflow: hidden;
}

#gameCanvas {
    display: block;
    max-width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    background: radial-gradient(circle, #08051a 0%, #000000 100%);
    cursor: none; /* Ocultar el cursor dentro del canvas */
}

/* HUD Overlay */
.hud-panel {
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    background: rgba(0, 0, 0, 0.85);
    border-bottom: 2px solid var(--neon-pink);
    padding: 12px;
    font-family: var(--font-header);
    font-size: 0.75rem;
    color: #fff;
    letter-spacing: 1px;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.hud-label {
    color: #8a8ab0;
    font-size: 0.55rem;
}

.hud-value {
    color: var(--neon-cyan);
    text-shadow: 0 0 5px var(--neon-cyan);
}

.hud-value.lives {
    color: var(--neon-pink);
    text-shadow: 0 0 5px var(--neon-pink);
}

/* Panel Lateral (Leaderboard / Controles / Power-ups) */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel-card {
    background: var(--bg-panel);
    border: 2px solid var(--neon-purple);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 0 10px rgba(189, 0, 255, 0.15);
    backdrop-filter: blur(10px);
}

.panel-card h2 {
    font-family: var(--font-header);
    font-size: 0.85rem;
    color: #fff;
    text-transform: uppercase;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(189, 0, 255, 0.4);
    padding-bottom: 8px;
    letter-spacing: 2px;
    text-shadow: 0 0 5px var(--neon-purple);
}

/* Efectos Activos */
.active-effect-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    border-left: 4px solid #fff;
    background: rgba(255, 255, 255, 0.05);
}

.active-effect-item.positive {
    border-left-color: var(--neon-green);
    color: var(--neon-green);
    box-shadow: inset 0 0 5px rgba(57, 255, 20, 0.2);
}

.active-effect-item.negative {
    border-left-color: var(--neon-red);
    color: var(--neon-red);
    box-shadow: inset 0 0 5px rgba(255, 49, 49, 0.2);
}

.active-effect-item .timer {
    font-family: var(--font-header);
    font-size: 0.65rem;
}

/* Leaderboard Table */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

.leaderboard-table th, .leaderboard-table td {
    padding: 8px 10px;
}

.leaderboard-table th {
    color: var(--neon-cyan);
    font-family: var(--font-body);
    font-weight: bold;
    border-bottom: 1px solid rgba(0, 240, 255, 0.2);
    font-size: 0.75rem;
    text-transform: uppercase;
}

.leaderboard-table tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.leaderboard-table tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.leaderboard-table td.pos {
    color: var(--neon-pink);
    font-weight: bold;
}

.leaderboard-table td.score {
    font-family: var(--font-header);
    font-size: 0.65rem;
    color: var(--neon-cyan);
}

/* Pantallas de Estado del Juego (Start/Game Over/Victory Overlays) */
.overlay-screen {
    position: absolute;
    top: 52px; /* Debajo del HUD */
    left: 0;
    width: 100%;
    height: calc(100% - 52px);
    background: rgba(5, 5, 15, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
    text-align: center;
    transition: opacity 0.3s ease;
}

.overlay-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-title {
    font-family: var(--font-header);
    font-size: 2rem;
    margin-bottom: 15px;
    letter-spacing: 2px;
}

.overlay-screen.gameover .overlay-title {
    color: var(--neon-red);
    text-shadow: 0 0 10px var(--neon-red);
}

.overlay-screen.victory .overlay-title {
    color: var(--neon-green);
    text-shadow: 0 0 10px var(--neon-green);
}

.overlay-screen.start .overlay-title {
    color: var(--neon-cyan);
    text-shadow: 0 0 10px var(--neon-cyan);
}

.overlay-text {
    font-size: 1rem;
    color: #b0b0d0;
    margin-bottom: 25px;
    line-height: 1.5;
    max-width: 500px;
}

/* Formularios y Botones Neon */
.retro-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 320px;
    margin-bottom: 20px;
}

.retro-input {
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid var(--neon-purple);
    border-radius: 4px;
    color: #fff;
    padding: 10px 15px;
    font-family: var(--font-body);
    font-size: 1rem;
    text-align: center;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.retro-input:focus {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 8px var(--neon-cyan);
}

.retro-btn {
    background: transparent;
    border: 2px solid var(--neon-pink);
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    font-family: var(--font-header);
    font-size: 0.75rem;
    padding: 12px 24px;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: all 0.2s ease-in-out;
    text-shadow: 0 0 4px var(--neon-pink);
    box-shadow: 0 0 4px rgba(255, 0, 127, 0.3);
}

.retro-btn:hover {
    background: var(--neon-pink);
    color: #000;
    box-shadow: 0 0 15px var(--neon-pink);
    text-shadow: none;
}

.retro-btn.cyan-btn {
    border-color: var(--neon-cyan);
    text-shadow: 0 0 4px var(--neon-cyan);
    box-shadow: 0 0 4px rgba(0, 240, 255, 0.3);
}

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

/* Controles Leyenda */
.controls-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.8rem;
    color: #8a8ab0;
}

.controls-legend div {
    display: flex;
    justify-content: space-between;
}

.controls-legend span.key {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--font-header);
    font-size: 0.55rem;
    border-bottom: 2px solid #555;
}

/* Animación de Parpadeo de Neon */
@keyframes neon-flicker {
    0%, 18%, 22%, 25%, 53%, 57%, 100% {
        text-shadow: 
            0 0 5px #fff,
            0 0 10px var(--neon-pink),
            0 0 20px var(--neon-pink),
            0 0 40px var(--neon-purple);
    }
    20%, 24%, 55% {
        text-shadow: none;
    }
}
