/* «El pulso» — maqueta. Paleta y tipos de zaxfun: entrar en un juguete no
   debe sentirse como cambiar de web. Mobile-first. */

:root {
  --fondo:       #05060f;
  --panel:       rgba(255, 255, 255, .045);
  --panel-borde: rgba(255, 255, 255, .09);
  --texto:       #e9edfb;
  --texto-tenue: #8e97b8;
  --cian:        #6fd3ff;
  --violeta:     #b98cff;
  --oro:         #ffd479;
  --rojo:        #ff6b8a;
  --radio:       20px;
  --tipo-titulo: 'Space Grotesk', system-ui, sans-serif;
  --tipo-texto:  'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(58% 46% at 50% 30%, #141c40 0%, transparent 72%),
    var(--fondo);
  color: var(--texto);
  font-family: var(--tipo-texto);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.pantalla {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- Marcador ---------- */

#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(1rem, env(safe-area-inset-top)) 1.15rem .3rem;
  gap: 1rem;
  opacity: 0;
  transition: opacity .3s ease;
  pointer-events: none;
}
body.jugando #hud { opacity: 1; }

#vidas { display: flex; gap: .38rem; }
#vidas i {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .13);
  transition: background .25s ease, box-shadow .25s ease;
}
#vidas i.viva {
  background: var(--rojo);
  box-shadow: 0 0 10px rgba(255, 107, 138, .75);
}

.marca-nivel {
  text-align: center;
  line-height: 1;
}
.marca-nivel span {
  display: block;
  font-size: .62rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--texto-tenue);
  margin-bottom: .22rem;
}
#nivel {
  font-family: var(--tipo-titulo);
  font-weight: 700;
  font-size: 1.55rem;
  font-variant-numeric: tabular-nums;
}

#salir {
  background: none; border: 0; cursor: pointer;
  color: var(--texto-tenue);
  font-size: 1.4rem; line-height: 1;
  padding: .2rem .4rem;
  pointer-events: auto;
}
#salir:hover { color: var(--texto); }

/* ---------- El lienzo ---------- */

#lienzo {
  flex: 1;
  width: 100%;
  display: block;
  touch-action: manipulation;
}

#forma {
  text-align: center;
  font-size: .78rem;
  letter-spacing: .04em;
  color: var(--texto-tenue);
  padding-bottom: max(1.6rem, env(safe-area-inset-bottom));
  min-height: 1.4em;
  opacity: 0;
  transition: opacity .3s ease;
}
body.jugando #forma { opacity: 1; }

#aviso {
  position: fixed;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  font-family: var(--tipo-titulo);
  font-weight: 700;
  color: var(--oro);
  text-shadow: 0 0 18px rgba(255, 212, 121, .6);
  pointer-events: none;
}

/* Vuelta a la casa. Se esconde mientras se juega: ahí el botón de salir es el
   ✕ del marcador, y dos maneras de irse a la vez es una de más. */
#atras {
  position: fixed;
  top: max(.9rem, env(safe-area-inset-top));
  left: max(.9rem, env(safe-area-inset-left));
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .42rem .85rem;
  border-radius: 999px;
  border: 1px solid var(--panel-borde);
  background: rgba(255, 255, 255, .05);
  color: var(--texto-tenue);
  font-size: .82rem;
  text-decoration: none;
  transition: color .2s ease, border-color .2s ease, transform .2s ease, opacity .25s ease;
}
#atras:hover {
  color: var(--texto);
  border-color: rgba(255, 255, 255, .26);
  transform: translateX(-2px);
}
body.jugando #atras { opacity: 0; pointer-events: none; }

/* Botón de silencio: fijo abajo a la izquierda y POR ENCIMA de las capas, para
   que también se pueda callar desde el menú o desde la pantalla de derrota. */
#sonido {
  position: fixed;
  left: max(.9rem, env(safe-area-inset-left));
  bottom: max(.9rem, env(safe-area-inset-bottom));
  z-index: 20;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 1px solid var(--panel-borde);
  background: rgba(255, 255, 255, .05);
  color: var(--texto);
  font-size: .95rem;
  line-height: 1;
  cursor: pointer;
  opacity: .55;
  transition: opacity .2s ease, border-color .2s ease;
}
#sonido:hover { opacity: 1; border-color: var(--cian); }
#sonido.apagado { opacity: .32; }

/* ---------- Capas ---------- */

.capa {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
  text-align: center;
  background: rgba(5, 6, 15, .82);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  overflow-y: auto;
}
.fuera { display: none !important; }

.titulo {
  font-family: var(--tipo-titulo);
  font-weight: 700;
  font-size: clamp(2.6rem, 15vw, 4rem);
  letter-spacing: -.04em;
  line-height: .95;
  margin: 0;
  background: linear-gradient(115deg, var(--oro), var(--cian) 60%, var(--violeta));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lema {
  margin: -.4rem 0 .3rem;
  color: var(--texto-tenue);
  font-size: .92rem;
  max-width: 19rem;
}

.boton {
  border: 0;
  border-radius: 999px;
  padding: .85rem 2.6rem;
  font-family: var(--tipo-titulo);
  font-size: 1.05rem;
  font-weight: 600;
  color: #06070f;
  background: linear-gradient(120deg, var(--oro), var(--cian));
  cursor: pointer;
  transition: transform .12s ease, filter .2s ease;
}
.boton:hover { filter: brightness(1.08); }
.boton:active { transform: scale(.96); }

.marca-record {
  font-size: .82rem;
  color: var(--texto-tenue);
  min-height: 1.2em;
}

/* Pantalla de derrota: el número grande y el botón debajo, nada más. Cuanto
   menos hay que leer para volver a jugar, antes se vuelve a jugar. */
#muerto .cifra {
  font-family: var(--tipo-titulo);
  font-weight: 700;
  font-size: clamp(4.5rem, 26vw, 7rem);
  line-height: .9;
  color: var(--oro);
  text-shadow: 0 0 40px rgba(255, 212, 121, .35);
}
#muerto .cifra small {
  display: block;
  font-size: .68rem;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--texto-tenue);
  text-shadow: none;
  margin-bottom: .3rem;
}

.separador {
  width: min(20rem, 86vw);
  height: 1px;
  background: var(--panel-borde);
  margin: .6rem 0 .2rem;
}

.pie {
  font-size: .76rem;
  color: var(--texto-tenue);
  margin-top: .4rem;
}
.pie b { color: var(--oro); font-weight: 600; }
