/* =====================================================================
   Los Gordis — estilos.css
   Estilo alegre tipo cartoon: colores cálidos, botones "3D", texto con
   contorno. Pantalla completa, sin scroll y preparado para móvil.
   ===================================================================== */

:root {
  --naranja: #ff9f43;
  --naranja-osc: #d9731a;
  --amarillo: #ffd23f;
  --amarillo-osc: #d9a400;
  --rosa: #ff6b9a;
  --rosa-osc: #c93e6c;
  --crema: #fff6e5;
  --marron: #5a3418;
  --marron-claro: #8a5a33;
  --verde: #4cd17a;
  --azul: #49b6ff;
  --sombra: rgba(70, 35, 10, 0.35);

  --fuente: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Quicksand",
            "Arial Rounded MT Bold", "Comic Sans MS", system-ui, -apple-system,
            "Segoe UI", Roboto, sans-serif;

  /* Márgenes seguros (notch, barra de gestos) */
  --sa-arriba: env(safe-area-inset-top, 0px);
  --sa-derecha: env(safe-area-inset-right, 0px);
  --sa-abajo: env(safe-area-inset-bottom, 0px);
  --sa-izquierda: env(safe-area-inset-left, 0px);

  color-scheme: light;
}

/* ---------- Base: pantalla completa, sin scroll ni selección ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed;
  inset: 0;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: #ffcf8a; /* se ve un instante antes de que el motor pinte */
  font-family: var(--fuente);
  color: var(--marron);
}

#juego {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: block;
  touch-action: none;
  background: linear-gradient(#8fd3ff, #ffe3b0);
}

/* ---------- Capa de interfaz: no captura toques por defecto ---------- */
#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.capa {
  position: absolute;
  inset: 0;
  padding: calc(12px + var(--sa-arriba)) calc(12px + var(--sa-derecha))
           calc(12px + var(--sa-abajo)) calc(12px + var(--sa-izquierda));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}
.capa.visible {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.25s ease, visibility 0s;
}

/* Paneles modales (menú, pausa, game over...): centrados y capturan toques */
.capa.modal {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}
.capa.modal.visible { pointer-events: auto; }
.capa-oscura { background: rgba(60, 25, 5, 0.38); }

/* Los botones siempre aceptan toques cuando su capa está visible */
.boton { pointer-events: auto; }

/* ---------- Paneles ---------- */
.panel {
  position: relative;
  width: min(92vw, 420px);
  max-height: 100%;
  padding: 22px 22px 24px;
  background: var(--crema);
  border: 4px solid var(--marron);
  border-radius: 28px;
  box-shadow: 0 8px 0 var(--marron), 0 14px 28px var(--sombra);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transform: scale(0.9) translateY(14px);
  transition: transform 0.3s cubic-bezier(.2, 1.6, .4, 1);
}
.capa.visible .panel { transform: none; }
.panel-mini { width: min(86vw, 340px); }

/* El menú va sin fondo de tarjeta: flota sobre el escenario */
.panel-menu {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 8px;
}

/* ---------- Tipografía con contorno ---------- */
.titulo, .titulo-panel, .texto-grande, .hud-chip, .nuevo-record {
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #fff;
  /* contorno marrón "cartoon" (compatible en todos los navegadores) */
  text-shadow:
    -3px -3px 0 var(--marron), 3px -3px 0 var(--marron),
    -3px 3px 0 var(--marron), 3px 3px 0 var(--marron),
    0 -3px 0 var(--marron), 0 3px 0 var(--marron),
    -3px 0 0 var(--marron), 3px 0 0 var(--marron),
    0 7px 0 var(--marron);
}

.titulo {
  margin: 0;
  font-size: clamp(44px, 13vw, 76px);
  line-height: 0.92;
  color: var(--amarillo);
  transform: rotate(-3deg);
  animation: titulo-bote 2.4s ease-in-out infinite;
}
@keyframes titulo-bote {
  0%, 100% { transform: rotate(-3deg) translateY(0); }
  50%      { transform: rotate(-1deg) translateY(-6px); }
}

.titulo-panel {
  margin: 0;
  font-size: clamp(32px, 9vw, 46px);
  color: var(--naranja);
}

.texto-grande { margin: 0; font-size: 28px; }
.texto-suave { margin: 0; font-size: 16px; color: var(--marron-claro); font-weight: 700; }
.texto-error { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.35; word-break: break-word; }
.emoji-grande { font-size: 56px; line-height: 1; }

.record-menu {
  margin: 0;
  padding: 6px 16px;
  font-size: 18px;
  font-weight: 900;
  color: var(--marron);
  background: rgba(255, 246, 229, 0.92);
  border: 3px solid var(--marron);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--marron);
}

.instrucciones {
  margin: 4px 0 0;
  max-width: 340px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--marron);
  background: rgba(255, 246, 229, 0.85);
  border-radius: 16px;
}

/* ---------- Botones "3D" ---------- */
.boton {
  font-family: inherit;
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 0.04em;
  color: #fff;
  cursor: pointer;
  border: 4px solid var(--marron);
  border-radius: 999px;
  padding: 14px 34px;
  min-height: 56px;
  background: var(--naranja);
  box-shadow: 0 7px 0 var(--marron), 0 10px 18px var(--sombra);
  text-shadow: 0 2px 0 rgba(90, 52, 24, 0.6);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s ease, opacity 0.2s;
  outline: none;
}
.boton:hover { filter: brightness(1.06); }
.boton:active {
  transform: translateY(6px);
  box-shadow: 0 1px 0 var(--marron), 0 3px 6px var(--sombra);
}
.boton:focus-visible { outline: 4px dashed var(--azul); outline-offset: 4px; }
.boton:disabled { opacity: 0.55; filter: grayscale(0.4); cursor: default; }
.boton:disabled:active { transform: none; box-shadow: 0 7px 0 var(--marron), 0 10px 18px var(--sombra); }

.boton-principal {
  background: linear-gradient(var(--amarillo), var(--naranja));
  font-size: 26px;
  padding: 16px 46px;
  min-width: 200px;
}
.boton-principal:not(:disabled) { animation: latido 1.6s ease-in-out infinite; }
.boton-principal:active { animation: none; }
@keyframes latido {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.05); }
}

.boton-secundario {
  background: var(--rosa);
  font-size: 18px;
  padding: 10px 26px;
  min-height: 48px;
}

.boton-redondo {
  width: 54px;
  height: 54px;
  min-height: 0;
  padding: 0;
  font-size: 24px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--crema);
  text-shadow: none;
  box-shadow: 0 5px 0 var(--marron), 0 8px 14px var(--sombra);
}
.boton-redondo:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--marron); }
.boton-redondo.apagado { background: #e5d6c0; }

.boton-esquina {
  position: absolute;
  top: calc(14px + var(--sa-arriba));
  right: calc(14px + var(--sa-derecha));
}

.fila-botones { display: flex; gap: 14px; align-items: center; justify-content: center; }

/* ---------- Cargando ---------- */
.cargando-huella {
  font-size: 54px;
  animation: huella 0.9s ease-in-out infinite alternate;
}
@keyframes huella {
  from { transform: translateX(-14px) rotate(-12deg); }
  to   { transform: translateX(14px) rotate(12deg); }
}

/* ---------- Retratos ---------- */
.retrato-marco {
  border-radius: 50%;
  border: 5px solid var(--marron);
  background: var(--amarillo);
  box-shadow: 0 7px 0 var(--marron), 0 12px 24px var(--sombra);
  overflow: hidden;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.retrato-menu { width: 150px; height: 150px; animation: retrato-bote 1.2s ease-in-out infinite; }
.retrato-gameover { width: 140px; height: 140px; }

.retrato-img { width: 100%; height: 100%; display: block; border-radius: 50%; }
.retrato-sustituto { font-size: 80px; line-height: 1; }

@keyframes retrato-bote {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50%      { transform: translateY(-8px) rotate(4deg); }
}

/* ---------- Menú ---------- */
.menu-contenido {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* ---------- HUD ---------- */
#capa-hud { padding-top: calc(10px + var(--sa-arriba)); }

.hud-fila {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.hud-marcadores {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.hud-chip {
  padding: 4px 14px;
  border-radius: 999px;
  background: rgba(90, 52, 24, 0.25);
  font-size: 24px;
  line-height: 1.2;
  text-shadow:
    -2px -2px 0 var(--marron), 2px -2px 0 var(--marron),
    -2px 2px 0 var(--marron), 2px 2px 0 var(--marron),
    0 4px 0 var(--marron);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.hud-puntos { font-size: 30px; color: #fff; min-width: 70px; text-align: center; }
.hud-huesos { color: var(--amarillo); }

.hud-poderes { display: flex; gap: 8px; }

.hud-poder {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 6px;
  border-radius: 999px;
  background: var(--crema);
  border: 3px solid var(--marron);
  box-shadow: 0 4px 0 var(--marron);
}
.hud-poder.activo { display: flex; animation: aparecer 0.3s cubic-bezier(.2, 1.6, .4, 1); }
.hud-poder.acabando { animation: parpadeo 0.3s steps(2, start) infinite; }
.hud-poder-icono { font-size: 20px; line-height: 1; }

.hud-barra {
  position: relative;
  width: 56px;
  height: 10px;
  border-radius: 999px;
  background: #e5d6c0;
  border: 2px solid var(--marron);
  overflow: hidden;
}
.hud-barra-relleno {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(1);
  will-change: transform;
}
#hud-escudo .hud-barra-relleno { background: var(--verde); }
#hud-iman .hud-barra-relleno { background: var(--rosa); }

@keyframes aparecer { from { transform: scale(0.3); } to { transform: scale(1); } }
@keyframes parpadeo { to { opacity: 0.35; } }

/* ---------- Game over ---------- */
.gameover-cabeza { position: relative; margin-top: 4px; }

/* Gordi mareado: cae inclinada y se tambalea */
.capa-gameover.visible .retrato-gameover,
#capa-gameover.visible .retrato-gameover {
  animation: caida 0.6s cubic-bezier(.3, 1.8, .5, 1) both, mareada 2.2s ease-in-out 0.6s infinite;
}
@keyframes caida {
  from { transform: translateY(-40px) rotate(0deg) scale(0.6); }
  to   { transform: translateY(0) rotate(-16deg) scale(1); }
}
@keyframes mareada {
  0%, 100% { transform: rotate(-16deg); }
  25%      { transform: rotate(-6deg) translateX(4px); }
  50%      { transform: rotate(-20deg); }
  75%      { transform: rotate(-10deg) translateX(-4px); }
}

.mareo {
  position: absolute;
  top: -14px;
  right: -12px;
  font-size: 36px;
  animation: girar 1.4s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

.gameover-contenido {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.nuevo-record {
  display: none;
  margin: 0;
  font-size: 26px;
  color: var(--amarillo);
}
.nuevo-record.visible { display: block; animation: record-pop 0.8s ease-in-out infinite alternate; }
@keyframes record-pop {
  from { transform: scale(1) rotate(-3deg); }
  to   { transform: scale(1.12) rotate(3deg); }
}

.mensaje-gracioso {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  font-style: italic;
  line-height: 1.3;
  color: var(--marron-claro);
  min-height: 2.6em;
  display: flex;
  align-items: center;
}

.go-stats {
  display: flex;
  gap: 8px;
  width: 100%;
  justify-content: center;
}
.go-stat {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 4px;
  background: #fff;
  border: 3px solid var(--marron);
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--marron);
}
.go-stat-etiqueta { font-size: 12px; font-weight: 800; color: var(--marron-claro); white-space: nowrap; }
.go-stat-valor { font-size: 24px; font-weight: 900; color: var(--marron); font-variant-numeric: tabular-nums; }
#capa-gameover.con-record #go-record { color: var(--naranja-osc); }

.noscript {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  font: 900 22px var(--fuente); color: var(--marron); background: var(--crema); pointer-events: auto;
}

/* ---------- Pantallas pequeñas en vertical ---------- */
@media (max-height: 640px) and (orientation: portrait) {
  .retrato-menu { width: 120px; height: 120px; }
  .retrato-gameover { width: 110px; height: 110px; }
  .panel { gap: 9px; padding: 16px 16px 18px; }
}

/* ---------- Horizontal (móvil tumbado): retrato a la izquierda ---------- */
@media (orientation: landscape) and (max-height: 560px) {
  .panel-gameover {
    flex-direction: row;
    width: min(94vw, 680px);
    gap: 22px;
    text-align: left;
  }
  .panel-gameover { padding: 14px 18px 16px; }
  .menu-contenido, .gameover-contenido { align-items: center; text-align: center; flex: 1 1 auto; }
  .gameover-contenido { gap: 7px; }
  .retrato-menu { width: 130px; height: 130px; }
  .retrato-gameover { width: 110px; height: 110px; }
  .titulo { font-size: clamp(36px, 10vh, 60px); }
  .titulo-panel { font-size: 30px; }
  .panel { gap: 8px; padding-top: 14px; padding-bottom: 16px; }
  .boton-principal { font-size: 22px; padding: 12px 36px; min-height: 50px; }
  .boton-secundario { min-height: 42px; padding: 8px 22px; }
  .mensaje-gracioso { min-height: 0; font-size: 15px; }
  .go-stat-valor { font-size: 20px; }
  .instrucciones { font-size: 13px; padding: 6px 12px; }
}

/* Horizontal muy bajo: compactar aún más */
@media (orientation: landscape) and (max-height: 380px) {
  .retrato-menu, .retrato-gameover { width: 90px; height: 90px; }
  .mareo { font-size: 26px; }
  .titulo { font-size: 38px; }
  .instrucciones { display: none; }
  .hud-chip { font-size: 20px; }
  .hud-puntos { font-size: 24px; }
}


/* =====================================================================
   Los Gordis: selección de personaje, vidas, escenario, carteles
   ===================================================================== */
.panel-menu { width: min(96vw, 560px); gap: 14px; }
.titulo { color: var(--naranja); }

.selector {
  display: flex;
  gap: 10px;
  justify-content: center;
  width: 100%;
}
.tarjeta {
  pointer-events: auto;
  flex: 1 1 0;
  max-width: 170px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px 10px;
  font-family: inherit;
  color: var(--marron);
  background: rgba(255, 246, 229, 0.92);
  border: 4px solid var(--marron);
  border-radius: 22px;
  box-shadow: 0 6px 0 var(--marron), 0 10px 18px var(--sombra);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.15s cubic-bezier(.2, 1.6, .4, 1), background 0.15s, box-shadow 0.15s;
  outline: none;
}
.tarjeta:focus-visible { outline: 4px dashed var(--azul); outline-offset: 3px; }
.tarjeta:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--marron); }
.tarjeta.elegida {
  background: linear-gradient(#fff3c4, var(--amarillo));
  transform: translateY(-6px) scale(1.04);
  box-shadow: 0 10px 0 var(--marron), 0 16px 24px var(--sombra);
}
.tarjeta .retrato-marco { width: 86px; height: 86px; border-width: 4px; box-shadow: 0 4px 0 var(--marron); }
.tarjeta.elegida .retrato-marco { animation: retrato-bote 1.2s ease-in-out infinite; }
.tarjeta-nombre { font-size: 20px; font-weight: 900; line-height: 1.1; }
.tarjeta-mote { font-size: 12px; font-weight: 800; color: var(--marron-claro); line-height: 1.1; }
.tarjeta-habilidad {
  font-size: 11px; font-weight: 800; line-height: 1.2;
  color: #fff; background: var(--rosa); border-radius: 999px; padding: 3px 8px;
}
.tarjeta-record { font-size: 12px; font-weight: 900; }

.instrucciones kbd {
  font: inherit; font-size: 12px; padding: 0 5px;
  border: 2px solid var(--marron); border-radius: 6px; background: #fff;
}

/* Vidas */
.hud-vidas { display: none; gap: 2px; font-size: 22px; line-height: 1; filter: drop-shadow(0 2px 0 var(--marron)); }
.hud-vidas.activo { display: flex; }
.hud-vidas .perdida { filter: grayscale(1); opacity: 0.35; }
.hud-vidas .latido { animation: aparecer 0.4s cubic-bezier(.2, 1.6, .4, 1); }

#hud-doble .hud-barra-relleno { background: var(--naranja); }

/* Escenario actual + progreso al siguiente */
.hud-derecha { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.hud-escenario {
  display: flex; flex-direction: column; align-items: flex-end; gap: 3px;
  padding: 4px 10px; border-radius: 14px;
  background: rgba(255, 246, 229, 0.85); border: 3px solid var(--marron);
  font-size: 13px; font-weight: 900; white-space: nowrap;
}
.hud-barra-escenario { width: 80px; height: 8px; }
#hud-escenario-barra { background: var(--azul); }

/* Cartel grande al cambiar de escenario */
.cartel {
  position: absolute;
  left: 50%; top: 30%;
  display: flex; flex-direction: column; align-items: center;
  transform: translate(-50%, -50%) scale(0.4);
  opacity: 0;
  pointer-events: none;
  text-align: center;
}
.cartel.visible { animation: cartel 2.4s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes cartel {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.4) rotate(-8deg); }
  15%  { opacity: 1; transform: translate(-50%, -50%) scale(1.08) rotate(2deg); }
  25%  { transform: translate(-50%, -50%) scale(1) rotate(-2deg); }
  80%  { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-2deg); }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(0.9) rotate(0deg); }
}
.cartel-emoji { font-size: 54px; line-height: 1; filter: drop-shadow(0 4px 0 rgba(90, 52, 24, 0.5)); }
.cartel-texto, .cartel-sub {
  font-weight: 900; color: #fff; white-space: nowrap;
  text-shadow:
    -3px -3px 0 var(--marron), 3px -3px 0 var(--marron),
    -3px 3px 0 var(--marron), 3px 3px 0 var(--marron),
    0 6px 0 var(--marron);
}
.cartel-texto { font-size: clamp(30px, 8vw, 52px); color: var(--amarillo); }
.cartel-sub { font-size: 18px; }

/* Pistas de las zonas táctiles */
.zonas {
  position: absolute; inset: auto 0 0 0;
  display: flex; justify-content: space-between;
  padding: 0 calc(16px + var(--sa-derecha)) calc(14px + var(--sa-abajo)) calc(16px + var(--sa-izquierda));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.zonas.visible { opacity: 1; }
.zona {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 999px;
  font-size: 14px; font-weight: 900; color: #fff;
  background: rgba(90, 52, 24, 0.45);
  border: 2px dashed rgba(255, 255, 255, 0.7);
}
.zona span { font-size: 20px; }

/* Game over con 4 estadísticas */
.go-stats { flex-wrap: wrap; }
.go-stat { min-width: 70px; }
.go-stat-texto { font-size: 15px; line-height: 1.6; white-space: nowrap; }

/* Selector en pantallas estrechas */
@media (max-width: 400px) {
  .tarjeta .retrato-marco { width: 70px; height: 70px; }
  .tarjeta-nombre { font-size: 17px; }
  .tarjeta-habilidad { font-size: 10px; padding: 2px 6px; }
  .selector { gap: 7px; }
}

/* Horizontal (móvil tumbado): todo más compacto */
@media (orientation: landscape) and (max-height: 560px) {
  .panel-menu { gap: 8px; padding: 4px; }
  .titulo br { display: none; }
  .titulo { font-size: clamp(30px, 9vh, 50px); }
  .tarjeta { padding: 6px 6px 8px; gap: 2px; }
  .tarjeta .retrato-marco { width: 60px; height: 60px; }
  .tarjeta-nombre { font-size: 17px; }
  .tarjeta-mote { display: none; }
  .cartel-emoji { font-size: 40px; }
}
@media (orientation: landscape) and (max-height: 380px) {
  .tarjeta .retrato-marco { width: 48px; height: 48px; }
  .tarjeta-record { display: none; }
  .hud-escenario { font-size: 11px; }
}

/* Accesibilidad: menos movimiento si el sistema lo pide */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
