/* =========================================================
   C.O.S.M.O.S. V2.2 - HOJA DE ESTILOS MAESTRA (SANEADA)
   Arquitectura Modular | Escalable | Cero Conflictos
========================================================= */

/* ==================================================================================================================
   1. VARIABLES GLOBALES (CALIBRADAS PARA ACCESIBILIDAD AA)
================================================================================================================== */
:root {
    /* Fondos */
    --espacio-profundo: #020305;
    --metal-cabina: #1e2630;
    --metal-oscuro: #0f141a;

    /* Colores de Interfaz (Ajustados para Contraste > 4.5:1) */
    --cyan-neon: #66fcf1;      /* Ratio 10.3:1 - Perfecto */
    --ambar-pantalla: #ffb703;  /* Ratio 8.1:1 - Perfecto */
    --rojo-alerta: #ff5c5c;     /* Ratio 4.6:1 - Cumple AA (Antes #ff4b4b era 4.1:1) */
    --verde-ok: #5df263;        /* Ratio 9.2:1 - Excelente (Antes #4caf50 era 3.8:1) */
    --azul-radar: #548ce1;      /* Ratio 5.1:1 - Cumple AA */
    --naranja-trajes: #ffa726;  /* Ratio 6.5:1 - Cumple AA */
    
    --fuente-titulos: 'Fredoka One', cursive;
    --fuente-texto: 'Nunito', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body, html { 
    margin: 0; padding: 0; height: 100vh; 
    background-color: var(--espacio-profundo); 
    color: white; font-family: var(--fuente-texto); 
    overflow: hidden; 
}

/* ==================================================================================================================
   2. UTILIDADES BASE Y ANIMACIONES
================================================================================================================== */
.text-cyan { color: var(--cyan-neon) !important; }
.text-ambar { color: var(--ambar-pantalla) !important; }
.text-rojo { color: var(--rojo-alerta) !important; }
.text-azul { color: var(--azul-radar) !important; }
.text-verde { color: var(--verde-ok) !important; }

.font-bold { font-weight: 800 !important; }
.mt-15 { margin-top: 15px !important; }
.mt-20 { margin-top: 20px !important; }
.mb-15 { margin-bottom: 15px !important; }

.parpadeo { animation: blinker 0.8s linear infinite; }
@keyframes blinker { 50% { opacity: 0.2; } }

.parpadeo-suave { animation: pulsarRojo 2s infinite; }
@keyframes pulsarRojo {
    0%, 100% { box-shadow: 0 0 5px rgba(255, 75, 75, 0.2); border-color: rgba(255, 75, 75, 0.5); }
    50% { box-shadow: 0 0 20px rgba(255, 75, 75, 0.6); border-color: rgba(255, 75, 75, 1); }
}

/* ==================================================================================================================
   3. LAYOUT PRINCIPAL Y PARABRISAS
================================================================================================================== */
.simulador-v2 { display: flex; flex-direction: column; height: 100vh; width: 100vw; }

.parabrisas {
    height: 42vh; flex: none; position: relative; width: 100%;
    background: radial-gradient(circle, #0a0e14 0%, #000000 100%); overflow: hidden;
}
.marco-superior { position: absolute; top: 0; left: 0; width: 100%; height: 25px; background: linear-gradient(to bottom, #111, transparent); z-index: 10; }
.pilar-izquierdo { position: absolute; top: 0; left: 0; width: 30px; height: 100%; background: linear-gradient(to right, #1a222c, #0a0e14, transparent); z-index: 10; clip-path: polygon(0 0, 100% 0, 40% 100%, 0 100%); }
.pilar-derecho { position: absolute; top: 0; right: 0; width: 30px; height: 100%; background: linear-gradient(to left, #1a222c, #0a0e14, transparent); z-index: 10; clip-path: polygon(0 0, 100% 0, 100% 100%, 60% 100%);}
.parabrisas canvas { width: 100% !important; height: 100% !important; outline: none; }

/* ==================================================================================================================
   4. SISTEMA DE BOTONES MAESTRO
================================================================================================================== */
.uni-btn, .tactic-btn, .boton-destino, .btn-aula, .btn-microfono, .btn-ancho-completo {
    font-family: var(--fuente-texto); font-weight: 700; text-transform: uppercase;
    cursor: pointer; border-radius: 6px; display: flex; align-items: center; justify-content: center;
    background: rgba(15, 20, 26, 0.8); color: white; border: 2px solid var(--cyan-neon);
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    padding: 8px 15px; height: 42px; font-size: 0.9rem; white-space: nowrap;
}
.uni-btn:hover, .tactic-btn:hover, .boton-destino:hover, .btn-aula:hover {
    transform: scale(1.03); box-shadow: 0 0 15px rgba(102, 252, 241, 0.4); border-width: 2px;
}
.btn-ancho-completo { width: 100%; margin: 0 !important; }
.btn-cancelar { border-color: var(--rojo-alerta); color: var(--rojo-alerta); }
.btn-ancho-completo:hover, .btn-cancelar:hover {
    transform: scale(0.98); background: var(--rojo-alerta); color: white;
    box-shadow: 0 0 20px rgba(255, 75, 75, 0.7); border-color: var(--rojo-alerta);
}
.uni-btn:active, .tactic-btn:active, .btn-ancho-completo:active { transform: scale(0.95); }


/* ==================================================================================================================
   5. TABLERO DE COMANDOS Y MONITORES
================================================================================================================== */
.tablero-comandos {
    flex: 1; min-height: 0; background: var(--metal-cabina); padding: 8px 23px 8px 23px !important;
    display: flex; flex-direction: column; gap: 4px !important; border-top: 3px solid var(--cyan-neon);
    box-shadow: 0 -10px 30px rgba(0,0,0,0.8); overflow: hidden !important; 
}

.fila-monitores { 
	display: flex; 
	gap: 10px; 
	width: 100%;
	margin-bottom: 0px !important; 
	padding-bottom: 0 !important; 
	z-index: 10; 
	flex: 1 1 160px; 
	min-height: 120px; 
	max-height: 180px; 
}

.monitor-modulo {
    flex: 1; 
	min-width: 200px; 
	background: #06080a; 
	border: 4px solid #141c24;
	border-left: 3px solid var(--cyan-neon);
    border-radius: 12px;
	padding: 10px; 
	box-shadow: inset 0 0 20px rgba(0,0,0,1);
    display: flex; 
	flex-direction: column; 
	min-height: 0;
}
.monitor-modulo h3 {
    font-family: var(--fuente-titulos); color: var(--ambar-pantalla); margin: 0 0 8px 0; 
    text-align: center; font-size: 0.85rem !important; letter-spacing: 1px; 
    text-transform: uppercase; border-bottom: 1px solid rgba(255, 183, 3, 0.2); 
    padding-bottom: 5px; flex-shrink: 0; white-space: nowrap !important; 
    overflow: hidden; text-overflow: ellipsis; 
}

/* ? EFECTO DE INTERFERENCIA DE ENCENDIDO */
.interferencia-hud {
    position: relative;
    overflow: hidden;
    animation: sacudida-radar 0.2s ease infinite; /* Vibraci��n de hardware */
}

/* Capa de parpadeo de est��tica */
.interferencia-hud::before {
    content: "";
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(102, 252, 241, 0.15); /* Color cyan-neon muy tenue */
    z-index: 5;
    pointer-events: none;
    animation: parpadeo-fast 0.1s steps(2) infinite;
}

@keyframes sacudida-radar {
    0% { transform: translate(1px, 1px); }
    50% { transform: translate(-1px, -1px); }
    100% { transform: translate(0, 0); }
}

@keyframes parpadeo-fast {
    0% { opacity: 0.2; }
    100% { opacity: 0.8; }
}

#monitor-apod { flex: 1; display: flex; min-height: 0; }
#monitor-apod img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; filter: contrast(1.1); }
#lista-asteroides { flex: 1; overflow-y: auto; margin: 0; padding-left: 15px; font-size: 0.85rem; line-height: 1.4; color: var(--cyan-neon); }

.modulo-ia { flex: 1.5; border-color: var(--cyan-neon); box-shadow: inset 0 0 20px rgba(102, 252, 241, 0.05); }
.modulo-ia h3 { color: var(--cyan-neon); border-bottom-color: rgba(102, 252, 241, 0.3); }
.historial-chat { flex: 1; min-height: 0; overflow-y: auto; padding: 5px 15px; font-size: 0.95rem; display: flex; flex-direction: column; justify-content: flex-end; }
.mensaje-ia { color: var(--cyan-neon); margin-bottom: 5px; }
.mensaje-nino { color: #fff; text-align: right; margin-bottom: 5px; }

/* ==================================================================================================================
   6. COMUNICACIONES (CHAT Y MICRO)
================================================================================================================== */
.controles-chat { display: flex; flex-direction: row; flex-wrap: nowrap; align-items: center; gap: 8px; margin-top: 10px; flex-shrink: 0; width: 100%; }
#btn-microfono { flex: 0 0 42px; width: 42px; height: 42px; font-size: 1.2rem; padding: 0; background: rgba(102, 252, 241, 0.1); border: 2px solid var(--cyan-neon); border-radius: 6px; color: white; cursor: pointer; transition: all 0.2s ease; display: flex; align-items: center; justify-content: center; }
#btn-microfono:hover { background: var(--cyan-neon); color: var(--metal-oscuro); box-shadow: 0 0 15px var(--cyan-neon); }
.controles-chat input { flex: 1 1 auto; height: 42px; padding: 0 15px; border-radius: 6px; border: 1px solid rgba(102, 252, 241, 0.3); background: #06080a; color: var(--cyan-neon); font-family: var(--fuente-texto); font-size: 0.95rem; min-width: 0; transition: all 0.3s ease; }
.controles-chat input:focus { outline: none; border-color: var(--cyan-neon); box-shadow: inset 0 0 10px rgba(102, 252, 241, 0.2); background: #0f141a; }
.controles-chat button:not(#btn-microfono) { flex: 0 0 auto; height: 42px; padding: 0 15px; background: rgba(15, 20, 26, 0.8); border: 2px solid var(--cyan-neon); border-radius: 6px; color: var(--cyan-neon); font-weight: 800; font-size: 0.85rem; letter-spacing: 1px; transition: all 0.2s ease; }
.controles-chat button:not(#btn-microfono):hover { background: var(--cyan-neon); color: var(--metal-oscuro); box-shadow: 0 0 15px var(--cyan-neon); transform: scale(1.03); }
.grabando-audio { background: var(--rojo-alerta) !important; border-color: var(--rojo-alerta) !important; color: white !important; animation: latido-microfono 1s infinite; }

/* Clase para ocultar texto solo a la vista, manteni��ndolo para lectores de pantalla */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* El historial debe tener estas propiedades para el scroll */
#historial-chat {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ==================================================================================================================
   7. CONSOLA DE NAVEGACIÓN
================================================================================================================== */
.consola-navegacion { 
	display: flex; 
	flex-direction: row; 
	justify-content: space-around; 
	align-items: stretch; 
	width: 100%; 
	gap: 15px; 
	margin-top: 0 !important; 
	padding: 0px 2px 0px 2px; 
	padding-top: 0 !important;
	padding-bottom: 0 !important;
	flex: 2; 
	min-height: 0; 
	overflow: visible !important; 
}
.destinos-grupo { 
	flex: 1; 
	display: grid; 
	grid-template-columns: repeat(3, 1fr); 
	grid-auto-rows: minmax(18px, 36px); 
	gap: 4px; 
	padding: 10px 4px 10px 4px !important; 
	align-content: center; 
	background: rgba(15, 20, 26, 0.9); 
	border: 1px solid #4a5a6b; 
	border-radius: 8px; 
	position: relative; 
	min-height: 0;
	margin-top: 8px !important;
}
.consola-navegacion .destinos-grupo:nth-child(3), .consola-navegacion .destinos-grupo:nth-child(4) { grid-template-columns: repeat(2, 1fr); }
.titulo-grupo { position: absolute; top: -12px; left: 15px; background: #1c2631; color: var(--cyan-neon); padding: 2px 12px; font-size: 0.75rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; border: 1px solid #4a5a6b; border-radius: 4px; z-index: 10; white-space: nowrap; }
.consola-navegacion button { width: 100% !important; height: 100% !important; min-height: 0 !important; max-height: none !important; margin: 0 !important; font-size: clamp(0.5rem, 0.8vw + 0.35rem, 0.8rem) !important; padding: 2px 4px !important; white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }

/* Colores de Botones de Navegación */
.consola-navegacion .uni-btn[onclick*="'sol'"], .consola-navegacion .uni-btn[onclick*="'mercurio'"], .consola-navegacion .uni-btn[onclick*="'venus'"], .consola-navegacion .uni-btn[onclick*="'tierra'"], .consola-navegacion .uni-btn[onclick*="'luna'"], .consola-navegacion .uni-btn[onclick*="'marte'"] { border-color: var(--ambar-pantalla); color: var(--ambar-pantalla); }
.consola-navegacion .uni-btn[onclick*="'sol'"]:hover, .consola-navegacion .uni-btn[onclick*="'mercurio'"]:hover, .consola-navegacion .uni-btn[onclick*="'venus'"]:hover, .consola-navegacion .uni-btn[onclick*="'tierra'"]:hover, .consola-navegacion .uni-btn[onclick*="'luna'"]:hover, .consola-navegacion .uni-btn[onclick*="'marte'"]:hover { background: var(--ambar-pantalla); color: #000; box-shadow: 0 0 20px rgba(255, 183, 3, 0.7); }

.consola-navegacion .uni-btn[onclick*="'cinturon'"], .consola-navegacion .uni-btn[onclick*="'jupiter'"], .consola-navegacion .uni-btn[onclick*="'saturno'"], .consola-navegacion .uni-btn[onclick*="'urano'"], .consola-navegacion .uni-btn[onclick*="'neptuno'"], .consola-navegacion .uni-btn[onclick*="'voyager'"] { border-color: var(--cyan-neon); color: var(--cyan-neon); }.consola-navegacion .uni-btn[onclick*="'jupiter'"]:hover, .consola-navegacion .uni-btn[onclick*="'saturno'"]:hover, .consola-navegacion .uni-btn[onclick*="'urano'"]:hover, .consola-navegacion .uni-btn[onclick*="'neptuno'"]:hover, .consola-navegacion .uni-btn[onclick*="'voyager'"]:hover { background: var(--cyan-neon); color: #000; box-shadow: 0 0 20px rgba(102, 252, 241, 0.7); }
.consola-navegacion .uni-btn[onclick*="'cinturon'"]:hover, .consola-navegacion .uni-btn[onclick*="'jupiter'"]:hover, .consola-navegacion .uni-btn[onclick*="'saturno'"]:hover, .consola-navegacion .uni-btn[onclick*="'urano'"]:hover, .consola-navegacion .uni-btn[onclick*="'neptuno'"]:hover, .consola-navegacion .uni-btn[onclick*="'voyager'"]:hover { background: var(--cyan-neon); color: #000; box-shadow: 0 0 20px rgba(102, 252, 241, 0.7); }

/* ? ANIMACI��N DE CARGA (BLINDAJE T��CNICO) */
/* Usamos el ancestro para ganar la batalla de especificidad */
.consola-navegacion button.animacion-encendido-boton {
    animation: encendidoFisico 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards !important;
    z-index: 100;
    pointer-events: none;
}

@keyframes encendidoFisico {
    0% {
        transform: translateY(15px) scale(0.8) !important;
        filter: brightness(0) grayscale(1) !important;
    }
    50% {
        /* Chispazo de energ��a */
        filter: brightness(3) contrast(1.2) grayscale(0) !important;
        box-shadow: 0 0 20px var(--cyan-neon), 0 0 40px var(--cyan-neon) !important;
        transform: translateY(-5px) scale(1.05) !important;
    }
    100% {
        transform: translateY(0) scale(1) !important;
        filter: brightness(1) contrast(1) grayscale(0) !important;
        box-shadow: none;
    }
}

/* Opcional: Para que los botones se vean apagados antes del encendido */
.consola-navegacion button:disabled:not(#btn-power-global) {
    opacity: 0.3;
    filter: grayscale(1) brightness(0.5);
    transform: translateY(10px);
    transition: all 0.5s ease;
}

.btn-trajes-spec { border-color: var(--naranja-trajes) !important; color: var(--naranja-trajes) !important; }
.btn-trajes-spec:hover { background: var(--naranja-trajes) !important; color: #000 !important; box-shadow: 0 0 20px rgba(255, 152, 0, 0.7) !important; }
.btn-gravedad-spec { border-color: var(--rojo-alerta) !important; color: var(--rojo-alerta) !important; }
.btn-gravedad-spec:hover { background: var(--rojo-alerta) !important; color: white !important; box-shadow: 0 0 20px rgba(255, 75, 75, 0.7) !important; }
.btn-artemis-spec { border-color: var(--rojo-alerta) !important; color: var(--rojo-alerta) !important; animation: pulsarRojo 2s infinite; }
.btn-artemis-spec:hover { background: var(--rojo-alerta) !important; color: white !important; box-shadow: 0 0 20px rgba(255, 75, 75, 0.7) !important; animation: none; }
.btn-aula-spec { border-color: var(--cyan-neon) !important; color: var(--cyan-neon) !important; }
.btn-aula-spec:hover { background: var(--cyan-neon) !important; color: #000 !important; box-shadow: 0 0 20px rgba(102, 252, 241, 0.7) !important; }
.btn-cielo-spec { border-color: #b766fc; color: #b766fc; transition: all 0.3s ease; }
.btn-cielo-spec:hover { background: #b766fc !important; color: #000 !important; box-shadow: 0 0 20px rgba(183, 102, 252, 0.7) !important; }

/* ==================================================================================================================
   8. MODALES Y MINIJUEGOS
================================================================================================================== */
.panel-minijuego { 
	display: none; 
	position: fixed; 
	top: 50%; 
	left: 50%; 
	transform: translate(-50%, -50%); 
	width: 95%; 
	height: 80vh !important;
	max-height: 85vh !important; 
	background: rgba(15, 20, 26, 0.98); 
	backdrop-filter: blur(10px); 
	border: 2px solid var(--cyan-neon); 
	border-radius: 12px; 
	padding: 20px 25px 30px 25px !important; 
	z-index: 2000; 
	flex-direction: column; 
	align-items: center; 
	text-align: center; 
	box-shadow: 0 0 30px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(102, 252, 241, 0.1); 
	overflow: hidden; 
	will-change: transform, opacity;
}

.panel-minijuego > * { width: 100%; }
.titulo-modal { font-family: var(--fuente-titulos); font-size: 1.4rem; margin: 0 0 10px 0; text-transform: uppercase; letter-spacing: 1px; }
.texto-modal { font-family: var(--fuente-texto); font-size: 1.1rem; color: #cbd5e1; margin: 5px 0; } 
.modal-gravedad { max-width: 450px; border-color: var(--rojo-alerta); }
.modal-radar { max-width: 450px; border-color: var(--azul-radar); }
.modal-aula { max-width: 900px; overflow: hidden !important; }
.controles-juego { display: flex; justify-content: center; gap: 10px; width: 100%; margin-top: 20px 0 10px 0 !important; flex-wrap: wrap; }

.btn-traje-estandar-spec { border-color: var(--verde-ok) !important; color: var(--verde-ok) !important; }
.btn-traje-estandar-spec:hover { background: var(--verde-ok) !important; color: #000 !important; box-shadow: 0 0 20px rgba(76, 175, 80, 0.7) !important; }
.btn-traje-termico-spec { border-color: var(--rojo-alerta) !important; color: var(--rojo-alerta) !important; }
.btn-traje-termico-spec:hover { background: var(--rojo-alerta) !important; color: white !important; box-shadow: 0 0 20px rgba(255, 75, 75, 0.7) !important; }
.btn-traje-criogenico-spec { border-color: var(--cyan-neon) !important; color: var(--cyan-neon) !important; }
.btn-traje-criogenico-spec:hover { background: var(--cyan-neon) !important; color: #000 !important; box-shadow: 0 0 20px rgba(102, 252, 241, 0.7) !important; }
.btn-traje-pesado-spec { border-color: #9c27b0 !important; color: #9c27b0 !important; }
.btn-traje-pesado-spec:hover { background: #9c27b0 !important; color: white !important; box-shadow: 0 0 20px rgba(156, 39, 176, 0.7) !important; }



/* ==================================================================================================================
   ?? BLOQUE T��CTICO: MODAL VESTUARIO V3.0
================================================================================================================== */

.modal-vestuario {
    display: none; /* Se activa por JS */
    width: 900px !important;    /* M��s ancho para el visor */
    height: 580px !important;   /* Alto fijo para evitar SCROLL */
    background: var(--metal-oscuro);
	position: fixed;
    border: 2px solid var(--cyan-neon);
    box-shadow: 0 0 40px rgba(102, 252, 241, 0.3);
    padding: 30px;
	padding-bottom: 40px !important;
    flex-direction: column;
    overflow: hidden !important;
	will-change: transform, opacity;
}

.contenedor-flexible-vestuario {
    display: flex;
    gap: 20px;
    flex: 1;
    min-height: 0; /* Clave para flexbox sin desbordes */
}

/* 1. Botonera Izquierda (M��s peque?a) */
.botonera-trajes {
    flex: 0.4; /* Ocupa menos espacio */
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-traje-mini {
    padding: 12px !important;
    font-size: 0.85rem !important;
    text-align: left !important;
}

/* 2. Visor Derecho (Protagonista) */
.visor-telemetria {
    flex: 2; 
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle, rgba(10, 20, 30, 1) 0%, rgba(0, 0, 0, 1) 100%);
    border: 1px solid var(--cyan-neon);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.contenedor-imagen-traje {
    height: 100%; /* Ahora ocupa todo el contenedor */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
}

.contenedor-imagen-traje img {
    max-height: 450px; /* Imagen imponente */
    width: auto;
    filter: drop-shadow(0 0 20px var(--cyan-neon));
}

#imagen-traje-preview {
    max-height: 100%;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 0 20px var(--cyan-neon));
    display: none;
    z-index: 2;
}

.scanner-line {
    display: none;
    position: absolute;
    top: 0; left: 0; width: 100%; height: 2px;
    background: var(--cyan-neon);
    box-shadow: 0 0 15px var(--cyan-neon);
    z-index: 3;
    animation: scanMove 2s linear infinite;
}

@keyframes scanMove {
    0% { top: 0; }
    100% { top: 100%; }
}

.texto-escaneo-espera {
    font-size: 0.8rem;
    opacity: 0.5;
    text-align: center;
}

/* 3. Monitor de Texto de la IA */
.monitor-ia-texto {
    flex: 1;
    background: rgba(102, 252, 241, 0.05);
    border-top: 1px solid var(--cyan-neon);
    padding: 20px;
    font-size: 0.95rem;
    line-height: 1.5;
    color: white;
}

.placeholder-ia {
    opacity: 0.4;
    font-style: italic;
    text-align: center;
}

/* 4. Controles Inferiores */
.controles-juego-vestuario {
    margin-top: 20px;
    width: 100%;
}

.btn-cancelar-vestuario {
    width: 100%;
    padding: 15px;
    border-color: var(--rojo-alerta);
    color: var(--rojo-alerta);
}

/* �?ESTA REGLA ACTIVA EL FLEXBOX CUANDO EL JS LO ABRE */
.panel-minijuego[style*="display: block"],
.panel-minijuego[style*="display: flex"] {
    display: flex !important;
    flex-direction: column;
	height: 80vh !important;
    max-height: 80vh !important;
    overflow: hidden; 
}

/* ==================================================================================================================
   ??? EXCEPCI��N PARA MODALES COMPACTOS (GRAVEDAD Y RADAR)
================================================================================================================== */
.panel-minijuego.modal-gravedad[style*="display: block"],
.panel-minijuego.modal-gravedad[style*="display: flex"],
.panel-minijuego.modal-radar[style*="display: block"],
.panel-minijuego.modal-radar[style*="display: flex"] {
    /* 1. Anulamos los 80vh fijos para que se adapte al contenido */
    height: auto !important; 
    
    /* 2. Mantenemos el l��mite m��ximo por si se abre en pantallas min��sculas */
    max-height: 85vh !important; 
    
    /* 3. Ajuste de espaciado interno */
    padding-bottom: 25px !important;
}

/* Evitamos que el contenido interno intente estirarse artificialmente */
.modal-gravedad > div,
.modal-radar > div {
    flex: 0 1 auto !important;
}

/* El pie de controles se mantiene en su sitio pero sin ser empujado al infinito */
.modal-gravedad .controles-juego,
.modal-radar .controles-juego {
    margin-top: 25px !important; /* Da un respiro entre el minijuego y el bot��n */
}

.contenido-aula-flex { display: flex; gap: 15px; align-items: stretch; min-height: 350px; max-height: 450px; }
.contenedor-video-aula { flex: 1.8; background: #000; border-radius: 10px; border: 2px solid #333; overflow: hidden; }
.contenedor-video-aula iframe { width: 100%; height: 100%; border: none; }
.lista-lecciones-aula { flex: 1; display: flex; flex-direction: column; gap: 8px; background: rgba(0, 0, 0, 0.4); padding: 12px; border-radius: 10px; border: 1px solid #333; overflow-y: auto; }
.btn-aula { height: 38px !important; font-size: 0.8rem !important; padding: 5px 10px !important; grid-template-columns: 45px 1fr; justify-content: flex-start; }

.medidor-fuerza { width: 100%; height: 35px; background: #111; border-radius: 10px; margin: 20px 0; overflow: hidden; border: 3px solid #4a5a6b; box-shadow: inset 0 0 15px #000; }
.btn-teclado { width: 70px; height: 38px; font-size: 1.1rem; font-family: var(--fuente-titulos); background: #1e2630; color: white; border: 2px solid #333; border-radius: 8px; cursor: pointer; transition: all 0.1s; }
.btn-teclado:active { transform: scale(0.9); background: #333; }
.btn-cable { width: 70px; height: 70px; border-radius: 50%; border: 4px solid #fff; cursor: pointer; box-shadow: 0 5px 15px rgba(0,0,0,0.8); transition: transform 0.1s; }
.btn-cable:active { transform: scale(0.85); box-shadow: none; }
.error-shake { animation: vibrar-centrado 0.4s ease-in-out; border-color: #ff0000 !important; box-shadow: 0 0 30px rgba(255, 0, 0, 0.7) !important; }

#panel-gravedad { will-change: transform, opacity; }

/* ==================================================================================================================
   9. TELEMETRÍA Y MAQUINARIA CENTRAL (NÚCLEO UNIFICADO)
================================================================================================================== */

/* 📊 1. HUD Central: Altura y padding compactos */
.barra-telemetria {
    display: flex;
    justify-content: space-between; 
    align-items: center;
    background: rgba(10, 15, 20, 0.6);
    border: 1px solid rgba(102, 252, 241, 0.15);
    border-radius: 8px;
    padding: 2px 20px 0px 20px; 
    
    /* 🎯 AJUSTE DE ANCHO: Se expande más, pero mantiene un límite en pantallas gigantes */
    width: 100%; 
    max-width: 1600px; 
	margin-bottom: 20px;
    margin: 2px auto 4px 0; 
    
    position: relative;
	height: auto;
    min-height: 50px; 
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}

/* ?? 1. Agrupaci��n de datos laterales (Izquierda y Derecha) */
.grupo-hud {
    display: flex;
    gap: 30px; /* M��s compactos para aprovechar el espacio */
    flex: 1;
	height: auto;
    align-items: center;
}

.hud-derecha { 
    justify-content: flex-end; 
}

/* ??? 2. Dise?o de "Caja Digital" para cada lectura de telemetr��a */
.dato-hud { 
    display: flex; 
    flex-direction: column; 
    align-items: flex-start !important; /* ?? Alineaci��n izquierda para lectura r��pida */
    justify-content: center; 
    background: rgba(10, 15, 20, 0.7); /* Fondo oscuro estilo panel */
    padding: 8px 12px;
    border-radius: 4px;
    border-left: 3px solid var(--cyan-neon); /* L��nea gu��a visual lateral */
	padding-left: 12px;
    min-width: max-content !important; /* Evita que el texto salte de tama?o al cambiar valores */
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
	margin: 0;
}

.dato-hud span,
.etiqueta-hud {
    font-family: var(--fuente-texto);
    font-size: 0.7rem;
    font-weight: 700;
    color: #7a8b9e; /* Gris azulado t��cnico */
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
	margin: 0 0 2px 0 !important;
	padding: 0 !important;
	text-align: left !important;
	white-space: nowrap !important;
	width: auto !important;
}

/* ?? Valor num��rico (Ej: 27.000 KM/H) */
.dato-hud strong,
.valor-hud {
    font-family: 'Courier New', Courier, monospace; /* Fuente monoespaciada para n��meros */
    font-size: 1.35rem; /* Tama?o prominente e imponente */
    font-weight: 900;
    color: #ffffff;
    text-shadow: 0 0 10px rgba(102, 252, 241, 0.5); /* Resplandor hologr��fico */
    letter-spacing: 1px;
    line-height: 1;
	margin: 0 !important;
    padding: 0 !important;
    text-align: left !important;
	white-space: nowrap !important;
    width: auto;
}

/* Los datos del lado derecho (Estado, Escudos) se alinean inversamente */
.hud-derecha .dato-hud {
    align-items: flex-end; /* Texto a la derecha */
    border-left: 3px solid var(--cyan-neon);
    border-right: none; /* L��nea gu��a a la derecha */
}

/* ??? 3. T��tulos peque?os (Ej: "VELOCIDAD NAVE:") */
.etiqueta-hud { 
    font-family: var(--fuente-texto);
    font-size: 0.65rem; 
    color: #7a8b9e; 
    letter-spacing: 1px; 
    font-weight: 800; 
    margin-bottom: 2px;
}

/* ?? 4. Valores din��micos (Ej: "27.000 KM/H") */
.valor-hud { 
    font-family: 'Courier New', Courier, monospace; 
    font-size: 1.1rem; 
    font-weight: 700; 
    text-shadow: 0 0 8px currentColor; /* ?? El brillo ne��n hereda el color del texto autom��ticamente */
    letter-spacing: 0.5px;
}

/* 🕹�?2. Maquinaria Central (Botones en línea horizontal) */
.maquinaria-central {
    display: flex;
    flex-direction: row; /* 👈 Obliga a los 3 botones a estar en una sola línea */
    align-items: center;
    justify-content: center !important;
	width: 100%;
    gap: 6px; /* Separación simétrica */
	margin-bottom: 30px;
	flex-wrap: nowrap;
	flex: 1;
    position: relative;
    z-index: 501;
	margin: 0 !important;
    margin-top: 0 !important; /* 👈 Sube el bloque para integrarse con el parabrisas */
	padding: 0 !important;
	padding-top: 0 !important;
	padding-bottom: 2px !important;
}

button:disabled {
    filter: grayscale(1);
    opacity: 0.5;
    cursor: not-allowed;
    /* Al estar en gris sobre negro, el contraste baja, pero es permitido por WCAG
       para estados desactivados siempre que el bot��n no sea funcional. */
}

/* Física de botones (Hover y Click) */
.btn-maquinaria:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.9), 0 0 12px currentColor !important;
}
.btn-maquinaria:active {
    transform: translateY(2px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.9) !important;
}

.btn-maquinaria {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px; /* Menor separaci��n entre icono y texto */
    padding: 0 !important; /* Menos padding lateral */
    background: var(--metal-oscuro);
    border: 2px solid #4a5a6b;
    border-radius: 8px;
    color: white;
    font-family: var(--fuente-titulos);
    font-size: 1.5rem !important; /* ?? Letra un poco m��s peque?a y profesional */
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	width: 48px !important;
    min-width: 48px !important; /* ?? Reducido desde 140px */
    height: 48px !important; /* ?? Reducido desde 48px para estilizar la barra */
    text-transform: uppercase;
    white-space: nowrap; /* ?? CR��TICO: Evita que el texto se rompa en dos l��neas */
	text-shadow: 0 0 8px rgba(255,255,255,0.3);
}

@keyframes rotar { 100% { transform: rotate(360deg); } }
.rotar-engranaje { animation: rotar 2s linear infinite !important; }

.power-pulsante {
    border-color: rgba(102, 252, 241, 0.3) !important;
    animation: latidoPower 2s infinite;
}

.power-on {
    background: rgba(102, 252, 241, 0.1) !important;
    color: var(--cyan-neon) !important;
    border-color: var(--cyan-neon) !important;
    box-shadow: 0 0 15px rgba(102, 252, 241, 0.5), 
                inset 0 0 10px rgba(102, 252, 241, 0.2) !important;
    text-shadow: 0 0 8px var(--cyan-neon) !important;
}

@keyframes latidoPower {
    0%, 100% { box-shadow: 0 0 5px rgba(102, 252, 241, 0.1); }
    50% { box-shadow: 0 0 20px rgba(102, 252, 241, 0.4); border-color: var(--cyan-neon) !important; }
}

.power-on i, .power-on svg {
    filter: drop-shadow(0 0 5px var(--cyan-neon));
}

/* �?4. Lógica Exclusiva del Botón Power */
#btn-power-global {
    color: #555; /* Inicia con el texto apagado */
}

@keyframes pulso-texto-cyan {
    0% { color: #555; text-shadow: 0 1px 2px #000; }
    50% { color: var(--cyan-neon); text-shadow: 0 0 15px var(--cyan-neon); }
    100% { color: #555; text-shadow: 0 1px 2px #000; }
}

#btn-reparar-emergencia:disabled {
    opacity: 0.15 !important; /* Casi fantasma, no distrae */
    filter: grayscale(100%) !important;
    cursor: not-allowed !important;
    pointer-events: none !important; /* Bloquea clics por seguridad */
    box-shadow: none !important;
    animation: none !important; /* Frena cualquier parpadeo rojo si lo tuviera */
    border-color: #333 !important;
    color: #555 !important;
}

#btn-reparar-emergencia:not(:disabled) {
    opacity: 1 !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    /* Aqu�� recuperar�� autom��ticamente su color rojo, ne��n o parpadeo 
       que ya tengas configurado en sus otras clases */
}

/* 🚫 5. REGLA DE INMUNIDAD (Única y global) */
.tablero-comandos button:not(.energia-online):not(#btn-power-global):not(#btn-reparar-emergencia) { 
    filter: grayscale(1) brightness(0.3) !important; 
    opacity: 0.5 !important; 
    pointer-events: none !important; 
    box-shadow: none !important; 
}

/* ==================================================================================================================
   10. HUDS FRONTALES TÁCTICOS (RADAR IZQ Y PLANETA DER)
================================================================================================================== */
/* A. Estructura Compartida del Cristal */
.hud-vidrio-tactico {
    position: absolute; 
    top: 60px; 
    width: 260px !important; /* Ancho optimizado */
    background: rgba(10, 15, 20, 0.15) !important;
    backdrop-filter: blur(2px) !important; 
    -webkit-backdrop-filter: blur(2px) !important;
    border: 1px solid rgba(102, 252, 241, 0.3) !important; 
    padding: 20px; 
    box-shadow: inset 0 0 15px rgba(102, 252, 241, 0.05);
    color: white; 
    font-family: 'Share Tech Mono', monospace, var(--fuente-texto); 
    z-index: 100; 
    pointer-events: none;
    animation: entradaHUD 1s ease-out;
    opacity: 0;
	transition: opacity 0.5s ease-in-out;
    overflow: visible !important; /* CRÍTICO para que no se recorten las órbitas ni los brackets */
}
.hud-vidrio-tactico h2 { margin: 0; font-size: 1rem; color: var(--cyan-neon); text-shadow: 0 0 10px rgba(102, 252, 241, 0.8); letter-spacing: 2px; }

/* B. HUD Derecho: Info Planeta */
#hud-informacion-planeta { 
    right: 20px !important; 
    left: auto !important;
    margin-right: 25px; 
    border-left: 4px solid var(--cyan-neon) !important;
    border-radius: 0 15px 0 15px; 
}

/* C. HUD Izquierdo: Radar Orbital */
#hud-radar-tactico { 
    left: 20px !important; 
    right: auto !important;
	top: -15px;
    margin-left: 25px; 
    border-right: 4px solid var(--cyan-neon) !important;
    border-radius: 15px 0 15px 0; 
}

/* D. Eliminamos Pilares Innecesarios */
#hud-informacion-planeta::before, #hud-radar-tactico::after { display: none !important; }

/* E. Soporte Metálico Derecho (Bracket Corto) */
#hud-informacion-planeta::after {
    content: ''; position: absolute;
    top: 10px; bottom: 20px; /* 👈 BRACKET CORTO (Abraza el cristal) */
    right: -25px; width: 25px;
    background: linear-gradient(180deg, #4a5568 0%, #1a202c 100%);
    border: 2px solid #111; border-left: none; border-radius: 0 6px 6px 0;
    z-index: -1; opacity: 2 !important;
    box-shadow: 5px 5px 10px rgba(0,0,0,0.7), inset 2px 2px 4px rgba(255,255,255,0.1);
    background-image: linear-gradient(to bottom, transparent 15%, var(--cyan-neon) 15%, var(--cyan-neon) 85%, transparent 85%), radial-gradient(circle, #000 2.5px, transparent 3px), radial-gradient(circle, #000 2.5px, transparent 3px);
    background-size: 2px 100%, 15px 15px, 15px 15px; background-repeat: no-repeat;
    background-position: left 2px center, right 4px top 10px, right 4px bottom 10px;
}

/* F. Soporte Metálico Izquierdo (Bracket Corto Espejado) */
#hud-radar-tactico::before {
    content: ''; position: absolute;
    top: 15px; bottom: 15px; /* 👈 BRACKET CORTO (Abraza el cristal) */
    left: -25px; width: 25px;
    background: linear-gradient(180deg, #4a5568 0%, #1a202c 100%);
    border: 2px solid #111; border-right: none; border-radius: 6px 0 0 6px;
    z-index: -1; opacity: 2 !important;
    box-shadow: -5px 5px 10px rgba(0,0,0,0.7), inset -2px 2px 4px rgba(255,255,255,0.1);
    background-image: linear-gradient(to bottom, transparent 15%, var(--cyan-neon) 15%, var(--cyan-neon) 85%, transparent 85%), radial-gradient(circle, #000 2.5px, transparent 3px), radial-gradient(circle, #000 2.5px, transparent 3px);
    background-size: 2px 100%, 15px 15px, 15px 15px; background-repeat: no-repeat;
    background-position: right 2px center, left 4px top 10px, left 4px bottom 10px;
}

/* G. Animaciones Internas de los HUDs */
@keyframes entradaHUD { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }

.datos-grid { display: flex; flex-direction: column; gap: 8px; }
.dato-item { display: flex; justify-content: space-between; font-size: 0.85rem; }
.dato-item span { color: #aaa; }
.dato-item strong { color: var(--ambar-pantalla); }

/* Ping de Radar */
@keyframes ping-radar { 0% { transform: scale(0.5); opacity: 1; border: 2px solid var(--cyan-neon); } 100% { transform: scale(3.5); opacity: 0; border: 1px solid var(--cyan-neon); } }

/* L��ser Esc��ner Original (Opcional si se usa en Info Planeta) */
.escaner-animacion { 
	position: absolute; 
	bottom: 0; 
	left: 0; 
	width: 100%; 
	height: 2px; 
	background: var(--cyan-neon); 
	box-shadow: 0 0 10px var(--cyan-neon); 
	animation: escanearLinea 4s linear infinite; 
	opacity: 0.5; 
}
@keyframes escanearLinea { 0% { bottom: 100%; } 100% { bottom: 0%; } }

/* ==================================================================================================================
   11. PANTALLAS EXTRA Y AVER��AS
================================================================================================================== */
.pantalla-carga { display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.95); z-index: 9999; color: var(--cyan-neon); font-family: var(--fuente-titulos); flex-direction: column; justify-content: center; align-items: center; text-align: center; backdrop-filter: blur(5px); }
.icono-warp { font-size: 6rem; margin-bottom: 20px; }
.mensaje-warp { font-size: 2.5rem; }

.modal-averia {
    height: auto !important; /* ?? Anula los 80vh para ajustarse al contenido */
    max-height: 90vh !important;
    width: 95% !important;
    max-width: 500px !important; /* Ancho ideal para la mayor��a */
    padding: 25px 30px !important;
    display: none; /* Se activa por JS */
    flex-direction: column;
    align-items: center;
    gap: 5px;
    overflow-y: auto;
}

#averia-mensaje, .texto-modal {
    font-size: 1.1rem; /* Asegura que las instrucciones de reparaci��n sean claras */
    line-height: 1.4;
}

#panel-averia.modal-averia {
    height: fit-content !important; /* ?? Obliga al modal a "abrazar" exactamente su contenido */
    min-height: 0 !important;       /* ?? Anula la altura m��nima fantasma */
    padding-bottom: 25px !important; /* Solo dejamos un peque?o respiro est��tico */
}

#minijuego-codigo {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
	gap: 3px;
}

.modal-averia .controles-juego {
    margin-top: 20px !important;
    padding-top: 0 !important;
    border-top: none !important;
}

.modal-averia:has(#minijuego-codigo[style*="display: block"]),
.modal-averia:has(#minijuego-codigo[style*="display: flex"]) {
    max-width: 450px !important;
}

.modal-averia:has(#minijuego-cables[style*="display: block"]),
.modal-averia:has(#minijuego-cables[style*="display: flex"]) {
    max-width: 400px !important;
}

.modal-averia:has(#minijuego-soldadura[style*="display: block"]),
.modal-averia:has(#minijuego-soldadura[style*="display: flex"]) {
    max-width: 550px !important; 
    padding-bottom: 30px !important;
}

/* Ajuste del contenedor de los botones de cable */
#minijuego-cables .controles-juego {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
    width: 100%;
	margin-bottom: 5px !important;
}

#progreso-cables {
    margin-bottom: 0 !important;
}

/* Mejora visual de los botones de cable */
.btn-cable {
    width: 60px; /* Tama?o t��ctico ideal */
    height: 60px;
    border-radius: 50%;
    border: 4px solid #fff; /* Borde blanco para que resalten */
    cursor: pointer;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3); /* Brillo suave */
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

/* Efecto de 'presionado' y brillo al pasar el mouse */
.btn-cable:hover {
    transform: scale(1.05);
    box-shadow: 0 0 25px rgba(255, 255, 255, 0.5);
}

.btn-cable:active {
    transform: scale(0.95);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

/* Toque final: A?adir un peque?o conector met��lico en el centro del cable */
.btn-cable::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

#minijuego-soldadura {
    width: 100%;
    display: none;
    flex-direction: column;
    align-items: center; 
}

#minijuego-soldadura .controles-juego {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

#minijuego-soldadura[style*="display: block"] {
    width: 100%;
}

.contenedor-teclado {
    width: auto !important; /* ?? Evita que se estire al 100% */
    display: inline-block;
    background: #0a0e14;
    padding: 10px;
    border-radius: 12px;
    border: 2px solid #333;
    margin: 10px auto;
	margin-top: 5px;
}

.medidor-fuerza {
    width: 100%;
    height: 40px;
    margin: 15px 0 !important;
    position: relative; /* Para el span absoluto */
}

#btn-soldar {
    margin: 10px 0 0 0 !important;
	margin-bottom: 0 !important;
}

.pantalla-codigo-averia { 
	background: #000; 
	color: #0f0; 
	padding: 5px; 
	margin-bottom: 8px; 
	font-family: 'Courier New', monospace; 
	font-size: 1.5rem; 
	height: 35px; 
	letter-spacing: 8px; 
	border: 1px solid #0f0; 
	border-radius: 5px; 
}
.rejilla-teclado { 
	display: grid; 
	grid-template-columns: repeat(3, 1fr); 
	gap: 5px; }

/* =========================================================
   ?? MODAL DE TRANSMISI��N (VIDEO FLUIDO Y BOT��N ANCLADO)
========================================================= */
.modal-transmision { 
    max-width: 800px; 
    border-color: var(--rojo-alerta); 
	will-change: transform, opacity;
}

/* 1. Zona de compresi��n central (Evita que el video empuje) */
#panel-transmision .cuerpo-modal-simple {
    flex: 1 1 auto;
    min-height: 0; /* ?? LA MAGIA: Permite que el contenedor respete los l��mites de la pantalla */
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
}

/* 2. El video con tecnolog��a moderna (sin el padding-bottom) */
.contenedor-video-transmision { 
    width: 100%; 
    max-height: 100%; /* Se encoge si la pantalla es muy peque?a */
    aspect-ratio: 16 / 9; /* ?? Mantiene la proporci��n de cine nativamente */
    border-radius: 10px; 
    border: 2px solid var(--cyan-neon); 
    background: #000; 
    overflow: hidden; 
}

.contenedor-video-transmision iframe { 
    width: 100%; 
    height: 100%; 
    border: none; 
}

/* 3. Blindaje del bot��n de cierre (Igual que en Vestuario) */
#panel-transmision .controles-juego {
    flex-shrink: 0; /* ?? PROHIBIDO ENCOGERSE: El bot��n se mantiene inamovible */
    width: 100%;
    margin-top: auto; /* Lo ancla al pie del modal */
    padding-top: 15px;
    border-top: 1px solid rgba(102, 252, 241, 0.2);
}

#panel-transmision::-webkit-scrollbar { display: none; }

/* ==================================================================================================================
   ?? PARCHE DE AISLAMIENTO: CURA PARA EL MODAL DE AVER��AS
================================================================================================================== */

/* 1. RESTAURAR TEXTOS GLOBALES (Permite que el modal tenga m��ltiples l��neas) */
.etiqueta-hud, 
.valor-hud, 
.dato-hud span, 
.dato-hud strong {
    white-space: normal !important; 
}

/* Bloquear saltos de l��nea ��NICAMENTE dentro de la barra de telemetr��a */
.barra-telemetria .etiqueta-hud, 
.barra-telemetria .valor-hud, 
.barra-telemetria .dato-hud span, 
.barra-telemetria .dato-hud strong {
    white-space: nowrap !important; 
}

/* 2. RESTAURAR BOTONES GLOBALES (Evita que los botones del modal sean cuadritos) */
.btn-maquinaria {
    width: auto !important;
    min-width: auto !important; 
    height: auto !important;
    padding: 10px 20px !important; /* Relleno normal para textos largos */
    font-size: 1rem !important; /* Tama?o de lectura normal */
}

/* Forzar el modo cuadrado (Iconos) ��NICAMENTE en la maquinaria central */
.maquinaria-central .btn-maquinaria {
    width: 48px !important;
    min-width: 48px !important; 
    height: 48px !important;
    padding: 0 !important; 
    font-size: 1.5rem !important; /* Icono gigante */
}

/* ==================================================================================================================
   ??? BLINDAJE DE CONTENIDO DEL MODAL DE AVER��AS
================================================================================================================== */
.modal-content * {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    color: white !important; /* Fuerza a que el texto no sea negro sobre fondo oscuro */
}

/* Evita que los textos del modal hereden comportamientos extra?os */
.modal-content h2, 
.modal-content p, 
.modal-content span {
    white-space: normal !important;
    height: auto !important;
    display: block !important;
}

/* ==================================================================================================================
   ?? VISOR DE CIELO LOCAL (PLANETARIO)
================================================================================================================== */
#visor-cielo-local {
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: rgba(0, 0, 0, 0.95); /* Oscurece el 3D del fondo */
    z-index: 500; /* Se pone por encima del espacio 3D pero por debajo del HUD */
    display: flex; 
    justify-content: center; 
    align-items: center;
    backdrop-filter: blur(5px);
}

#planetario-embed { 
    width: 100%; 
    height: 100%; 
}

#planetario-embed iframe { 
    width: 100%; 
    height: 100%; 
    border: none; 
}

/* ==================================================================================================================
   GRAVEDAD ZERO
================================================================================================================== */
.vfx-overlay-zero-g {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 5;
    background: radial-gradient(circle, transparent 50%, rgba(102, 252, 241, 0.05) 100%);
    opacity: 0; transition: opacity 2s ease;
}

.btn-toggle-activo {
    background: var(--cyan-neon) !important;
    color: #000 !important;
    border-color: var(--cyan-neon) !important;
    box-shadow: 0 0 20px var(--cyan-neon), inset 0 0 10px rgba(0,0,0,0.5) !important;
    pointer-events: auto !important; /* CRÍTICO: Evita que se deshabilite el clic */
    transform: scale(0.95); /* Efecto de que está presionado hacia adentro */
}

.zero-g-activo { opacity: 1; animation: pulsoAtmosfera 4s infinite ease-in-out; }

@keyframes pulsoAtmosfera {
    0%, 100% { filter: brightness(1) saturate(1); }
    50% { filter: brightness(1.1) saturate(1.2); }
}

/* ==================================================================================================================
   INICIO TUTORIAL
================================================================================================================== */

.ignicion-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    
    /* 🌌 IMAGEN REAL + DEGRADADO RADIAL PARA ENMARCAR EL BOTÓN */
    background: 
        radial-gradient(circle at center, rgba(2, 3, 5, 0.2) 0%, rgba(2, 3, 5, 0.9) 80%),
        url('https://assets.science.nasa.gov/dynamicimage/assets/science/missions/hubble/galaxies/spiral/Hubble_IC486.jpg?w=2749&h=1790&fit=clip&crop=faces%2Cfocalpoint') no-repeat center center;
    
    background-size: cover;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    overflow: hidden;
    background-attachment: fixed;
    transition: background-position 0.1s ease-out;
}

.ignicion-overlay::after {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background-image: url('https://www.transparenttextures.com/patterns/stardust.png');
    opacity: 0.3;
    animation: derivaEspacial 120s linear infinite;
    pointer-events: none;
}

@keyframes derivaEspacial {
    from { transform: translate(0, 0); }
    to { transform: translate(-50px, -50px); }
}

.ignicion-overlay::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(0, 229, 238, 0.05) 0%, transparent 50%);
    animation: rotacionNebulosa 60s linear infinite;
    pointer-events: none;
}

@keyframes rotacionNebulosa {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.titulo-mision {
    font-family: 'Fredoka One', cursive;
    color: white;
    font-size: 2.5rem;
    letter-spacing: 8px;
    margin-top: 40px;
    text-shadow: 0 0 20px rgba(0, 243, 255, 0.5);
    z-index: 10;
    animation: brilloTitulo 3s ease-in-out infinite alternate;
}

@keyframes brilloTitulo {
    from { text-shadow: 0 0 10px rgba(0, 243, 255, 0.5); }
    to { text-shadow: 0 0 25px rgba(0, 243, 255, 0.9), 0 0 10px rgba(255, 255, 255, 0.5); }
}

.ignicion-overlay[style*="display: none"] {
    pointer-events: none;
}

.modulo-arranque {
    position: relative; /* CRÍTICO: Anclaje para el anillo */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.btn-master {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: #000;
    border: 4px solid var(--cyan-neon);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 10; /* Por encima del anillo */
    transition: 0.5s;
    box-shadow: 0 0 30px var(--cyan-neon);
}

.power-content {
    display: flex;
    flex-direction: column; /* Icono arriba, texto abajo */
    align-items: center;
    justify-content: center;
    color: var(--cyan-neon);
}

.glifo-master {
    font-size: 3rem;
    line-height: 1;
    margin-bottom: 5px; /* Separación mínima con el texto */
}

.texto-master {
    font-size: 0.8rem;
    font-family: var(--fuente-titulos);
    letter-spacing: 2px;
    font-weight: bold;
}

/* El Anillo debe estar centrado con el botón */
.anillo-pulsante {
    position: absolute;
    /* Centramos respecto al .modulo-arranque */
    top: 30%; 
    left: 50%;
    /* Desplazamos la mitad de su tamaño hacia atrás para centrar el eje */
    transform: translate(-50%, -50%); 
    
    /* El tamaño debe coincidir con el botón o ser apenas mayor */
    width: 140px;
    height: 140px;
    
    border: 2px solid var(--cyan-neon);
    border-radius: 50%;
    pointer-events: none;
    z-index: 1;
    
    /* Modificamos la animación para que no rompa el centrado */
    animation: pulso-centrado 2s infinite;
}

@keyframes pulso-centrado {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 0.8; }
    100% { transform: translate(-50%, -50%) scale(1.8); opacity: 0; }
}

/* ==========================================
   MODO TUTORIAL (OVERLAY Y FOCO)
========================================== */
#tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 5, 0.85); /* Azul muy oscuro casi negro */
    backdrop-filter: blur(3px); /* Desenfoca levemente la nave de fondo */
    z-index: 999; /* Muy alto, tapa casi todo */
    opacity: 0;
    pointer-events: none; /* Evita clics accidentales en el fondo */
    transition: opacity 0.4s ease;
    display: none;
}

#tutorial-overlay.activo {
    display: block;
    /* Un pequeño truco para que la transición funcione de display:none a block */
    animation: fadeInOverlay 0.4s forwards; 
}

@keyframes fadeInOverlay {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* El elemento que recibe la luz */
.resaltar-elemento {
    position: relative !important;
    z-index: 1000 !important; /* Se pone POR ENCIMA del overlay */
    box-shadow: 0 0 30px 10px rgba(0, 243, 255, 0.4), inset 0 0 15px rgba(0, 243, 255, 0.2) !important;
    border: 1px solid var(--cyan-neon) !important;
    border-radius: 12px; /* Ajusta esto si tus paneles son más cuadrados */
    background-color: rgba(10, 15, 30, 0.95) !important; /* Evita que sea transparente */
    transform: scale(1.02); /* Lo hace "saltar" un poquito hacia el frente */
    transition: all 0.3s ease;
    pointer-events: auto !important; /* Permite hacer clic en este elemento */
}

/* ==========================================
   TUTORIAL: Tarjeta Tecnológica
   ========================================== */
.hud-tutorial {
    position: fixed; top: 100px; left: 40px;
    z-index: 100000; width: 340px; pointer-events: auto;
}

.ia-tarjeta {
    background: rgba(10, 20, 30, 0.95);
    border: 2px solid var(--cyan-neon); border-radius: 20px;
    padding: 20px; box-shadow: 0 0 30px rgba(0, 255, 255, 0.2);
    display: flex; flex-direction: column; gap: 15px;
}

.ia-header {
    display: flex; align-items: center; gap: 15px;
    border-bottom: 1px solid rgba(102, 252, 241, 0.2);
    padding-bottom: 10px;
}

#ia-texto-tutorial {
    font-family: var(--fuente-texto); font-size: 1.1rem;
    color: white; line-height: 1.4; margin: 0;
}

.ia-controles {
    display: flex; gap: 10px; justify-content: space-between;
}

/* Botones Estilo Arcade para Niños */
.btn-tuto-pri, .btn-tuto-sec {
    flex: 1; padding: 12px; border-radius: 10px;
    font-family: var(--fuente-titulos); cursor: pointer;
    transition: 0.3s; text-transform: uppercase; font-size: 0.8rem;
}

.btn-tuto-pri {
    background: var(--cyan-neon); border: none; color: black;
    box-shadow: 0 0 10px var(--cyan-neon);
}

.btn-tuto-sec {
    background: transparent; border: 1px solid white; color: white;
    opacity: 0.7;
}

.btn-tuto-pri:hover { transform: scale(1.05); filter: brightness(1.2); }

/* ==================================================================================================================
   ??? SISTEMA DE AISLAMIENTO: MODAL OVERLAY
================================================================================================================== */

.modal-overlay {
    display: none;             /* Oculto por defecto */
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7); /* Oscurece el fondo */
    backdrop-filter: blur(5px);    /* Efecto de ofuscado (blur) */
    z-index: 9000;                 /* Por debajo de los modales (10000) */
    pointer-events: all;           /* Bloquea absolutamente todo el fondo */
    transition: opacity 0.3s ease;
	will-change: opacity;
	backdrop-filter: blur(5px);
	-webkit-backdrop-filter: blur(5px);
}

/* Aseguramos que los modales tengan prioridad sobre el escudo */
.panel-minijuego, .modal-vestuario {
    z-index: 10000 !important;
}

/* ==================================================================================================================
   ?? ERRADICACI��N DE SCROLLBARS Y BLOQUEO VERTICAL
================================================================================================================== */

/* 1. Muerte absoluta al scrollbar en toda la nave */
html, body {
    overflow: hidden !important; 
    max-width: 100vw;
    max-height: 100vh;
}

/* Oculta la barra nativa de los navegadores basados en Webkit (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 0px;
    height: 0px;
    background: transparent;
    display: none;
}

/* 2. Dise?o de la Pantalla de Alerta para Portrait (Vertical) */
#alerta-orientacion {
    display: none; /* Se oculta por defecto en PC y en m��viles horizontales */
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background-color: var(--espacio-profundo);
    z-index: 99999; /* Por encima de Absolutamente Todo */
    color: var(--cyan-neon);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
}

#alerta-orientacion h2 {
    font-family: var(--fuente-titulos);
    font-size: 26px;
    margin-top: 20px;
    letter-spacing: 2px;
}

#alerta-orientacion p {
    font-family: var(--fuente-texto);
    color: #fff;
    font-size: 16px;
    max-width: 80%;
    margin-top: 10px;
}

.icono-rotar {
    font-size: 80px;
    animation: animacion-rotar-dispositivo 1.5s ease-in-out infinite alternate;
}

/* Animaci��n que muestra el celular girando */
@keyframes animacion-rotar-dispositivo {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(-90deg); }
}

/* 3. EL GATILLO: Si el dispositivo mide menos de 1024px (Tablet/Celular) y est�� en VERTICAL */
@media screen and (max-width: 1024px) and (orientation: portrait) {
    #alerta-orientacion {
        display: flex !important; /* Enciende la pantalla de advertencia */
    }
    .simulador-v2 {
        position: relative !important;
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        min-height: 100vh !important;
        
        /* ? TEXTURA DE CABINA: Un patr��n sutil de rejilla para dar contexto de "nave" */
        background-image: 
            radial-gradient(circle at 50% 50%, rgba(102, 252, 241, 0.05) 1px, transparent 1px) !important;
        background-size: 30px 30px !important;
    }
}

/* ==================================================================================================================
   ?? RANGO INTERMEDIO: LAPTOPS Y TABLETS PRO (1025px - 1150px)
================================================================================================================== */
@media screen and (min-width: 1025px) and (max-width: 1150px) {

    /* 1. CUERPO Y FONDO: Mantenemos el scroll pero con mayor suavidad */
    body, html {
        overflow-y: auto !important;
        background-attachment: scroll !important; /* M��s ligero para procesadores de laptop */
    }

    /* 2. PARABRISAS Y HUDs: Recuperan un poco de aire */
    .parabrisas {
        margin-top: 65px !important; /* Un poco m��s de margen para el HUD Pro */
        min-height: 45vh !important;
    }
	
	.pilar-izquierdo, .pilar-derecho {
        width: 25px !important; /* Reducimos grosor */
    }
    .pilar-izquierdo { clip-path: polygon(0 0, 100% 0, 60% 100%, 0 100%) !important; }
    .pilar-derecho { clip-path: polygon(0 0, 100% 0, 100% 100%, 40% 100%) !important; }

    .hud-vidrio-tactico {
        width: 45% !important; /* M��s angostos para dejar ver m��s espacio al centro */
        max-width: 500px !important;
        height: 50px !important; /* Un poco m��s altos para mejor click con mouse */
    }

    .hud-vidrio-tactico h2, .hud-vidrio-tactico h3 {
        height: 50px !important;
        line-height: 50px !important;
        font-size: 0.95rem !important; /* Texto m��s legible */
    }

    /* =========================================================
       ?? 3. TELEMETR��A: DISTRIBUCI��N HORIZONTAL RELAJADA
       ========================================================= */
    .barra-telemetria {
        flex-wrap: nowrap !important; /* ?? Aqu�� ya NO bajan de l��nea, caben todos */
        gap: 15px !important;
        min-height: 80px !important; /* M��s bajito que en tablet */
        padding: 10px 20px !important;
    }

    .grupo-hud {
        flex: 1 !important;
    }

    .dato-hud {
        padding: 10px 5px !important;
        border-bottom: 4px solid var(--cyan-neon) !important;
    }

    .etiqueta-hud { font-size: 0.65rem !important; }
    .valor-hud { font-size: 0.9rem !important; }

    /* =========================================================
       ??? 4. MONITORES: ESCALA PROPORCIONAL
       ========================================================= */
    .fila-monitores {
        height: 240px !important; /* ?? M��s altos que en tablet */
        min-height: 240px !important;
        max-height: 240px !important;
        gap: 12px !important;
        margin-top: 0 !important; /* Ya no necesitamos el margen negativo */
    }

    /* =========================================================
       ?? 5. CONSOLA DE NAVEGACI��N: MODO H��BRIDO
       ========================================================= */
    .consola-navegacion {
        width: 100% !important;
        padding: 0 4px 4px 4px !important; 
        box-sizing: border-box !important;
    }
	
	.destinos-grupo,
    .grupo-destinos,
    .grupo-naves {
        width: 100% !important;
        max-width: none !important; /* Eliminamos cualquier restricci��n previa */
        
        /* Usamos flex para que los botones se distribuyan y llenen el espacio */
        display: flex !important;
        justify-content: flex-start !important; /* Alineados a la izquierda */
        flex-wrap: wrap !important;
        gap: 12px !important;
        
        /* Eliminamos m��rgenes laterales que puedan estar empujando el contenido */
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
	
	.destinos-grupo {
        gap: 12px !important; /* M��s espacio entre botones */
        padding: 12px !important;
    }

    .boton-destino, 
    .boton-nave, 
    .consola-navegacion button:not(.btn-cancelar) { /* Agregu�� este selector para mayor seguridad */
        
        flex: 1 1 0% !important; /* ?? LA MAGIA: Se reparten el espacio equitativamente */
        max-width: none !important; /* ?? Liberamos el l��mite de ancho */
        min-width: 90px !important; /* Evitamos que colapsen si hay muchos */
        
        min-height: 45px !important;
        font-size: 0.95rem !important;
        
        /* Aseguramos que el contenido del bot��n siga centrado al estirarse */
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
    }

    /* =========================================================
       ?? MODAL AULA: OPTIMIZACI��N DE VISOR
       ========================================================= */
    #panel-aula-espacial {
        width: 85% !important; /* No necesita ser tan ancho */
        max-width: 1100px !important;
        height: auto !important;
        max-height: 85vh !important; /* Bajamos la altura para laptops */
        padding: 25px !important;
    }

    #panel-aula-espacial .video-contenedor-aula {
        max-height: 50vh !important; /* Video m��s grande para mayor resoluci��n */
    }

    #panel-aula-espacial .btn-cancelar {
        margin-top: 20px !important;
        padding: 12px !important;
        font-size: 0.95rem !important;
    }
}

/* ==================================================================================================================
   ?? MODO T��CTIL: TABLETS Y PANTALLAS MEDIANAS (MAX 1024px)
================================================================================================================== */
@media (max-width: 1024px) {
    
    /* 1. RESET MAESTRO */
    body, html {
        overflow-y: auto !important;
        overflow-x: hidden !important;
        height: auto !important;
        min-height: 100vh !important;
        max-height: none !important;
        
        /* ?? FONDO CONTINUO: Crea un degradado que simula la profundidad de la cabina */
        background: linear-gradient(
            to bottom, 
            var(--espacio-profundo) 0%, 
            #0a0f14 50%, 
            #1e2630 100%
        ) !important;
        background-attachment: fixed !important; /* El fondo se queda quieto mientras el contenido desliza */
    }
	
	/* =========================================================
       ?? CALIBRACI��N DEL MARGEN PERFECTO (M��VILES Y TABLETS)
       ========================================================= */
    
    /* 1. El casco exterior ocupa todo el universo disponible */
    .simulador-v2 {
        width: 100vw !important;
        max-width: 100% !important;
		margin: 0 !important;
		display: flex !important;
        padding: 0 !important; 
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    /* 2. El tablero se hace 30px m��s angosto y se centra autom��ticamente */
    .tablero-comandos, .tablero-inferior {
        /* Restamos 30px (15px por lado) m��s los m��rgenes de la c��mara del m��vil */
        width: calc(100% - 15px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)) !important;
        max-width: 100% !important;
        
        /* Centrado autom��tico para equilibrar el margen izquierdo y derecho */
        margin-left: auto !important;
        margin-right: auto !important;
        
        /* Reseteamos el padding interno */
        padding-left: 0 !important;
        padding-right: 0 !important;
        
        box-sizing: border-box !important;
    }

    /* 2. PROTECCI��N DEL PARABRISAS (WINDSHIELD) */
    /* Empujamos el visor 3D hacia abajo para que la visera de los HUDs nunca lo tape */
    .parabrisas {
        margin-top: 55px !important; 
        min-height: 40vh !important;
    }

    /* =========================================================
       ?? 3. HUDS "VISERA" (BLINDAJE DE DIMENSIONES)
       ========================================================= */
    .hud-vidrio-tactico {
        position: fixed !important;
        top: 0 !important;
        bottom: auto !important;
        transform: none !important;
        z-index: 99999 !important;
        
        /* Ajuste de ancho: Separados sutilmente en el centro */
        width: 48% !important; 
        
        /* ?? CANDADO DE ESTADO CERRADO */
        height: 45px !important; 
        min-height: 45px !important;
        max-height: 45px !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: hidden !important; /* Oculta todo el contenido extra */

        background: rgba(10, 15, 20, 0.8) !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
        border-top: none !important;
        transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s !important;
    }

    /* Posicionamiento Exacto */
    #hud-radar-tactico { left: 1% !important; border-radius: 0 0 12px 12px !important; }
    #info-planeta { right: 1% !important; border-radius: 0 0 12px 12px !important; }

    /* Centrado perfecto de los T��tulos cuando est�� cerrado */
    .hud-vidrio-tactico h2, 
    .hud-vidrio-tactico h3 {
        margin: 0 !important;
        height: 45px !important;
        line-height: 45px !important; /* Centra verticalmente exacto */
        font-size: 0.85rem !important;
        text-align: center !important;
        white-space: nowrap !important;
        color: var(--cyan-neon) !important;
    }

    /* ?? ESTADO DESPLEGADO */
    .hud-vidrio-tactico.activo {
        max-height: 60vh !important;
        height: auto !important; /* Crece seg��n el contenido hasta el 60% de la pantalla */
        min-height: 250px !important;
        padding: 15px !important;
        overflow-y: auto !important; /* Scroll interno si hay mucho texto */
        background: rgba(5, 8, 12, 0.95) !important;
        box-shadow: 0 15px 30px rgba(0, 0, 0, 0.9) !important;
    }

    /* Restauramos el formato del t��tulo al abrir */
    .hud-vidrio-tactico.activo h2, 
    .hud-vidrio-tactico.activo h3 {
        line-height: normal !important;
        height: auto !important;
        border-bottom: 1px solid var(--cyan-neon) !important;
        padding-bottom: 10px !important;
        margin-bottom: 15px !important;
    }

    /* =========================================================
       ?? 4. ORDEN MAESTRO (EL TABLERO COMPLETO)
       ========================================================= */
    /* Asignamos Flexbox al contenedor padre que envuelve todo el tablero.
       (Puede llamarse .tablero-comandos o .tablero-inferior seg��n tu HTML) */
    .tablero-comandos, .tablero-inferior {
        position: relative !important;
        bottom: auto !important;
        top: auto !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    /* EL ORDEN ESTRICTO (1, 2, 3, 4) DE ARRIBA HACIA ABAJO */
    .barra-telemetria   { order: 1 !important; margin-bottom: 15px !important; }
    .maquinaria-central { order: 2 !important; margin-bottom: 20px !important; }
    .fila-monitores     { order: 3 !important; margin-bottom: 20px !important; }
    .consola-navegacion { order: 4 !important; }

    /* =========================================================
       ?? 5. TELEMETR��A (MATEM��TICA EXACTA Y BLINDAJE DE ALTURA)
       ========================================================= */
    .barra-telemetria {
        position: relative !important;
        display: flex !important;
        flex-wrap: wrap !important; /* ?? Permite que los botones bajen de l��nea */
		align-content: flex-start !important;
        width: 100% !important;
        gap: 10px 5px !important; /* 10px separaci��n vertical, 5px horizontal */
        padding: 5px !important;
        margin-bottom: 20px !important;
        
        /* ??? EL ESCUDO ANTI-SUPERPOSICI��N: Forzamos la altura din��mica */
        height: auto !important;
        min-height: 120px !important; 
        max-height: none !important;
        overflow: visible !important; 
    }

    /* Mantenemos los grupos intactos, los alineamos en la fila superior */
    .grupo-hud {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        gap: 5px !important;
        order: 1 !important; /* Fila 1 */
        
        background: transparent !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
    }

    /* ?? C��LCULO PERFECTO: Grupo 1 (2 datos) = 40%, Grupo 2 (3 datos) = 60% */
    .barra-telemetria > .grupo-hud:first-of-type { flex: 0 0 calc(40% - 2.5px) !important; }
    .barra-telemetria > .grupo-hud:last-of-type { flex: 0 0 calc(60% - 2.5px) !important; }

    /* Los cuadros individuales de datos */
    .dato-hud { 
        flex: 1 1 0% !important; /* Se estiran para ser todos id��nticos */
        min-width: 0 !important; 
        margin: 0 !important;
        
        display: flex !important; 
        flex-direction: column !important; 
        align-items: center !important; 
        justify-content: center !important; 
        
        background: rgba(10, 15, 20, 0.9) !important; 
        padding: 8px 2px !important;
        border-radius: 6px !important;
        border-bottom: 3px solid var(--cyan-neon) !important; 
        border-left: none !important;
        box-shadow: inset 0 0 10px rgba(0,0,0,0.5) !important;
    }

    .etiqueta-hud { 
        font-size: 0.55rem !important; 
        margin-bottom: 2px !important; 
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        width: 100% !important;
        text-align: center !important;
    }

    .valor-hud { 
        font-size: 0.8rem !important; 
        font-weight: bold !important;
        white-space: nowrap !important;
    }

    /* =========================================================
       ?? 6. MAQUINARIA CENTRAL (FILA INFERIOR)
       ========================================================= */
    .maquinaria-central { 
        order: 2 !important; /* Forzada a la segunda l��nea */
        flex: 0 0 100% !important; /* ?? Al ocupar el 100%, salta abajo sola */
        
        display: flex !important;
        flex-direction: row !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 15px !important;
        margin: 2px 0 0 2px !important;
        padding: 0 10px !important;
    }

    .btn-maquinaria {
        /* ?? RESTAURACI��N: Vuelven a ser rectangulares para que el texto sea legible */
        flex: 1 !important; 
        max-width: 350px !important;
        width: auto !important;
        min-height: 30px !important;
        height: auto !important;
        padding: 2px !important;
        font-size: 0.9rem !important;
        white-space: normal !important; /* Permite que el texto baje de l��nea si es largo */
    }

    /* =========================================================
       ??? 7. MONITORES Y CONSOLA (RESTAURACI��N VISUAL)
       ========================================================= */
    .fila-monitores {
        order: 3 !important; 
        position: relative !important; 
        
        /* ?? LA MAGIA: Convertimos la caja en una pista horizontal */
        display: flex !important;
        flex-direction: row !important; 
        flex-wrap: nowrap !important; /* Proh��be que el segundo monitor caiga abajo */
        justify-content: center !important;
        align-items: stretch !important; /* Fuerza a que todos midan lo mismo de alto */
        
        width: 100% !important;
        gap: 6px !important; /* Separaci��n entre monitores */
        
		height: 200px !important; 
        min-height: 200px !important;
        max-height: 200px !important; /* Candado estricto */
		
		margin-top: -20px !important; 
        margin-bottom: 8px !important;
        padding: 2px 2px 2px 2px !important; 
        z-index: 10 !important;
		overflow: hidden !important;
    }

    .monitor-modulo {
        position: relative !important; /* ?? CLAVE: Sin esto, los gr��ficos internos se rompen */
        top: auto !important;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        transform: none !important; /* Solo anulamos los movimientos raros de escritorio */
        
		flex: 1 1 0% !important;
		min-width: 0 !important;
        height: 100% !important;
		max-height: 100% !important;
		overflow: hidden !important;
        
        margin: 0 !important;
		border-radius: 12px !important;
    }

    /* =========================================================
       ?? 8. CONSOLA DE NAVEGACI��N (FLUJO SECUENCIAL DESKTOP)
       ========================================================= */
    .consola-navegacion {
        order: 4 !important; 
        position: relative !important;
        width: 100% !important;
        height: auto !important; 
        
        /* ?? REVESTIMIENTO T��CNICO: 
           Usamos un fondo semitransparente para que se vea la textura de la nave atr��s */
        background: linear-gradient(
            180deg, 
            rgba(15, 20, 26, 0.95) 0%, 
            rgba(10, 15, 20, 0.98) 100%
        ) !important;
        border-top: none !important;
		box-shadow: none !important;
        
        /* Espaciado interno para que no toque los bordes */
        padding: 0 4px 4px 4px !important; 
        margin-top: 0 !important;
        display: block !important; /* Volvemos al flujo de bloque est��ndar */
    }
	
	.consola-navegacion::after {
		display: none !important;
        content: "" !important;
        position: absolute !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 5px !important;
        background: var(--cyan-neon) !important;
        box-shadow: none !important;
        opacity: 0.3 !important;
    }
    
    /* ??? T��TULOS: Posici��n natural arriba de su grupo */
    .consola-navegacion h2,
    .consola-navegacion h3, 
    .consola-navegacion h4 {
        display: block !important;
        position: relative !important;
        margin: 25px 0 15px 0 !important; /* Espacio arriba y abajo del t��tulo */
        padding: 0 !important;
        font-size: 1.2rem !important;
        text-align: center !important;
        color: var(--cyan-neon) !important;
        width: 100% !important;
        clear: both !important; /* Evita que botones anteriores se le suban */
    }

    /* El primer t��tulo de la consola no necesita margen superior */
    .consola-navegacion h2:first-child,
    .consola-navegacion h3:first-child {
        margin-top: 0 !important;
    }

    /* ?? CONTENEDORES: Mantienen a los botones adentro */
    .destinos-grupo,
    .grupo-destinos,
    .grupo-naves {
        display: flex !important;
        flex-direction: row !important; /* Botones uno al lado del otro */
        flex-wrap: wrap !important;    /* Si no caben, bajan a la siguiente fila */
        justify-content: center !important;
        align-items: center !important;
        gap: 8px !important; 
        width: 100% !important;
		margin-right: 0 !important;
        margin-bottom: 6px !important;
        padding: 9px !important;
        position: relative !important;
    }

    /* ?? BOTONES: Tama?o contenido y equilibrado */
    .boton-destino, 
    .boton-nave,
    .consola-navegacion button:not(.btn-cancelar) {
        
        flex: 1 1 0% !important; /* ?? LA MAGIA: Expansi��n fluida */
        max-width: none !important; /* ?? Liberamos el l��mite */
        min-width: 75px !important; /* Un m��nimo razonable para tablets */
        
        min-height: 40px !important; 
        padding: 4px 10px !important;
        
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 6px !important;
        
        font-size: 0.75rem !important;
        border-radius: 6px !important;
        cursor: pointer !important;
        transition: transform 0.2s, background 0.2s !important;
    }

    /* Ajuste para los iconos dentro de los botones */
    .icono-aula, .icono-destino, .boton-destino span:first-child {
        font-size: 1rem !important;
		line-height: 1 !important;
    }
	
	/* =========================================================
       ?? MODAL AULA: CENTRADO TOTAL Y ALTURA AJUSTADA
       ========================================================= */
    
    #panel-aula-espacial {
        /* 1. POSICIONAMIENTO Y CENTRADO ABSOLUTO */
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important; /* Mantiene el centro exacto */
        
        /* 2. DIMENSIONES PARA TABLET */
        width: 95% !important;
        max-width: 1000px !important;
        height: auto !important; /* Ocupa casi todo el alto de la pantalla */
        max-height: 95vh !important;
        
        /* 3. COMPORTAMIENTO INTERNO */
        padding: 10px !important;
        box-sizing: border-box !important;
        z-index: 1000000 !important;
        
        /* ?? IMPORTANTE: No declaramos 'display' para que el JS controle el cierre */
    }

    /* 4. AJUSTE DE VIDEO (Compactaci��n vertical) */
    #panel-aula-espacial .video-contenedor-aula {
        width: 100% !important;
        max-height: 45vh !important; /* El video no debe empujar el bot��n fuera */
        aspect-ratio: 16 / 9 !important;
        margin-bottom: 15px !important;
    }

    /* 5. BOT��N FINALIZAR (Visible y accesible) */
    #panel-aula-espacial .btn-cancelar {
        display: block !important;
        width: 100% !important;
        margin: 5px 0 5px 0 !important;
        padding: 5px !important;
        background: #ff5c5c !important;
        color: white !important;
        font-weight: bold !important;
    }
}

/* ==================================================================================================================
   ?? OPTIMIZACI��N T��CTICA PARA M��VILES (LANDSCAPE Y NOTCHES)
================================================================================================================== */

/* 1. Protecci��n contra Notches (C��maras frontales en m��viles) */
body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* 2. Prevenci��n de interacciones accidentales en pantallas t��ctiles */
button, .uni-btn, .btn-maquinaria, .leccion-btn {
    touch-action: manipulation; /* Evita el doble-tap que hace zoom accidental */
    -webkit-tap-highlight-color: transparent; /* Quita el molesto recuadro azul en Android al tocar */
}

/* 3. Escalado Din��mico de Interfaz para M��viles en Horizontal */
/* Si la pantalla est�� acostada y tiene menos de 500px de altura... */
@media screen and (max-height: 500px) and (orientation: landscape) {
    
    /* Reducimos el chat de la IA y lo anclamos a la esquina segura */
    .chat-ia-container {
        width: 300px !important;
        transform: scale(0.8);
        transform-origin: bottom right;
        bottom: 5px !important;
        right: env(safe-area-inset-right, 10px) !important;
    }

    /* Escalamos el tablero inferior para que no ocupe media pantalla */
    .tablero-comandos {
        padding-bottom: env(safe-area-inset-bottom, 5px) !important;
    }

    /* Habilitamos Scroll Interno en Modales para que no queden botones fuera de pantalla */
    .modal-vestuario, .panel-minijuego, .modal-transmision, #panel-gravedad {
        max-height: 90vh !important;
        height: auto !important;
        overflow-y: auto !important;
    }
}

/* ==================================================================================================================
   ?? MODO TABLET COMPACTA Y PANTALLAS < 900px
================================================================================================================== */
@media screen and (max-width: 900px) {
    
	.barra-telemetria {
		gap: 5px 5px !important;
        min-height: 90px !important; 
    }
	
	.dato-hud {
        padding: 5px 2px !important;
    }
    
    .etiqueta-hud { 
        font-size: 0.55rem !important; 
    }
    
    .valor-hud { 
        font-size: 0.75rem !important; 
    }

    /* 2. MAQUINARIA CENTRAL: Botones ligeramente m��s compactos */
    .btn-maquinaria {
		min-height: 15px !important;
		max-height: 35px !important;
        font-size: 0.8rem !important;
        padding: 2px 4px !important;
    }

    /* 3. MONITORES: Reducimos 20px la altura para ahorrar espacio vertical */
    .fila-monitores {
        height: 180px !important;
        min-height: 180px !important;
        max-height: 180px !important;
    }

    /* 4. CONSOLA DE NAVEGACI��N: Botones m��s chicos pero fluidos */
    .consola-navegacion {
        padding: 0 10px 10px 10px !important;
    }

    .boton-destino, 
    .boton-nave, 
    .consola-navegacion button:not(.btn-cancelar) {
        min-width: 80px !important; /* M��s angostos que en 1024px */
        min-height: 38px !important;
        font-size: 0.7rem !important;
        padding: 2px 2px !important;
    }
	
	/* 6. MODAL VESTUARIO: Evita el desbordamiento horizontal */
    .modal-vestuario {
        width: 95% !important; /* Toma el 95% de la pantalla, dejando margen a los lados */
        max-width: none !important; /* Liberamos cualquier restricci��n previa */
    }

    /* 5. AULA ESPACIAL: Ajuste del visor */
    #panel-aula-espacial {
        width: 98% !important;
        padding: 15px !important;
    }

    #panel-aula-espacial .video-contenedor-aula {
        max-height: 35vh !important;
    }
}

/* ==================================================================================================================
   ?? MODO SMARTPHONE HORIZONTAL (MAX 768px)
================================================================================================================== */
@media screen and (max-width: 768px) {
	
	.pilar-izquierdo, .pilar-derecho {
        width: 12px !important; /* ?? Grosor m��nimo para no tapar los botones */
        opacity: 0.8 !important; /* Los hacemos m��s sutiles */
    }
    
    /* ?? Ajustamos el ��ngulo para que sea m��s vertical y no "muerda" las esquinas */
    .pilar-izquierdo { 
        clip-path: polygon(0 0, 100% 0, 80% 100%, 0 100%) !important; 
    }
    .pilar-derecho { 
        clip-path: polygon(0 0, 100% 0, 100% 100%, 20% 100%) !important; 
    }
	
	/* 1. HUDS VISERA: M��xima reducci��n para no tapar el parabrisas */
    .hud-vidrio-tactico {
		position: absolute !important;
		top: -180px !important;
        height: 38px !important;
        min-height: 38px !important;
        max-height: 38px !important;
        padding: 0 5px !important;
    }
    .hud-vidrio-tactico h2 {
        height: 38px !important;
        line-height: 38px !important;
        font-size: 0.65rem !important;
    }

    /* =========================================================
       ?? 2. TELEMETR��A: EXPANSI��N Y 3 FILAS AUTOM��TICAS (768px)
       ========================================================= */
       
    /* 1. CONTENEDOR MAESTRO: Al 100% del ancho y fundido con la nave */
    .barra-telemetria {
        display: grid !important;
        grid-template-columns: 1fr !important;
        width: 100% !important;
		box-sizing: border-box !important;
        height: auto !important;
        min-height: 160px !important;
        
        /* Fondo semitransparente como en tablets */
        background: rgba(10, 15, 20, 0.9) !important;
        border: 1px solid rgba(102, 252, 241, 0.3) !important;
        border-radius: 8px !important;
        
        padding: 8px 4px !important;
        gap: 10px !important;
        margin-bottom: 20px !important;
        box-shadow: 0 0 15px rgba(0, 0, 0, 0.5) !important;
    }

    /* 2. LIMPIEZA DE M��RGENES FANTASMAS */
    .grupo-hud {
        margin: 0 !important; /* ?? Erradicamos el margen que empujaba todo a la izquierda */
    }

    /* 3. FILAS DE HUDs (Izquierda y Derecha): 100% ancho y centradas */
    .hud-izquierda, .hud-derecha {
        display: grid !important;
        width: 100% !important;
        gap: 6px !important;
        margin: 0 !important;
    }
	
	.hud-izquierda { grid-template-columns: 1fr 1fr !important; order: 1 !important; }
    .hud-derecha { grid-template-columns: repeat(3, 1fr) !important; order: 2 !important; }
    
    /* 4. CAJITAS DE DATOS: Simetr��a matem��tica perfecta */
    .dato-hud {
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        padding: 6px 2px !important;
        background: rgba(10, 15, 20, 0.9) !important;
        
        /* ?? HERENCIA: El borde ne��n inferior caracter��stico */
        border-bottom: 3px solid var(--cyan-neon) !important;
        border-radius: 4px !important;
        
        /* Sombra interna para dar profundidad */
        box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5) !important;
    }

    /* Textos internos adaptables */
    .etiqueta-hud {
        font-size: 0.55rem !important; /* Mismo tama?o que en 900px */
        text-transform: uppercase !important;
        letter-spacing: 1px !important;
        margin-bottom: 2px !important;
    }
	
    .valor-hud {
        font-size: 0.75rem !important;
        font-weight: bold !important;
    }

    /* 5. MAQUINARIA CENTRAL (FILA 3): 100% ancho y botones repartidos */
    .maquinaria-central {
        order: 3 !important;
        display: flex !important; /* ?? Cambiamos Grid por Flex para permitir expansi��n */
        flex-direction: row !important;
        width: 100% !important;
        
        /* ?? Justificaci��n total de borde a borde */
        justify-content: space-between !important; 
        align-items: stretch !important;
        
        gap: 8px !important; /* Espaciado uniforme entre botones */
        margin-top: 10px !important;
        padding: 5px 0 !important;
        background: transparent !important;
    }

    .btn-maquinaria {
        /* ?? LA CLAVE: Reparto equitativo del ancho total */
        flex: 1 1 0% !important; 
        
        min-width: 0 !important; /* Evita que el contenido interno bloquee el encogimiento */
        min-height: 40px !important;
        height: auto !important;
        
        /* Estilos visuales heredados de 900px */
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        padding: 4px !important;
        margin-top: -8px !important;
        
        /* Aseguramos que el bot��n mantenga su est��tica de "bloque t��ctico" */
        background: rgba(10, 15, 20, 0.8) !important;
        border-radius: 6px !important;
        transition: all 0.3s ease !important;
    }
    
    /* 3. ESCUDO PARA MONITORES: En su lugar, respetando la f��sica normal */
    .fila-monitores {
        margin-top: -15px !important; 
    }
    
    .monitor-modulo {
        padding: 5px !important;
        border-width: 2px !important;
    }

    .monitor-modulo h3 {
        font-size: 0.6rem !important;
        margin-bottom: 4px !important;
    }

    /* 4. CONSOLA DE NAVEGACI��N: Botones T��ctiles Densos */
    .consola-navegacion h2, 
    .consola-navegacion h3 {
        font-size: 0.9rem !important;
        margin: 10px 0 5px 0 !important;
    }

    .destinos-grupo {
        gap: 5px !important;
        padding: 5px !important;
    }

    .boton-destino, 
    .boton-nave, 
    .consola-navegacion button:not(.btn-cancelar) {
        min-width: 60px !important; /* Permitimos que se encojan m��s */
        min-height: 32px !important; /* Botones m��s delgados */
        font-size: 0.6rem !important;
        padding: 2px 4px !important;
    }

    /* Ajuste de iconos para que encajen en el bot��n micro */
    .boton-destino span:first-child, .boton-nave span:first-child {
        font-size: 0.75rem !important;
    }
}

@media screen and (max-width: 600px) {
    
    body {
        overflow: hidden; 
        position: fixed;
        width: 100%;
        height: 100%;
    }

    #contenedor-3d {
        height: 50vh; /
    }
    
    .barra-telemetria {
        flex-direction: column; 
        height: auto;
        padding: 5px;
        font-size: 0.8rem;
    }

    .botones-mision button {
        padding: 8px;
        scale: 0.8;
    }

    .etiqueta-hud {
        font-size: 0.7rem;
    }

    .valor-hud {
        font-size: 0.9rem;
    }

    .radar-asteroides, .transmision-nasa {
        display: none; 
    }

    .paneles-inferiores {
        grid-template-columns: 1fr; 
        margin-bottom: 20px;
    }

    .cosmos-ia-input {
        flex-direction: row;
        gap: 5px;
    }
}

/* ==================================================================================================================
   ? PROTOCOLOS DE ACCESIBILIDAD (WCAG AA)
================================================================================================================== */

/* 1. INDICADOR DE FOCO VISIBLE (Keyboard Navigation)
   Obligatorio para que los usuarios de teclado sepan qu�� bot��n est��n por pulsar */
button:focus-visible, 
.uni-btn:focus-visible, 
a:focus-visible,
[tabindex="0"]:focus-visible {
    outline: 3px solid var(--ambar-pantalla) !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 15px var(--ambar-pantalla) !important;
    transition: none !important; /* El foco debe ser instant��neo */
}

/* Evitar que el mouse/dedo active el outline feo, solo se activa con teclado */
button:focus:not(:focus-visible) {
    outline: none !important;
}

/* 2. REDUCCI��N DE MOVIMIENTO (Vestibular Disorders)
   Si el sistema operativo del usuario tiene activada la opci��n de "Reducir movimiento",
   desactivamos las rotaciones 3D css y animaciones bruscas. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .hud-vidrio-tactico {
        transition: none !important; /* Despliegue instant��neo del HUD */
    }
    
    .error-shake {
        animation: none !important; /* Sin vibraciones en errores */
        border-color: var(--rojo-alerta) !important;
    }
}
