html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  color: #d8c8b8;
  user-select: none;
}

/* Todo vive en un lienzo lógico de 384x216 que se escala con transform (píxel duro). */
#stage {
  position: relative;
  flex: none;
  width: 384px;
  height: 216px;
  transform-origin: center center;
  cursor: crosshair;
}

#game {
  position: absolute;
  inset: 0;
  width: 384px;
  height: 216px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-size: 5px;
  line-height: 1;
}

/* HUD orgánico: vejigas de fluido (ui/Bladders.js) */
#organs {
  position: absolute;
  left: 3px;
  top: 2px;
  width: 110px;
  height: 40px;
}
#organs canvas { position: absolute; inset: 0; image-rendering: pixelated; }
#organs-glow { filter: blur(2px); mix-blend-mode: screen; opacity: 0.9; }

#boss-bar {
  position: absolute;
  left: 50%;
  top: 6px;
  width: 180px;
  transform: translateX(-50%);
  text-align: center;
  font-size: 5px;
  color: #ff5a6a;
  text-shadow: 1px 1px 0 #000;
}
#boss-bar .bar { width: 180px; height: 3px; margin-top: 2px; background: #2a0810; box-shadow: 0 0 0 1px #000; }
#boss-bar .bar[hidden] { display: none; }
#boss-bar .fill { display: block; height: 100%; background: #c0283a; box-shadow: 0 0 4px #ff2040; transition: width .2s; }

/* Textos del juego, en tres niveles que se distinguen por forma, color y sitio:
     #message         información (has cogido algo, te han herido...): una cápsula
                      pequeña, lisa y verde fría, abajo en el centro; se va sola.
     #dialogue.narr   narración en off (ambiental, de contexto): sin caja, una franja de
                      sombra que se difumina por los lados, texto lila; espera a E.
     #dialogue.npc    conversación con un personaje: membrana de carne de bordes
                      irregulares que respiran, con su nombre; espera a E.
     #bark            voz suelta de un personaje: la misma membrana, centrada abajo;
                      se va sola. Mientras hay voz o diálogo, la información se calla. */
@keyframes text-membrane {
  0%, 100% { border-radius: 10px 4px 12px 5px / 6px 11px 4px 10px; }
  33% { border-radius: 5px 11px 4px 12px / 11px 4px 10px 6px; }
  66% { border-radius: 12px 5px 10px 4px / 4px 10px 6px 11px; }
}
#message, #dialogue, #bark {
  position: absolute;
  box-sizing: border-box;
  font-size: 5px;
  line-height: 1.75;
  text-shadow: 1px 1px 0 #000;
  pointer-events: none;
}

/* Información: cápsula. */
#message {
  left: 50%;
  bottom: 12px;
  transform: translate(-50%, 2px);
  width: max-content;
  max-width: calc(100% - 64px);
  padding: 2px 9px 1px;
  text-align: center;
  color: #cfe8d6;
  background: rgba(6, 16, 11, .55);
  border: 1px solid rgba(120, 220, 150, .3);
  border-radius: 999px;
  box-shadow: 0 0 4px rgba(0, 0, 0, .45);
  opacity: 0;
  transition: opacity .2s, transform .2s;
}
#message.show { opacity: 1; transform: translate(-50%, 0); }

/* Diálogos: se quedan hasta que el jugador pasa (E / Usar). */
#dialogue {
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
}
#dialogue[hidden] { display: none; }
#dialogue .who, #bark .who { font-size: 4px; letter-spacing: 1px; margin-bottom: 2px; }
#dialogue .who:empty, #bark .who:empty { display: none; }
#dialogue .next { position: absolute; right: 6px; bottom: 1px; font-size: 4px; animation: dlg-blink 1s steps(2) infinite; }

/* Conversación: membrana de carne. */
#dialogue.npc, #bark {
  color: #f2e2cc;
  background: radial-gradient(ellipse at 20% 0%, rgba(150, 40, 55, .25), transparent 65%), rgba(20, 5, 10, .6);
  border: 1px solid rgba(220, 120, 110, .4);
  box-shadow: 0 0 6px rgba(0, 0, 0, .5), inset 0 0 7px rgba(130, 30, 45, .3);
  border-radius: 10px 4px 12px 5px / 6px 11px 4px 10px;
  animation: text-membrane 7s ease-in-out infinite;
}
#dialogue.npc { width: min(78%, 300px); padding: 5px 11px 7px; }
#dialogue.npc .who, #bark .who { color: #ffd27a; }
#dialogue.npc .next { color: #ffd27a; }
#bark {
  left: 50%;
  bottom: 10px;              /* centrada abajo, como el resto (tapa la información) */
  transform: translateX(-50%);
  width: max-content;
  max-width: min(78%, 300px);
  padding: 4px 10px 5px;
  transition: opacity .3s;
}
#bark[hidden] { display: none; }
#bark.out { opacity: 0; }

/* Narración en off: sin caja, una franja de sombra. */
#dialogue.narr {
  width: 100%;
  bottom: 12px;
  padding: 5px 70px 7px;
  text-align: center;
  color: #e0d2ea;
  letter-spacing: .4px;
  background: linear-gradient(90deg, transparent, rgba(10, 4, 14, .55) 22%, rgba(10, 4, 14, .55) 78%, transparent);
}
#dialogue.narr .who { display: none; }
#dialogue.narr .next { right: 74px; color: #b498cc; }
@keyframes dlg-blink { 50% { opacity: 0.2; } }

#prompt {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 34px;
  text-align: center;
  font-size: 5px;
  color: #7dff9a;
  text-shadow: 1px 1px 0 #000;
  pointer-events: none;
}

/* ---------- Menú del Nodo Seguro ---------- */
/* Nodo Seguro: una membrana viva. A la izquierda el útero (pixel art, NodeMenu.js),
   a la derecha las opciones como tejido; la elegida late con su núcleo. */
#node-menu {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 276px;
  max-height: 210px;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 8px;
  padding: 7px 10px 7px 10px;
  box-sizing: border-box;
  background:
    radial-gradient(ellipse at 14% 55%, rgba(30, 110, 60, .35), transparent 55%),
    radial-gradient(ellipse at 85% 20%, rgba(110, 20, 40, .35), transparent 60%),
    #0a0507;
  border-radius: 22px 12px 26px 14px / 14px 24px 12px 22px;
  box-shadow: 0 0 0 1px #000, 0 0 0 2px #2c5a3a, 0 0 0 3px #000, 0 0 22px rgba(60, 255, 140, .18);
  font-size: 5px;
  line-height: 1.6;
  animation: nm-breathe 2.6s ease-in-out infinite;
}
#node-menu[hidden] { display: none; }
@keyframes nm-breathe {
  50% { box-shadow: 0 0 0 1px #000, 0 0 0 2px #3f8a55, 0 0 0 3px #000, 0 0 30px rgba(60, 255, 140, .28); }
}
#node-menu .nm-veins {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#node-menu .nm-veins .vein { fill: none; stroke: #3a0c18; stroke-width: 2.5; vector-effect: non-scaling-stroke; }
#node-menu .nm-veins .pulse {
  fill: none;
  stroke: #c02a44;
  stroke-width: 1;
  stroke-dasharray: 6 90;
  vector-effect: non-scaling-stroke;
  animation: bloodflow 2.2s linear infinite;
}
#node-menu .nm-body { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; max-height: 196px; }
#node-menu .nm-scroll { position: relative; display: flex; gap: 3px; min-height: 0; flex: 1; }
#node-menu .nm-list { overflow-y: auto; scrollbar-width: none; flex: 1; min-width: 0; }
/* Barra propia: un tendón oscuro con un asa de hueso que avisa de que hay más opciones. */
#node-menu .nm-bar { position: relative; width: 4px; flex: none; margin: 2px 0; border-radius: 2px; background: #2a0c14; box-shadow: inset 0 0 0 1px #4a1020; }
#node-menu .nm-bar[hidden] { display: none; }
#node-menu .nm-bar i { position: absolute; left: 0; width: 4px; border-radius: 2px; background: linear-gradient(90deg, #e8d8c0, #a08868); box-shadow: 0 0 3px rgba(125, 255, 154, .45); cursor: grab; touch-action: none; }
#node-menu .nm-close { position: absolute; right: 0; top: -2px; padding: 0 2px; font-size: 7px; line-height: 1; color: #8a5a62; cursor: pointer; z-index: 1; }
#node-menu .nm-close:hover { color: #ff7a8a; text-shadow: 0 0 4px rgba(255, 90, 110, .7); }
#node-menu .nm-list::-webkit-scrollbar { display: none; }

#node-menu h2 {
  margin: 0 0 1px;
  font-size: 7px;
  color: #7dff9a;
  font-weight: normal;
  text-shadow: 0 0 4px rgba(60, 255, 140, .5);
  animation: nm-title 2.6s ease-in-out infinite;
}
@keyframes nm-title { 50% { text-shadow: 0 0 8px rgba(60, 255, 140, .8); } }
#node-menu .nm-res { margin-bottom: 5px; font-size: 3.5px; letter-spacing: .5px; }
#node-menu .nm-res span { margin-right: 4px; }

#node-menu .c-int { color: #ff5a6a; }
#node-menu .c-bio { color: #e07a98; }
#node-menu .c-lux { color: #ffd23f; }
#node-menu .c-o2 { color: #4ff0ff; }
#node-menu .c-rej { color: #c07bff; }
#node-menu .c-scrap { color: #c8b8a0; }
#node-menu .dim { color: #6a5a5a; }

#node-menu button {
  position: relative;
  display: block;
  width: 100%;
  margin: 0 0 2px;
  padding: 2px 5px 2px 25px;
  min-height: 19px;
  line-height: 1.35;
  background: #1a0b10;
  color: #e8dcc8;
  border: 0;
  border-radius: 7px 3px 8px 4px / 4px 8px 3px 7px;
  box-shadow: inset 0 0 0 1px #3a1822, inset 0 -2px 0 #12070a;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
/* Pestañas del útero (Mutar, Cuidados, Tienda, Viajar) y la rejilla de dos columnas. */
#node-menu .nm-tabs { display: flex; gap: 2px; margin-bottom: 3px; flex-wrap: wrap; }
#node-menu button.nm-tab {
  display: inline-block; width: auto; min-height: 0; margin: 0; padding: 1px 5px 0;
  font-size: 4px; letter-spacing: .5px; color: #a89080; background: #140a0d;
  border-radius: 5px 5px 2px 2px; box-shadow: inset 0 0 0 1px #3a1822;
}
#node-menu button.nm-tab.on { color: #ffd27a; background: #2a1418; box-shadow: inset 0 0 0 1px #c8784a, 0 0 4px rgba(255, 180, 90, .25); }
#node-menu button.nm-tab.nav-sel { color: #7dff9a; box-shadow: inset 0 0 0 1px #7dff9a; }
#node-menu .nm-list.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; align-content: start; }
#node-menu .nm-list.cols button { margin: 0; }
#node-menu button.mut { background: #160d1c; box-shadow: inset 0 0 0 1px #3a2050, inset 0 -2px 0 #0c0610; }
#node-menu button .nm-icon {
  position: absolute;
  left: 3px;
  top: 50%;
  margin-top: -9px;
  width: 18px;
  height: 18px;
  image-rendering: pixelated;
  opacity: .85;
}
#node-menu button.nav-sel {
  background: #13261a;
  box-shadow: inset 0 0 0 1px #7dff9a, inset 0 -2px 0 #0a1a10, 0 0 6px rgba(60, 255, 140, .25);
}
#node-menu button.nav-sel .nm-icon { opacity: 1; filter: drop-shadow(0 0 2px rgba(125, 255, 154, .7)); }
#node-menu button:disabled { color: #5a4a4a; cursor: default; background: #120a0c; }
#node-menu button:disabled .nm-icon { opacity: .35; filter: grayscale(.7); }

/* Cada opción destaca por su tipo (--c, del JS): franja lateral, fondo teñido, título
   y brillo del icono en su color. */
#node-menu button[style*="--c"] {
  background: linear-gradient(90deg, var(--tint) 0%, #1a0b10 55%);
  box-shadow: inset 2px 0 0 var(--c), inset 0 -2px 0 #0c0608;
}
#node-menu button .nm-label { color: var(--c, #e8dcc8); text-shadow: 0 0 3px rgba(0, 0, 0, .8); }
#node-menu button .nm-icon { filter: drop-shadow(0 0 1.5px var(--c, transparent)); }
#node-menu button[style*="--c"].nav-sel {
  background: linear-gradient(90deg, var(--tint) 0%, #241018 70%);
  box-shadow: inset 2px 0 0 var(--c), inset 0 0 0 1px var(--c), 0 0 7px var(--tint);
}
#node-menu button.nav-sel .nm-icon { filter: drop-shadow(0 0 2.5px var(--c, #7dff9a)); }
#node-menu button:disabled .nm-label { color: #6a5a5a; }
#node-menu button[style*="--c"]:disabled { background: #120a0c; box-shadow: inset 2px 0 0 #3a2a2a; }
#node-menu button:disabled .nm-icon { opacity: .35; filter: grayscale(.7); }
/* Mutaciones: lo más importante del útero. Ficha más alta, nombre mayor, icono más
   grande y un latido de brillo en el color de su órgano. */
#node-menu button.mut[style*="--c"] {
  min-height: 27px;
  padding-left: 31px;
  background: linear-gradient(90deg, var(--tint) 0%, #1c0c1e 70%);
  animation: nm-mut 1.6s ease-in-out infinite;
}
#node-menu button.mut .nm-label { font-size: 6px; }
#node-menu button.mut .nm-line { font-size: 3.5px; color: #c8b8a8; margin-left: 3px; }
#node-menu button.mut .nm-icon { left: 3px; width: 25px; height: 25px; margin-top: -12.5px; }
@keyframes nm-mut {
  50% { box-shadow: inset 3px 0 0 var(--c), inset 0 0 0 1px var(--tint), 0 0 8px var(--tint); }
}
#node-menu button.mut[style*="--c"]:disabled { animation: none; }
#node-menu .nm-info .nm-line { color: #a89888; font-size: 3px; margin-left: 2px; }
/* Panel de información: qué hace la opción señalada (con su nombre en su color). */
#node-menu .nm-info .nm-info-t { color: var(--c); font-weight: normal; }
#node-menu .nm-info {
  flex: none;
  min-height: 15px;
  margin-top: 3px;
  padding: 2px 4px;
  font-size: 3.5px;
  line-height: 1.5;
  color: #d8c8b8;
  background: rgba(0, 0, 0, .35);
  border-left: 2px solid var(--c, #6a5a5a);
  border-radius: 2px;
}
#node-menu .desc {
  display: block;
  color: #8a7a6a;
}

/* ---------- Mapa interno (M) ---------- */
/* Minimapa del HUD (tecla M) */
#minimap {
  position: absolute;
  right: 6px;
  top: 6px;
  outline: 1px solid #4a3a1a;
  box-shadow: 0 0 0 1px #000;
}
#minimap canvas { display: block; width: 104px; height: 52px; image-rendering: pixelated; }
#minimap span {
  position: absolute;
  left: 2px;
  top: 2px;
  font-size: 3px;
  color: #c8b070;
  text-shadow: 1px 1px 0 #000;
}

/* ---------- Menú de desarrollo (F9 / º) ---------- */
#dev-menu {
  position: absolute;
  inset: 6px;
  padding: 8px 10px;
  overflow-y: auto;
  background: rgba(4, 10, 14, .96);
  outline: 1px solid #2a6a7a;
  font-size: 5px;
  line-height: 1.6;
  color: #b8d8e0;
  scrollbar-width: thin;
}
#dev-menu h2 { margin: 0 0 4px; font-size: 7px; font-weight: normal; color: #4ff0ff; }
#dev-menu h2 span { font-size: 4px; color: #4a7a8a; margin-left: 6px; }
#dev-menu h3 { margin: 6px 0 3px; font-size: 5px; font-weight: normal; color: #7a9aa8; }
#dev-menu .dev-stats { color: #ffd23f; }
#dev-menu button {
  margin: 0 3px 3px 0;
  padding: 2px 4px;
  font: inherit;
  color: #b8d8e0;
  background: #0c1a20;
  border: 0;
  outline: 1px solid #1f4250;
  cursor: pointer;
}
#dev-menu button.nav-sel { outline-color: #4ff0ff; }
#dev-menu button.nav-sel { outline-width: 2px; }
#dev-menu button.on { background: #0f4a3a; color: #7dff9a; outline-color: #7dff9a; }

/* ---------- Genoma del Huésped (tecla I) ---------- */
#genome {
  --beat: 1s;
  position: absolute;
  z-index: 5;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 10px 14px 8px;
  box-sizing: border-box;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 22% 50%, rgba(90, 10, 24, .55), transparent 60%),
    radial-gradient(ellipse at 80% 30%, rgba(30, 40, 70, .45), transparent 65%),
    #060306;
  font-size: 5px;
  line-height: 1.6;
  animation: membrane 6s ease-in-out infinite;
}

#genome[hidden] { display: none; }

@keyframes membrane {
  50% { background-position: 4px 2px, -3px 3px, 0 0; filter: saturate(1.25); }
}

#genome .veins {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#genome .vein {
  fill: none;
  stroke: #3a0a14;
  stroke-width: 2.5;
}

#genome .pulse {
  fill: none;
  stroke: #e0304a;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-dasharray: 6 90;
  animation: bloodflow calc(var(--beat) * 3) linear infinite;
  filter: drop-shadow(0 0 2px #ff2040);
}

@keyframes bloodflow { to { stroke-dashoffset: -96; } }

/* Células del fondo: pixel art plano (dibujadas en Genome.js), a saltos de píxel */
#genome .cell {
  position: absolute;
  image-rendering: pixelated;
  opacity: 0.75;
  animation: drift 9s steps(18) infinite;
  pointer-events: none;
}

@keyframes drift {
  25% { transform: translate(6px, -4px); }
  50% { transform: translate(2px, -9px); }
  75% { transform: translate(-5px, -3px); }
}

#genome .g-head {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid #4a1020;
}

#genome h2 {
  margin: 0;
  font-size: 8px;
  font-weight: normal;
  color: #ff5a6a;
  text-shadow: 0 0 6px #a0102a;
  letter-spacing: 1px;
  animation: throb var(--beat) ease-in-out infinite;
}

@keyframes throb {
  10% { text-shadow: 0 0 10px #ff2040, 1px 0 0 #00e0ff; }
  20% { text-shadow: 0 0 4px #a0102a; }
}

#g-count { color: #c07bff; }
#genome .g-res { display: flex; align-items: center; gap: 8px; }
#g-scrap { width: 46px; height: 10px; image-rendering: pixelated; }
#g-quit {
  font: inherit;
  font-size: 6px;
  padding: 3px 5px;
  color: #ff8a9a;
  background: #2a0a14;
  border: 1px solid #7a1a30;
  cursor: pointer;
}
#g-quit[hidden] { display: none; }
#g-quit.armed { color: #fff; background: #8a1028; border-color: #ff5a6a; }

#genome .g-body {
  position: relative;
  flex: 1;
  display: flex;
  gap: 10px;
  min-height: 0;
}

#genome .g-left {
  flex: 0 0 104px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

#genome .g-specimen {
  position: relative;
  flex: none;
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #2a3a3a;
  background:
    repeating-linear-gradient(0deg, rgba(79, 240, 255, .05) 0 1px, transparent 1px 4px),
    radial-gradient(circle, #10201e, #050808 75%);
  overflow: hidden;
}

#genome .g-aura {
  position: absolute;
  width: 60px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(200, 30, 60, .35), transparent 70%);
  animation: aura var(--beat) ease-in-out infinite;
}

@keyframes aura {
  10% { transform: scale(1.25); opacity: 1; }
  30% { transform: scale(1); opacity: .6; }
}

#g-canvas {
  position: relative;
  width: 64px;
  height: 60px;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 2px rgba(79, 240, 255, .35));
  animation: breathe calc(var(--beat) * 3) ease-in-out infinite;
  transform-origin: 50% 100%;
}

@keyframes breathe {
  50% { transform: scale(1.03, 1.05); }
}

#genome .g-scan {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: #4ff0ff;
  box-shadow: 0 0 6px 1px rgba(79, 240, 255, .6);
  opacity: .7;
  animation: scan 3s linear infinite;
}

@keyframes scan {
  from { top: 0; }
  to { top: 100%; }
}

#g-organ {
  position: absolute;
  left: 3px;
  bottom: 2px;
  color: #4ff0ff;
}

#genome .g-ecg {
  flex: none;
  width: 100%;
  height: 12px;
  border: 1px solid #1a2a20;
  background: #030806;
  overflow: hidden;
}

#genome .g-ecg polyline {
  fill: none;
  stroke: #7dff9a;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 1px #7dff9a);
  animation: ecg calc(var(--beat) * 2) linear infinite;
}

#genome.critical .g-ecg polyline { stroke: #ff3b2f; filter: drop-shadow(0 0 1px #ff3b2f); }

@keyframes ecg { to { transform: translateX(-100px); } }

/* Genoma gráfico: constantes en vejigas, árbol de órganos y panel breve */
#g-vitals { width: 104px; height: 46px; image-rendering: pixelated; }

#genome .g-tree {
  position: relative;
  flex: 1;
  min-width: 0;
}
#genome .g-links {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#genome .g-links line {
  stroke: #6a1a2a;
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 3 2;
  animation: bloodflow calc(var(--beat) * 4) linear infinite;
}
#genome .g-col {
  position: absolute;
  top: 0;
  transform: translate(-50%, -130%);
  font-size: 3px;
  color: #6a4a4a;
  white-space: nowrap;
}
#genome .g-node {
  position: absolute;
  width: 19px;
  height: 19px;
  transform: translate(-50%, 0);
  border-radius: 50% 45% 50% 42%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 40% 35%, #2a1418, #0c0608 75%);
  outline: 1px solid #2a1418;
  cursor: pointer;
  transition: transform .15s;
}
#genome .g-node canvas { width: 15px; height: 15px; image-rendering: pixelated; }
#genome .g-node.active {
  outline-color: var(--c);
  box-shadow: 0 0 6px var(--c), inset 0 0 6px rgba(0, 0, 0, .8);
  animation: organ var(--beat) ease-in-out infinite;
}
#genome .g-node.latent {
  outline: 1px dashed #a08a9a;
  animation: latent 1.2s steps(2) infinite;
}
#genome .g-node.unknown { opacity: .6; }
#genome .g-node.focus { transform: translate(-50%, 0) scale(1.18); outline-width: 2px; z-index: 2; }
@keyframes organ { 15% { box-shadow: 0 0 10px var(--c), inset 0 0 4px rgba(0, 0, 0, .8); } }
@keyframes latent { 50% { box-shadow: 0 0 6px #a08a9a; } }

#genome .g-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 2px 4px;
}
#genome .g-frag { display: inline-flex; gap: 1px; margin-right: 5px; }
#genome .g-frag i {
  width: 3px;
  height: 7px;
  background: #1e1418;
  outline: 1px solid #000;
  border-radius: 1px;
}
#genome .g-frag i.on { background: var(--c); box-shadow: 0 0 3px var(--c); }
#genome .g-memory.nav-sel { outline: 2px solid #ffd23f; z-index: 2; }
#genome .g-memory {
  display: inline-block;
  width: 6px;
  height: 7px;
  margin-left: 2px;
  background: radial-gradient(circle at 40% 35%, #f0e4d0, #8a6a5a 70%);
  border-radius: 40% 40% 50% 50%;
  outline: 1px solid #000;
  cursor: pointer;
}

#genome .g-info {
  flex: 0 0 96px;
  padding: 4px 5px;
  border-left: 1px solid #3a1420;
  font-size: 4px;
  line-height: 1.55;
  color: #a89888;
  overflow: hidden;
}
#genome .i-name { display: block; font-size: 5px; font-weight: normal; }
#genome .i-tag { display: block; margin-bottom: 3px; font-size: 3.5px; color: #6a5a5a; letter-spacing: 1px; }
#genome .g-info p { margin: 0 0 3px; }
#genome .i-fx { color: #e8dcc8; }
#genome .i-dw { color: #ff7a6a; }
#genome .i-lore { color: #8a6a6a; font-style: italic; }
#genome .i-dim { color: #6a5a5a; }
#genome .i-cost .c-int { color: #ff5a6a; }
#genome .i-cost .c-rej { color: #c07bff; margin-left: 3px; }

#genome .g-foot {
  position: relative;
  margin-top: 5px;
  text-align: center;
  font-size: 4px;
  color: #6a5a5a;
}

/* ---------- Pantallas ---------- */
#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 45%, #2a0a10 0%, #000 70%);
  text-align: center;
  cursor: pointer;
}

#overlay[hidden] { display: none; }

#overlay h1 {
  margin: 0;
  font-size: 14px;
  font-weight: normal;
  color: #c0283a;
  text-shadow: 2px 2px 0 #000, 0 0 12px #6a0d18;
  letter-spacing: 1px;
}

#overlay .sub {
  margin: 6px 0 14px;
  font-size: 6px;
  color: #8a6a6a;
}

#overlay .controls {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  font-size: 5px;
  line-height: 2;
  color: #a89888;
}

#overlay .blink {
  font-size: 6px;
  color: #7dff9a;
  animation: blink 1s steps(1) infinite;
}

#boot-error {
  max-width: 300px;
  margin: 10px 0 0;
  font-size: 5px;
  line-height: 1.8;
  color: #ff5a4a;
}

/* Fuera del escenario escalado: tamaño real de pantalla. */
#fullscreen {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 10;
  width: 36px;
  height: 36px;
  border: 1px solid #3a2a2a;
  background: rgba(10, 6, 8, .7);
  color: #8a6a6a;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  opacity: .5;
}

#fullscreen:hover { opacity: 1; color: #7dff9a; }
:fullscreen #fullscreen { display: none; }

#fade {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
}

@keyframes blink {
  50% { opacity: .25; }
}

/* Genoma: vejigas señalables y su ficha debajo */
#g-vitals { display: block; }
#genome .g-vitals { position: relative; width: 104px; height: 52px; flex: none; }
#genome .g-vital {
  position: absolute;
  top: 0;
  width: 17px;
  height: 52px;
  cursor: pointer;
  border-radius: 6px;
}
#genome .g-vital span {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 3.5px;
  color: var(--c);
  opacity: 0.7;
}
#genome .g-vital.focus, #genome .g-vital.nav-sel { box-shadow: inset 0 0 0 1px var(--c); background: rgba(255, 255, 255, 0.04); }
#genome .g-vital.focus span { opacity: 1; }
/* Consumibles: se señalan y se usan desde aquí (no tienen tecla ni icono en el HUD). */
#genome .g-items { display: flex; gap: 3px; margin: 1px 0 2px; flex: none; }
#genome .g-item { display: flex; align-items: center; gap: 1px; padding: 1px 2px; border-radius: 3px; cursor: pointer; font-size: 3.5px; color: #e8dcc8; box-shadow: inset 0 0 0 0.5px #4a1020; }
#genome .g-item canvas { width: 8px; height: 8px; image-rendering: pixelated; }
#genome .g-item.empty { opacity: 0.35; }
#genome .g-item.on { color: #7dff9a; animation: throb .6s ease-in-out infinite; }
#genome .g-item.focus, #genome .g-item.nav-sel { box-shadow: inset 0 0 0 1px #4ff0ff; background: rgba(255, 255, 255, 0.05); }
#genome .g-vinfo { flex: 1; min-height: 0; overflow: hidden; font-size: 3px; line-height: 1.4; }
#genome .g-vinfo p { margin: 0 0 1px; }
#genome .g-vinfo .i-name { font-size: 4px; margin-bottom: 1px; }
#genome .i-amount { color: #e8dcc8; font-size: 3px; margin-left: 2px; }
#genome .i-up { color: #9ad8a0; }
#node-menu h2 .nm-name { font-size: 4px; color: #4a9a62; margin-left: 3px; letter-spacing: .5px; text-shadow: none; }

/* Genoma: carga genética, sinergias y choques, fusiones */
.g-links line.fusion { stroke: #d040ff; stroke-dasharray: 2 1.5; }
#g-load { display: flex; align-items: center; gap: 3px; font-size: 3.5px; letter-spacing: 1px; color: #c07bff; }
#g-load .over { color: #ff4a6a; }
.g-loadbar { display: inline-flex; gap: 1px; }
.g-loadbar i { width: 3px; height: 4px; background: #2a1830; display: inline-block; }
.g-loadbar i.on { background: #a040d8; }
.g-loadbar i.over { background: #ff4a6a; }
.g-ext { color: #e8dcc8; }
#g-pairs { display: flex; flex-wrap: wrap; gap: 1px 4px; font-size: 3px; flex: 1 1 100%; order: -1; }
.g-pair.syn { color: #6aff9a; }
.g-pair.clash { color: #ff6a7a; }
#genome .i-pairs { font-size: 3px; margin-top: 2px; line-height: 1.5; }

/* ---------------------------------------------------------------- táctil (ui/Touch.js) */
body.touch { touch-action: none; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#touch { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
#touch[hidden] { display: none; }
#touch svg { position: absolute; pointer-events: auto; touch-action: none; opacity: 0.36; transition: opacity 0.12s; overflow: visible; }
#touch svg.on { opacity: 0.72; }
#touch .tdpad:active { opacity: 0.6; }
#touch .tl { font: 4.6px 'Press Start 2P', monospace; fill: #f4e6d4; opacity: 0.85; }
.tleft { position: absolute; left: max(3vmin, env(safe-area-inset-left)); bottom: 4vmin; width: 42vmin; height: 42vmin; max-width: 220px; max-height: 220px; }
.tleft .tdpad { position: static; width: 100%; height: 100%; }
.tright { position: absolute; right: max(3vmin, env(safe-area-inset-right)); bottom: 3vmin; width: 52vmin; height: 44vmin; }
.tright [data-act="jump"] { right: 0; bottom: 7vmin; width: 22vmin; height: 22vmin; }
.tright [data-act="fire"] { right: 24vmin; bottom: 2vmin; width: 18vmin; height: 18vmin; }
.tright [data-act="dash"] { right: 4vmin; bottom: 31vmin; width: 13vmin; height: 13vmin; }
.tright [data-act="grapple"] { right: 26.5vmin; bottom: 21vmin; width: 13vmin; height: 13vmin; }
.tright [data-act="interact"] { right: 43vmin; bottom: 20vmin; width: 14vmin; height: 14vmin; opacity: 0.6; animation: tpulse 1.1s ease-in-out infinite; }
@keyframes tpulse { 50% { transform: scale(1.08); opacity: 0.85; } }
.ttop { position: absolute; left: 50%; transform: translateX(-50%); top: 1.5vmin; display: flex; gap: 2vmin; }
.ttop svg { position: static !important; width: 10vmin; height: 10vmin; }
.taim { position: fixed; display: none; width: 16px; height: 16px; margin: -8px 0 0 -8px; border: 2px solid rgba(255, 170, 190, 0.7); border-radius: 50%; pointer-events: none; box-shadow: 0 0 8px rgba(255, 90, 120, 0.6); }
/* En la portada todo se juega tocando la pantalla; en los menús, solo cruceta, aceptar y salir. */
#touch.title .tleft, #touch.title .tright, #touch.title .ttop { display: none; }
#touch.menu [data-act="fire"], #touch.menu [data-act="dash"], #touch.menu [data-act="grapple"], #touch.menu [data-act="interact"], #touch.menu [data-act="light"], #touch.menu [data-act="weapon"] { display: none !important; }
#overlay .touch-help { display: none; }
body.touch #overlay .touch-help { display: block; }
body.touch #overlay .controls:not(.touch-help) { display: none; }
/* Aviso de girar el móvil: temporal, arriba, sin bloquear el juego (Touch.js). */
#rotate { position: fixed; left: 50%; top: max(12px, env(safe-area-inset-top)); transform: translateX(-50%); width: min(92vw, 520px); box-sizing: border-box; z-index: 100; padding: 10px 14px; border-radius: 6px; background: rgba(10, 6, 8, 0.88); box-shadow: 0 0 0 1px #4a1020, 0 4px 18px rgba(0, 0, 0, 0.6); color: #e8dcc0; font: 11px 'Press Start 2P', monospace; text-align: center; line-height: 1.5; pointer-events: none; opacity: 0; transition: opacity 0.5s; }
#rotate p { margin: 0 0 6px; }
#rotate .dim { margin: 0; font-size: 8px; color: #a08080; }
body.touch #rotate.show { opacity: 1; }
#touch.menu svg { opacity: 0.2; }
#touch.menu svg.on { opacity: 0.5; }
body.touch #fullscreen { top: 6px; bottom: auto; right: 6px; opacity: 0.5; }
