@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Press+Start+2P&family=Rajdhani:wght@600;700&display=swap');

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #0b0e14;
  font-family: 'Rajdhani', sans-serif;
  color: #fff;
}

#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#webgl-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ================= HUD SUPERIOR ================= */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 10;
  background: linear-gradient(to bottom, rgba(10, 14, 25, 0.85) 0%, rgba(10, 14, 25, 0) 100%);
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.hud-card {
  background: rgba(18, 24, 38, 0.75);
  border: 1px solid rgba(255, 215, 0, 0.35);
  border-radius: 10px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
}

.hud-icon {
  font-size: 1.3rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.hud-label {
  font-size: 0.75rem;
  color: #9ab4d0;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.hud-val {
  font-family: 'Fredoka One', cursive;
  font-size: 1.25rem;
  color: #ffd700;
  letter-spacing: 0.5px;
}

/* Indicador de peligro del Agua */
.water-gauge-container {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 130px;
}

.water-gauge-bar {
  width: 100%;
  height: 10px;
  background: #111a2e;
  border: 1px solid #00e5ff;
  border-radius: 5px;
  overflow: hidden;
}

.water-gauge-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #00e5ff, #ff3366);
  transition: width 0.2s ease, background 0.3s ease;
}

/* Viñeta de peligro bajo agua */
#danger-vignette {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 5;
  background: radial-gradient(circle at 50% 100%, rgba(0, 162, 255, 0.45) 0%, rgba(255, 0, 60, 0.3) 70%, transparent 100%);
}

#danger-vignette.critical {
  animation: pulse-danger 0.8s infinite alternate;
}

@keyframes pulse-danger {
  0% { opacity: 0.3; }
  100% { opacity: 0.85; }
}

/* Botón Pausa / Sonido */
.hud-btn {
  pointer-events: auto;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid #475569;
  color: #f1f5f9;
  border-radius: 8px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.hud-btn:hover {
  background: #3b82f6;
  border-color: #60a5fa;
  transform: scale(1.05);
}

/* ================= HUD RETRO INFERIOR (Estilo PHONEKY) ================= */
#retro-bottom-hud {
  position: absolute;
  bottom: 14px;
  left: 22px;
  right: 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 12;
}

.retro-arcade-text {
  font-family: 'Fredoka One', 'Press Start 2P', cursive, monospace;
  font-size: 1.85rem;
  letter-spacing: 1.5px;
  color: #ffea00;
  background: linear-gradient(to bottom, #fffb00 0%, #f59e0b 80%, #d97706 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: #ffea00;
  text-shadow:
    -2px -2px 0 #000,
     2px -2px 0 #000,
    -2px  2px 0 #000,
     2px  2px 0 #000,
     0px  3px 0 #000,
     3px  3px 0 #78350f,
     0px  0px 10px rgba(245, 158, 11, 0.45);
}

@media (max-width: 768px) {
  #retro-bottom-hud {
    bottom: 94px; /* Flota sobre los botones táctiles en celulares */
    left: 18px;
    right: 18px;
  }
  .retro-arcade-text {
    font-size: 1.45rem;
  }
}

/* ================= CONTROLES TÁCTILES MÓVILES ================= */
#touch-controls {
  position: absolute;
  bottom: 15px;
  left: 0;
  right: 0;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 15;
}

.touch-cluster {
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.touch-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.7);
  border: 2px solid rgba(255, 215, 0, 0.5);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  backdrop-filter: blur(6px);
  transition: transform 0.1s, background 0.1s, border-color 0.1s;
}

.touch-btn:active, .touch-btn.pressed {
  background: rgba(255, 215, 0, 0.35);
  border-color: #ffd700;
  transform: scale(0.92);
}

.touch-btn.btn-action-smash {
  background: rgba(239, 68, 68, 0.3);
  border-color: #ef4444;
}
.touch-btn.btn-action-smash:active {
  background: rgba(239, 68, 68, 0.6);
}

.touch-btn.btn-action-tongue {
  background: rgba(236, 72, 153, 0.35);
  border-color: #ec4899;
}
.touch-btn.btn-action-tongue:active {
  background: rgba(236, 72, 153, 0.7);
}

.touch-label-sub {
  position: absolute;
  bottom: -4px;
  font-size: 0.55rem;
  font-weight: bold;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ================= MODALES Y MENÚS ================= */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(6, 10, 18, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-card {
  background: linear-gradient(135deg, #162032 0%, #0d131f 100%);
  border: 2px solid #f59e0b;
  border-radius: 20px;
  padding: 30px 35px;
  max-width: 460px;
  width: 90%;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7), 0 0 25px rgba(245, 158, 11, 0.25);
  animation: pop-modal 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes pop-modal {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-title {
  font-family: 'Fredoka One', cursive;
  font-size: 2.1rem;
  color: #ffd700;
  text-shadow: 0 3px 10px rgba(255, 215, 0, 0.4);
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.modal-subtitle {
  font-size: 0.95rem;
  color: #94a3b8;
  margin-bottom: 20px;
}

.modal-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-box {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px;
}

.stat-box-val {
  font-family: 'Fredoka One', cursive;
  font-size: 1.6rem;
  color: #38bdf8;
}

.stat-box-lbl {
  font-size: 0.75rem;
  color: #64748b;
  text-transform: uppercase;
}

.modal-instruction-box {
  background: rgba(15, 23, 42, 0.6);
  border-left: 3px solid #ec4899;
  border-radius: 8px;
  padding: 12px;
  text-align: left;
  font-size: 0.88rem;
  color: #cbd5e1;
  margin-bottom: 22px;
  line-height: 1.4;
}

.modal-instruction-box ul {
  padding-left: 18px;
  margin-top: 6px;
}

.modal-btn-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-primary {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #000;
  font-family: 'Fredoka One', cursive;
  font-size: 1.25rem;
  padding: 14px 24px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.6);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.7);
  color: #cbd5e1;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  padding: 10px 20px;
  border: 1px solid #475569;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-secondary:hover {
  background: #334155;
}

/* Efecto de aturdimiento en pantalla */
#stun-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Fredoka One', cursive;
  font-size: 1.8rem;
  color: #facc15;
  text-shadow: 0 0 15px #ca8a04;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 20;
}

/* Efecto de notificación flotante */
.floating-toast {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid #ffd700;
  padding: 8px 18px;
  border-radius: 20px;
  font-family: 'Fredoka One', cursive;
  font-size: 1rem;
  color: #ffd700;
  pointer-events: none;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 25;
}

.floating-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(5px);
}

/* Optimización móvil y PC */
#pc-controls-legend {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(255, 215, 0, 0.45);
  border-radius: 30px;
  padding: 8px 22px;
  box-shadow: 0 4px 25px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: 12;
  pointer-events: none;
}

.key-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: #f1f5f9;
}

.key-pill kbd {
  background: #1e293b;
  border: 1px solid #64748b;
  border-bottom: 3px solid #334155;
  border-radius: 6px;
  padding: 3px 8px;
  font-family: inherit;
  font-weight: 700;
  color: #ffd700;
  font-size: 0.82rem;
  box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}

.key-pill span {
  color: #94a3b8;
  font-weight: 600;
}

@media (max-width: 820px) {
  #pc-controls-legend {
    display: none;
  }
  #touch-controls {
    display: flex;
    bottom: max(16px, env(safe-area-inset-bottom) + 8px);
    padding: 0 14px;
  }
}

@media (min-width: 821px) {
  #touch-controls {
    display: none;
  }
}

@media (max-width: 600px) {
  #hud {
    padding: max(6px, env(safe-area-inset-top) + 2px) 8px;
    gap: 6px;
  }
  .hud-group {
    gap: 6px;
  }
  .hud-card {
    padding: 4px 8px;
    gap: 5px;
  }
  .hud-icon {
    font-size: 1rem;
  }
  .hud-label {
    font-size: 0.65rem;
  }
  .hud-val {
    font-size: 0.95rem;
  }
  .water-gauge-container {
    width: 65px;
  }
  .hud-btn {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }
  .touch-btn {
    width: 60px;
    height: 60px;
    font-size: 1.4rem;
  }
  .touch-cluster {
    gap: 8px;
  }
  .modal-card {
    padding: 20px 16px;
    max-height: 88vh;
    overflow-y: auto;
  }
  .modal-title {
    font-size: 1.6rem;
  }
}

