/* ============================================================
   FRENZY DE FRASES — Estilos (arcade, mobile-first)
   ============================================================ */

:root {
  --rojo: #ff3b54;
  --rojo-osc: #c81f37;
  --azul: #2f7bff;
  --azul-osc: #1a52c4;
  --amarillo: #ffd23f;
  --verde: #22d3a6;
  --fondo: #0b1020;
  --fondo-2: #161d3a;
  --texto: #ffffff;
  --texto-suave: #b9c2e0;
  --sombra-btn: 0 6px 0 rgba(0, 0, 0, 0.35);
  --fuente: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  font-family: var(--fuente);
  color: var(--texto);
  background: radial-gradient(circle at 50% -10%, #1d2a5c 0%, var(--fondo) 60%);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* ---------- Pantallas ---------- */
.pantalla {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: max(16px, env(safe-area-inset-top)) 20px max(16px, env(safe-area-inset-bottom));
  overflow-y: auto;
}
.pantalla.activa { display: flex; }
.pantalla.centrada {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 18px;
}

/* ---------- Botones ---------- */
.btn {
  font-family: var(--fuente);
  font-weight: 800;
  border: none;
  border-radius: 18px;
  color: #fff;
  cursor: pointer;
  padding: 18px 24px;
  font-size: 20px;
  letter-spacing: 0.5px;
  box-shadow: var(--sombra-btn);
  transition: transform 0.06s ease, filter 0.1s ease;
  outline-offset: 3px;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,0.35); }
.btn:focus-visible { outline: 3px solid var(--amarillo); }

.btn-grande { font-size: 28px; padding: 24px 40px; width: 100%; max-width: 360px; }

.btn-jugar { background: linear-gradient(180deg, var(--verde), #14a17c); }
.btn-comenzar { background: linear-gradient(180deg, var(--amarillo), #e0a800); color: #2a1d00; }
.btn-correcto { background: linear-gradient(180deg, var(--verde), #14a17c); }
.btn-saltar { background: linear-gradient(180deg, #5a6488, #3a4470); }
.btn-borde {
  background: transparent;
  border: 3px solid rgba(255,255,255,0.35);
  box-shadow: none;
  color: var(--texto);
}
.btn-borde:active { transform: translateY(2px); }

/* ---------- Logo / inicio ---------- */
.logo { display: flex; flex-direction: column; align-items: center; line-height: 0.9; margin-bottom: 8px; }
.logo-frenzy {
  font-size: clamp(56px, 18vw, 120px);
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--amarillo);
  text-shadow: 0 0 18px rgba(255,210,63,0.5), 4px 5px 0 var(--rojo-osc);
  transform: rotate(-3deg);
}
.logo-frases {
  font-size: clamp(24px, 7vw, 44px);
  font-weight: 900;
  letter-spacing: 6px;
  color: #fff;
  text-shadow: 3px 3px 0 var(--azul-osc);
}
.logo-tag { margin-top: 12px; color: var(--texto-suave); font-size: 16px; letter-spacing: 1px; }
.menu-secundario { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.creditos { color: var(--texto-suave); font-size: 13px; margin-top: 6px; }

/* ---------- Títulos ---------- */
.titulo-pantalla {
  font-size: 30px; font-weight: 900; color: var(--amarillo);
  text-align: center; margin: 8px 0 18px; text-shadow: 2px 2px 0 var(--rojo-osc);
}

/* ---------- Ajustes ---------- */
.ajustes { display: flex; flex-direction: column; gap: 18px; max-width: 480px; width: 100%; margin: 0 auto; }
.campo { display: flex; flex-direction: column; gap: 8px; font-size: 17px; color: var(--texto); }
.campo-fila { flex-direction: row; align-items: center; justify-content: space-between; }
.campo select, .campo input[type="range"] {
  width: 100%; padding: 12px; border-radius: 12px; border: 2px solid rgba(255,255,255,0.2);
  background: var(--fondo-2); color: #fff; font-size: 16px; font-family: var(--fuente);
}
.campo input[type="range"] { padding: 0; accent-color: var(--verde); height: 30px; }
.switch { width: 54px; height: 30px; accent-color: var(--verde); transform: scale(1.4); }
.fila-botones { display: flex; gap: 12px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
.fila-botones .btn { flex: 1; min-width: 140px; max-width: 240px; }

/* ---------- Cómo se juega ---------- */
.reglas { max-width: 520px; margin: 0 auto 20px; font-size: 17px; line-height: 1.6; color: var(--texto); }
.reglas p { margin-bottom: 12px; }
.reglas ul { margin: 0 0 12px 22px; color: var(--texto-suave); }
.reglas b { color: var(--amarillo); }
#pantalla-como .btn { max-width: 360px; margin: 0 auto; width: 100%; }

/* ---------- Pasar dispositivo ---------- */
.aviso-pasar h2 { font-size: 34px; color: var(--amarillo); margin-bottom: 12px; }
.aviso-pasar p { font-size: 19px; color: var(--texto-suave); margin-bottom: 6px; }
.aviso-pasar .mini { font-size: 15px; }

/* ============================================================
   PANTALLA DE JUEGO
   ============================================================ */
/* Mantiene position:fixed de .pantalla (llena la pantalla); no usar relative. */
#pantalla-juego { padding: 0; justify-content: space-between; overflow: hidden; }

.pulso-fondo {
  position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255,210,63,0.0), rgba(255,210,63,0));
}
.pulso-fondo.late { animation: latido 0.4s ease-out; }
@keyframes latido {
  0% { background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.18), rgba(255,255,255,0) 60%); }
  100% { background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0), rgba(255,255,255,0) 60%); }
}

/* Intensidad: el borde late más fuerte y "caliente" conforme acelera */
#pantalla-juego.etapa-1 { box-shadow: inset 0 0 0 6px rgba(47,123,255,0.35); }
#pantalla-juego.etapa-2 { box-shadow: inset 0 0 0 8px rgba(34,211,166,0.45); }
#pantalla-juego.etapa-3 { box-shadow: inset 0 0 0 12px rgba(255,210,63,0.6); }
#pantalla-juego.etapa-4 { box-shadow: inset 0 0 0 16px rgba(255,59,84,0.8); animation: alerta 0.2s infinite alternate; }
@keyframes alerta { from { filter: brightness(1); } to { filter: brightness(1.12); } }

.btn-salir {
  position: absolute; top: max(10px, env(safe-area-inset-top)); right: 12px; z-index: 3;
  background: rgba(0,0,0,0.35); color: #fff; border: 2px solid rgba(255,255,255,0.25);
  border-radius: 999px; padding: 7px 14px; font-size: 14px; font-weight: 800; cursor: pointer;
  font-family: var(--fuente); letter-spacing: 0.5px;
}
.btn-salir:active { transform: scale(0.94); }
.btn-salir:focus-visible { outline: 3px solid var(--amarillo); }

.barra-superior {
  display: flex; align-items: center; justify-content: space-between;
  padding: max(46px, calc(env(safe-area-inset-top) + 40px)) 18px 8px; z-index: 1; position: relative;
}
.chip { font-weight: 900; font-size: 15px; padding: 6px 14px; border-radius: 999px; letter-spacing: 1px; }
.chip-rojo { background: var(--rojo); }
.chip-azul { background: var(--azul); }
.etiqueta-tip { font-size: 13px; color: var(--texto-suave); text-transform: uppercase; letter-spacing: 1px; }

.zona-palabra {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 12px 18px; text-align: center; z-index: 1; position: relative; min-height: 0;
}
.palabra {
  font-weight: 900; line-height: 1.05; color: #fff;
  text-shadow: 0 4px 18px rgba(0,0,0,0.4); word-break: break-word; hyphens: auto;
}

.zona-botones {
  display: flex; gap: 10px; padding: 12px 16px max(16px, env(safe-area-inset-bottom));
  z-index: 1; position: relative;
}
.btn-correcto { flex: 1; font-size: 26px; padding: 26px; border-radius: 22px; }
.btn-saltar { flex: 0 0 34%; max-width: 160px; font-size: 17px; }

/* ---------- Buzzer ---------- */
.titulo-buzzer { font-size: 44px; color: var(--rojo); text-shadow: 0 0 20px rgba(255,59,84,0.6); animation: alerta 0.25s infinite alternate; }
.pregunta { font-size: 24px; font-weight: 800; }
.mini { font-size: 14px; color: var(--texto-suave); }
.fila-equipos { display: flex; gap: 16px; margin-top: 12px; width: 100%; max-width: 460px; }
.btn-equipo { flex: 1; font-size: 20px; padding: 30px 12px; line-height: 1.3; }
.btn-equipo.rojo { background: linear-gradient(180deg, var(--rojo), var(--rojo-osc)); }
.btn-equipo.azul { background: linear-gradient(180deg, var(--azul), var(--azul-osc)); }
.btn-equipo b { font-size: 30px; }

/* ---------- Etiqueta equipo (bonus) ---------- */
.etiqueta-equipo { padding: 4px 12px; border-radius: 8px; }
.etiqueta-equipo.rojo { background: var(--rojo); }
.etiqueta-equipo.azul { background: var(--azul); }
.zona-bonus { flex: 0 1 auto; min-height: 30vh; }
.palabra-bonus { font-size: clamp(36px, 12vw, 80px); }

/* ---------- Marcador ---------- */
.tablero { display: flex; align-items: center; gap: 16px; margin: 10px 0 24px; }
.equipo-puntos {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 22px 26px; border-radius: 20px; min-width: 120px;
}
.equipo-puntos.rojo { background: linear-gradient(180deg, var(--rojo), var(--rojo-osc)); }
.equipo-puntos.azul { background: linear-gradient(180deg, var(--azul), var(--azul-osc)); }
.nombre-equipo { font-weight: 900; letter-spacing: 2px; }
.puntos { font-size: 64px; font-weight: 900; line-height: 1; }
.vs { font-size: 22px; color: var(--texto-suave); font-weight: 800; }

/* Palabra revelada (buzzer) y corrección de puntos (marcador) */
.palabra-revelada {
  font-size: 15px; color: var(--texto-suave); text-transform: uppercase; letter-spacing: 1px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 4px 0 6px;
}
.palabra-revelada b {
  font-size: clamp(28px, 8vw, 52px); color: #fff; letter-spacing: 0; text-transform: none;
  text-shadow: 0 3px 14px rgba(0,0,0,0.4); line-height: 1.05;
}
.marcador-palabra { font-size: 14px; color: var(--texto-suave); margin-bottom: 12px; }
.marcador-palabra b { color: var(--amarillo); }
.stepper { display: flex; gap: 8px; margin-top: 10px; }
.btn-step {
  width: 40px; height: 40px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.55);
  background: rgba(0,0,0,0.22); color: #fff; font-size: 24px; font-weight: 900; line-height: 1;
  cursor: pointer; font-family: var(--fuente); display: flex; align-items: center; justify-content: center;
}
.btn-step:active { transform: scale(0.88); }
.btn-step:focus-visible { outline: 3px solid var(--amarillo); }

/* ---------- Victoria ---------- */
#pantalla-victoria.rojo { background: radial-gradient(circle at 50% -10%, #5c1d2a 0%, var(--fondo) 60%); }
#pantalla-victoria.azul { background: radial-gradient(circle at 50% -10%, #1d2f5c 0%, var(--fondo) 60%); }
.texto-victoria {
  font-size: clamp(32px, 10vw, 64px); font-weight: 900; color: var(--amarillo);
  text-shadow: 3px 3px 0 var(--rojo-osc); z-index: 2;
}
.marcador-final-label { color: var(--texto-suave); font-size: 16px; z-index: 2; }
.marcador-final { font-size: 48px; font-weight: 900; z-index: 2; }

/* ---------- Confeti ---------- */
.confeti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 1; }
.confeti i {
  position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 2px;
  animation-name: caer; animation-timing-function: linear; animation-iteration-count: 1;
}
@keyframes caer {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg); opacity: 0.9; }
}

/* ---------- Responsive: orientación horizontal ---------- */
@media (orientation: landscape) and (max-height: 480px) {
  .logo-frenzy { font-size: 64px; }
  .zona-botones { flex-direction: row; }
  .fila-equipos { max-width: 600px; }
  .btn-equipo { padding: 18px 12px; }
}

/* ---------- Accesibilidad: reduce-motion ---------- */
@media (prefers-reduced-motion: reduce) {
  #pantalla-juego.etapa-4, .titulo-buzzer { animation: none; }
  .pulso-fondo.late { animation: none; }
  .confeti i { animation-duration: 0.01s; opacity: 0; }
}
