:root {
  --green-paramo: #10b981;
  --volcano-orange: #f97316;
  --lake-blue: #06b6d4;
  --fauna-gold: #eab308;
  --guardian-purple: #8b5cf6;
  --dark-glass: rgba(15, 23, 42, 0.92);
  --border-glass: rgba(255, 255, 255, 0.18);
  --text-white: #f8fafc;
}

/* Reset Global Limpio */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #050811;
  color: var(--text-white);
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
}

/* CANVAS TRES.JS EN CAPA POSTERIOR */
#canvas3d {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: block;
}

/* PORTADA DE BIENVENIDA CON SCROLL INTERNO Y SOPORTE GLASS */
.welcome-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 8, 17, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  overflow-y: auto;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.welcome-card {
  background: var(--dark-glass);
  border: 1px solid var(--border-glass);
  padding: 32px 24px;
  border-radius: 24px;
  max-width: 580px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  margin: auto;
}

.welcome-badge {
  display: inline-block;
  background: rgba(16, 185, 129, 0.15);
  color: var(--green-paramo);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 2px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(16, 185, 129, 0.3);
  margin-bottom: 12px;
}

.welcome-card h1 {
  font-size: 1.8rem;
  color: #ffffff;
  margin-bottom: 16px;
}

/* FICHA DE DATOS PERSONALES */
.profile-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(234, 179, 8, 0.3);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 18px;
  text-align: left;
}

.profile-card h3 {
  font-size: 0.85rem;
  color: var(--fauna-gold);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid rgba(234, 179, 8, 0.2);
  padding-bottom: 4px;
}

.profile-info {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  color: #e2e8f0;
}

.profile-info li strong {
  color: var(--green-paramo);
}

.welcome-subtitle {
  font-size: 0.9rem;
  line-height: 1.5;
  color: #cbd5e1;
  margin-bottom: 18px;
}

.levels-preview {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.levels-preview span {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-glass);
  padding: 5px 10px;
  border-radius: 10px;
  font-size: 0.8rem;
  color: #e2e8f0;
}

.start-game-btn {
  background: linear-gradient(135deg, var(--green-paramo), #059669);
  color: #ffffff;
  border: none;
  padding: 14px 32px;
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(16, 185, 129, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
  max-width: 280px;
}

.start-game-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(16, 185, 129, 0.5);
}

/* INTERFAZ HUD SUPERPUESTA */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px;
  pointer-events: none;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--dark-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 12px 20px;
  border-radius: 16px;
  border: 1px solid var(--border-glass);
  pointer-events: auto;
}

.badge-label {
  font-size: 0.7rem;
  letter-spacing: 1px;
  color: var(--green-paramo);
  font-weight: 700;
}

.level-badge h2 {
  font-size: 1.1rem;
}

.stats-container {
  display: flex;
  gap: 12px;
}

.stat-box {
  background: rgba(255, 255, 255, 0.06);
  padding: 6px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.instruction-banner {
  align-self: center;
  background: var(--dark-glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 8px 18px;
  border-radius: 20px;
  border: 1px solid var(--border-glass);
  font-size: 0.88rem;
  text-align: center;
}

.instruction-banner code {
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 5px;
  border-radius: 4px;
  color: var(--fauna-gold);
}

/* MODALES Y RETOS */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 16px;
  pointer-events: auto;
}

.modal-card {
  background: var(--dark-glass);
  border: 1px solid var(--border-glass);
  padding: 24px;
  border-radius: 20px;
  max-width: 500px;
  width: 100%;
  text-align: center;
}

.modal-card h3 {
  font-size: 1.4rem;
  color: var(--fauna-gold);
  margin-bottom: 10px;
}

.modal-card p {
  font-size: 0.95rem;
  line-height: 1.4;
  color: #cbd5e1;
  margin-bottom: 20px;
}

.quiz-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-option {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-glass);
  padding: 12px 14px;
  border-radius: 10px;
  color: #ffffff;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease;
}

.quiz-option:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: var(--green-paramo);
}

.primary-btn {
  background: linear-gradient(135deg, var(--green-paramo), #059669);
  color: #ffffff;
  border: none;
  padding: 12px 24px;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  margin-top: 16px;
}

.hidden {
  display: none !important;
}

/* CONTROLES PARA MÓVILES */
.mobile-controls {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: auto;
  width: 100%;
}

.dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.dpad-row {
  display: flex;
  gap: 4px;
}

.dpad-btn {
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  color: #ffffff;
  font-size: 1.1rem;
  cursor: pointer;
}

.dpad-btn:active {
  background: rgba(255, 255, 255, 0.3);
}

.action-trigger-btn {
  background: linear-gradient(135deg, var(--volcano-orange), #ea580c);
  border: none;
  color: #ffffff;
  padding: 14px 20px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}

/* RESPONSIVIDAD PARA PANTALLAS PEQUEÑAS */
@media (max-width: 500px) {
  .top-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .stats-container {
    width: 100%;
    justify-content: space-between;
  }
}