/* Base: reset, tipografía, botones, guía, avisos, banda de ensayo y nieve. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--noche);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--fuente);
  font-size: 17px;
  line-height: 1.45;
  color: var(--texto);
  background:
    radial-gradient(120% 60% at 50% 0%, var(--noche3) 0%, transparent 70%),
    linear-gradient(180deg, var(--noche) 0%, var(--noche2) 100%) fixed;
  background-color: var(--noche);
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

body.jugando {
  overflow: hidden;
  overscroll-behavior: none;
}

h1, h2, h3, p {
  margin: 0;
}

img, svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

button {
  font: inherit;
  color: inherit;
}

/* Todo texto del servidor respeta sus saltos de línea. */
.texto-servidor {
  white-space: pre-line;
  overflow-wrap: anywhere;
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 3px solid var(--oro);
  outline-offset: 3px;
  border-radius: 10px;
}

/* Lo que solo recibe el foco por código (títulos, la raíz de la pantalla) no se
   alcanza con el tabulador: el recuadro dorado ahí solo despista. */
[tabindex="-1"]:focus,
[tabindex="-1"]:focus-visible {
  outline: none;
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  padding:
    calc(var(--seguro-arriba) + var(--alto-banda)) calc(var(--seguro-der))
    var(--seguro-abajo) calc(var(--seguro-izq));
}

.pantalla {
  width: 100%;
  max-width: var(--ancho-max);
  margin: 0 auto;
  padding: 12px var(--hueco) 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pantalla-centrada {
  min-height: calc(100dvh - var(--seguro-arriba) - var(--seguro-abajo) - var(--alto-banda));
  justify-content: center;
  align-items: center;
  text-align: center;
}

.titulo-pantalla {
  font-size: 1.65rem;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.subtitulo {
  color: var(--texto-suave);
}

/* ——— Botones ——— */

.boton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--diana);
  min-width: var(--diana);
  padding: 10px 20px;
  border: 0;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.12s ease, filter 0.12s ease, background-color 0.2s ease;
}

.boton:active:not(:disabled) {
  transform: scale(0.96);
}

.boton:disabled {
  cursor: default;
  opacity: 0.65;
}

.boton-principal {
  background: var(--rojo);
  color: var(--nieve);
  box-shadow: 0 4px 0 var(--rojo-oscuro), var(--sombra-suave);
}

.boton-principal:hover:not(:disabled) {
  filter: brightness(1.07);
}

.boton-suave {
  background: rgba(247, 243, 234, 0.1);
  color: var(--nieve);
  box-shadow: inset 0 0 0 2px rgba(247, 243, 234, 0.25);
}

.boton-grande {
  min-height: 60px;
  padding: 14px 32px;
  font-size: 1.25rem;
}

.botonera {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  width: 100%;
}

.botonera > .boton {
  flex: 1 1 140px;
  max-width: 320px;
}

.botonera-fija {
  position: sticky;
  bottom: calc(12px + var(--seguro-abajo));
  margin-top: auto;
  padding-top: 8px;
}

/* ——— Barra superior ——— */

.barra {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.boton-volver {
  padding: 8px 16px 8px 10px;
  background: rgba(247, 243, 234, 0.08);
  color: var(--nieve);
}

.icono {
  width: 24px;
  height: 24px;
  flex: none;
}

.icono-flecha {
  width: 22px;
  height: 22px;
}

.icono-grande {
  width: 64px;
  height: 64px;
}

.insignia-dia {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--oro);
  color: var(--carbon);
  font-weight: 800;
}

/* ——— Guía y bocadillo ——— */

.guia-habla {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  width: 100%;
  text-align: left;
}

.guia {
  flex: none;
  width: 76px;
  height: 76px;
  animation: flotar 4s ease-in-out infinite;
}

.guia-dibujo,
.guia-foto {
  width: 100%;
  height: 100%;
}

.guia-foto {
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid var(--oro);
  background: var(--noche2);
}

.guia-grande .guia {
  width: 112px;
  height: 112px;
}

.guia-pequena .guia {
  width: 60px;
  height: 60px;
}

.bocadillo {
  position: relative;
  flex: 1;
  min-width: 0;
  padding: 10px 14px 12px;
  margin-bottom: 14px;
  border-radius: var(--radio) var(--radio) var(--radio) 6px;
  background: var(--crema);
  color: var(--texto-papel);
  box-shadow: var(--sombra-suave);
}

.bocadillo::before {
  content: "";
  position: absolute;
  left: -8px;
  bottom: 6px;
  width: 16px;
  height: 16px;
  background: var(--crema);
  clip-path: polygon(100% 0, 0 100%, 100% 100%);
}

.bocadillo-nombre {
  display: block;
  overflow-wrap: anywhere;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--rojo);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.bocadillo-texto {
  font-size: 1rem;
}

.bocadillo-nuevo {
  animation: rebote 0.35s ease-out;
}

/* ——— Cargando ——— */

.cargando-estrella {
  animation: girar 2.4s linear infinite;
}

.cargando-texto {
  color: var(--texto-suave);
}

/* ——— Avisos ——— */

.avisos {
  position: fixed;
  z-index: 60;
  left: 0;
  right: 0;
  bottom: calc(16px + var(--seguro-abajo));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 var(--hueco);
  pointer-events: none;
}

/* Durante la partida los avisos no tapan el juego. */
body.jugando .avisos {
  display: none;
}

.aviso {
  max-width: 440px;
  padding: 12px 18px;
  border-radius: var(--radio-pequeno);
  background: var(--crema);
  color: var(--carbon);
  font-weight: 600;
  text-align: center;
  box-shadow: var(--sombra);
  animation: subir 0.3s ease-out;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.aviso-saliendo {
  opacity: 0;
  transform: translateY(8px);
}

/* ——— Banda del modo ensayo ——— */

.banda-ensayo {
  position: fixed;
  z-index: 70;
  top: 0;
  left: 0;
  right: 0;
  /* Siempre una sola línea de 32 px: la capa del juego empieza justo debajo
     (dia.css) y en 320 px de ancho el texto partido tapaba el HUD. */
  box-sizing: border-box;
  height: calc(32px + var(--seguro-arriba));
  padding: calc(6px + var(--seguro-arriba)) 12px 6px;
  line-height: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: repeating-linear-gradient(-45deg, var(--oro) 0 14px, #d9a43c 14px 28px);
  color: var(--carbon);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
  pointer-events: none;
}

.banda-ensayo[hidden] {
  display: none;
}

/* ——— Nieve decorativa (solo transform: barata para el móvil) ——— */

.nieve {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.nieve::before,
.nieve::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  will-change: transform;
}

.nieve::before {
  top: -180px;
  background-image:
    radial-gradient(2px 2px at 20px 30px, rgba(247, 243, 234, 0.8) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 90px 120px, rgba(247, 243, 234, 0.6) 50%, transparent 51%),
    radial-gradient(2.5px 2.5px at 140px 60px, rgba(247, 243, 234, 0.7) 50%, transparent 51%);
  background-size: 180px 180px;
  animation: nevar1 14s linear infinite;
}

.nieve::after {
  top: -260px;
  background-image:
    radial-gradient(3px 3px at 60px 40px, rgba(247, 243, 234, 0.5) 50%, transparent 51%),
    radial-gradient(2px 2px at 200px 170px, rgba(247, 243, 234, 0.45) 50%, transparent 51%);
  background-size: 260px 260px;
  animation: nevar2 22s linear infinite;
}

body.jugando .nieve {
  display: none;
}

@keyframes nevar1 {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(0, 180px, 0); }
}

@keyframes nevar2 {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(0, 260px, 0); }
}

@keyframes flotar {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes rebote {
  0% { transform: scale(0.94); }
  60% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

@keyframes girar {
  to { transform: rotate(360deg); }
}

@keyframes subir {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

noscript p {
  padding: 24px;
  text-align: center;
}

/* ——— Menos movimiento ——— */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .nieve {
    display: none;
  }
}
