/* ===============================================================
   SELENE-7 · RETO 1 · ASPECTO
   Mismo lenguaje que el Reto 2: interfaz de película de ciencia
   ficción con líneas finas, esquinas de encuadre, rótulos muy
   espaciados y lecturas monoespaciadas.
   =============================================================== */
:root {
  --fondo: #010409;
  --panel: rgba(5, 12, 21, .84);
  --linea: rgba(126, 206, 255, .13);
  --linea-2: rgba(126, 206, 255, .28);
  --linea-3: rgba(126, 206, 255, .6);
  --texto: #d7ecff;
  --texto-2: #9bb6cc;
  --tenue: #5a768c;
  --cian: #62dcff;
  --cian-2: #b8f2ff;
  --verde: #4dffa0;
  --ambar: #ffb13d;
  --rojo: #ff4d4d;
  --f-titulo: "Michroma", "Bahnschrift", "Segoe UI", sans-serif;
  --f-ui: "Barlow Semi Condensed", "Bahnschrift SemiCondensed", "Segoe UI", sans-serif;
  --f-mono: "JetBrains Mono", Consolas, "Cascadia Mono", monospace;
  --f-seg: "DSEG7 Classic", "JetBrains Mono", monospace;
  --sans: var(--f-ui);
  --mono: var(--f-mono);
  --esq: 12px;
  --suave: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; color: var(--texto); font-family: var(--f-ui); font-variant-ligatures: none; overflow: hidden; -webkit-font-smoothing: antialiased; }
body {
  background:
    radial-gradient(1100px 620px at 12% -12%, rgba(38, 110, 185, .17), transparent 62%),
    radial-gradient(900px 520px at 108% 112%, rgba(26, 86, 150, .14), transparent 60%),
    radial-gradient(rgba(140, 205, 255, .075) 1px, transparent 1.3px) 0 0 / 24px 24px,
    var(--fondo);
}
.oculto { display: none !important; }
button { touch-action: none; font: inherit; }
::selection { background: rgba(98, 220, 255, .3); }

#app { display: grid; grid-template-rows: 60px 1fr; height: 100vh; transition: filter .8s; }

/* ---------- Piezas comunes ---------- */
/* Esquinas de encuadre: ocho trazos finos en las cuatro esquinas */
.marco {
  --c: var(--linea-3);
  background-image:
    linear-gradient(var(--c), var(--c)), linear-gradient(var(--c), var(--c)),
    linear-gradient(var(--c), var(--c)), linear-gradient(var(--c), var(--c)),
    linear-gradient(var(--c), var(--c)), linear-gradient(var(--c), var(--c)),
    linear-gradient(var(--c), var(--c)), linear-gradient(var(--c), var(--c));
  background-size: var(--esq) 1px, 1px var(--esq);
  background-position: left top, left top, right top, right top, left bottom, left bottom, right bottom, right bottom;
  background-repeat: no-repeat;
  background-origin: border-box;
}
.mini { font: 500 9.5px/1 var(--f-ui); letter-spacing: .28em; color: var(--tenue); white-space: nowrap; }
.mini sub, .caja-cod sub { font-size: .8em; vertical-align: -.15em; letter-spacing: 0; }
.idx { display: inline-block; padding: 3px 5px 2px; border-radius: 1px; background: var(--cian); color: #021018; font: 600 9.5px/1 var(--f-mono); letter-spacing: .04em; }
.punto { display: inline-block; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--cian); box-shadow: 0 0 8px var(--cian); }
.punto.vivo { animation: vivo 2.4s ease-in-out infinite; }
.punto.rec { background: var(--rojo); box-shadow: 0 0 8px var(--rojo); animation: vivo 1.6s steps(1) infinite; }
@keyframes vivo { 50% { opacity: .2; } }
@keyframes latido { 50% { opacity: .45; } }
@keyframes subir { from { opacity: 0; transform: translateY(10px); } }
@keyframes girar { to { transform: rotate(360deg); } }
@keyframes recorrer { from { background-position: -40% 0; } to { background-position: 140% 0; } }

.btn {
  font: 600 13px/1 var(--f-ui); letter-spacing: .16em; text-transform: uppercase; border-radius: 2px; padding: 11px 18px; cursor: pointer;
  border: 1px solid var(--linea-2); background: rgba(98, 220, 255, .05); color: var(--texto); user-select: none;
  transition: transform .08s, filter .15s, background .2s, border-color .2s, box-shadow .2s;
}
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
.btn:hover { filter: brightness(1.2); border-color: var(--linea-3); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: default; }
.btn:focus-visible { outline: 1px solid var(--cian); outline-offset: 2px; }

/* ---------- Barra superior ---------- */
#barra {
  position: relative; display: flex; align-items: center; gap: 30px; padding: 0 20px;
  background: linear-gradient(rgba(8, 18, 30, .92), rgba(4, 10, 18, .7));
  border-bottom: 1px solid var(--linea);
}
#barra::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; opacity: .7;
  background: linear-gradient(90deg, transparent, var(--cian), transparent) no-repeat;
  background-size: 28% 100%; animation: recorrer 8s linear infinite;
}
.marca { display: flex; align-items: center; gap: 13px; flex: 1; min-width: 0; user-select: none; }
.emblema { flex: none; width: 36px; height: 36px; overflow: visible; }
.em-aro { fill: none; stroke: var(--linea-3); stroke-width: .8; stroke-dasharray: 1.5 3.2; transform-box: fill-box; transform-origin: center; animation: girar 40s linear infinite; }
.em-luna { fill: rgba(98, 220, 255, .12); stroke: var(--cian); stroke-width: 1; }
.em-orbita { fill: none; stroke: var(--cian); stroke-width: .7; opacity: .5; }
.em-nave { fill: var(--cian-2); filter: drop-shadow(0 0 2px var(--cian)); }
.marca-txt { min-width: 0; }
.marca-txt b { display: block; font: 400 15px/1 var(--f-titulo); letter-spacing: .22em; color: var(--texto); }
.marca-txt span { display: block; margin-top: 7px; font: 500 10px/1 var(--f-ui); letter-spacing: .26em; color: var(--tenue); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.estado-mision { display: flex; gap: 10px; }
.chip { display: flex; align-items: center; gap: 9px; height: 30px; padding: 0 12px; border: 1px solid var(--linea-2); background: rgba(98, 220, 255, .04); font: 500 9.5px/1 var(--f-ui); letter-spacing: .26em; color: var(--tenue); white-space: nowrap; transition: border-color .3s, background .3s; }
.chip b { font: 600 11.5px/1 var(--f-mono); letter-spacing: .08em; color: var(--texto); }
/* Estado del arranque: pendiente (ámbar) · ejecutando (cian) · fallo (rojo) · completado (verde) */
#chip-arranque { --c: var(--ambar); border-color: color-mix(in srgb, var(--c) 40%, transparent); background: color-mix(in srgb, var(--c) 5%, transparent); }
#chip-arranque .punto { background: var(--c); box-shadow: 0 0 8px var(--c); }
#chip-arranque b { color: var(--c); }
#chip-arranque.activo { --c: var(--cian); }
#chip-arranque.mal { --c: var(--rojo); }
#chip-arranque.ok { --c: var(--verde); }
#chip-arranque.ok .punto { animation: none; }

.reloj { display: flex; flex-direction: column; gap: 6px; }
.reloj-val { font: 500 21px/1 var(--f-mono); letter-spacing: .03em; color: var(--texto); }
.reloj-val small { margin-right: 7px; font-size: 11px; letter-spacing: .1em; color: var(--cian); }

.o2 { position: relative; display: flex; flex-direction: column; gap: 7px; width: 250px; }
.o2-cab { display: flex; justify-content: space-between; align-items: flex-end; }
#o2-valor { font: 600 18px/1 var(--f-mono); color: var(--texto); }
.o2-barra { position: relative; height: 9px; background: repeating-linear-gradient(90deg, rgba(126, 206, 255, .13) 0 5px, transparent 5px 7px); }
#o2-relleno {
  height: 100%; width: 100%; background: var(--verde); filter: drop-shadow(0 0 4px rgba(77, 255, 160, .9));
  -webkit-mask: repeating-linear-gradient(90deg, #000 0 5px, transparent 5px 7px); mask: repeating-linear-gradient(90deg, #000 0 5px, transparent 5px 7px);
  transition: width .6s var(--suave), background .6s;
}
#o2-relleno.medio { background: var(--ambar); filter: drop-shadow(0 0 4px rgba(255, 177, 61, .9)); }
#o2-relleno.bajo { background: var(--rojo); filter: drop-shadow(0 0 4px rgba(255, 77, 77, .9)); }
body.o2-critico .o2 { animation: latido 1s infinite; }
body.o2-critico #o2-valor { color: var(--rojo); }
.flotante { position: absolute; right: 0; top: 34px; font: 600 14px var(--f-mono); color: var(--rojo); text-shadow: 0 0 10px rgba(255, 77, 77, .6); animation: sube 1.8s forwards; pointer-events: none; }
@keyframes sube { to { transform: translateY(14px); opacity: 0; } }

/* ---------- Distribución y paneles ---------- */
main { display: grid; grid-template-columns: minmax(440px, 1.1fr) 1fr; gap: 14px; padding: 14px; min-height: 0; }
.panel { position: relative; min-height: 0; background-color: var(--panel); border: 1px solid var(--linea); box-shadow: 0 24px 60px rgba(0, 0, 0, .4); }
.panel-titulo {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 14px; border-bottom: 1px solid var(--linea);
  font: 500 11.5px/1 var(--f-ui); letter-spacing: .24em; color: #c3dcef; white-space: nowrap; overflow: hidden;
}
.panel-titulo .sep { color: var(--tenue); letter-spacing: 0; }
.panel-titulo .sub { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; font: 400 11.5px/1 var(--f-ui); letter-spacing: .04em; color: var(--tenue); }
.regla {
  flex: 1 1 20px; min-width: 20px; height: 7px; opacity: .8;
  background:
    repeating-linear-gradient(90deg, var(--linea-2) 0 1px, transparent 1px 6px) left bottom / 100% 3px no-repeat,
    repeating-linear-gradient(90deg, var(--linea-3) 0 1px, transparent 1px 30px) left bottom / 100% 7px no-repeat;
}
.panel-estado { flex: none; display: flex; align-items: center; gap: 7px; font: 500 10px/1 var(--f-mono); letter-spacing: .14em; color: var(--tenue); }

/* ---------- Programa (Blockly) ---------- */
#panel-programa { display: flex; flex-direction: column; overflow: hidden; }
#zona-blockly { position: relative; flex: 1; min-height: 0; }
#blockly { position: absolute; inset: 0; }
#bloqueo { position: absolute; inset: 0; z-index: 50; display: none; align-items: flex-start; justify-content: flex-end; padding: 14px 16px; cursor: not-allowed; background: rgba(3, 8, 14, .28); }
#bloqueo::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--ambar), transparent) no-repeat; background-size: 40% 100%; animation: recorrer 1.6s linear infinite; }
#bloqueo span { display: flex; align-items: center; gap: 9px; padding: 7px 11px; border: 1px solid rgba(255, 177, 61, .5); background: rgba(20, 12, 2, .85); font: 600 10px/1 var(--f-mono); letter-spacing: .24em; color: var(--ambar); }
#bloqueo .punto { background: var(--ambar); box-shadow: 0 0 8px var(--ambar); }
body.ejecutando #bloqueo { display: flex; }

.acciones { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--linea); background: linear-gradient(rgba(7, 16, 27, .92), rgba(3, 8, 14, .96)); }
.btn.btn-ejecutar {
  display: inline-flex; align-items: center; gap: 11px; padding: 13px 22px; font-size: 14px; letter-spacing: .28em;
  background: rgba(77, 255, 160, .1); border-color: rgba(77, 255, 160, .65); color: #e3fff0;
  box-shadow: 0 0 22px rgba(77, 255, 160, .14), inset 0 0 16px rgba(77, 255, 160, .08);
}
.btn-ejecutar svg { width: 11px; height: 11px; fill: var(--verde); filter: drop-shadow(0 0 4px var(--verde)); }
.btn-ejecutar small { margin-left: 2px; font: 500 9px/1 var(--f-mono); letter-spacing: .08em; color: rgba(200, 255, 225, .55); }
body.ejecutando .btn-ejecutar, body.ejecutando .btn-houston { opacity: .4; pointer-events: none; }
#contador-bloques { margin-left: auto; font: 500 10.5px/1 var(--f-mono); letter-spacing: .14em; color: var(--tenue); }
#contador-bloques b { color: var(--texto); font-weight: 600; }

/* Blockly con la misma estética */
.blocklyMainBackground { stroke: none !important; }
.blocklyFlyoutLabelText { font-family: var(--f-ui) !important; font-size: 10px !important; font-weight: 600 !important; fill: #5f7d93 !important; }
.blocklyTooltipDiv { background: #0a1826 !important; color: var(--texto) !important; border: 1px solid var(--linea-2) !important; border-radius: 2px !important; font: 400 13px/1.4 var(--f-ui) !important; box-shadow: 0 8px 24px rgba(0, 0, 0, .5) !important; }
.blocklyWidgetDiv .blocklyHtmlInput { font-family: var(--f-mono) !important; }
.blocklyZoom > image, .blocklyTrash > image { opacity: .35; }
.blocklyZoom > image:hover, .blocklyTrash > image:hover { opacity: .7; }

/* ---------- Columna derecha ---------- */
#columna { display: grid; grid-template-rows: minmax(200px, 1fr) auto 168px auto; gap: 14px; min-height: 0; }

/* Ventanilla 3D con encuadre de cámara */
#ventanilla { display: flex; flex-direction: column; overflow: hidden; }
#vista3d { flex: 1; min-height: 0; cursor: grab; }
#vista3d:active { cursor: grabbing; }
.scanlines { position: absolute; inset: 36px 0 0 0; pointer-events: none; background: repeating-linear-gradient(transparent 0 2px, rgba(0, 0, 0, .16) 2px 3px); box-shadow: inset 0 0 80px rgba(0, 0, 0, .85); }
.esquinas {
  position: absolute; inset: 46px 10px 10px 10px; pointer-events: none; --c: rgba(160, 225, 255, .5);
  background-image:
    linear-gradient(var(--c), var(--c)), linear-gradient(var(--c), var(--c)), linear-gradient(var(--c), var(--c)), linear-gradient(var(--c), var(--c)),
    linear-gradient(var(--c), var(--c)), linear-gradient(var(--c), var(--c)), linear-gradient(var(--c), var(--c)), linear-gradient(var(--c), var(--c)),
    linear-gradient(var(--c), var(--c)), linear-gradient(var(--c), var(--c)), linear-gradient(var(--c), var(--c)), linear-gradient(var(--c), var(--c));
  background-size: 22px 1px, 1px 22px, 22px 1px, 1px 22px, 22px 1px, 1px 22px, 22px 1px, 1px 22px, 1px 9px, 1px 9px, 9px 1px, 9px 1px;
  background-position: left top, left top, right top, right top, left bottom, left bottom, right bottom, right bottom, center top, center bottom, left center, right center;
  background-repeat: no-repeat;
}
.hud-cam { position: absolute; left: 22px; top: 56px; pointer-events: none; font: 500 9.5px/1 var(--f-mono); letter-spacing: .2em; color: rgba(185, 225, 250, .55); }
.banner {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); min-width: 62%; max-width: 88%;
  padding: 12px 20px 14px; text-align: center; border: 1px solid; backdrop-filter: blur(3px); animation: aparece .3s var(--suave);
}
.banner.mal {
  background: repeating-linear-gradient(-45deg, rgba(255, 77, 77, .75) 0 6px, transparent 6px 12px) top / 100% 4px no-repeat, rgba(40, 4, 4, .84);
  border-color: rgba(255, 77, 77, .7); color: #ffd6d6; box-shadow: 0 0 30px rgba(255, 77, 77, .25);
}
.banner.bien { background: rgba(2, 30, 16, .84); border-color: rgba(77, 255, 160, .6); color: #d4ffe6; box-shadow: 0 0 30px rgba(77, 255, 160, .2); }
.b-cab { font: 500 9.5px/1 var(--f-mono); letter-spacing: .24em; opacity: .75; }
.b-titulo { margin-top: 8px; font: 400 18px/1.25 var(--f-titulo); letter-spacing: .1em; }
.banner.mal .b-titulo { color: var(--rojo); text-shadow: 0 0 14px rgba(255, 77, 77, .6); }
.banner.bien .b-titulo { color: var(--verde); text-shadow: 0 0 14px rgba(77, 255, 160, .5); }
.b-sub { margin-top: 7px; font: 400 14.5px/1.4 var(--f-ui); }
@keyframes aparece { from { transform: translateX(-50%) scale(.94); opacity: 0; } }

/* Estado de sistemas: luces de aviso, como las del DSKY */
#lista-sistemas { list-style: none; margin: 0; padding: 12px 14px 14px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
#lista-sistemas li {
  position: relative; display: flex; flex-direction: column; justify-content: center; gap: 5px; min-height: 40px; padding: 6px 10px; border-radius: 2px;
  background: #0c1117; border: 1px solid #1a242e; color: #3b4a58; transition: background .25s, color .25s, border-color .25s, box-shadow .25s;
}
#lista-sistemas li::after { content: ""; position: absolute; top: 7px; right: 8px; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .45; }
#lista-sistemas .nombre { font: 600 10px/1 var(--f-ui); letter-spacing: .16em; }
#lista-sistemas .est { font: 500 9px/1 var(--f-mono); letter-spacing: .08em; opacity: .85; }
#lista-sistemas li.on { background: rgba(77, 255, 160, .1); border-color: rgba(77, 255, 160, .5); color: #c9ffe3; box-shadow: inset 0 0 16px rgba(77, 255, 160, .1); }
#lista-sistemas li.on .est, #lista-sistemas li.on::after { color: var(--verde); }
#lista-sistemas li.on::after { opacity: 1; box-shadow: 0 0 8px var(--verde); }
#lista-sistemas li.aviso { background: rgba(255, 177, 61, .1); border-color: rgba(255, 177, 61, .55); color: #ffe2b0; }
#lista-sistemas li.aviso::after { color: var(--ambar); opacity: 1; box-shadow: 0 0 8px var(--ambar); }
#lista-sistemas li.fallo { background: rgba(255, 77, 77, .16); border-color: var(--rojo); color: #ffd6d6; animation: latido .35s infinite; }
#lista-sistemas li.fallo::after { color: var(--rojo); opacity: 1; box-shadow: 0 0 8px var(--rojo); }
/* Prueba de lámparas al encender */
#lista-sistemas.prueba li { background: #e4e8ea; border-color: #fff; color: #151a1e; }

/* Terminal de fósforo verde */
#terminal { display: flex; flex-direction: column; }
#log {
  flex: 1; overflow-y: auto; padding: 9px 14px; font: 400 12px/1.55 var(--f-mono); color: #9ff0c2;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .25) 0 1px, transparent 1px 3px), #020704;
}
#log::-webkit-scrollbar { width: 6px; }
#log::-webkit-scrollbar-thumb { background: #1d3a2a; }
.linea { white-space: pre-wrap; min-height: 1.2em; }
.linea.ok { color: var(--verde); }
.linea.error { color: #ff7b7b; }
.linea.aviso { color: var(--ambar); }
.linea.titulo { color: var(--cian); font-weight: 600; }

.btn.btn-houston {
  display: flex; align-items: center; justify-content: center; gap: 14px; padding: 11px 16px;
  border-color: rgba(255, 177, 61, .55); background: linear-gradient(90deg, rgba(255, 177, 61, .13), rgba(255, 177, 61, .03)); color: #ffe0a8; letter-spacing: .22em;
}
.h-txt { text-align: left; }
.h-txt small { display: block; margin-top: 5px; font: 500 10px/1 var(--f-mono); letter-spacing: .04em; text-transform: none; color: #c9a063; }
.btn-houston .onda i { animation-play-state: paused; }
.btn-houston:hover .onda i { animation-play-state: running; }

/* ---------- Ventanas superpuestas ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(3, 11, 20, .7), rgba(1, 3, 7, .92)); backdrop-filter: blur(5px);
}
.caja { position: relative; width: 100%; max-width: 680px; padding: 24px 32px 28px; background-color: rgba(4, 12, 21, .94); border: 1px solid var(--linea-2); box-shadow: 0 30px 90px rgba(0, 0, 0, .65); }
.caja.marco { --esq: 18px; }
.overlay:not(.oculto) .caja { animation: caja-entra .55s var(--suave) both; }
.overlay:not(.oculto) .caja > * { animation: subir .6s var(--suave) both; }
.caja > :nth-child(2) { animation-delay: .12s !important; }
.caja > :nth-child(3) { animation-delay: .2s !important; }
.caja > :nth-child(4) { animation-delay: .28s !important; }
.caja > :nth-child(5) { animation-delay: .36s !important; }
.caja > :nth-child(6) { animation-delay: .44s !important; }
.caja > :nth-child(7) { animation-delay: .52s !important; }
.caja > :nth-child(8) { animation-delay: .6s !important; }
@keyframes caja-entra { from { opacity: 0; transform: scale(.975); clip-path: inset(0 0 100% 0); } to { opacity: 1; transform: none; clip-path: inset(0 0 0 0); } }
.caja-cab { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-bottom: 13px; margin-bottom: 18px; border-bottom: 1px solid var(--linea); font: 500 10.5px/1 var(--f-mono); letter-spacing: .16em; color: var(--cian); }
.caja-cab > span:first-child { display: flex; align-items: center; gap: 10px; }
.caja-cod { color: var(--tenue); white-space: nowrap; }
.caja-cab.ok { color: var(--verde); }
.caja-cab.ok .punto { background: var(--verde); box-shadow: 0 0 8px var(--verde); }
.caja-cab.mal { color: var(--rojo); }
.caja-cab.mal .punto { background: var(--rojo); box-shadow: 0 0 8px var(--rojo); }
.caja-sub { font: 500 11px/1 var(--f-ui); letter-spacing: .34em; color: var(--tenue); }
.caja h1 { margin: 12px 0 18px; font: 400 30px/1.2 var(--f-titulo); letter-spacing: .12em; color: var(--cian-2); text-shadow: 0 0 26px rgba(98, 220, 255, .35); }
.caja p { margin: 0 0 12px; font: 400 18px/1.55 var(--f-ui); color: var(--texto-2); }
.caja p b { font-weight: 600; color: var(--texto); }
.aviso-o2 { display: flex; align-items: center; gap: 12px; margin-top: 18px !important; font: 600 12px/1 var(--f-ui) !important; letter-spacing: .24em; text-transform: uppercase; color: var(--ambar) !important; }
.aviso-o2::before { content: "!"; display: grid; place-items: center; width: 20px; height: 18px; padding-top: 5px; background: var(--ambar); color: #1c1000; font: 700 10px/1 var(--f-mono); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.btn-ejecutar.grande { position: relative; overflow: hidden; margin-top: 20px; padding: 16px 38px; font-size: 14px; letter-spacing: .34em; }
.btn-ejecutar.grande::after { content: ""; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%; background: linear-gradient(100deg, transparent, rgba(180, 255, 215, .22), transparent); animation: brillo 3.2s ease-in-out infinite; }
@keyframes brillo { 0%, 55% { left: -60%; } 100% { left: 130%; } }
@keyframes rayas { to { background-position: -45px 0; } }
.caja .btn-sec { display: block; margin: 20px 0 0 auto; }

#radio { align-items: flex-end; padding-bottom: 56px; background: linear-gradient(transparent 40%, rgba(1, 4, 8, .75)); backdrop-filter: none; }
.caja-radio { max-width: 780px; --c: rgba(255, 177, 61, .75); border-color: rgba(255, 177, 61, .4); box-shadow: 0 0 50px rgba(255, 177, 61, .1), 0 30px 90px rgba(0, 0, 0, .65); }
.caja-radio .caja-cab { color: var(--ambar); border-color: rgba(255, 177, 61, .2); }
#radio-texto { min-height: 3em; font: 400 17px/1.6 var(--f-mono); color: #ffe7bd; }
.onda { display: inline-flex; gap: 2px; align-items: center; height: 16px; }
.onda i { width: 2px; height: 3px; background: var(--ambar); animation: onda .9s infinite ease-in-out; }
.onda i:nth-child(3n) { animation-delay: .15s; } .onda i:nth-child(3n+1) { animation-delay: .3s; }
.onda i:nth-child(4n) { animation-duration: .7s; } .onda i:nth-child(5n) { animation-duration: 1.1s; }
@keyframes onda { 0%, 100% { height: 3px; } 50% { height: 16px; } }

.caja-exito { --c: rgba(77, 255, 160, .75); border-color: rgba(77, 255, 160, .35); max-width: 740px; }
.caja-exito .caja-cab { border-color: rgba(77, 255, 160, .18); }
.caja-exito h1 { color: #c9ffe3; text-shadow: 0 0 26px rgba(77, 255, 160, .4); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stats > div { padding: 12px 14px; border: 1px solid var(--linea); background: rgba(98, 220, 255, .03); }
.stats span { display: block; font: 500 9.5px/1 var(--f-ui); letter-spacing: .26em; color: var(--tenue); white-space: nowrap; }
.stats b { display: block; margin-top: 10px; font: 500 26px/1 var(--f-mono); color: var(--texto); }
.modulo { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; padding: 10px 14px; border: 1px dashed var(--linea-2); }
.modulo span { font: 500 9.5px/1 var(--f-ui); letter-spacing: .26em; color: var(--cian); }
.modulo code { font: 500 14px var(--f-mono); color: var(--texto); }
.codigo-caja { position: relative; padding: 16px; text-align: center; border: 1px solid rgba(255, 177, 61, .45); background: radial-gradient(ellipse at center, rgba(255, 177, 61, .1), transparent 70%); }
.codigo-et { font: 500 10px/1 var(--f-ui); letter-spacing: .4em; color: var(--ambar); }
.codigo { display: flex; justify-content: center; gap: 16px; min-height: 54px; margin: 14px 0 12px; font: 700 54px/1 var(--f-seg); color: #fff3da; text-shadow: 0 0 18px var(--ambar), 0 0 3px #fff; }
.rodillo { position: relative; z-index: 0; }
.rodillo::before { content: "8"; position: absolute; left: 0; z-index: -1; color: rgba(255, 177, 61, .09); text-shadow: none; }
.rodillo:not(.fijo) { color: rgba(255, 220, 170, .55); text-shadow: none; }
.codigo-txt { font: 400 15px/1.4 var(--f-ui); color: #ffe2a8; }
.exito-botones { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.exito-botones .btn-sec { margin: 0; }

.caja-mal { --c: rgba(255, 77, 77, .8); border-color: rgba(255, 77, 77, .5); text-align: center; overflow: hidden; }
.caja-mal::before, .caja-mal::after { content: ""; position: absolute; left: 0; right: 0; height: 8px; background: repeating-linear-gradient(-45deg, var(--rojo) 0 8px, transparent 8px 16px); background-size: 200% 100%; animation: rayas 1s linear infinite; opacity: .8; }
.caja-mal::before { top: 0; } .caja-mal::after { bottom: 0; }
.caja-mal .caja-cab { border-color: rgba(255, 77, 77, .25); }
.caja-mal h1 { color: var(--rojo); text-shadow: 0 0 26px rgba(255, 77, 77, .6); animation: latido 1s infinite; }

/* ---------- Panel del director de juego ---------- */
#gm { position: fixed; top: 70px; right: 16px; z-index: 200; width: 380px; padding: 16px; background: rgba(18, 9, 28, .97); border: 1px solid rgba(190, 140, 255, .6); box-shadow: 0 20px 60px rgba(0, 0, 0, .6); font: 400 12px/1.4 var(--f-mono); color: var(--texto); }
.gm-cab { margin-bottom: 12px; font: 600 11px/1 var(--f-ui); letter-spacing: .26em; color: #d2a8ff; }
.gm-botones { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.gm-botones .btn { padding: 9px 8px; font-size: 11px; letter-spacing: .1em; border-color: rgba(190, 140, 255, .35); background: rgba(190, 140, 255, .06); }
.gm-sub { margin-bottom: 6px; color: var(--tenue); }
#gm-resultados { max-height: 160px; overflow: auto; margin: 0 0 12px; padding-left: 18px; }
#gm .btn-sec { margin: 0; border-color: rgba(190, 140, 255, .35); }

/* ---------- Destello ---------- */
#flash { position: fixed; inset: 0; z-index: 90; pointer-events: none; opacity: 0; }
#flash.activo { animation: destello .7s; }
#flash.rojo { background: radial-gradient(transparent 30%, rgba(255, 30, 30, .5)); }
#flash.ambar { background: radial-gradient(transparent 30%, rgba(255, 170, 30, .45)); }
#flash.verde { background: radial-gradient(transparent 30%, rgba(61, 255, 138, .35)); }
@keyframes destello { 0% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- Cámaras de la ventanilla ---------- */
.camaras { flex: none; display: flex; gap: 4px; margin-left: 4px; }
.cam {
  padding: 5px 8px 4px; border: 1px solid var(--linea-2); border-radius: 1px; background: transparent; cursor: pointer;
  font: 600 9.5px/1 var(--f-mono); letter-spacing: .14em; color: var(--tenue); transition: color .2s, background .2s, border-color .2s, box-shadow .2s;
}
.cam:hover { color: var(--texto); border-color: var(--linea-3); }
.cam.activo { color: #021018; background: var(--cian); border-color: var(--cian); box-shadow: 0 0 10px rgba(98, 220, 255, .35); }

/* Interferencia al cambiar de cámara */
.interferencia {
  position: absolute; inset: 36px 0 0 0; pointer-events: none; opacity: 0; mix-blend-mode: screen;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='r'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 1.6 -.55'/></filter><rect width='100%' height='100%' filter='url(%23r)'/></svg>") 0 0 / 180px 180px, repeating-linear-gradient(0deg, rgba(180, 230, 255, .1) 0 2px, transparent 2px 5px);
}
#ventanilla.cambio .interferencia { animation: interferencia .42s steps(6) both; }
#ventanilla.cambio #vista3d { animation: salto-senal .42s steps(3); }
@keyframes interferencia {
  0% { opacity: 1; background-position: 0 0, 0 0; }
  50% { opacity: .8; background-position: 60px -40px, 0 12px; }
  100% { opacity: 0; background-position: -30px 70px, 0 24px; }
}
@keyframes salto-senal { 0% { transform: translateX(-5px); filter: brightness(1.7); } 50% { transform: translateX(4px); } 100% { transform: none; filter: none; } }

/* Ayudas de la cámara de cabina */
.hud-notas { position: absolute; right: 22px; top: 54px; pointer-events: none; padding: 5px 9px 4px; border: 1px solid rgba(255, 225, 120, .4); background: rgba(20, 16, 4, .6); font: 500 9.5px/1 var(--f-mono); letter-spacing: .18em; color: #ffe08a; }
.hud-notas b { font-weight: 600; color: #fff3c4; }
.hud-notas.completo { border-color: rgba(77, 255, 160, .5); background: rgba(2, 24, 12, .6); color: var(--verde); }
.hud-notas.completo b { color: #c9ffe3; }
.hud-ayuda { position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); pointer-events: none; padding: 7px 12px 6px; background: rgba(2, 8, 14, .62); white-space: nowrap; font: 500 9.5px/1 var(--f-mono); letter-spacing: .16em; color: rgba(215, 236, 255, .72); transition: opacity .8s; }
.hud-ayuda i { font-style: normal; margin: 0 9px; color: var(--cian); }
.hud-ayuda .sin-notas-txt { display: none; }
#ventanilla.sin-notas .hud-ayuda .solo-notas { display: none; }
#ventanilla.sin-notas .hud-ayuda .sin-notas-txt { display: inline; }
#ventanilla.sin-notas .hud-notas { display: none; }
#ventanilla.sin-ayuda .hud-ayuda { opacity: 0; }
#ventanilla.cam-exterior .hud-notas, #ventanilla.cam-exterior .hud-ayuda { display: none; }
#banner { pointer-events: none; }

/* ---------- Tablero de notas recogidas ---------- */
#fila-inferior { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; min-height: 0; }
#fila-inferior.sin-notas { grid-template-columns: 1fr; }
#tablero { display: flex; align-items: center; gap: 12px; padding: 7px 12px 7px 14px; overflow: visible; }
.tab-etq { flex: none; display: flex; flex-direction: column; gap: 6px; }
.tab-etq b { font: 600 16px/1 var(--f-mono); color: var(--texto); transition: color .3s; }
.tab-etq b.completo { color: var(--verde); }
#tablero-notas { flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; }
.nota-mini {
  --g: 0deg; position: relative; flex: 0 1 46px; min-width: 30px; height: 40px; padding: 10px 5px 4px; border: 0; border-radius: 1px 1px 6px 1px; cursor: pointer;
  background: linear-gradient(170deg, #fde66e 70%, #e3c44a); box-shadow: 0 3px 7px rgba(0, 0, 0, .55); transform: rotate(var(--g)); transition: transform .2s var(--suave), box-shadow .2s;
}
.nota-mini b { display: block; overflow: hidden; font: 700 10.5px/1 "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive; color: #c23b2b; text-align: right; white-space: nowrap; }
.nota-mini .nm-lineas { display: block; height: 11px; margin-top: 4px; background: repeating-linear-gradient(transparent 0 3px, rgba(29, 42, 106, .45) 3px 4px); }
.nota-mini .nm-celo { position: absolute; left: 50%; top: -4px; width: 22px; height: 8px; margin-left: -11px; background: rgba(240, 240, 228, .55); transform: rotate(-4deg); }
button.nota-mini:hover { transform: rotate(0deg) translateY(-3px) scale(1.1); box-shadow: 0 8px 16px rgba(0, 0, 0, .6); }
.nota-mini.vacia { display: flex; align-items: center; justify-content: center; padding: 0; cursor: default; background: none; border: 1px dashed var(--linea-2); box-shadow: none; }
.nota-mini.vacia::after { content: "?"; font: 500 12px/1 var(--f-mono); color: var(--tenue); }
.nota-mini.por-llegar { opacity: 0; }
.nota-mini.llega { animation: llega .5s var(--suave); }
@keyframes llega { 0% { transform: rotate(var(--g)) scale(1.35); filter: brightness(1.5); } 100% { transform: rotate(var(--g)); filter: none; } }
.btn.btn-houston { min-width: 210px; }

/* ---------- Lectura de una nota o una pegatina en grande ---------- */
#lectura { position: fixed; inset: 0; z-index: 150; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 16px; cursor: pointer; }
.lectura-fondo { position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(3, 11, 20, .55), rgba(1, 3, 7, .82)); backdrop-filter: blur(3px); opacity: 0; transition: opacity .35s; }
#lectura.visible .lectura-fondo { opacity: 1; }
#lectura-hoja { position: relative; transform-origin: 0 0; will-change: transform; }
#lectura-pie { position: relative; font: 500 10px/1 var(--f-mono); letter-spacing: .24em; color: var(--texto-2); opacity: 0; transition: opacity .3s; }
#lectura.visible #lectura-pie { opacity: 1; transition-delay: .25s; }
.nota-grande {
  position: relative; width: min(410px, 88vw); min-height: 330px; padding: 34px 30px 30px; border-radius: 1px 1px 3px 3px / 1px 1px 14px 14px;
  font: 400 17px/1.6 "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive; color: #1d2a6a;
  background:
    linear-gradient(rgba(0, 0, 0, .05), rgba(0, 0, 0, .015) 26px, transparent 27px),
    linear-gradient(100deg, rgba(0, 0, 0, .04), transparent 30%, transparent 70%, rgba(0, 0, 0, .06)),
    linear-gradient(170deg, #fee873 60%, #eccf50);
  box-shadow: 0 2px 2px rgba(0, 0, 0, .3), 0 30px 60px rgba(0, 0, 0, .65);
}
.ng-celo { position: absolute; left: 50%; top: -13px; width: 118px; height: 30px; margin-left: -59px; background: rgba(240, 240, 228, .55); box-shadow: 0 0 1px rgba(0, 0, 0, .25); transform: rotate(-3deg); }
.ng-hora { position: absolute; top: 12px; right: 20px; font-weight: 700; font-size: 18px; color: #c23b2b; transform: rotate(3deg); }
.ng-texto b { font-weight: 700; }
.ng-texto small { font-size: 13px; line-height: 1.5; }
.ng-texto .subr { text-decoration: underline; text-decoration-thickness: 2px; }
.ng-texto .tres { text-decoration: underline double; text-decoration-thickness: 2px; }
.ng-texto .mancha { position: relative; display: inline-block; width: 58px; }
.ng-texto .mancha::after {
  content: ""; position: absolute; left: -26px; top: -28px; width: 110px; height: 78px; border-radius: 48% 52% 45% 55%;
  background: radial-gradient(ellipse at 45% 50%, rgba(108, 60, 22, .92) 0 36%, rgba(128, 78, 32, .62) 55%, rgba(140, 90, 40, 0) 72%);
}
.ng-firma { margin-top: 6px; font-size: 14px; color: #4a5a78; }
.ng-garabato { position: absolute; right: 20px; bottom: 14px; font-size: 34px; opacity: .55; transform: rotate(-10deg); }
.peg-grande {
  width: min(470px, 88vw); padding: 24px 20px 20px; text-align: center; border: 6px solid #111; background: #f2c200; color: #111;
  font-family: Consolas, "JetBrains Mono", monospace; box-shadow: 0 30px 60px rgba(0, 0, 0, .65);
}
.peg-grande.gris { background: #d9dde2; }
.peg-grande.roja { background: #c62828; color: #fff; border-color: #600; }
.peg-grande.azul { background: #1f5aa6; color: #fff; border-color: #0b2a55; }
.peg-grande .t { font-size: 18px; font-weight: 700; letter-spacing: .14em; }
.peg-grande .v { margin: 12px 0 10px; font-size: 68px; font-weight: 700; letter-spacing: .06em; line-height: 1; }
.peg-grande .p { font-size: 13px; font-weight: 700; letter-spacing: .06em; }
.peg-grande.largo .v { font-size: 50px; }

/* Tablero en pantallas estrechas: las horas de los pósits siguen cabiendo enteras */
@media (max-width: 1300px) {
  #tablero { gap: 9px; padding: 7px 10px; }
  #tablero-notas { gap: 5px; }
  .nota-mini { padding: 10px 3px 4px; }
  .nota-mini b { font-size: 9.5px; }
  .btn.btn-houston { min-width: 0; gap: 10px; padding: 11px 12px; }
}

/* ---------- Encendido ---------- */
/* Detrás de la intro la cabina está apagada; al empezar se enciende por partes */
body.apagado #app { filter: saturate(.2) brightness(.45); }
body.encendiendo #barra { animation: encender-barra .7s var(--suave) both; }
body.encendiendo .panel { animation: encender-panel .9s var(--suave) both; }
body.encendiendo #ventanilla { animation-delay: .12s; }
body.encendiendo #sistemas { animation-delay: .22s; }
body.encendiendo #terminal { animation-delay: .32s; }
body.encendiendo #tablero { animation-delay: .42s; }
body.encendiendo #btn-houston { animation: subir .6s .5s var(--suave) both; }
@keyframes encender-barra { from { opacity: 0; transform: translateY(-100%); } }
@keyframes encender-panel {
  0% { opacity: 0; clip-path: inset(49.5% 0 49.5% 0); }
  35% { opacity: 1; clip-path: inset(49.5% 0 49.5% 0); }
  40% { opacity: .4; }
  45% { opacity: 1; }
  100% { opacity: 1; clip-path: inset(0 0 0 0); }
}

/* ---------- Pantallas bajas, medianas y estrechas ---------- */
@media (max-height: 820px) {
  #columna { grid-template-rows: minmax(170px, 1fr) auto 132px auto; gap: 10px; }
  main { gap: 10px; padding: 10px; }
  #lista-sistemas li { min-height: 34px; padding: 5px 9px; }
}
@media (max-width: 1400px) {
  .estado-mision .chip:last-child { display: none; }
  .panel-titulo .sub { display: none; }
}
@media (max-width: 1100px) {
  html, body { overflow: auto; }
  #app { height: auto; }
  main { grid-template-columns: 1fr; }
  #panel-programa { height: 72vh; }
  #columna { grid-template-rows: 50vh auto 200px auto; }
  .marca-txt span, .estado-mision, .o2-sv { display: none; }
  .o2 { width: 150px; }
}

/* ---------- Historia: intro con ilustración, personajes en la radio y Tang ---------- */
.caja-historia { max-width: 1040px; }
.historia-cuerpo { display: grid; grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr); gap: 26px; align-items: center; }
.intro-img { margin: 0; }
.intro-img img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border: 1px solid var(--linea-2); }
.intro-img figcaption { margin-top: 8px; font: 400 12.5px/1.45 var(--f-mono); color: var(--tenue); }
.intro-texto h1 { margin-top: 10px; }
.intro-texto .btn-ejecutar.grande { margin-top: 12px; }
@media (max-width: 980px) {
  .historia-cuerpo { grid-template-columns: 1fr; }
  .intro-img { display: none; }
}

.radio-cuerpo { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 18px; align-items: start; }
#radio-avatar { width: 76px; height: 76px; object-fit: cover; border: 1px solid rgba(255, 177, 61, .55); box-shadow: 0 0 18px rgba(255, 177, 61, .18); }
.radio-quien { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 6px; }
.radio-quien b { font: 400 13px/1.2 var(--f-titulo); letter-spacing: .12em; color: #ffd08a; }
.radio-quien span { font: 500 10px/1 var(--f-mono); letter-spacing: .2em; color: var(--tenue); }

#aviso-tang {
  position: absolute; left: 50%; top: 84px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; max-width: 88%;
  padding: 8px 16px 8px 8px; border: 1px solid rgba(255, 201, 77, .6); background: rgba(30, 20, 4, .88); box-shadow: 0 0 30px rgba(255, 177, 61, .25);
  color: #ffe7bd; pointer-events: none; animation: aparece .35s var(--suave);
}
#aviso-tang img { width: 46px; height: 46px; object-fit: contain; flex: none; }
#aviso-tang b { display: block; font: 400 13px/1.3 var(--f-titulo); letter-spacing: .12em; color: var(--ambar); }
#aviso-tang span { font: 400 14.5px/1.35 var(--f-ui); }

.ex-tang { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; padding: 8px 14px; border: 1px dashed rgba(255, 201, 77, .45); font: 500 14px/1.3 var(--f-ui); letter-spacing: .04em; color: #ffe7bd; }
.ex-tang img { width: 34px; height: 34px; object-fit: contain; flex: none; }
.ex-tang.no { color: var(--texto-2); border-color: var(--linea-2); }
.ex-tang.no img { filter: grayscale(1) brightness(.7); }

/* Huella de Tang, en café, sobre la nota de las 06:16 */
.ng-huella {
  position: absolute; right: 44px; bottom: 26px; width: 48px; height: 48px; opacity: .6; transform: rotate(-22deg); pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cg fill='%236b3f18'%3E%3Cellipse cx='20' cy='27' rx='9' ry='7.5'/%3E%3Cellipse cx='8.5' cy='16' rx='3.6' ry='4.6'/%3E%3Cellipse cx='15.5' cy='9.5' rx='3.6' ry='4.6'/%3E%3Cellipse cx='24.5' cy='9.5' rx='3.6' ry='4.6'/%3E%3Cellipse cx='31.5' cy='16' rx='3.6' ry='4.6'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
}

/* ---------- Menos movimiento ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
