/* ============================================================
   STAGE RUN · NIHIL RUNNER — hoja de estilos
   Paleta y tipografía según el game art bible v1
   ============================================================ */
:root {
  --noche:   #0d0a13;
  --panel:   #1d1530;
  --magenta: #ff2d87;
  --purpura: #9b4dff;
  --cian:    #25e0d6;
  --rojo:    #ff4d4d;
  --oro:     #ffcc4d;
  --texto:   #f2ecf8;
  --texto-2: #cdbfe0;
  --texto-3: #8d7fa6;
  --borde:   #2e2440;
  --lima:    #b6ff3a;
  --px: 'Press Start 2P', monospace;
  --vt: 'VT323', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: #060409;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  font-family: var(--vt);
  color: var(--texto);
  user-select: none;
  -webkit-user-select: none;
}

@keyframes blink  { 0%,49%{opacity:1} 50%,100%{opacity:.15} }
@keyframes floaty { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-6px)} }
.blink { animation: blink 1.1s steps(1) infinite; }

/* Splash v2 — glow que respira + glitch RGB-split del logo */
@keyframes logoFX {
  0%       { filter: drop-shadow(0 0 15px rgba(255,45,135,.5)); }
  40%      { filter: drop-shadow(0 0 26px rgba(255,45,135,.8)) drop-shadow(0 0 42px rgba(155,77,255,.3)); }
  78%      { filter: drop-shadow(0 0 15px rgba(255,45,135,.5)); }
  80%      { filter: drop-shadow(-3px 0 0 rgba(255,45,135,.9)) drop-shadow(3px 0 0 rgba(37,224,214,.9)) brightness(1.3); }
  83%      { filter: drop-shadow(3px 0 0 rgba(255,45,135,.9)) drop-shadow(-3px 0 0 rgba(37,224,214,.9)); }
  86%      { filter: drop-shadow(-2px 0 0 rgba(255,45,135,.85)) drop-shadow(2px 0 0 rgba(37,224,214,.85)) brightness(1.15); }
  89%      { filter: drop-shadow(2px 0 0 rgba(37,224,214,.7)) drop-shadow(-2px 0 0 rgba(255,45,135,.7)); }
  92%,100% { filter: drop-shadow(0 0 15px rgba(255,45,135,.5)); }
}
@keyframes logoJitter {
  0%,78%,92%,100% { transform: translate(0,0) scale(1); }
  80% { transform: translate(-3px,1px)  scale(1.01); }
  83% { transform: translate(3px,-1px)  scale(1); }
  86% { transform: translate(-2px,0)    scale(1.015); }
  89% { transform: translate(2px,1px)   scale(1); }
}
/* barrido de scanlines CRT sobre el splash */
@keyframes scan { 0%{background-position:0 0} 100%{background-position:0 8px} }
/* parpadeo del ojo cian: encendido con pulso + doble parpadeo tipo neón fallado */
@keyframes eyeBlink {
  0%, 40%   { opacity: 1;   filter: drop-shadow(0 0 5px rgba(37,224,214,.9)); }
  20%       { opacity: .85; filter: drop-shadow(0 0 9px rgba(37,224,214,1)); }
  42%       { opacity: .12; }
  45%       { opacity: 1; }
  48%       { opacity: .12; }
  51%, 100% { opacity: 1;   filter: drop-shadow(0 0 5px rgba(37,224,214,.9)); }
}

img { image-rendering: pixelated; }

/* ============ STAGE 360×760 escalado ============ */
#stage {
  position: absolute;
  top: 50%; left: 50%;
  width: 360px; height: 760px;
  transform: translate(-50%, -50%);
  transform-origin: center;
  background: #000;
  overflow: hidden;
}

#game {
  position: absolute; inset: 0;
  width: 360px; height: 760px;
  image-rendering: pixelated;
  touch-action: none;
}

/* ============ Pantallas ============ */
.screen { position: absolute; inset: 0; z-index: 10; }
.hidden { display: none !important; }
.scrim  { background: rgba(8,6,16,.78); }
.magenta { color: var(--magenta); }
.cyan    { color: var(--cian); }

/* ============ Botones ============ */
.btn {
  display: block;
  width: 100%;
  border: 0;
  cursor: pointer;
  font-family: var(--px);
  font-size: 13px;
  text-align: center;
  padding: 16px;
  color: var(--texto);
  background: transparent;
}
.btn-magenta {
  background: var(--magenta); color: var(--noche);
  box-shadow: 0 0 16px rgba(255,45,135,.5), inset 0 -4px 0 rgba(0,0,0,.3);
}
.btn-cyan {
  background: var(--cian); color: #06121a;
  box-shadow: 0 0 14px rgba(37,224,214,.4), inset 0 -4px 0 rgba(0,0,0,.25);
}
.btn-cyan-outline { border: 2px solid var(--cian); color: var(--cian); font-size: 11px; padding: 13px; }
.btn-outline      { border: 2px solid var(--borde); color: var(--texto-2); font-size: 11px; padding: 13px; }
.btn-ghost        { color: var(--texto-3); font-size: 9px; padding: 6px; }
.btn.small        { font-size: 9px; padding: 12px 6px; }
.btn:active { transform: translateY(2px); }

/* ============ SPLASH ============ */
#scr-splash { background: linear-gradient(#0a0712 0%, #1a0f2e 55%, #3a1245 100%); }
/* scanlines CRT sutiles sobre toda la portada */
#scr-splash::after {
  content: "";
  position: absolute; inset: 0;
  z-index: 40;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0) 0, rgba(0,0,0,0) 2px,
    rgba(0,0,0,.11) 3px, rgba(0,0,0,0) 4px);
  animation: scan 6s linear infinite;
}
.splash-glow {
  position: absolute; top: 60px; left: 50%;
  transform: translateX(-50%);
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(255,45,135,.35), transparent 65%);
}
.splash-skyline {
  position: absolute; bottom: 34px; left: 0;
  height: 172px;
  opacity: .92;
  filter: drop-shadow(0 0 12px rgba(155,77,255,.25));
}
.splash-band {
  position: absolute; bottom: 6px; left: 0; right: 0;
  display: flex; justify-content: center; align-items: flex-end; gap: 2px;
  opacity: .55;
}
.splash-band img { filter: brightness(0); }
.splash-content {
  position: absolute; top: 74px; left: 0; right: 0;
  text-align: center; padding: 0 24px;
}
.splash-presenta { font-size: 20px; color: var(--cian); letter-spacing: 2px; margin-bottom: 24px; }
.logo-wrap {
  position: relative;
  display: inline-block;
  margin-bottom: 18px;
  will-change: transform;
  animation: logoJitter 5.5s steps(1, end) infinite;
}
.splash-logo {
  display: block;
  width: 256px;
  will-change: filter;
  animation: logoFX 5.5s ease-in-out infinite;
}
/* ojo cian del skull (una sola cuenca visible en la vista 3/4) */
.skull-eye {
  position: absolute;
  left: 138px; top: 33px;
  width: 30px; height: 26px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(190,255,255,.95) 0%,
    rgba(37,224,214,.9) 24%,
    rgba(37,224,214,.35) 48%,
    rgba(37,224,214,0) 72%);
  mix-blend-mode: screen;
  pointer-events: none;
  animation: eyeBlink 4.4s ease-in-out infinite;
}
.splash-sub {
  font-family: var(--px); font-size: 11px; color: var(--cian);
  letter-spacing: 1px; text-shadow: 0 0 10px rgba(37,224,214,.6);
}
.press-start {
  position: absolute; bottom: 300px; left: 0; right: 0;
  text-align: center;
  font-family: var(--px); font-size: 13px; color: #fff;
  text-shadow: 0 0 10px rgba(255,45,135,.85);
  pointer-events: none;
}
.splash-buttons {
  position: absolute; bottom: 150px; left: 0; right: 0;
  padding: 0 40px;
  display: flex; flex-direction: column; gap: 12px;
}

/* ============ SELECCIÓN ============ */
#scr-select { background: linear-gradient(#0e0a18, #1a1230); }
.select-bg { position: absolute; inset: 0; overflow: hidden; }
.select-truss {
  position: absolute; top: 62px; left: 50%;
  transform: translateX(-50%);
  height: 280px; opacity: .38;
}
.select-crowd { position: absolute; bottom: 186px; left: -30px; height: 58px; opacity: .5; }
.neon-bar { position: absolute; top: 30px; width: 60px; height: 8px; opacity: .7; }
.neon-bar.left  { left: 24px;  background: var(--magenta); box-shadow: 0 0 10px var(--magenta); }
.neon-bar.right { right: 24px; background: var(--cian);    box-shadow: 0 0 10px var(--cian); }
.select-header {
  position: absolute; top: 54px; left: 0; right: 0;
  text-align: center; font-family: var(--px); font-size: 12px; color: #fff;
}
.select-header .magenta { margin-top: 6px; text-shadow: 0 0 8px rgba(255,45,135,.6); }
.select-preview {
  position: absolute; top: 120px; left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center;
}
.preview-float { position: relative; animation: floaty 2.4s ease-in-out infinite; }
.preview-shadow {
  position: absolute; bottom: -6px; left: 50%;
  transform: translateX(-50%);
  width: 120px; height: 18px;
  background: radial-gradient(ellipse, rgba(0,0,0,.5), transparent 70%);
}
#sel-preview-img { height: 215px; filter: drop-shadow(0 0 14px rgba(255,45,135,.4)); }
.select-name { font-family: var(--px); font-size: 20px; color: #fff; margin-top: 14px; }
.select-role {
  display: inline-block; margin-top: 10px;
  background: var(--magenta); color: var(--noche);
  font-family: var(--px); font-size: 9px; padding: 6px 12px;
}
.select-chips {
  position: absolute; bottom: 116px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 8px;
}
.chip {
  width: 50px; height: 62px;
  background: var(--noche);
  border: 2px solid var(--borde);
  display: flex; align-items: flex-end; justify-content: center;
  overflow: hidden; cursor: pointer; padding: 0;
}
.chip img { height: 46px; opacity: .8; }
.chip.active {
  background: var(--panel);
  border-color: var(--magenta);
  box-shadow: 0 0 12px rgba(255,45,135,.5);
}
.chip.active img { opacity: 1; height: 50px; }
.select-start { position: absolute; bottom: 36px; left: 28px; right: 28px; width: auto; }
.back-mini {
  position: absolute; top: 44px; left: 16px;
  width: 44px; height: 44px;
  background: rgba(13,10,19,.55);
  border: 2px solid var(--borde);
  color: var(--texto-2);
  font-family: var(--px); font-size: 14px;
  cursor: pointer;
}

/* ============ HUD pausa ============ */
#btn-pause {
  position: absolute; z-index: 20;
  top: calc(14px + env(safe-area-inset-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  width: 44px; height: 44px;
  background: rgba(13,10,19,.55);
  border: 2px solid var(--borde);
  display: flex; align-items: center; justify-content: center; gap: 4px;
  cursor: pointer;
}
#btn-pause span { width: 5px; height: 16px; background: var(--texto-2); display: block; }

#btn-mute {
  position: absolute; z-index: 20;
  top: calc(66px + env(safe-area-inset-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
  width: 44px; height: 44px;
  background: rgba(13,10,19,.55);
  border: 2px solid var(--borde);
  font-size: 18px; line-height: 1;
  cursor: pointer;
}
#btn-mute.muted { opacity: .55; }

/* ============ Panel (pausa / créditos) ============ */
.panel {
  position: absolute; top: 170px; left: 36px; right: 36px;
  background: #120e1b;
  padding: 26px 22px;
  display: flex; flex-direction: column; gap: 12px;
}
.panel-purple {
  border: 2px solid var(--purpura);
  box-shadow: 0 0 24px rgba(155,77,255,.3);
}
.panel-title { font-family: var(--px); font-size: 16px; color: #fff; text-align: center; }
.panel-rule  { width: 40px; height: 3px; background: var(--purpura); margin: 0 auto 10px; }
.panel-label { font-size: 19px; color: var(--texto-3); text-align: center; }
.panel-score {
  font-family: var(--px); font-size: 22px; color: var(--cian);
  text-align: center; margin-bottom: 14px;
}

/* ============ GAME OVER ============ */
.over-bg { background: linear-gradient(#160a14, #0c0913); }
.over-glow {
  position: absolute; top: 0; left: 0; right: 0; height: 240px;
  background: radial-gradient(ellipse at 50% 0%, rgba(255,77,77,.25), transparent 70%);
}
.over-title {
  position: absolute; top: 30px; left: 0; right: 0;
  text-align: center;
  font-family: var(--px); font-size: 24px; color: var(--rojo);
  text-shadow: 3px 3px 0 var(--noche);
}
.over-title div + div { margin-top: 8px; }
.over-char {
  position: absolute; top: 116px; left: 0; right: 0;
  display: flex; align-items: center; justify-content: center; gap: 14px;
}
.over-char img { height: 90px; filter: drop-shadow(0 4px 6px rgba(0,0,0,.6)); }
.over-charname { font-family: var(--px); font-size: 11px; color: #fff; }
.over-charrole { font-size: 18px; color: var(--texto-3); }
.over-scorebox { position: absolute; top: 222px; left: 0; right: 0; text-align: center; }
.over-scorelabel { font-size: 20px; color: var(--texto-3); letter-spacing: 2px; }
.over-score {
  font-family: var(--px); font-size: 34px; color: var(--cian);
  text-shadow: 0 0 14px rgba(37,224,214,.5);
  margin-top: 8px;
}
.over-ig { position: absolute; top: 326px; left: 26px; right: 26px; }
.over-ig label { display: block; font-size: 18px; color: var(--texto-2); margin-bottom: 7px; }
.ig-field {
  display: flex; align-items: center;
  background: var(--noche);
  border: 2px solid var(--magenta);
  box-shadow: 0 0 12px rgba(255,45,135,.3);
}
.ig-at { font-family: var(--px); font-size: 13px; color: var(--magenta); padding: 0 12px; }
#ig-user {
  flex: 1;
  background: transparent; border: 0; outline: none;
  font-family: var(--vt); font-size: 22px; color: #fff;
  padding: 11px 8px 11px 0;
}
#ig-user::placeholder { color: #55476b; }
.over-buttons {
  position: absolute; top: 424px; left: 26px; right: 26px;
  display: flex; flex-direction: column; gap: 10px;
}
.over-row { display: flex; gap: 10px; }
.over-row .btn { flex: 1; }
.save-msg { min-height: 20px; font-size: 17px; color: var(--lima); text-align: center; }
.over-cta {
  position: absolute; bottom: 22px; left: 26px; right: 26px;
  background: var(--panel);
  border: 1px dashed var(--purpura);
  padding: 13px;
  font-size: 17px; color: var(--texto-2); line-height: 1.3; text-align: center;
}

/* ============ RANKING ============ */
.ranking-bg { background: var(--noche); }
.ranking-header {
  position: absolute; top: 0; left: 0; right: 0;
  background: linear-gradient(var(--panel), var(--noche));
  padding: 26px 0 16px;
  text-align: center;
  border-bottom: 2px solid var(--borde);
  font-family: var(--px); font-size: 14px; color: var(--oro);
  text-shadow: 0 0 10px rgba(255,204,77,.5);
}
.ranking-cols {
  position: absolute; top: 84px; left: 18px; right: 18px;
  display: flex;
  font-family: var(--px); font-size: 8px; color: var(--texto-3);
  padding: 0 8px 8px;
  border-bottom: 2px solid var(--borde);
}
.col-pos { width: 30px; }
.col-user { flex: 1; }
.col-score { width: 74px; text-align: right; }
.ranking-rows {
  position: absolute; top: 118px; left: 18px; right: 18px; bottom: 96px;
  display: flex; flex-direction: column; gap: 5px;
  overflow-y: auto;
}
.rk-row {
  display: flex; align-items: center;
  background: #120e1b;
  padding: 10px 8px;
  flex: none;
}
.rk-row .pos  { width: 30px; font-family: var(--px); font-size: 10px; color: var(--texto-3); }
.rk-row .user { flex: 1; font-family: var(--vt); font-size: 20px; color: var(--texto-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk-row .chr  { height: 30px; margin-right: 6px; }
.rk-row .scr  { width: 74px; text-align: right; font-family: var(--px); font-size: 10px; color: var(--texto-2); }
.rk-row.top1 { background: #231a10; border-left: 3px solid var(--oro); }
.rk-row.top1 .pos, .rk-row.top1 .scr { color: var(--oro); font-size: 11px; }
.rk-row.top1 .user { color: #fff; font-size: 21px; }
.rk-row.top2 { background: #1a1820; border-left: 3px solid var(--texto-2); }
.rk-row.top2 .user { color: #fff; }
.rk-row.top3 { background: #201510; border-left: 3px solid #c97b3a; }
.rk-row.top3 .pos, .rk-row.top3 .scr { color: #c97b3a; }
.rk-row.top3 .user { color: #fff; }
.rk-row.me {
  background: var(--panel);
  border: 2px solid var(--magenta);
  box-shadow: 0 0 12px rgba(255,45,135,.4);
}
.rk-row.me .pos, .rk-row.me .scr { color: var(--magenta); }
.rk-row.me .user { color: #fff; }
.rk-empty { text-align: center; color: var(--texto-3); font-size: 20px; padding: 30px 10px; }
.rk-note  { text-align: center; color: var(--texto-3); font-size: 16px; padding: 10px 0 4px; flex: none; }
.ranking-back { position: absolute; bottom: 24px; left: 26px; right: 26px; width: auto; }

/* ============ CRÉDITOS ============ */
.credits { text-align: center; }
.credits-list { list-style: none; font-size: 22px; color: var(--texto-2); line-height: 1.7; }
.credits-list b { color: #fff; }
.credits-ig { font-size: 20px; color: var(--cian); margin-bottom: 8px; }
