/* --- ESTILOS BASE --- */
* {
    box-sizing: border-box; 
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    background-color: #000;
    font-family: 'Courier New', Courier, monospace;
    color: #0f0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* --- ACCESIBILIDAD --- */
main {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    z-index: 5; 
}

/* --- MATRIX BACKGROUND --- */
#matrixBg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1; 
    pointer-events: none; 
}

/* --- BLOQUE 1: CABECERA --- */
header {
    width: 100%;
    max-width: 800px;
    text-align: center;
    padding: 10px 5px;
    flex-shrink: 0;
    z-index: 5; 
}
h2 { margin: 0; font-size: 1.4em; text-shadow: 0 0 5px #0f0; }
#introMessage {
    color: #aff; font-size: 0.85em; margin-top: 5px;
    border-bottom: 1px solid #004400; padding-bottom: 5px;
    background: rgba(0, 0, 0, 0.6); 
    display: inline-block;
    padding: 5px 10px;
    border-radius: 4px;
}
#introMessage b { color: #fff; }

/* --- BLOQUE 2: ÁREA DE JUEGO --- */
#gameContainer {
    position: relative;
    width: 100%; 
    max-width: 800px;
    padding: 0 20px; 
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#gameCanvas {
    border: 2px solid #0f0;
    background-color: #051105;
    box-shadow: 0 0 15px #0f0, 0 0 30px #0f0 inset;
    display: block;
    width: 100%; 
    height: auto; 
    cursor: none;
}

/* Capa UI Flotante */
#uiLayer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 95%;
    max-width: 500px;
    text-align: center;
    z-index: 10;
    pointer-events: none; 
}

/* Pantallas superpuestas */
.overlay-screen {
    pointer-events: auto;
    background-color: rgba(0, 17, 0, 0.95);
    border: 1px solid #0f0;
    padding: 20px;
    box-shadow: 0 0 50px #000;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    max-height: 80vh;
    overflow-y: auto;
}

#respawnMessage {
    color:#ff0; font-size:1.2em; text-shadow: 0 0 5px #000;
}

#secretMessage {
    border:1px dashed #aff; padding:10px; font-size:0.85em; color:#aff;
}

#rankingSection {
    width:100%;
}

#inputHighScore {
    margin-bottom:10px;
}

/* --- BLOQUE 3: CONTROLES --- */
#controlsArea {
    width: 100%;
    max-width: 800px;
    padding: 10px 5px;
    background-color: #000;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 12px; 
    flex-shrink: 0;
    border-top: 1px solid #003300;
}

/* Fila 1: JUGADOR */
.player-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    width: 100%;
}

/* Fila 2: SISTEMA */
.system-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    opacity: 0.8; 
}

/* ESTILOS BOTONES */
button, select {
    background-color: #002200;
    color: #0f0;
    border: 1px solid #0f0;
    padding: 12px 18px; 
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.95em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 0 5px #0f0;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
    user-select: none;
    touch-action: manipulation; 
}
button:hover, select:hover { background-color: #004400; color: #fff; box-shadow: 0 0 10px #0f0; }
button:active { background-color: #001100; box-shadow: 0 0 5px #0f0 inset; transform: translateY(2px); }
button:disabled { opacity: 0.5; cursor: not-allowed; filter: grayscale(100%); }

#btnShoot {
    padding: 10px 30px;
    border-color: #aff;
    color: #aff;
    box-shadow: 0 0 8px #aff;
}

button.highlight-btn { border-color: #ff0; color: #ff0; font-weight: bold; }
button.muted { opacity: 0.6; border-color: #555; color: #555; box-shadow: none; }

.btn-icon { width: 28px; height: 28px; fill: currentColor; }

/* UI Elements - Tabla Ranking */
#rankingTableContainer {
    width: 100%;
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid #004400;
    background: #000;
}
#rankingTableContainer::-webkit-scrollbar { width: 6px; }
#rankingTableContainer::-webkit-scrollbar-thumb { background: #0f0; }

table { width: 100%; font-size: 0.8em; border-collapse: collapse; }
th { position: sticky; top: 0; background: #002200; padding: 5px; color: #aff; text-align: center; }
td { padding: 4px; border-bottom: 1px solid #003300; text-align: center; }
.highlight-row { background-color: #003300; color: #fff; font-weight: bold; border: 1px solid #ff0; }
.ranking-separator td { border: none !important; text-align: center; color: #555; padding: 5px 0; }

#playerNameInput {
    background: #000; border: 1px solid #0f0; color: #0f0;
    font-family: inherit; font-size: 1.1em; text-align: center;
    width: 180px; padding: 5px; text-transform: uppercase;
    outline: none;
}

.hidden { display: none !important; }

@media (max-height: 600px) { header { display: none; } }