/* ═══════════════════════════════════════════
   CARGA LA FURGO — style.css
   ═══════════════════════════════════════════ */

:root {
  --navy:     #0B214A;
  --turq:     #00E6BC;
  --lime:     #04FFB4;
  --mint:     #C5FFDF;
  --lemon:    #FFFFAB;
  --rojo:     #E74C3C;
  --white:    #FFFFFF;
  --card-bg:  rgba(255,255,255,0.07);
  --card-border: rgba(255,255,255,0.13);
}

/* ── Reset ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--navy);
  font-family: 'Baloo 2', sans-serif;
  color: var(--white);
  -webkit-tap-highlight-color: transparent;
}
html.results { overflow: auto; }

/* ── Wrapper ───────────────────────────────── */
.wrapper {
  width: 100%;
  max-width: 430px;
  height: 100%;
  margin: 0 auto;
  position: relative;
  padding-top:    env(safe-area-inset-top,    0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-top:    constant(safe-area-inset-top,    0px);
  padding-bottom: constant(safe-area-inset-bottom, 0px);
}

/* ── Screens ───────────────────────────────── */
.screen {
  display: none;
  position: fixed; inset: 0;
  overflow: hidden;
}
.screen.active { display: flex; align-items: center; justify-content: center; }

/* ══════════════════════════════════════════════
   INTRO
   ══════════════════════════════════════════════ */
.intro-inner {
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; padding-bottom: 28px;
  width: 100%;
}
.intro-avatar {
  width: 100%;
  aspect-ratio: 2111 / 1536;
  object-fit: cover;
  display: block;
}
.game-title {
  font-size: clamp(28px, 8vw, 36px);
  font-weight: 800;
  color: var(--lemon);
  text-align: center;
  line-height: 1.1;
  padding: 0 24px;
}
.game-subtitle {
  font-size: 16px; color: var(--mint); text-align: center;
  padding: 0 24px;
}

/* ── Bubble ────────────────────────────────── */
.bubble {
  background: var(--white);
  color: var(--navy);
  border-radius: 16px;
  padding: 12px 16px;
  font-size: 16px; font-weight: 600; line-height: 1.45;
  width: 100%; max-width: 370px;
  position: relative;
}
.bubble p { margin: 0; }

/* ── Button ────────────────────────────────── */
.btn {
  background: var(--turq); color: var(--navy);
  border: none; border-radius: 14px;
  padding: 14px 0; width: 100%; max-width: 300px;
  font-family: 'Baloo 2', sans-serif;
  font-size: 20px; font-weight: 700;
  cursor: pointer; touch-action: manipulation;
  transition: opacity .15s;
}
.btn:active { opacity: .75; }

/* ══════════════════════════════════════════════
   PLAY — layout
   ══════════════════════════════════════════════ */
.play-wrapper {
  display: flex; flex-direction: column;
  height: 100%; overflow: hidden;
}

/* ── Parking dial SVG — encima de .videocall ── */
#parking-dial {
  position: absolute;
  top: 10px; left: 10px;
  z-index: 20;
  filter: drop-shadow(0 2px 10px rgba(0,0,0,0.6));
}
#parking-dial.danger { animation: dialBlink .6s infinite; }
@keyframes dialBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: .3; }
}

/* Progreso flotante — esquina superior derecha de la imagen */
.hud-progress-overlay {
  position: absolute;
  top: 10px;
  right: 10px;
  padding-right: 56px; /* RN close button */
  z-index: 20;
  font-size: 22px; font-weight: 800;
  color: var(--mint);
  text-shadow: 0 1px 6px rgba(0,0,0,0.7);
}

/* ── Videocall ─────────────────────────────── */
.videocall {
  flex-shrink: 0;
  position: relative; overflow: hidden;
  width: 100%;
  /* aspect ratio del asset 2111×1536 ≈ 11:8 */
  aspect-ratio: 2111 / 1536;
  max-height: 48vh;
  background: #111;
}

/* Juan Carlos — landscape, cubre todo el área */
.jc-img {
  position: absolute;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center center;
  z-index: 10;
  transition: opacity .3s;
}

/* Bocadillo de texto — entre videollamada y bandeja, altura fija 3 líneas */
.call-bubble {
  flex-shrink: 0;
  margin: 0;
  border-radius: 0;
  border-top: 2px solid rgba(0,230,188,.18);
  border-bottom: 2px solid rgba(0,230,188,.18);
  font-size: 16px;
  line-height: 1.45;
  /* 3 líneas exactas: 3 × 16px × 1.45 + padding vertical */
  height: calc(3 * 16px * 1.45 + 20px);
  overflow: hidden;
  max-width: 100%;
  background: rgba(11,33,74,.97);
  color: var(--white);
  padding: 10px 16px;
  z-index: 20;
  position: relative;
  display: flex;
  align-items: center;
}

/* Lluvia */
#rain-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 18;
  opacity: 0; transition: opacity .6s;
}
#rain-canvas.active { opacity: 1; }

/* Notificación llamada */
.notif-call {
  position: absolute;
  top: -56px; left: 50%; transform: translateX(-50%);
  z-index: 25;
  background: var(--navy);
  border: 2px solid var(--turq);
  border-radius: 20px;
  padding: 8px 20px;
  font-size: 17px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap;
  transition: top .3s ease-out;
}
.notif-call.visible { top: 12px; }
.notif-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--rojo);
  animation: blink .8s infinite;
}

/* ── Bandeja ───────────────────────────────── */
.bandeja {
  flex: 1;
  background: #0d1b2e;
  border-top: 2px solid rgba(255,255,255,.08);
  overflow: hidden;
  position: relative;
}

.piezas-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 6px;
  padding: 8px;
  height: 100%;
}

/* Celda de pieza */
.pieza {
  background: var(--card-bg);
  border: 1.5px solid var(--card-border);
  border-radius: 12px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px;
  cursor: pointer; touch-action: manipulation;
  position: relative; overflow: hidden;
  transition: transform .1s ease, border-color .15s;
  user-select: none;
}
.pieza:active { transform: scale(1.06); }

.pieza img {
  width: 58px; height: 58px;
  object-fit: contain;
  pointer-events: none;
}
.pieza-name {
  font-size: 12px; font-weight: 700;
  color: var(--mint); text-align: center;
  line-height: 1.2; padding: 0 3px;
  pointer-events: none;
}

/* Estado acertada */
.pieza.done {
  opacity: .38; pointer-events: none;
}
.pieza-check {
  position: absolute; top: 4px; right: 4px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #27ae60;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: #fff; font-weight: 800;
  animation: popIn .2s ease-out;
  z-index: 5;
}

/* Tint de error */
.pieza.errada::after {
  content: '';
  position: absolute; inset: 0;
  background: rgba(231,76,60,.25);
  border-radius: 11px;
  pointer-events: none;
}
.pieza.errada { border-color: rgba(231,76,60,.5); }

/* ══════════════════════════════════════════════
   OVERLAY RECOMPENSA
   ══════════════════════════════════════════════ */
.overlay-reward {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(11,33,74,.88);
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 24px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .28s ease;
}
.overlay-reward.active {
  display: flex;
  opacity: 1;
}

.reward-img {
  width: 120px; height: 120px;
  object-fit: contain;
  /* start small at origin — JS overrides transform-origin */
  transform: scale(0);
  opacity: 0;
  filter: drop-shadow(0 0 24px rgba(4,255,180,.7));
  transition: transform .42s cubic-bezier(.18,1.4,.4,1), opacity .28s ease;
}
.reward-img.show {
  transform: scale(1);
  opacity: 1;
}

.reward-msg {
  font-size: 32px; font-weight: 800;
  color: var(--lime);
  text-align: center;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .3s ease .18s, transform .3s ease .18s;
}
.reward-msg.show {
  opacity: 1;
  transform: translateY(0);
}

/* ══════════════════════════════════════════════
   OVERLAY EDUCATIVO
   ══════════════════════════════════════════════ */
.overlay-edu {
  position: fixed; inset: 0; z-index: 200;
  background: var(--navy);
  display: none; flex-direction: column; align-items: center; justify-content: center;
  overflow-y: auto;
  animation: fadeIn .2s ease;
}
.overlay-edu.active { display: flex; }

.overlay-card {
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; width: 100%; max-width: 430px;
}
.overlay-jc {
  width: 100%; height: auto;
  aspect-ratio: 2111 / 1536;
  object-fit: cover;
  display: block;
}
.overlay-body {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 14px 18px;
  width: 100%; max-width: 100%;
  margin: 0 24px;
  box-sizing: border-box;
  display: flex; flex-direction: column; gap: 10px;
}
.overlay-mandaste {
  font-size: 15px; color: var(--mint); font-weight: 600; line-height: 1.45;
}
.overlay-pista {
  font-size: 16px; color: var(--lemon); font-weight: 700; line-height: 1.5;
}
.overlay-edu .btn {
  margin: 0 24px; width: calc(100% - 48px); max-width: 382px;
}

/* ══════════════════════════════════════════════
   RESULTADOS
   ══════════════════════════════════════════════ */
#screen-results .wrapper { overflow-y: auto; height: auto; min-height: 100%; }
.results-inner {
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; padding: 32px 24px 56px;
  width: 100%;
}
.results-avatar {
  width: min(220px, 55vw); height: auto;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,.4));
}
.results-estado { font-size: 26px; font-weight: 800; text-align: center; }
.results-estado.win  { color: var(--turq); }
.results-estado.lose { color: var(--rojo); }

.results-stats { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.results-fallos { font-size: 22px; font-weight: 700; color: var(--lemon); }
.results-extra  { font-size: 13px; color: var(--mint); }
.results-record { font-size: 12px; color: var(--mint); opacity: .7; }
.results-record.new { color: var(--turq); font-weight: 700; font-size: 14px; opacity: 1; animation: pulse .8s ease-in-out infinite alternate; }

.results-bubble { max-width: 100%; }

.results-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 6px; width: 100%;
}
.result-cell {
  background: var(--card-bg); border-radius: 10px;
  padding: 8px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 9px; color: var(--mint); text-align: center; font-weight: 600;
}
.result-icon { font-size: 15px; font-weight: 800; }

/* ══════════════════════════════════════════════
   ANIMACIONES
   ══════════════════════════════════════════════ */
@keyframes fadeIn  { from { opacity:0 } to { opacity:1 } }
@keyframes popIn   { from { transform:scale(0) } to { transform:scale(1) } }
@keyframes blink   { 0%,100% { opacity:1 } 50% { opacity:.25 } }
@keyframes pulse   { from { opacity:.7 } to { opacity:1 } }

@keyframes shake {
  0%   { transform: translateX(0) }
  15%  { transform: translateX(-8px) }
  35%  { transform: translateX(8px) }
  55%  { transform: translateX(-5px) }
  75%  { transform: translateX(5px) }
  100% { transform: translateX(0) }
}
.pieza.shaking { animation: shake .4s linear; }

/* Clone volando */
.pieza-clone {
  position: fixed; z-index: 500;
  pointer-events: none;
  width: 58px; height: 58px;
  object-fit: contain;
}

/* ── ASMR feedback ─────────────────────────────── */

/* Glow ring — correct */
@keyframes glowCorrect {
  0%   { box-shadow: 0 0 0 0 rgba(4,255,180,.9), inset 0 0 0 2px rgba(4,255,180,.9); opacity: 1; }
  60%  { box-shadow: 0 0 0 14px rgba(4,255,180,.0), inset 0 0 0 2px rgba(4,255,180,.0); opacity: 1; }
  100% { opacity: 0; }
}
.pieza.asmr-correct {
  animation: glowCorrect .55s ease-out forwards;
  border-color: var(--lime) !important;
}

/* Shockwave ring — wrong */
@keyframes shockwave {
  0%   { transform: scale(1); opacity: .85; }
  100% { transform: scale(1.9); opacity: 0; }
}
.pieza-shock {
  position: fixed; z-index: 501; pointer-events: none;
  border-radius: 14px;
  border: 3px solid var(--rojo);
  box-shadow: 0 0 8px 2px rgba(231,76,60,.5);
}
.pieza-shock.run {
  animation: shockwave .45s cubic-bezier(.2,0,.8,1) forwards;
}

/* Particle canvas overlay */
#asmr-canvas {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 502;
}
