:root {
  --stain: #172a74;        /* azul de tinción, para el texto sobre el campo claro */
  --stain-soft: rgba(23, 42, 116, 0.5);
  --mark: #8c1d5a;         /* magenta de núcleo, marca de selección */
  --halo: rgba(240, 246, 255, 0.85);
  --font: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
html, body { margin: 0; height: 100%; background: #8f918c; overflow: hidden; }
body { font-family: var(--font); -webkit-user-select: none; user-select: none; }

/* ---------- motor ---------- */
#gl, #ui { position: fixed; left: 0; top: 0; display: block; }
#ui { pointer-events: none; }
#hud { position: fixed; left: 14px; top: 12px; color: #1b2624; font: 11px/1.55 var(--font); opacity: 0; pointer-events: none; letter-spacing: .02em; white-space: pre; z-index: 3; }
#err { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); color: #2a1a1a; font: 14px system-ui; background: #f2e9e2; padding: 16px 20px; border-radius: 6px; display: none; z-index: 50; }

/* ---------- vídeo en bucle ---------- */
.vloop { position: absolute; inset: 0; overflow: hidden; }
.vloop video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }

/* ---------- pantallas ---------- */
#screens { position: fixed; inset: 0; z-index: 10; }
#screens.gone { pointer-events: none; }
.screen { position: absolute; inset: 0; background: #dfe7f1; }
.screen.off { display: none; }
.screen .ui { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; }

.press {
  position: absolute; bottom: 16vh; left: 0; right: 0; margin: 0; text-align: center;
  color: var(--stain); font-size: clamp(12px, 1.25vw, 16px); font-weight: 500; letter-spacing: .32em; text-transform: uppercase;
  text-shadow: 0 0 14px var(--halo), 0 0 3px var(--halo);
  animation: breathe 2.8s ease-in-out infinite; transition: opacity .3s;
}
.press.out { animation: none; opacity: 0; }
@keyframes breathe { 0%, 100% { opacity: .35; } 50% { opacity: .95; } }

.title {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%);
  width: min(52vw, 82vh, 900px); height: auto; pointer-events: none;
  filter: drop-shadow(0 10px 28px rgba(20, 40, 90, 0.18));
}
.menu { position: absolute; left: 50%; top: calc(40% + min(17vw, 27vh, 300px)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 1.1em; }
.menu button {
  position: relative; background: none; border: 0; padding: .35em 1.4em; cursor: pointer;
  font: 500 clamp(12px, 1.2vw, 16px)/1 var(--font); letter-spacing: .3em; text-transform: uppercase;
  color: var(--stain); opacity: .5; text-shadow: 0 0 14px var(--halo), 0 0 3px var(--halo);
  transition: opacity .25s;
}
.menu button::before {
  content: ""; position: absolute; left: .1em; top: 50%; width: .55em; height: .55em; margin-top: -.3em; border-radius: 50%;
  background: radial-gradient(circle at 40% 38%, #c2457f 0, var(--mark) 55%, #5a0f3a 100%);
  box-shadow: 0 0 0 2px rgba(240, 246, 255, .7); transform: scale(0); transition: transform .3s cubic-bezier(.3, 1.6, .5, 1);
}
.menu button.sel { opacity: 1; }
.menu button.sel::before { transform: scale(1); }
.menu button:focus-visible { outline: 1px dashed var(--stain-soft); outline-offset: 4px; }

.fadein { animation: fadein .9s ease both; }
.fadein.d2 { animation-delay: .25s; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.screen .ui > * { transition: opacity .35s ease; }
.screen .ui.hidden > * { opacity: 0; }

/* ---------- pad de mitosis ---------- */
#pad {
  position: fixed; left: 50%; bottom: 0; z-index: 6;
  width: clamp(320px, 46vh, 560px); aspect-ratio: 544 / 512; transform: translate(-50%, 15%);
  opacity: 0; pointer-events: none; transition: opacity .8s ease; touch-action: none;
}
#pad.on { opacity: 1; pointer-events: auto; }
#pad .vloop { position: absolute; inset: 0; }
#pad .vloop video { object-fit: contain; }
#pad .padfx { position: absolute; z-index: 5; display: block; pointer-events: none; cursor: crosshair; }
#pad { cursor: crosshair; }
.menu button[hidden] { display: none; }
