:root {
  --bg-0: #02040a;
  --bg-1: #051024;
  --cyan: #00d4ff;
  --blue: #3d7bff;
  --violet: #8a2be2;
  --text: #e6f4ff;
  --muted: #6d86a8;
  --font-display: "Orbitron", "Segoe UI", sans-serif;
  --font-body: "Rajdhani", "Segoe UI", sans-serif;

  --ship-speed: 24s;
  --ship-angle-out: -35deg;
  --ship-angle-in: 145deg;

  --bg-oscuro: #050811;
  --panel: rgba(8, 14, 28, 0.76);
  --panel-card: rgba(13, 23, 44, 0.84);
  --borde: #1e355d;
  --borde-activo: #38bdf8;
  --texto: #e6f1ff;
  --texto-suave: #7f9bb8;
  --acento: #38bdf8;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --fuente-pixel: "Courier New", Courier, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100vh;
  margin: 0;
  padding: 0;
  background-color: var(--bg-0);
  overflow-x: clip;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background: radial-gradient(
    circle at 50% 50%,
    var(--bg-1) 0%,
    var(--bg-0) 80%
  );
  display: flex;
  flex-direction: column;
  position: relative;
}

.stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.stars-far {
  background-image:
    radial-gradient(1px 1px at 10% 20%, #fff, transparent),
    radial-gradient(1px 1px at 30% 70%, #cfe8ff, transparent),
    radial-gradient(1px 1px at 60% 15%, #fff, transparent),
    radial-gradient(1px 1px at 80% 55%, #aed4ff, transparent),
    radial-gradient(1px 1px at 45% 90%, #fff, transparent),
    radial-gradient(1px 1px at 92% 85%, #fff, transparent);
  background-size: 400px 400px;
  animation: drift 150s linear infinite;
  opacity: 0.4;
}

.stars-near {
  background-image:
    radial-gradient(2px 2px at 20% 40%, #fff, transparent),
    radial-gradient(2px 2px at 70% 25%, #9fd8ff, transparent),
    radial-gradient(2px 2px at 85% 75%, #fff, transparent),
    radial-gradient(2px 2px at 40% 80%, #ffffff, transparent);
  background-size: 600px 600px;
  animation: drift 100s linear infinite;
  opacity: 0.7;
}

.nebula {
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(
      circle at 30% 40%,
      rgba(138, 43, 226, 0.15),
      transparent 50%
    ),
    radial-gradient(circle at 70% 60%, rgba(0, 212, 255, 0.1), transparent 50%);
  filter: blur(60px);
  pointer-events: none;
  z-index: 0;
}

@keyframes drift {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-600px);
  }
}

.earth {
  position: absolute;
  left: -40vw;
  bottom: -55vh;
  width: 155vw;
  max-width: 1500px;
  height: auto;
  image-rendering: pixelated;
  opacity: 0.95;
  filter: drop-shadow(0 0 40px rgba(0, 150, 255, 0.3));
  pointer-events: none;
  z-index: 1;
}

.moon {
  position: absolute;
  top: 8%;
  right: 8%;
  width: clamp(120px, 15vw, 250px);
  height: auto;
  image-rendering: pixelated;
  opacity: 0.85;
  filter: drop-shadow(0 0 35px rgba(255, 255, 255, 0.2));
  pointer-events: none;
  z-index: 1;
  animation: floatMoon 6s ease-in-out infinite alternate;
}

@keyframes floatMoon {
  from {
    transform: translateY(0px);
  }
  to {
    transform: translateY(-15px);
  }
}

.sun {
  display: none;
  position: absolute;
  top: -1%;
  left: 10%;
  width: clamp(150px, 35vw, 250px);
  height: auto;
  image-rendering: pixelated;
  opacity: 0.85;
  filter: drop-shadow(0 0 60px rgba(255, 140, 0, 0.6));
  pointer-events: none;
  z-index: 1;
  animation: pulseSun 8s ease-in-out infinite alternate;
}

body:has(#screen-mission:not([hidden])) .sun,
body:has(#screen-ship:not([hidden])) .sun {
  display: block;
}

@keyframes pulseSun {
  from {
    transform: scale(1);
    filter: drop-shadow(0 0 50px rgba(255, 140, 0, 0.5));
  }
  to {
    transform: scale(1.05);
    filter: drop-shadow(0 0 80px rgba(255, 180, 0, 0.8));
  }
}

.ship {
  position: absolute;
  top: 0;
  left: 0;
  width: 200px;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 15px rgba(0, 212, 255, 0.8));
  pointer-events: none;
  z-index: 2;
  animation: flyDiagonal var(--ship-speed) linear infinite;
  will-change: transform;
}

@keyframes flyDiagonal {
  0% {
    transform: translate(-20vw, 110vh) rotate(var(--ship-angle-out));
  }
  48% {
    transform: translate(120vw, -20vh) rotate(var(--ship-angle-out));
  }
  50% {
    transform: translate(120vw, -20vh) rotate(var(--ship-angle-in));
  }
  98% {
    transform: translate(-20vw, 110vh) rotate(var(--ship-angle-in));
  }
  100% {
    transform: translate(-20vw, 110vh)
      rotate(calc(var(--ship-angle-in) + 180deg));
  }
}

.menu {
  position: relative;
  z-index: 3;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  padding: 2rem;
  animation: fadeIn 1.2s ease-out both;
  margin-left: 10vw;
}

.title-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.logo {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(4rem, 11vw, 8rem);
  letter-spacing: 0.1em;
  background: linear-gradient(90deg, #00e5ff 0%, #3d7bff 50%, #9c5cff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 25px rgba(0, 212, 255, 0.6));
  line-height: 1;
}

.subtitle {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.2rem, 3vw, 2rem);
  letter-spacing: 0.5em;
  color: #e6f4ff;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
  margin-right: -0.5em;
}

.event {
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.35em;
  color: var(--cyan);
  opacity: 0.9;
  margin-top: 0.5rem;
}

.tagline {
  font-size: 1.25rem;
  color: var(--muted);
  line-height: 1.6;
  max-width: 480px;
  margin-bottom: 1rem;
  font-weight: 500;
  text-align: center;
}

.buttons {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  width: min(340px, 80vw);
}

.btn {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.25em;
  padding: 1.1rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 4px;
}

.btn-primary {
  background: linear-gradient(90deg, #00d4ff 0%, #3d7bff 100%);
  color: #02040a;
  border: 2px solid #00d4ff;
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 0 35px rgba(0, 212, 255, 0.8);
  color: #ffffff;
}

.btn-secondary {
  background: rgba(0, 212, 255, 0.05);
  color: var(--text);
  border: 1px solid #3d7bff;
  box-shadow: inset 0 0 10px rgba(0, 212, 255, 0.1);
}

.btn-secondary:hover {
  background: rgba(0, 212, 255, 0.15);
  border-color: var(--cyan);
  transform: translateY(-2px);
}

select.btn {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  text-align: center;
  text-align-last: center;
  background-image: url('data:image/svg+xml;utf8,<svg fill="%2300d4ff" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
  outline: none;
}
select.btn option {
  background-color: var(--bg-1);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
}
select.btn:hover {
  cursor: pointer;
}
a.btn {
  display: flex;
  justify-content: center;
  align-items: center;
  text-decoration: none;
}

.footer {
  position: relative;
  text-align: center;
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.4em;
  color: rgba(109, 134, 168, 0.5);
  z-index: 3;
  padding: 1.5rem;
  margin-top: auto;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 4, 10, 0.85);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.modal[hidden] {
  display: none;
}
.modal-card {
  background: linear-gradient(160deg, #0a1733, #050a18);
  border: 1px solid rgba(0, 212, 255, 0.4);
  border-radius: 12px;
  padding: 2.5rem;
  width: min(480px, 90vw);
  box-shadow: 0 0 50px rgba(0, 212, 255, 0.25);
  animation: fadeIn 0.3s ease-out both;
}
.modal-card h3 {
  font-family: var(--font-display);
  letter-spacing: 0.25em;
  color: var(--cyan);
  margin-bottom: 1.2rem;
  text-align: center;
}
.modal-card ol {
  padding-left: 1.5rem;
  margin-bottom: 2rem;
  line-height: 1.8;
  font-size: 1.1rem;
  color: var(--text);
}
.modal-card li + li {
  margin-top: 0.5rem;
}
.modal-card .btn {
  width: 100%;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.menu[hidden],
.mission[hidden] {
  display: none;
}

.mission {
  position: relative;
  z-index: 3;
  width: min(760px, 94vw);
  margin: 0 auto;
  padding: 2.5rem 0 3rem;
  animation: fadeIn 0.8s ease-out both;
}
.mission-header {
  text-align: center;
  margin-bottom: 1.8rem;
}
.mission-title {
  outline: none;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(1.6rem, 5vw, 2.6rem);
  letter-spacing: 0.15em;
  background: linear-gradient(90deg, #00e5ff, #3d7bff 50%, #9c5cff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px rgba(0, 212, 255, 0.5));
}
.mission-sub {
  color: var(--muted);
  font-size: 1.15rem;
  margin-top: 0.4rem;
}
.mission-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.panel {
  background: rgba(10, 23, 51, 0.7);
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: 12px;
  padding: 1.2rem 1.3rem 1.3rem;
  backdrop-filter: blur(6px);
}
.panel legend {
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  color: var(--cyan);
  padding: 0 0.6rem;
}
.panel input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.destinos {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem;
}
.destino {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  text-align: center;
  padding: 1rem 0.6rem;
  border: 1px solid rgba(61, 123, 255, 0.35);
  border-radius: 10px;
  cursor: pointer;
  transition:
    border-color 0.25s,
    background 0.25s,
    box-shadow 0.25s;
}
.destino strong {
  font-family: var(--font-display);
  letter-spacing: 0.15em;
  font-size: 0.95rem;
}
.destino small,
.dificultad small,
.hint {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.3;
}
.destino:hover,
.dificultad:hover {
  border-color: var(--cyan);
}
.destino:has(input:checked),
.dificultad:has(input:checked) {
  border-color: var(--cyan);
  background: rgba(0, 212, 255, 0.1);
  box-shadow: 0 0 22px rgba(0, 212, 255, 0.35);
}
.destino:has(input:focus-visible),
.dificultad:has(input:focus-visible) {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}
.destino-icon {
  width: 64px;
  height: 64px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.15));
  transition:
    transform 0.3s ease,
    filter 0.3s ease;
}
.destino:has(input:checked) .destino-icon {
  transform: scale(1.1);
  filter: drop-shadow(0 0 15px var(--cyan));
}

.panel select,
.panel input[type="text"] {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1.15rem;
  color: var(--text);
  background: rgba(2, 4, 10, 0.7);
  border: 1px solid #3d7bff;
  border-radius: 8px;
  padding: 0.75rem 1rem;
}
.panel select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.panel select:focus-visible,
.panel input[type="text"]:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}
.hint {
  margin-top: 0.6rem;
  min-height: 1.3em;
}

.dificultades {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem;
}
.dificultad {
  display: block;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(61, 123, 255, 0.35);
  border-radius: 10px;
  cursor: pointer;
  transition:
    border-color 0.25s,
    background 0.25s,
    box-shadow 0.25s;
}
.dificultad strong {
  display: block;
  font-family: var(--font-display);
  letter-spacing: 0.12em;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.nombre-row {
  display: flex;
  gap: 0.8rem;
}
.nombre-row .btn {
  padding: 0.7rem 1.2rem;
  font-size: 0.8rem;
}
.error {
  color: #ff6b81;
  font-size: 1.05rem;
  margin-top: 0.6rem;
}

.acciones {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  margin-top: 0.4rem;
}
.acciones .btn-primary {
  flex: 1;
  max-width: 320px;
}

.ship-screen[hidden] {
  display: none;
}
.ship-screen {
  position: relative;
  z-index: 3;
  flex: 1;
  padding: 16px 24px 28px;
  font-family: var(--fuente-pixel);
  font-weight: bold;
  color: var(--texto);
  animation: fadeIn 0.8s ease-out both;
}
.ship-screen h1 {
  font-family: var(--fuente-pixel);
  font-size: 1.2rem;
  margin-top: 3px;
  letter-spacing: 1px;
}
.ship-screen h2 {
  font-family: var(--fuente-pixel);
  font-size: 0.92rem;
  color: var(--acento);
}
.ship-screen h3 {
  font-family: var(--fuente-pixel);
  font-size: 0.76rem;
  color: var(--acento);
  margin-bottom: 6px;
}

.hud-top {
  max-width: 1120px;
  margin: 0 auto 14px;
  background: var(--panel);
  border: 2px solid var(--borde);
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  position: relative;
  z-index: 2;
}
.badge-fase {
  font-size: 0.72rem;
  color: var(--acento);
  letter-spacing: 1px;
}
.hud-presupuesto {
  min-width: 240px;
}
.etiqueta-mini {
  font-size: 0.68rem;
  color: var(--texto-suave);
  display: block;
}
.hud-presupuesto strong {
  display: block;
  margin: 3px 0 6px;
  font-size: 0.9rem;
  color: var(--acento);
}

.hangar-grid {
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  gap: 16px;
  align-items: stretch;
  position: relative;
  z-index: 2;
}
.caja-pixel {
  background: var(--panel);
  border: 2px solid var(--borde);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  backdrop-filter: blur(4px);
}
.caja-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--borde);
  padding-bottom: 8px;
}
.pista {
  font-size: 0.68rem;
  color: var(--texto-suave);
}

.subsistemas-lista {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.grupo-titulo {
  font-size: 0.72rem;
  color: var(--texto-suave);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.tarjetas-fila {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}
.tarjeta-pieza {
  position: relative;
  background: var(--panel-card);
  border: 2px solid var(--borde);
  padding: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  color: var(--texto);
  font-family: var(--fuente-pixel);
}
.tarjeta-pieza:hover {
  border-color: var(--acento);
}
.tarjeta-pieza.activa {
  border-color: var(--borde-activo);
  background: rgba(16, 36, 69, 0.9);
  box-shadow: inset 0 0 0 1px var(--borde-activo);
}
.pieza-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pieza-canvas-wrap {
  position: relative;
  width: 78px;
  height: 64px;
  flex-shrink: 0;
  border: 1px solid var(--borde);
  background: rgba(6, 11, 23, 0.85);
  overflow: hidden;
}
.pieza-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  display: block;
}
.pieza-nombre {
  font-size: 0.78rem;
  line-height: 1.2;
}
.pieza-stats {
  font-size: 0.68rem;
  color: var(--acento);
  margin-top: 2px;
}
.pieza-desc {
  font-size: 0.68rem;
  color: var(--texto-suave);
  line-height: 1.3;
  font-weight: normal;
}

.visor-wrap {
  position: relative;
  border: 1px solid var(--borde);
  background: rgba(5, 10, 22, 0.75);
  min-height: 550px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
  overflow: hidden;
}

.barras-telemetria {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.fila-texto {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  margin-bottom: 4px;
}
.barra-pixel {
  width: 100%;
  height: 10px;
  background: rgba(5, 10, 22, 0.88);
  border: 1px solid var(--borde);
  padding: 1px;
}
.barra-fill {
  height: 100%;
  width: 0%;
  transition: width 0.15s steps(8);
}
.barra-fill.ok {
  background: var(--ok);
}
.barra-fill.warn {
  background: var(--warn);
}
.barra-fill.err {
  background: var(--err);
}

.alerta-pixel {
  border: 1px solid var(--ok);
  background: rgba(34, 197, 94, 0.12);
  color: #86efac;
  padding: 8px 10px;
  font-size: 0.72rem;
  line-height: 1.35;
}
.alerta-pixel.err {
  border-color: var(--err);
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
}

.consecuencias-box {
  background: var(--panel-card);
  border: 1px solid var(--borde);
  padding: 10px;
}
.lista-pixel {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: normal;
}
.lista-pixel li::before {
  content: "> ";
  color: var(--acento);
  font-weight: bold;
}

.btn-pixel {
  width: 100%;
  padding: 10px;
  border: 2px solid var(--borde-activo);
  background: rgba(7, 19, 38, 0.92);
  color: var(--acento);
  font-family: var(--fuente-pixel);
  font-size: 0.8rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-pixel:hover:not(:disabled) {
  background: var(--acento);
  color: #04101f;
}
.btn-pixel:disabled {
  background: #1e293b;
  border-color: #475569;
  color: #64748b;
  cursor: not-allowed;
}

.json-box summary {
  cursor: pointer;
  font-size: 0.7rem;
  color: var(--texto-suave);
}
.json-box pre {
  margin-top: 6px;
  background: rgba(5, 10, 22, 0.9);
  border: 1px solid var(--borde);
  padding: 8px;
  font-size: 0.65rem;
  font-weight: normal;
  overflow-x: auto;
  color: #cbd5e1;
}

#nave-composicion {
  position: relative;
  width: 100%;
  max-width: 450px;
  height: 550px;
  margin: 0 auto;
  display: block;
}
.nave-parte {
  position: absolute;
  image-rendering: pixelated;
  object-fit: contain;
}
.parte-cohete {
  width: 20%;
  top: 55%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
}
.parte-motor {
  width: 35%;
  bottom: 0%;
  left: 25%;
  transform: translateX(-50%);
  z-index: 5;
}
.parte-energia {
  width: 25%;
  top: 40%;
  left: -1%;
  z-index: 4;
}
.parte-comunicacion {
  width: 25%;
  top: 5%;
  right: -1%;
  z-index: 4;
}
.parte-instrumento {
  width: 25%;
  bottom: 5%;
  right: -1%;
  z-index: 4;
}

@media (max-width: 1100px) {
  .ship-screen {
    padding: 14px;
  }
}
@media (max-width: 960px) {
  .hangar-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 900px) {
  .menu {
    margin-left: 0;
    padding: 2rem 1rem;
    gap: 1.2rem;
  }
  .logo {
    font-size: clamp(3rem, 15vw, 5rem);
  }
  .subtitle {
    font-size: clamp(0.9rem, 4vw, 1.2rem);
    letter-spacing: 0.2em;
    margin-right: 0;
  }
  .event {
    font-size: 0.65rem;
    letter-spacing: 0.15em;
  }
  .tagline {
    font-size: 1rem;
    padding: 0 1rem;
  }
  .buttons {
    width: 100%;
    max-width: 320px;
  }
  .btn {
    letter-spacing: 0.1em;
    font-size: 0.9rem;
    padding: 1rem;
  }
  .earth {
    width: 150vw;
    left: -75vw;
    bottom: -10vh;
    opacity: 0.3;
  }
  .moon {
    width: 100px;
    top: 5%;
    right: -2%;
    opacity: 0.3;
    animation: none;
  }
  .sun {
    width: 200px;
    top: -1%;
    left: -10%;
    opacity: 0.3;
    animation: none;
  }
  .ship {
    display: none;
  }
  .footer {
    font-size: 0.55rem;
    letter-spacing: 0.2em;
    padding: 1rem;
  }
}
@media (max-width: 640px) {
  .destinos,
  .dificultades {
    grid-template-columns: 1fr;
  }
  .destino {
    flex-direction: row;
    text-align: left;
    gap: 0.9rem;
  }
  .destino .destino-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
  }
  .destino strong {
    min-width: 6.5rem;
  }
  .nombre-row,
  .acciones {
    flex-direction: column;
  }
  .acciones .btn-primary {
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

.game-screen,
.results-screen {
  position: relative;
  z-index: 2;
  width: min(1100px, 94vw);
  margin: 0 auto;
  padding: 2rem 0 4rem;
  max-height: 100vh;
  overflow-y: auto;
}

.game-screen {
  max-height: none;
  overflow: visible;
}

/* Pantalla de juego más grande: usa casi todo el ancho y alto disponible */
.game-screen {
  /* ancho del escenario: lo más grande posible sin pasarse de la altura */
  --stage-w: min(100%, max(560px, calc((100vh - 300px) * 16 / 9)));
  width: min(1800px, 98vw);
  padding: 0.8rem 0 0.4rem;
}
.game-screen .hud-game,
.game-screen .canvas-box,
.game-screen .keys-panel,
.game-screen .game-foot {
  width: var(--stage-w);
  margin-left: auto;
  margin-right: auto;
}

.game-screen[hidden],
.results-screen[hidden],
#r-sin-partida[hidden],
#r-contenido[hidden],
#g-start[hidden],
#g-banner[hidden],
#hud-rover[hidden],
.res-badge[hidden] {
  display: none !important;
}

.hud-game {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.7rem;
  margin-bottom: 0.9rem;
}

.hud-card {
  padding: 0.6rem 0.8rem;
  border: 1px solid rgba(0, 212, 255, 0.3);
  border-radius: 8px;
  background: rgba(6, 16, 40, 0.7);
}

.hud-card > span {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.15em;
  color: var(--muted);
}

.hud-card b {
  color: #9fd8ff;
  font-weight: 700;
}

.hud-bar {
  height: 8px;
  margin-top: 0.4rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.hud-bar i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--blue));
  transition: width 0.15s linear;
}

.hud-bar i.is-low {
  background: linear-gradient(90deg, #ff7a7a, #ff4d6d);
}

.canvas-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid rgba(0, 212, 255, 0.35);
  border-radius: 10px;
  overflow: hidden;
  background: #02040a;
  box-shadow: 0 0 40px rgba(0, 212, 255, 0.15);
}

#g-canvas {
  image-rendering: auto;
}

#g-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  padding: 1rem;
  text-align: center;
  background: rgba(2, 4, 10, 0.6);
  backdrop-filter: blur(8px);
}

.overlay h2 {
  font-family: var(--font-display);
  letter-spacing: 0.2em;
  color: var(--cyan);
}

.banner {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.45rem 1rem;
  border: 1px solid rgba(0, 212, 255, 0.5);
  border-radius: 6px;
  background: rgba(2, 4, 10, 0.7);
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  color: var(--cyan);
  white-space: nowrap;
}

.game-foot {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 1rem;
  margin-top: 0.6rem;
  align-items: start;
}

.g-log {
  list-style: none;
  max-height: 4.6em;
  overflow: hidden;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}
.hud-goal {
  color: #9fd8ff;
  margin-bottom: 0.4rem;
}
.hint {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.res-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.res-badge {
  display: inline-block;
  margin-top: 0.6rem;
  padding: 0.3rem 0.8rem;
  border: 1px solid rgba(255, 200, 80, 0.6);
  border-radius: 4px;
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  color: #ffd166;
}

.res-alert {
  max-width: 520px;
  margin: 3rem auto;
  padding: 1.5rem;
  border: 1px solid rgba(255, 120, 120, 0.5);
  border-radius: 8px;
  background: rgba(255, 80, 80, 0.08);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.res-panel {
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: 10px;
  padding: 1.1rem 1.3rem;
  background: rgba(6, 16, 40, 0.65);
  margin-bottom: 1.1rem;
}

.res-panel h2 {
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  color: var(--cyan);
  margin-bottom: 0.8rem;
}

.res-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.1rem;
}

.res-resumen {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.2rem 2rem;
  align-items: center;
  border-color: rgba(0, 212, 255, 0.5);
}

.res-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.8rem 1.6rem;
  border: 1px solid rgba(0, 212, 255, 0.4);
  border-radius: 10px;
}

.res-score span {
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.25em;
  color: var(--muted);
}

.res-score strong {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 2.6rem;
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(0, 212, 255, 0.5);
}

.res-estado {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.12em;
}
.res-estado.is-ok {
  color: #7dffb0;
}
.res-estado.is-bad {
  color: #ff8a8a;
}
.res-texto {
  color: var(--muted);
  line-height: 1.5;
  margin-top: 0.4rem;
}

.res-lista {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  line-height: 1.4;
}
.res-lista li.ok::before {
  content: "✔ ";
  color: #7dffb0;
}
.res-lista li.bad::before {
  content: "✖ ";
  color: #ff8a8a;
}

.res-dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem 1rem;
}
.res-dl dt {
  color: var(--muted);
}
.res-dl dd {
  text-align: right;
  font-family: var(--font-display);
  font-size: 0.78rem;
  color: #9fd8ff;
  align-self: center;
}

.res-decisiones {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.res-decisiones li {
  padding: 0.75rem 0.9rem;
  border-left: 3px solid;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  line-height: 1.45;
}
.res-decisiones li.ok {
  border-color: #7dffb0;
}
.res-decisiones li.bad {
  border-color: #ff8a8a;
}

.res-decisiones strong {
  display: block;
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  margin-bottom: 0.25rem;
}
.res-decisiones li.ok strong {
  color: #7dffb0;
}
.res-decisiones li.bad strong {
  color: #ff8a8a;
}

.ciencia-bloque {
  padding-bottom: 0.9rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid rgba(0, 212, 255, 0.12);
}
.ciencia-bloque:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}
.ciencia-bloque h3 {
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  margin-bottom: 0.4rem;
}
.ciencia-bloque p {
  line-height: 1.5;
  margin-bottom: 0.35rem;
}
.ciencia-bloque .fuente {
  font-size: 0.85rem;
  color: var(--muted);
}

.tag {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  margin-right: 0.4rem;
  border-radius: 4px;
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
}
.tag-cientifico {
  background: rgba(125, 255, 176, 0.15);
  color: #7dffb0;
}
.tag-estimacion {
  background: rgba(255, 209, 102, 0.15);
  color: #ffd166;
}
.tag-juego {
  background: rgba(157, 124, 255, 0.2);
  color: #c2b0ff;
}

.res-leyenda {
  margin-top: 0.9rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.res-acciones {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}
.res-acciones .btn {
  min-width: 220px;
}

.res-guardado {
  text-align: center;
  margin-top: 0.8rem;
  color: #7dffb0;
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
}

@media (max-width: 900px) {
  .res-grid,
  .res-decisiones {
    grid-template-columns: 1fr;
  }
  .res-resumen {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .game-foot {
    grid-template-columns: 1fr;
  }
}

[hidden] {
  display: none !important;
}

.start-panel {
  background: linear-gradient(
    160deg,
    rgba(10, 23, 51, 0.9),
    rgba(2, 4, 10, 0.95)
  );
  border: 1px solid rgba(0, 212, 255, 0.4);
  border-radius: 16px;
  padding: 3rem 4rem;
  box-shadow:
    0 0 50px rgba(0, 212, 255, 0.2),
    inset 0 0 20px rgba(0, 212, 255, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  animation: fadeIn 0.8s ease-out;
}

.start-panel h2 {
  font-family: var(--font-display);
  font-size: 2.5rem;
  letter-spacing: 0.2em;
  color: #ffffff;
  text-shadow: 0 0 20px var(--cyan);
  margin: 0;
}

.start-panel .hint {
  font-family: var(--font-body);
  font-size: 1.1rem;
  color: var(--cyan);
  letter-spacing: 0.1em;
  margin: 0;
}

.btn-launch {
  font-size: 1.2rem;
  padding: 1rem 3rem;
  letter-spacing: 0.3em;
  margin-top: 1rem;
}

/* ==========================================
   TECLAS DEL JUEGO
   ========================================== */
.keys-panel {
  margin-top: 0.6rem;
  padding: 0.5rem 1rem;
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: 12px;
  background: rgba(6, 16, 40, 0.72);
  backdrop-filter: blur(4px);
}

.keys-group {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.6rem 2.2rem;
}
.keys-panel[data-scene="space"] .keys-group[data-group="space"],
.keys-panel[data-scene="landing"] .keys-group[data-group="landing"],
.keys-panel[data-scene="surface"] .keys-group[data-group="surface"] {
  display: flex;
}

.key-block {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.key-label {
  margin-right: 0.3rem;
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.key-or {
  padding: 0 0.15rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.key-note {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.note-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-left: 0.8rem;
}

.note-icon {
  width: 30px;
  height: 30px;
  object-fit: contain;
  image-rendering: pixelated;
}

/* Tecla con relieve */
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 0.5rem;
  border: 1px solid rgba(0, 212, 255, 0.55);
  border-bottom-width: 4px;
  border-radius: 8px;
  background: linear-gradient(
    180deg,
    rgba(20, 44, 90, 0.95),
    rgba(8, 20, 48, 0.95)
  );
  color: #d8f4ff;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  user-select: none;
  transition:
    transform 0.06s ease,
    border-bottom-width 0.06s ease,
    background 0.06s ease,
    box-shadow 0.06s ease;
}

kbd.k-space {
  min-width: 96px;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
}

kbd.k-accent {
  border-color: #ffd166;
  color: #ffd166;
}

/* Se ilumina cuando la presionas de verdad */
kbd.pressed {
  transform: translateY(3px);
  border-bottom-width: 1px;
  background: linear-gradient(180deg, #00d4ff, #3a7bff);
  color: #02040a;
  box-shadow: 0 0 18px rgba(0, 212, 255, 0.8);
}
kbd.k-accent.pressed {
  background: linear-gradient(180deg, #ffd166, #ff9f43);
  box-shadow: 0 0 18px rgba(255, 209, 102, 0.8);
}

/* Cruz de flechas / WASD en forma de "T" invertida */
.cluster {
  display: inline-grid;
  grid-template-columns: repeat(3, 34px);
  grid-template-rows: repeat(2, 34px);
  gap: 3px;
}
.cluster kbd {
  min-width: 0;
  padding: 0;
}
.cluster .k-up {
  grid-column: 2;
  grid-row: 1;
}
.cluster .k-left {
  grid-column: 1;
  grid-row: 2;
}
.cluster .k-down {
  grid-column: 2;
  grid-row: 2;
}
.cluster .k-right {
  grid-column: 3;
  grid-row: 2;
}

@media (max-width: 700px) {
  kbd {
    min-width: 32px;
    height: 32px;
    font-size: 0.75rem;
  }
  .cluster {
    grid-template-columns: repeat(3, 32px);
    grid-template-rows: repeat(2, 32px);
  }
}

body:has(#screen-game:not([hidden])) .footer {
  display: none;
}

/* ==========================================
   JUEGO MÁS GRANDE: escenario a la izquierda,
   teclas y datos en una columna lateral
   ========================================== */
.game-screen {
  --side-w: 330px;
  --gap: 16px;
  /* el escenario crece hasta ocupar todo el alto o el ancho disponible */
  --stage-w: min(
    calc(98vw - var(--side-w) - var(--gap)),
    calc((100vh - 130px) * 16 / 9)
  );
  display: grid;
  grid-template-columns: var(--stage-w) var(--side-w);
  grid-template-rows: auto auto 1fr;
  column-gap: var(--gap);
  align-items: start;
  width: max-content;
  max-width: 98vw;
  margin-left: auto;
  margin-right: auto;
}
.game-screen[hidden] {
  display: none;
}

.game-screen .hud-game {
  grid-column: 1 / -1;
  width: 100%;
  margin: 0 0 0.7rem;
}
.game-screen .canvas-box {
  grid-column: 1;
  grid-row: 2 / span 2;
  width: 100%;
  margin: 0;
}
.game-screen .keys-panel {
  grid-column: 2;
  grid-row: 2;
  width: 100%;
  margin: 0;
  padding: 0.8rem 1rem;
}
.game-screen .game-foot {
  grid-column: 2;
  grid-row: 3;
  width: 100%;
  margin: 0.7rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.game-screen .game-foot > div {
  order: -1;
}
.game-screen .game-foot .btn {
  width: 100%;
}
.game-screen .g-log {
  max-height: 6.6em;
}

/* teclas en vertical dentro de la columna lateral */
.game-screen .keys-group {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.8rem;
}
.game-screen .key-block {
  flex-wrap: wrap;
  row-gap: 0.35rem;
}
.game-screen .key-label {
  flex-basis: 100%;
  margin: 0;
}
.game-screen .key-note {
  flex-wrap: wrap;
  row-gap: 0.4rem;
}
.game-screen .note-item {
  margin-left: 0;
  margin-right: 0.8rem;
}

/* etiqueta y valor del HUD nunca se pegan */
.hud-card > span {
  gap: 0.6rem;
}
.hud-card b {
  text-align: right;
}

/* pantallas estrechas: vuelve al diseño apilado */
@media (max-width: 1100px) {
  .game-screen {
    --stage-w: min(100%, max(560px, calc((100vh - 300px) * 16 / 9)));
    display: block;
    width: min(1800px, 98vw);
  }
  .game-screen .hud-game,
  .game-screen .canvas-box,
  .game-screen .keys-panel,
  .game-screen .game-foot {
    width: var(--stage-w);
    margin-left: auto;
    margin-right: auto;
  }
  .game-screen .hud-game {
    margin-bottom: 0.9rem;
  }
  .game-screen .keys-panel {
    margin-top: 0.6rem;
    padding: 0.5rem 1rem;
  }
  .game-screen .game-foot {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    margin-top: 0.6rem;
  }
  .game-screen .game-foot > div {
    order: 0;
  }
  .game-screen .game-foot .btn {
    width: auto;
  }
  .game-screen .keys-group {
    flex-direction: row;
    align-items: center;
  }
  .game-screen .key-label {
    flex-basis: auto;
    margin-right: 0.3rem;
  }
  .game-screen .g-log {
    max-height: 4.6em;
  }
}

/* ==========================================
   ALERTA DE LLEGADA + CUENTA ATRÁS
   ========================================== */
.arrival {
  --arr: #ffd166;
  --arr-glow: rgba(255, 209, 102, 0.35);
  position: absolute;
  top: 3.2rem;
  left: 50%;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: clamp(0.6rem, 0.9vw, 1rem);
  width: max-content;
  max-width: 70%;
  padding: clamp(0.4rem, 0.6vw, 0.65rem) clamp(0.7rem, 1vw, 1.1rem);
  border: 1px solid var(--arr);
  border-left-width: 4px;
  border-radius: 8px;
  background: linear-gradient(
    90deg,
    rgba(2, 10, 24, 0.9),
    rgba(6, 20, 44, 0.78)
  );
  box-shadow:
    0 0 26px var(--arr-glow),
    inset 0 0 18px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  pointer-events: none;
  transform: translateX(-50%);
  animation: arr-in 0.45s ease-out;
}
.arrival[hidden],
.countdown[hidden] {
  display: none;
}
.arrival[data-level="urgent"] {
  --arr: #ff5a5a;
  --arr-glow: rgba(255, 90, 90, 0.5);
  animation:
    arr-in 0.45s ease-out,
    arr-pulse 0.55s ease-in-out 0.45s infinite alternate;
}

.arrival-icon {
  position: relative;
  flex: none;
  width: clamp(1.6rem, 2.1vw, 2.3rem);
  aspect-ratio: 1;
}
.arrival-icon i {
  position: absolute;
  inset: 0;
  border: 2px solid var(--arr);
  border-radius: 50%;
  opacity: 0;
  animation: arr-ping 1.8s ease-out infinite;
}
.arrival-icon i:nth-child(2) {
  animation-delay: 0.6s;
}
.arrival-icon i:nth-child(3) {
  animation-delay: 1.2s;
}
.arrival-icon::after {
  content: "";
  position: absolute;
  inset: 38%;
  border-radius: 50%;
  background: var(--arr);
  box-shadow: 0 0 12px var(--arr);
}
.arrival[data-level="urgent"] .arrival-icon i {
  animation-duration: 0.9s;
}

.arrival-body {
  flex: 1;
  min-width: 0;
  /* el título nunca se mete debajo del contador */
  overflow: hidden;
}
.arrival-kicker {
  font-family: var(--font-display);
  font-size: clamp(0.48rem, 0.55vw, 0.62rem);
  letter-spacing: 0.25em;
  color: var(--arr);
}
.arrival-title {
  margin: 0.1rem 0 0.1rem;
  font-family: var(--font-display);
  font-size: clamp(0.65rem, 0.85vw, 0.95rem);
  letter-spacing: 0.06em;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.arrival-sub {
  font-size: clamp(0.7rem, 0.8vw, 0.9rem);
  color: var(--muted);
}
.arrival-bar {
  height: 4px;
  margin-top: 0.35rem;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.arrival-bar i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--arr);
  box-shadow: 0 0 8px var(--arr);
  transition: width 0.2s linear;
}

.arrival-time {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-left: clamp(0.3rem, 0.8vw, 1rem);
  padding-left: clamp(0.7rem, 1vw, 1.1rem);
  border-left: 1px solid rgba(255, 255, 255, 0.15);
}
.arrival-label {
  font-family: var(--font-display);
  font-size: clamp(0.45rem, 0.5vw, 0.58rem);
  letter-spacing: 0.2em;
  white-space: nowrap;
  color: var(--muted);
}
.arrival-time b {
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 1.7vw, 1.9rem);
  line-height: 1.1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--arr);
  text-shadow: 0 0 14px var(--arr-glow);
}

/* Números grandes de la cuenta final: 5, 4, 3, 2, 1 */
.countdown {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.countdown span {
  font-family: var(--font-display);
  font-size: clamp(5rem, 13vw, 11rem);
  line-height: 1;
  color: rgba(255, 90, 90, 0.55);
  text-shadow: 0 0 40px rgba(255, 90, 90, 0.6);
}
.countdown span.pop {
  animation: count-pop 0.95s ease-out;
}
.countdown small {
  font-family: var(--font-display);
  font-size: clamp(0.7rem, 1.1vw, 1.2rem);
  letter-spacing: 0.4em;
  color: rgba(255, 200, 200, 0.7);
}

@keyframes arr-in {
  from {
    opacity: 0;
    transform: translate(-50%, -14px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}
@keyframes arr-pulse {
  from {
    box-shadow:
      0 0 14px var(--arr-glow),
      inset 0 0 18px rgba(0, 0, 0, 0.5);
  }
  to {
    box-shadow:
      0 0 40px var(--arr-glow),
      inset 0 0 24px rgba(255, 90, 90, 0.18);
  }
}
@keyframes arr-ping {
  0% {
    transform: scale(0.35);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.15);
    opacity: 0;
  }
}
@keyframes count-pop {
  0% {
    transform: scale(1.7);
    opacity: 0;
  }
  25% {
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 0.45;
  }
}

@media (prefers-reduced-motion: reduce) {
  .arrival,
  .arrival[data-level="urgent"],
  .arrival-icon i,
  .countdown span.pop {
    animation: none;
  }
  .arrival-icon i:first-child {
    opacity: 0.6;
  }
}

/* ===== FASE 06: MISSION DEBRIEF ===== */
.report-screen {
  position: relative;
  z-index: 2;
  width: min(1100px, 94vw);
  margin: 0 auto;
  padding: 2rem 0 4rem;
  max-height: 100vh;
  overflow-y: auto;
}
.report-screen[hidden],
#rp-vacio[hidden],
#report-doc[hidden] {
  display: none !important;
}
.rp-top {
  text-align: center;
  margin-bottom: 1rem;
}
.rp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  margin: 0 0 1.2rem;
}
.rp-actions .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.rp-doc {
  display: grid;
  gap: 1rem;
}
.rp-head {
  background: rgba(5, 8, 17, 0.93);
  border: 1px solid var(--borde-activo);
  padding: 1rem 1.2rem;
  text-align: center;
}
.rp-head h2 {
  font-family: var(--font-display);
  color: var(--cyan);
  letter-spacing: 0.15em;
  margin: 0 0 0.3rem;
}
.rp-head small {
  color: var(--texto-suave);
}
.rp-sim {
  background: rgba(245, 158, 11, 0.15);
  border: 2px dashed var(--warn);
  color: var(--warn);
  font-family: var(--font-display);
  text-align: center;
  padding: 0.7rem;
  letter-spacing: 0.12em;
}
.rp-sec {
  background: rgba(5, 8, 17, 0.93);
  border: 1px solid var(--borde);
  padding: 1rem 1.2rem;
}
.rp-sec h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--acento);
  letter-spacing: 0.1em;
  margin: 0 0 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.rp-sec h2 span {
  background: var(--acento);
  color: #04101c;
  padding: 0.1rem 0.5rem;
}
.rp-sec h3 {
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  margin: 1rem 0 0.5rem;
  color: var(--texto);
}
.rp-sec h3 small {
  color: var(--texto-suave);
  font-weight: 400;
}
.rp-ov {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.2rem;
  align-items: start;
}
.rp-badge {
  border: 2px solid;
  padding: 1rem 1.4rem;
  text-align: center;
  font-family: var(--font-display);
  min-width: 170px;
}
.rp-badge b {
  display: block;
  font-size: 2.4rem;
  line-height: 1.1;
}
.rp-badge.is-success {
  color: var(--ok);
  background: rgba(34, 197, 94, 0.1);
}
.rp-badge.is-partial {
  color: var(--warn);
  background: rgba(245, 158, 11, 0.1);
}
.rp-badge.is-failed {
  color: var(--err);
  background: rgba(239, 68, 68, 0.1);
}
.rp-cards,
.rp-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.7rem;
}
.rp-card,
.rp-metric {
  background: var(--panel-card);
  border: 1px solid var(--borde);
  padding: 0.7rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.rp-card .tag,
.rp-metric .tag {
  align-self: flex-start;
}
.rp-k,
.rp-metric span {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--texto-suave);
}
.rp-v,
.rp-metric strong {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--texto);
}
.rp-card small,
.rp-note {
  color: var(--texto-suave);
  font-size: 0.9rem;
}
.rp-bar {
  height: 8px;
  background: #0b1630;
  border: 1px solid var(--borde);
}
.rp-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
}
.rp-chart {
  display: grid;
  gap: 0.3rem;
}
.rp-brow {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 1.2fr 52px;
  gap: 0.6rem;
  align-items: center;
  font-size: 0.9rem;
}
.rp-brow b {
  text-align: right;
  font-family: var(--font-display);
}
.rp-brow.neg i {
  background: var(--err);
}
.rp-list {
  display: grid;
  gap: 0.4rem;
  padding-left: 1.1rem;
}
.rp-time {
  list-style: none;
  margin: 0;
  padding: 0 0 0 1rem;
  border-left: 2px solid var(--borde-activo);
  display: grid;
  gap: 0.5rem;
}
.rp-time li {
  display: grid;
  grid-template-columns: 60px 200px 1fr;
  gap: 0.6rem;
  align-items: baseline;
}
.rp-time time {
  font-family: var(--fuente-pixel);
  color: var(--cyan);
}
.rp-time b {
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
}
.rp-time .t-crash b,
.rp-time .t-damage b {
  color: var(--err);
}
.rp-time .t-landing b,
.rp-time .t-transmit b {
  color: var(--ok);
}
.rp-cml-r {
  font-family: var(--font-display);
  color: var(--cyan);
}
.rp-cml {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.7rem;
}
.rp-cml li {
  border: 1px solid var(--borde);
  background: var(--panel-card);
  padding: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.rp-cml li.met {
  border-color: var(--ok);
}
.rp-cml li.now {
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.6);
  border-color: var(--acento);
}
.rp-cml em {
  font-style: normal;
  font-size: 0.75rem;
  color: var(--texto-suave);
}
.rp-cml li.met em {
  color: var(--ok);
}
.rp-refs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.7rem;
}
.rp-refs a {
  color: var(--cyan);
  font-family: var(--font-display);
  font-size: 0.85rem;
  word-break: break-word;
}
.rp-refs p {
  margin: 0.2rem 0 0;
  color: var(--texto-suave);
}
@media (max-width: 700px) {
  .rp-ov {
    grid-template-columns: 1fr;
  }
  .rp-time li {
    grid-template-columns: 52px 1fr;
  }
  .rp-time li span {
    grid-column: 1 / -1;
  }
  .rp-brow {
    grid-template-columns: 1fr 44px;
  }
  .rp-brow .rp-bar {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}
@media print {
  body > *:not(#screen-report) {
    display: none !important;
  }
  body {
    background: #fff !important;
  }
  #screen-report {
    max-height: none;
    overflow: visible;
    width: 100%;
    padding: 0;
  }
  .rp-actions,
  .badge-fase {
    display: none !important;
  }
  #screen-report,
  #screen-report * {
    color: #111 !important;
    background: #fff !important;
    box-shadow: none !important;
    border-color: #999 !important;
  }
  #screen-report .rp-bar i {
    background: #444 !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .rp-sec,
  .rp-card,
  .rp-metric {
    break-inside: avoid;
  }
}
:root {
  --bg-0: #02040a;
  --bg-1: #051024;
  --cyan: #00d4ff;
  --blue: #3d7bff;
  --violet: #8a2be2;
  --text: #e6f4ff;
  --muted: #6d86a8;
  --font-display: "Orbitron", "Segoe UI", sans-serif;
  --font-body: "Rajdhani", "Segoe UI", sans-serif;

  --ship-speed: 24s;
  --ship-angle-out: -35deg;
  --ship-angle-in: 145deg;

  --bg-dark: #050811;
  --panel: rgba(8, 14, 28, 0.76);
  --panel-card: rgba(13, 23, 44, 0.84);
  --border: #1e355d;
  --border-active: #38bdf8;
  --text-main: #e6f1ff;
  --text-soft: #7f9bb8;
  --accent: #38bdf8;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --font-pixel: "Courier New", Courier, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100vh;
  margin: 0;
  padding: 0;
  background-color: var(--bg-0);
  overflow-x: clip;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background: radial-gradient(
    circle at 50% 50%,
    var(--bg-1) 0%,
    var(--bg-0) 80%
  );
  display: flex;
  flex-direction: column;
  position: relative;
}

.stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.stars-far {
  background-image:
    radial-gradient(1px 1px at 10% 20%, #fff, transparent),
    radial-gradient(1px 1px at 30% 70%, #cfe8ff, transparent),
    radial-gradient(1px 1px at 60% 15%, #fff, transparent),
    radial-gradient(1px 1px at 80% 55%, #aed4ff, transparent),
    radial-gradient(1px 1px at 45% 90%, #fff, transparent),
    radial-gradient(1px 1px at 92% 85%, #fff, transparent);
  background-size: 400px 400px;
  animation: drift 150s linear infinite;
  opacity: 0.4;
}

.stars-near {
  background-image:
    radial-gradient(2px 2px at 20% 40%, #fff, transparent),
    radial-gradient(2px 2px at 70% 25%, #9fd8ff, transparent),
    radial-gradient(2px 2px at 85% 75%, #fff, transparent),
    radial-gradient(2px 2px at 40% 80%, #ffffff, transparent);
  background-size: 600px 600px;
  animation: drift 100s linear infinite;
  opacity: 0.7;
}

.nebula {
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(
      circle at 30% 40%,
      rgba(138, 43, 226, 0.15),
      transparent 50%
    ),
    radial-gradient(circle at 70% 60%, rgba(0, 212, 255, 0.1), transparent 50%);
  filter: blur(60px);
  pointer-events: none;
  z-index: 0;
}

@keyframes drift {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-600px);
  }
}

.earth {
  position: absolute;
  left: -40vw;
  bottom: -55vh;
  width: 155vw;
  max-width: 1500px;
  height: auto;
  image-rendering: pixelated;
  opacity: 0.95;
  filter: drop-shadow(0 0 40px rgba(0, 150, 255, 0.3));
  pointer-events: none;
  z-index: 1;
}

.moon {
  position: absolute;
  top: 8%;
  right: 8%;
  width: clamp(120px, 15vw, 250px);
  height: auto;
  image-rendering: pixelated;
  opacity: 0.85;
  filter: drop-shadow(0 0 35px rgba(255, 255, 255, 0.2));
  pointer-events: none;
  z-index: 1;
  animation: floatMoon 6s ease-in-out infinite alternate;
}

@keyframes floatMoon {
  from {
    transform: translateY(0px);
  }
  to {
    transform: translateY(-15px);
  }
}

.sun {
  display: none;
  position: absolute;
  top: -1%;
  left: 10%;
  width: clamp(150px, 35vw, 250px);
  height: auto;
  image-rendering: pixelated;
  opacity: 0.85;
  filter: drop-shadow(0 0 60px rgba(255, 140, 0, 0.6));
  pointer-events: none;
  z-index: 1;
  animation: pulseSun 8s ease-in-out infinite alternate;
}

body:has(#screen-mission:not([hidden])) .sun,
body:has(#screen-ship:not([hidden])) .sun {
  display: block;
}

@keyframes pulseSun {
  from {
    transform: scale(1);
    filter: drop-shadow(0 0 50px rgba(255, 140, 0, 0.5));
  }
  to {
    transform: scale(1.05);
    filter: drop-shadow(0 0 80px rgba(255, 180, 0, 0.8));
  }
}

.ship {
  position: absolute;
  top: 0;
  left: 0;
  width: 200px;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 15px rgba(0, 212, 255, 0.8));
  pointer-events: none;
  z-index: 2;
  animation: flyDiagonal var(--ship-speed) linear infinite;
  will-change: transform;
}

@keyframes flyDiagonal {
  0% {
    transform: translate(-20vw, 110vh) rotate(var(--ship-angle-out));
  }
  48% {
    transform: translate(120vw, -20vh) rotate(var(--ship-angle-out));
  }
  50% {
    transform: translate(120vw, -20vh) rotate(var(--ship-angle-in));
  }
  98% {
    transform: translate(-20vw, 110vh) rotate(var(--ship-angle-in));
  }
  100% {
    transform: translate(-20vw, 110vh)
      rotate(calc(var(--ship-angle-in) + 180deg));
  }
}

.menu {
  position: relative;
  z-index: 3;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  padding: 2rem;
  animation: fadeIn 1.2s ease-out both;
  margin-left: 10vw;
}

.title-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.logo {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(4rem, 11vw, 8rem);
  letter-spacing: 0.1em;
  background: linear-gradient(90deg, #00e5ff 0%, #3d7bff 50%, #9c5cff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 25px rgba(0, 212, 255, 0.6));
  line-height: 1;
}

.subtitle {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.2rem, 3vw, 2rem);
  letter-spacing: 0.5em;
  color: #e6f4ff;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
  margin-right: -0.5em;
}

.event {
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.35em;
  color: var(--cyan);
  opacity: 0.9;
  margin-top: 0.5rem;
}

.tagline {
  font-size: 1.25rem;
  color: var(--muted);
  line-height: 1.6;
  max-width: 480px;
  margin-bottom: 1rem;
  font-weight: 500;
  text-align: center;
}

.buttons {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  width: min(340px, 80vw);
}

.btn {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.25em;
  padding: 1.1rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 4px;
}

.btn-primary {
  background: linear-gradient(90deg, #00d4ff 0%, #3d7bff 100%);
  color: #02040a;
  border: 2px solid #00d4ff;
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 0 35px rgba(0, 212, 255, 0.8);
  color: #ffffff;
}

.btn-secondary {
  background: rgba(0, 212, 255, 0.05);
  color: var(--text);
  border: 1px solid #3d7bff;
  box-shadow: inset 0 0 10px rgba(0, 212, 255, 0.1);
}

.btn-secondary:hover {
  background: rgba(0, 212, 255, 0.15);
  border-color: var(--cyan);
  transform: translateY(-2px);
}

select.btn {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  text-align: center;
  text-align-last: center;
  background-image: url('data:image/svg+xml;utf8,<svg fill="%2300d4ff" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
  outline: none;
}
select.btn option {
  background-color: var(--bg-1);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
}
select.btn:hover {
  cursor: pointer;
}
a.btn {
  display: flex;
  justify-content: center;
  align-items: center;
  text-decoration: none;
}

.footer {
  position: relative;
  text-align: center;
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.4em;
  color: rgba(109, 134, 168, 0.5);
  z-index: 3;
  padding: 1.5rem;
  margin-top: auto;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 4, 10, 0.85);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.modal[hidden] {
  display: none;
}
.modal-card {
  background: linear-gradient(160deg, #0a1733, #050a18);
  border: 1px solid rgba(0, 212, 255, 0.4);
  border-radius: 12px;
  padding: 2.5rem;
  width: min(480px, 90vw);
  box-shadow: 0 0 50px rgba(0, 212, 255, 0.25);
  animation: fadeIn 0.3s ease-out both;
}
.modal-card h3 {
  font-family: var(--font-display);
  letter-spacing: 0.25em;
  color: var(--cyan);
  margin-bottom: 1.2rem;
  text-align: center;
}
.modal-card ol {
  padding-left: 1.5rem;
  margin-bottom: 2rem;
  line-height: 1.8;
  font-size: 1.1rem;
  color: var(--text);
}
.modal-card li + li {
  margin-top: 0.5rem;
}
.modal-card .btn {
  width: 100%;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.menu[hidden],
.mission[hidden] {
  display: none;
}

.mission {
  position: relative;
  z-index: 3;
  width: min(760px, 94vw);
  margin: 0 auto;
  padding: 2.5rem 0 3rem;
  animation: fadeIn 0.8s ease-out both;
}
.mission-header {
  text-align: center;
  margin-bottom: 1.8rem;
}
.mission-title {
  outline: none;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(1.6rem, 5vw, 2.6rem);
  letter-spacing: 0.15em;
  background: linear-gradient(90deg, #00e5ff, #3d7bff 50%, #9c5cff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px rgba(0, 212, 255, 0.5));
}
.mission-sub {
  color: var(--muted);
  font-size: 1.15rem;
  margin-top: 0.4rem;
}
.mission-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.panel {
  background: rgba(10, 23, 51, 0.7);
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: 12px;
  padding: 1.2rem 1.3rem 1.3rem;
  backdrop-filter: blur(6px);
}
.panel legend {
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  color: var(--cyan);
  padding: 0 0.6rem;
}
.panel input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.destinations {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem;
}
.destination {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  text-align: center;
  padding: 1rem 0.6rem;
  border: 1px solid rgba(61, 123, 255, 0.35);
  border-radius: 10px;
  cursor: pointer;
  transition:
    border-color 0.25s,
    background 0.25s,
    box-shadow 0.25s;
}
.destination strong {
  font-family: var(--font-display);
  letter-spacing: 0.15em;
  font-size: 0.95rem;
}
.destination small,
.difficulty small,
.hint {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.3;
}
.destination:hover,
.difficulty:hover {
  border-color: var(--cyan);
}
.destination:has(input:checked),
.difficulty:has(input:checked) {
  border-color: var(--cyan);
  background: rgba(0, 212, 255, 0.1);
  box-shadow: 0 0 22px rgba(0, 212, 255, 0.35);
}
.destination:has(input:focus-visible),
.difficulty:has(input:focus-visible) {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}
.destination-icon {
  width: 64px;
  height: 64px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.15));
  transition:
    transform 0.3s ease,
    filter 0.3s ease;
}
.destination:has(input:checked) .destination-icon {
  transform: scale(1.1);
  filter: drop-shadow(0 0 15px var(--cyan));
}

.panel select,
.panel input[type="text"] {
  width: 100%;
  font-family: var(--font-body);
  font-size: 1.15rem;
  color: var(--text);
  background: rgba(2, 4, 10, 0.7);
  border: 1px solid #3d7bff;
  border-radius: 8px;
  padding: 0.75rem 1rem;
}
.panel select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.panel select:focus-visible,
.panel input[type="text"]:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}
.hint {
  margin-top: 0.6rem;
  min-height: 1.3em;
}

.difficulties {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem;
}
.difficulty {
  display: block;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(61, 123, 255, 0.35);
  border-radius: 10px;
  cursor: pointer;
  transition:
    border-color 0.25s,
    background 0.25s,
    box-shadow 0.25s;
}
.difficulty strong {
  display: block;
  font-family: var(--font-display);
  letter-spacing: 0.12em;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.name-row {
  display: flex;
  gap: 0.8rem;
}
.name-row .btn {
  padding: 0.7rem 1.2rem;
  font-size: 0.8rem;
}
.error {
  color: #ff6b81;
  font-size: 1.05rem;
  margin-top: 0.6rem;
}

.actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  margin-top: 0.4rem;
}
.actions .btn-primary {
  flex: 1;
  max-width: 320px;
}

.ship-screen[hidden] {
  display: none;
}
.ship-screen {
  position: relative;
  z-index: 3;
  flex: 1;
  padding: 16px 24px 28px;
  font-family: var(--font-pixel);
  font-weight: bold;
  color: var(--text-main);
  animation: fadeIn 0.8s ease-out both;
}
.ship-screen h1 {
  font-family: var(--font-pixel);
  font-size: 1.2rem;
  margin-top: 3px;
  letter-spacing: 1px;
}
.ship-screen h2 {
  font-family: var(--font-pixel);
  font-size: 0.92rem;
  color: var(--accent);
}
.ship-screen h3 {
  font-family: var(--font-pixel);
  font-size: 0.76rem;
  color: var(--accent);
  margin-bottom: 6px;
}

.hud-top {
  max-width: 1120px;
  margin: 0 auto 14px;
  background: var(--panel);
  border: 2px solid var(--border);
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  position: relative;
  z-index: 2;
}
.phase-badge {
  font-size: 0.72rem;
  color: var(--accent);
  letter-spacing: 1px;
}
.hud-budget {
  min-width: 240px;
}
.label-mini {
  font-size: 0.68rem;
  color: var(--text-soft);
  display: block;
}
.hud-budget strong {
  display: block;
  margin: 3px 0 6px;
  font-size: 0.9rem;
  color: var(--accent);
}

.hangar-grid {
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  gap: 16px;
  align-items: stretch;
  position: relative;
  z-index: 2;
}
.pixel-box {
  background: var(--panel);
  border: 2px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  backdrop-filter: blur(4px);
}
.box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.sub-hint {
  font-size: 0.68rem;
  color: var(--text-soft);
}

.subsystems-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.group-title {
  font-size: 0.72rem;
  color: var(--text-soft);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}
.part-card {
  position: relative;
  background: var(--panel-card);
  border: 2px solid var(--border);
  padding: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  color: var(--text-main);
  font-family: var(--font-pixel);
}
.part-card:hover {
  border-color: var(--accent);
}
.part-card.active {
  border-color: var(--border-active);
  background: rgba(16, 36, 69, 0.9);
  box-shadow: inset 0 0 0 1px var(--border-active);
}
.part-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.part-canvas-wrap {
  position: relative;
  width: 78px;
  height: 64px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: rgba(6, 11, 23, 0.85);
  overflow: hidden;
}
.part-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  display: block;
}
.part-name {
  font-size: 0.78rem;
  line-height: 1.2;
}
.part-stats {
  font-size: 0.68rem;
  color: var(--accent);
  margin-top: 2px;
}
.part-desc {
  font-size: 0.68rem;
  color: var(--text-soft);
  line-height: 1.3;
  font-weight: normal;
}

.viewer-wrap {
  position: relative;
  border: 1px solid var(--border);
  background: rgba(5, 10, 22, 0.75);
  min-height: 550px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
  overflow: hidden;
}

.telemetry-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.row-text {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  margin-bottom: 4px;
}
.pixel-bar {
  width: 100%;
  height: 10px;
  background: rgba(5, 10, 22, 0.88);
  border: 1px solid var(--border);
  padding: 1px;
}
.bar-fill {
  height: 100%;
  width: 0%;
  transition: width 0.15s steps(8);
}
.bar-fill.ok {
  background: var(--ok);
}
.bar-fill.warn {
  background: var(--warn);
}
.bar-fill.err {
  background: var(--err);
}

.pixel-alert {
  border: 1px solid var(--ok);
  background: rgba(34, 197, 94, 0.12);
  color: #86efac;
  padding: 8px 10px;
  font-size: 0.72rem;
  line-height: 1.35;
}
.pixel-alert.err {
  border-color: var(--err);
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
}

.consequences-box {
  background: var(--panel-card);
  border: 1px solid var(--border);
  padding: 10px;
}
.pixel-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: normal;
}
.pixel-list li::before {
  content: "> ";
  color: var(--accent);
  font-weight: bold;
}

.btn-pixel {
  width: 100%;
  padding: 10px;
  border: 2px solid var(--border-active);
  background: rgba(7, 19, 38, 0.92);
  color: var(--accent);
  font-family: var(--font-pixel);
  font-size: 0.8rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-pixel:hover:not(:disabled) {
  background: var(--accent);
  color: #04101f;
}
.btn-pixel:disabled {
  background: #1e293b;
  border-color: #475569;
  color: #64748b;
  cursor: not-allowed;
}

.json-box summary {
  cursor: pointer;
  font-size: 0.7rem;
  color: var(--text-soft);
}
.json-box pre {
  margin-top: 6px;
  background: rgba(5, 10, 22, 0.9);
  border: 1px solid var(--border);
  padding: 8px;
  font-size: 0.65rem;
  font-weight: normal;
  overflow-x: auto;
  color: #cbd5e1;
}

#ship-composition {
  position: relative;
  width: 100%;
  max-width: 450px;
  height: 550px;
  margin: 0 auto;
  display: block;
}
.ship-part {
  position: absolute;
  image-rendering: pixelated;
  object-fit: contain;
}
.part-rocket {
  width: 20%;
  top: 55%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
}
.part-engine {
  width: 35%;
  bottom: 0%;
  left: 25%;
  transform: translateX(-50%);
  z-index: 5;
}
.part-energy {
  width: 25%;
  top: 40%;
  left: -1%;
  z-index: 4;
}
.part-communication {
  width: 25%;
  top: 5%;
  right: -1%;
  z-index: 4;
}
.part-instrument {
  width: 25%;
  bottom: 5%;
  right: -1%;
  z-index: 4;
}

@media (max-width: 1100px) {
  .ship-screen {
    padding: 14px;
  }
}
@media (max-width: 960px) {
  .hangar-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 900px) {
  .menu {
    margin-left: 0;
    padding: 2rem 1rem;
    gap: 1.2rem;
  }
  .logo {
    font-size: clamp(3rem, 15vw, 5rem);
  }
  .subtitle {
    font-size: clamp(0.9rem, 4vw, 1.2rem);
    letter-spacing: 0.2em;
    margin-right: 0;
  }
  .event {
    font-size: 0.65rem;
    letter-spacing: 0.15em;
  }
  .tagline {
    font-size: 1rem;
    padding: 0 1rem;
  }
  .buttons {
    width: 100%;
    max-width: 320px;
  }
  .btn {
    letter-spacing: 0.1em;
    font-size: 0.9rem;
    padding: 1rem;
  }
  .earth {
    width: 150vw;
    left: -75vw;
    bottom: -10vh;
    opacity: 0.3;
  }
  .moon {
    width: 100px;
    top: 5%;
    right: -2%;
    opacity: 0.3;
    animation: none;
  }
  .sun {
    width: 200px;
    top: -1%;
    left: -10%;
    opacity: 0.3;
    animation: none;
  }
  .ship {
    display: none;
  }
  .footer {
    font-size: 0.55rem;
    letter-spacing: 0.2em;
    padding: 1rem;
  }
}
@media (max-width: 640px) {
  .destinations,
  .difficulties {
    grid-template-columns: 1fr;
  }
  .destination {
    flex-direction: row;
    text-align: left;
    gap: 0.9rem;
  }
  .destination .destination-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
  }
  .destination strong {
    min-width: 6.5rem;
  }
  .name-row,
  .actions {
    flex-direction: column;
  }
  .actions .btn-primary {
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

.game-screen,
.results-screen {
  position: relative;
  z-index: 2;
  width: min(1100px, 94vw);
  margin: 0 auto;
  padding: 2rem 0 4rem;
  max-height: 100vh;
  overflow-y: auto;
}

.game-screen {
  max-height: none;
  overflow: visible;
}

.game-screen {
  --stage-w: min(100%, max(560px, calc((100vh - 300px) * 16 / 9)));
  width: min(1800px, 98vw);
  padding: 0.8rem 0 0.4rem;
}
.game-screen .hud-game,
.game-screen .canvas-box,
.game-screen .keys-panel,
.game-screen .game-foot {
  width: var(--stage-w);
  margin-left: auto;
  margin-right: auto;
}

.game-screen[hidden],
.results-screen[hidden],
#r-no-run[hidden],
#r-content[hidden],
#g-start[hidden],
#g-banner[hidden],
#hud-rover[hidden],
.res-badge[hidden] {
  display: none !important;
}

.hud-game {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.7rem;
  margin-bottom: 0.9rem;
}

.hud-card {
  padding: 0.6rem 0.8rem;
  border: 1px solid rgba(0, 212, 255, 0.3);
  border-radius: 8px;
  background: rgba(6, 16, 40, 0.7);
}

.hud-card > span {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.15em;
  color: var(--muted);
}

.hud-card b {
  color: #9fd8ff;
  font-weight: 700;
}

.hud-bar {
  height: 8px;
  margin-top: 0.4rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.hud-bar i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--blue));
  transition: width 0.15s linear;
}

.hud-bar i.is-low {
  background: linear-gradient(90deg, #ff7a7a, #ff4d6d);
}

.canvas-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid rgba(0, 212, 255, 0.35);
  border-radius: 10px;
  overflow: hidden;
  background: #02040a;
  box-shadow: 0 0 40px rgba(0, 212, 255, 0.15);
}

#g-canvas {
  image-rendering: auto;
}

#g-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  padding: 1rem;
  text-align: center;
  background: rgba(2, 4, 10, 0.6);
  backdrop-filter: blur(8px);
}

.overlay h2 {
  font-family: var(--font-display);
  letter-spacing: 0.2em;
  color: var(--cyan);
}

.banner {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.45rem 1rem;
  border: 1px solid rgba(0, 212, 255, 0.5);
  border-radius: 6px;
  background: rgba(2, 4, 10, 0.7);
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  color: var(--cyan);
  white-space: nowrap;
}

.game-foot {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 1rem;
  margin-top: 0.6rem;
  align-items: start;
}

.g-log {
  list-style: none;
  max-height: 4.6em;
  overflow: hidden;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}
.hud-goal {
  color: #9fd8ff;
  margin-bottom: 0.4rem;
}
.hint {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.res-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.res-badge {
  display: inline-block;
  margin-top: 0.6rem;
  padding: 0.3rem 0.8rem;
  border: 1px solid rgba(255, 200, 80, 0.6);
  border-radius: 4px;
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  color: #ffd166;
}

.res-alert {
  max-width: 520px;
  margin: 3rem auto;
  padding: 1.5rem;
  border: 1px solid rgba(255, 120, 120, 0.5);
  border-radius: 8px;
  background: rgba(255, 80, 80, 0.08);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.res-panel {
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: 10px;
  padding: 1.1rem 1.3rem;
  background: rgba(6, 16, 40, 0.65);
  margin-bottom: 1.1rem;
}

.res-panel h2 {
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  color: var(--cyan);
  margin-bottom: 0.8rem;
}

.res-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.1rem;
}

.res-summary {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.2rem 2rem;
  align-items: center;
  border-color: rgba(0, 212, 255, 0.5);
}

.res-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.8rem 1.6rem;
  border: 1px solid rgba(0, 212, 255, 0.4);
  border-radius: 10px;
}

.res-score span {
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.25em;
  color: var(--muted);
}

.res-score strong {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 2.6rem;
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(0, 212, 255, 0.5);
}

.res-status {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.12em;
}
.res-status.is-ok {
  color: #7dffb0;
}
.res-status.is-bad {
  color: #ff8a8a;
}
.res-text {
  color: var(--muted);
  line-height: 1.5;
  margin-top: 0.4rem;
}

.res-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  line-height: 1.4;
}
.res-list li.ok::before {
  content: "✔ ";
  color: #7dffb0;
}
.res-list li.bad::before {
  content: "✖ ";
  color: #ff8a8a;
}

.res-dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.45rem 1rem;
}
.res-dl dt {
  color: var(--muted);
}
.res-dl dd {
  text-align: right;
  font-family: var(--font-display);
  font-size: 0.78rem;
  color: #9fd8ff;
  align-self: center;
}

.res-decisions {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.res-decisions li {
  padding: 0.75rem 0.9rem;
  border-left: 3px solid;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  line-height: 1.45;
}
.res-decisions li.ok {
  border-color: #7dffb0;
}
.res-decisions li.bad {
  border-color: #ff8a8a;
}

.res-decisions strong {
  display: block;
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  margin-bottom: 0.25rem;
}
.res-decisions li.ok strong {
  color: #7dffb0;
}
.res-decisions li.bad strong {
  color: #ff8a8a;
}

.science-block {
  padding-bottom: 0.9rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid rgba(0, 212, 255, 0.12);
}
.science-block:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}
.science-block h3 {
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  margin-bottom: 0.4rem;
}
.science-block p {
  line-height: 1.5;
  margin-bottom: 0.35rem;
}
.science-block .source {
  font-size: 0.85rem;
  color: var(--muted);
}

.tag {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  margin-right: 0.4rem;
  border-radius: 4px;
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
}
.tag-scientific {
  background: rgba(125, 255, 176, 0.15);
  color: #7dffb0;
}
.tag-estimate {
  background: rgba(255, 209, 102, 0.15);
  color: #ffd166;
}
.tag-game {
  background: rgba(157, 124, 255, 0.2);
  color: #c2b0ff;
}

.res-legend {
  margin-top: 0.9rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.res-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}
.res-actions .btn {
  min-width: 220px;
}

.res-saved {
  text-align: center;
  margin-top: 0.8rem;
  color: #7dffb0;
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
}

@media (max-width: 900px) {
  .res-grid,
  .res-decisions {
    grid-template-columns: 1fr;
  }
  .res-summary {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .game-foot {
    grid-template-columns: 1fr;
  }
}

[hidden] {
  display: none !important;
}

.start-panel {
  background: linear-gradient(
    160deg,
    rgba(10, 23, 51, 0.9),
    rgba(2, 4, 10, 0.95)
  );
  border: 1px solid rgba(0, 212, 255, 0.4);
  border-radius: 16px;
  padding: 3rem 4rem;
  box-shadow:
    0 0 50px rgba(0, 212, 255, 0.2),
    inset 0 0 20px rgba(0, 212, 255, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  animation: fadeIn 0.8s ease-out;
}

.start-panel h2 {
  font-family: var(--font-display);
  font-size: 2.5rem;
  letter-spacing: 0.2em;
  color: #ffffff;
  text-shadow: 0 0 20px var(--cyan);
  margin: 0;
}

.start-panel .hint {
  font-family: var(--font-body);
  font-size: 1.1rem;
  color: var(--cyan);
  letter-spacing: 0.1em;
  margin: 0;
}

.btn-launch {
  font-size: 1.2rem;
  padding: 1rem 3rem;
  letter-spacing: 0.3em;
  margin-top: 1rem;
}

.keys-panel {
  margin-top: 0.6rem;
  padding: 0.5rem 1rem;
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: 12px;
  background: rgba(6, 16, 40, 0.72);
  backdrop-filter: blur(4px);
}

.keys-group {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.6rem 2.2rem;
}
.keys-panel[data-scene="space"] .keys-group[data-group="space"],
.keys-panel[data-scene="landing"] .keys-group[data-group="landing"],
.keys-panel[data-scene="surface"] .keys-group[data-group="surface"] {
  display: flex;
}

.key-block {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.key-label {
  margin-right: 0.3rem;
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.key-or {
  padding: 0 0.15rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.key-note {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.note-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-left: 0.8rem;
}

.note-icon {
  width: 30px;
  height: 30px;
  object-fit: contain;
  image-rendering: pixelated;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 0.5rem;
  border: 1px solid rgba(0, 212, 255, 0.55);
  border-bottom-width: 4px;
  border-radius: 8px;
  background: linear-gradient(
    180deg,
    rgba(20, 44, 90, 0.95),
    rgba(8, 20, 48, 0.95)
  );
  color: #d8f4ff;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  user-select: none;
  transition:
    transform 0.06s ease,
    border-bottom-width 0.06s ease,
    background 0.06s ease,
    box-shadow 0.06s ease;
}

kbd.k-space {
  min-width: 96px;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
}

kbd.k-accent {
  border-color: #ffd166;
  color: #ffd166;
}

kbd.pressed {
  transform: translateY(3px);
  border-bottom-width: 1px;
  background: linear-gradient(180deg, #00d4ff, #3a7bff);
  color: #02040a;
  box-shadow: 0 0 18px rgba(0, 212, 255, 0.8);
}
kbd.k-accent.pressed {
  background: linear-gradient(180deg, #ffd166, #ff9f43);
  box-shadow: 0 0 18px rgba(255, 209, 102, 0.8);
}

.cluster {
  display: inline-grid;
  grid-template-columns: repeat(3, 34px);
  grid-template-rows: repeat(2, 34px);
  gap: 3px;
}
.cluster kbd {
  min-width: 0;
  padding: 0;
}
.cluster .k-up {
  grid-column: 2;
  grid-row: 1;
}
.cluster .k-left {
  grid-column: 1;
  grid-row: 2;
}
.cluster .k-down {
  grid-column: 2;
  grid-row: 2;
}
.cluster .k-right {
  grid-column: 3;
  grid-row: 2;
}

@media (max-width: 700px) {
  kbd {
    min-width: 32px;
    height: 32px;
    font-size: 0.75rem;
  }
  .cluster {
    grid-template-columns: repeat(3, 32px);
    grid-template-rows: repeat(2, 32px);
  }
}

body:has(#screen-game:not([hidden])) .footer {
  display: none;
}

.game-screen {
  --side-w: 330px;
  --gap: 16px;
  --stage-w: min(
    calc(98vw - var(--side-w) - var(--gap)),
    calc((100vh - 130px) * 16 / 9)
  );
  display: grid;
  grid-template-columns: var(--stage-w) var(--side-w);
  grid-template-rows: auto auto 1fr;
  column-gap: var(--gap);
  align-items: start;
  width: max-content;
  max-width: 98vw;
  margin-left: auto;
  margin-right: auto;
}
.game-screen[hidden] {
  display: none;
}

.game-screen .hud-game {
  grid-column: 1 / -1;
  width: 100%;
  margin: 0 0 0.7rem;
}
.game-screen .canvas-box {
  grid-column: 1;
  grid-row: 2 / span 2;
  width: 100%;
  margin: 0;
}
.game-screen .keys-panel {
  grid-column: 2;
  grid-row: 2;
  width: 100%;
  margin: 0;
  padding: 0.8rem 1rem;
}
.game-screen .game-foot {
  grid-column: 2;
  grid-row: 3;
  width: 100%;
  margin: 0.7rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.game-screen .game-foot > div {
  order: -1;
}
.game-screen .game-foot .btn {
  width: 100%;
}
.game-screen .g-log {
  max-height: 6.6em;
}

.game-screen .keys-group {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.8rem;
}
.game-screen .key-block {
  flex-wrap: wrap;
  row-gap: 0.35rem;
}
.game-screen .key-label {
  flex-basis: 100%;
  margin: 0;
}
.game-screen .key-note {
  flex-wrap: wrap;
  row-gap: 0.4rem;
}
.game-screen .note-item {
  margin-left: 0;
  margin-right: 0.8rem;
}

.hud-card > span {
  gap: 0.6rem;
}
.hud-card b {
  text-align: right;
}

@media (max-width: 1100px) {
  .game-screen {
    --stage-w: min(100%, max(560px, calc((100vh - 300px) * 16 / 9)));
    display: block;
    width: min(1800px, 98vw);
  }
  .game-screen .hud-game,
  .game-screen .canvas-box,
  .game-screen .keys-panel,
  .game-screen .game-foot {
    width: var(--stage-w);
    margin-left: auto;
    margin-right: auto;
  }
  .game-screen .hud-game {
    margin-bottom: 0.9rem;
  }
  .game-screen .keys-panel {
    margin-top: 0.6rem;
    padding: 0.5rem 1rem;
  }
  .game-screen .game-foot {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    margin-top: 0.6rem;
  }
  .game-screen .game-foot > div {
    order: 0;
  }
  .game-screen .game-foot .btn {
    width: auto;
  }
  .game-screen .keys-group {
    flex-direction: row;
    align-items: center;
  }
  .game-screen .key-label {
    flex-basis: auto;
    margin-right: 0.3rem;
  }
  .game-screen .g-log {
    max-height: 4.6em;
  }
}

.arrival {
  --arr: #ffd166;
  --arr-glow: rgba(255, 209, 102, 0.35);
  position: absolute;
  top: 3.2rem;
  left: 50%;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: clamp(0.6rem, 0.9vw, 1rem);
  width: max-content;
  max-width: 70%;
  padding: clamp(0.4rem, 0.6vw, 0.65rem) clamp(0.7rem, 1vw, 1.1rem);
  border: 1px solid var(--arr);
  border-left-width: 4px;
  border-radius: 8px;
  background: linear-gradient(
    90deg,
    rgba(2, 10, 24, 0.9),
    rgba(6, 20, 44, 0.78)
  );
  box-shadow:
    0 0 26px var(--arr-glow),
    inset 0 0 18px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  pointer-events: none;
  transform: translateX(-50%);
  animation: arr-in 0.45s ease-out;
}
.arrival[hidden],
.countdown[hidden] {
  display: none;
}
.arrival[data-level="urgent"] {
  --arr: #ff5a5a;
  --arr-glow: rgba(255, 90, 90, 0.5);
  animation:
    arr-in 0.45s ease-out,
    arr-pulse 0.55s ease-in-out 0.45s infinite alternate;
}

.arrival-icon {
  position: relative;
  flex: none;
  width: clamp(1.6rem, 2.1vw, 2.3rem);
  aspect-ratio: 1;
}
.arrival-icon i {
  position: absolute;
  inset: 0;
  border: 2px solid var(--arr);
  border-radius: 50%;
  opacity: 0;
  animation: arr-ping 1.8s ease-out infinite;
}
.arrival-icon i:nth-child(2) {
  animation-delay: 0.6s;
}
.arrival-icon i:nth-child(3) {
  animation-delay: 1.2s;
}
.arrival-icon::after {
  content: "";
  position: absolute;
  inset: 38%;
  border-radius: 50%;
  background: var(--arr);
  box-shadow: 0 0 12px var(--arr);
}
.arrival[data-level="urgent"] .arrival-icon i {
  animation-duration: 0.9s;
}

.arrival-body {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.arrival-kicker {
  font-family: var(--font-display);
  font-size: clamp(0.48rem, 0.55vw, 0.62rem);
  letter-spacing: 0.25em;
  color: var(--arr);
}
.arrival-title {
  margin: 0.1rem 0 0.1rem;
  font-family: var(--font-display);
  font-size: clamp(0.65rem, 0.85vw, 0.95rem);
  letter-spacing: 0.06em;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.arrival-sub {
  font-size: clamp(0.7rem, 0.8vw, 0.9rem);
  color: var(--muted);
}
.arrival-bar {
  height: 4px;
  margin-top: 0.35rem;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.arrival-bar i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--arr);
  box-shadow: 0 0 8px var(--arr);
  transition: width 0.2s linear;
}

.arrival-time {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-left: clamp(0.3rem, 0.8vw, 1rem);
  padding-left: clamp(0.7rem, 1vw, 1.1rem);
  border-left: 1px solid rgba(255, 255, 255, 0.15);
}
.arrival-label {
  font-family: var(--font-display);
  font-size: clamp(0.45rem, 0.5vw, 0.58rem);
  letter-spacing: 0.2em;
  white-space: nowrap;
  color: var(--muted);
}
.arrival-time b {
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 1.7vw, 1.9rem);
  line-height: 1.1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--arr);
  text-shadow: 0 0 14px var(--arr-glow);
}

.countdown {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.countdown span {
  font-family: var(--font-display);
  font-size: clamp(5rem, 13vw, 11rem);
  line-height: 1;
  color: rgba(255, 90, 90, 0.55);
  text-shadow: 0 0 40px rgba(255, 90, 90, 0.6);
}
.countdown span.pop {
  animation: count-pop 0.95s ease-out;
}
.countdown small {
  font-family: var(--font-display);
  font-size: clamp(0.7rem, 1.1vw, 1.2rem);
  letter-spacing: 0.4em;
  color: rgba(255, 200, 200, 0.7);
}

@keyframes arr-in {
  from {
    opacity: 0;
    transform: translate(-50%, -14px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}
@keyframes arr-pulse {
  from {
    box-shadow:
      0 0 14px var(--arr-glow),
      inset 0 0 18px rgba(0, 0, 0, 0.5);
  }
  to {
    box-shadow:
      0 0 40px var(--arr-glow),
      inset 0 0 24px rgba(255, 90, 90, 0.18);
  }
}
@keyframes arr-ping {
  0% {
    transform: scale(0.35);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.15);
    opacity: 0;
  }
}
@keyframes count-pop {
  0% {
    transform: scale(1.7);
    opacity: 0;
  }
  25% {
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 0.45;
  }
}

@media (prefers-reduced-motion: reduce) {
  .arrival,
  .arrival[data-level="urgent"],
  .arrival-icon i,
  .countdown span.pop {
    animation: none;
  }
  .arrival-icon i:first-child {
    opacity: 0.6;
  }
}

.report-screen {
  position: relative;
  z-index: 2;
  width: min(1100px, 94vw);
  margin: 0 auto;
  padding: 2rem 0 4rem;
  max-height: 100vh;
  overflow-y: auto;
}
.report-screen[hidden],
#rp-empty[hidden],
#report-doc[hidden] {
  display: none !important;
}
.rp-top {
  text-align: center;
  margin-bottom: 1rem;
}
.rp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  margin: 0 0 1.2rem;
}
.rp-actions .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.rp-doc {
  display: grid;
  gap: 1rem;
}
.rp-head {
  background: rgba(5, 8, 17, 0.93);
  border: 1px solid var(--border-active);
  padding: 1rem 1.2rem;
  text-align: center;
}
.rp-head h2 {
  font-family: var(--font-display);
  color: var(--cyan);
  letter-spacing: 0.15em;
  margin: 0 0 0.3rem;
}
.rp-head small {
  color: var(--text-soft);
}
.rp-sim {
  background: rgba(245, 158, 11, 0.15);
  border: 2px dashed var(--warn);
  color: var(--warn);
  font-family: var(--font-display);
  text-align: center;
  padding: 0.7rem;
  letter-spacing: 0.12em;
}
.rp-sec {
  background: rgba(5, 8, 17, 0.93);
  border: 1px solid var(--border);
  padding: 1rem 1.2rem;
}
.rp-sec h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--accent);
  letter-spacing: 0.1em;
  margin: 0 0 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.rp-sec h2 span {
  background: var(--accent);
  color: #04101c;
  padding: 0.1rem 0.5rem;
}
.rp-sec h3 {
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  margin: 1rem 0 0.5rem;
  color: var(--text-main);
}
.rp-sec h3 small {
  color: var(--text-soft);
  font-weight: 400;
}
.rp-ov {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.2rem;
  align-items: start;
}
.rp-badge {
  border: 2px solid;
  padding: 1rem 1.4rem;
  text-align: center;
  font-family: var(--font-display);
  min-width: 170px;
}
.rp-badge b {
  display: block;
  font-size: 2.4rem;
  line-height: 1.1;
}
.rp-badge.is-success {
  color: var(--ok);
  background: rgba(34, 197, 94, 0.1);
}
.rp-badge.is-partial {
  color: var(--warn);
  background: rgba(245, 158, 11, 0.1);
}
.rp-badge.is-failed {
  color: var(--err);
  background: rgba(239, 68, 68, 0.1);
}
.rp-cards,
.rp-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.7rem;
}
.rp-card,
.rp-metric {
  background: var(--panel-card);
  border: 1px solid var(--border);
  padding: 0.7rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.rp-card .tag,
.rp-metric .tag {
  align-self: flex-start;
}
.rp-k,
.rp-metric span {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-soft);
}
.rp-v,
.rp-metric strong {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--text-main);
}
.rp-card small,
.rp-note {
  color: var(--text-soft);
  font-size: 0.9rem;
}
.rp-bar {
  height: 8px;
  background: #0b1630;
  border: 1px solid var(--border);
}
.rp-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
}
.rp-chart {
  display: grid;
  gap: 0.3rem;
}
.rp-brow {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 1.2fr 52px;
  gap: 0.6rem;
  align-items: center;
  font-size: 0.9rem;
}
.rp-brow b {
  text-align: right;
  font-family: var(--font-display);
}
.rp-brow.neg i {
  background: var(--err);
}
.rp-list {
  display: grid;
  gap: 0.4rem;
  padding-left: 1.1rem;
}
.rp-time {
  list-style: none;
  margin: 0;
  padding: 0 0 0 1rem;
  border-left: 2px solid var(--border-active);
  display: grid;
  gap: 0.5rem;
}
.rp-time li {
  display: grid;
  grid-template-columns: 60px 200px 1fr;
  gap: 0.6rem;
  align-items: baseline;
}
.rp-time time {
  font-family: var(--font-pixel);
  color: var(--cyan);
}
.rp-time b {
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
}
.rp-time .t-crash b,
.rp-time .t-damage b {
  color: var(--err);
}
.rp-time .t-landing b,
.rp-time .t-transmit b {
  color: var(--ok);
}
.rp-cml-r {
  font-family: var(--font-display);
  color: var(--cyan);
}
.rp-cml {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.7rem;
}
.rp-cml li {
  border: 1px solid var(--border);
  background: var(--panel-card);
  padding: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.rp-cml li.met {
  border-color: var(--ok);
}
.rp-cml li.now {
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.6);
  border-color: var(--accent);
}
.rp-cml em {
  font-style: normal;
  font-size: 0.75rem;
  color: var(--text-soft);
}
.rp-cml li.met em {
  color: var(--ok);
}
.rp-refs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.7rem;
}
.rp-refs a {
  color: var(--cyan);
  font-family: var(--font-display);
  font-size: 0.85rem;
  word-break: break-word;
}
.rp-refs p {
  margin: 0.2rem 0 0;
  color: var(--text-soft);
}
@media (max-width: 700px) {
  .rp-ov {
    grid-template-columns: 1fr;
  }
  .rp-time li {
    grid-template-columns: 52px 1fr;
  }
  .rp-time li span {
    grid-column: 1 / -1;
  }
  .rp-brow {
    grid-template-columns: 1fr 44px;
  }
  .rp-brow .rp-bar {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}
@media print {
  body > *:not(#screen-report) {
    display: none !important;
  }
  body {
    background: #fff !important;
  }
  #screen-report {
    max-height: none;
    overflow: visible;
    width: 100%;
    padding: 0;
  }
  .rp-actions,
  .phase-badge {
    display: none !important;
  }
  #screen-report,
  #screen-report * {
    color: #111 !important;
    background: #fff !important;
    box-shadow: none !important;
    border-color: #999 !important;
  }
  #screen-report .rp-bar i {
    background: #444 !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .rp-sec,
  .rp-card,
  .rp-metric {
    break-inside: avoid;
  }
}
