/* =========================================================
   FaunaQuest – Sistema de Diseño UI/UX Pro Max
   Estilo: Claymorphism Táctil + Gamificación Aventura
   Guía: design-system/faunaquest/MASTER.md
   Público: Niños (Primaria) y Adolescentes (Secundaria)
   ========================================================= */

@font-face { font-family: "Quicksand"; font-weight: 500; font-display: swap; src: url(../fonts/quicksand-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Quicksand"; font-weight: 600; font-display: swap; src: url(../fonts/quicksand-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Quicksand"; font-weight: 700; font-display: swap; src: url(../fonts/quicksand-latin-700-normal.woff2) format("woff2"); }

:root {
  /* Tipografías Oficiales UI/UX Pro Max */
  --font-display: "Baloo 2", "Fredoka", "Quicksand", system-ui, sans-serif;
  --font-body: "Outfit", "Comic Neue", "Quicksand", system-ui, sans-serif;

  /* Paleta Claymorphic Aventura de Alta Energía */
  --primary: #059669;
  --primary-light: #10b981;
  --primary-bright: #00d26a;
  --primary-dark: #047857;
  --primary-container: #10b981;
  --on-primary: #ffffff;
  --on-primary-container: #064e3b;

  --secondary: #0284c7;
  --secondary-light: #38bdf8;
  --secondary-container: #38bdf8;
  --on-secondary-container: #0369a1;

  --accent-orange: #f97316;
  --accent-orange-shadow: #c2410c;

  --sun-yellow: #f59e0b;
  --sun-yellow-light: #fbbf24;
  --sun-yellow-shadow: #b45309;
  --sun-yellow-glow: rgba(245, 158, 11, 0.35);

  --coral-pink: #f43f5e;
  --coral-pink-light: #fb7185;
  --coral-pink-shadow: #be123c;
  --pink: #f43f5e;

  --purple-epic: #4f46e5;
  --purple-light: #818cf8;
  --purple-shadow: #3730a3;

  --error: #ef4444;
  --error-container: #fee2e2;
  --error-shadow: #b91c1c;

  /* Superficies Claymorphic Limpias */
  --surface: #f0fbf5;
  --surface-lowest: #ffffff;
  --surface-low: #e6f7ee;
  --surface-c: #daf0e4;
  --surface-high: #cce7d8;
  --surface-variant: #bfded0;

  /* Texto y Contrastes WCAG AAA (Mínimo 4.5:1, aquí > 10:1) */
  --on-surface: #0f172a;
  --on-surface-variant: #475569;
  --outline: #94a3b8;
  --outline-variant: #cbd5e1;
  --soft-dark: #0f172a;

  /* Radios Claymorphic (16px-24px y Pill) */
  --r-sm: 0.65rem;
  --r: 1rem;
  --r-md: 1.35rem;
  --r-lg: 1.85rem;
  --r-xl: 2.5rem;
  --r-full: 9999px;

  --top: 80px;
  --dock: 92px;

  /* Sombras y Profundidad 3D Claymorphic */
  --btn-shadow-y: 5px;
  --btn-shadow-active-y: 1px;
  --clay-card-border: 3px solid var(--surface-high);
  --clay-card-shadow: 0 6px 0 0 rgba(15, 23, 42, 0.08), 0 16px 32px -8px rgba(15, 23, 42, 0.08);
  --clay-inner-bevel: inset 0 2px 0 rgba(255, 255, 255, 0.7);
  --glow: 0 4px 20px rgba(5, 150, 105, 0.2);
  --block: 0 4px 0 0 rgba(15, 23, 42, 0.08);
}

/* =========================================================
   Reset y Accesibilidad Global
   ========================================================= */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 16px;
  line-height: 1.5;
  background: var(--surface);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(16, 185, 129, 0.09) 0%, transparent 45%),
    radial-gradient(circle at 90% 80%, rgba(14, 165, 233, 0.09) 0%, transparent 45%);
  color: var(--on-surface);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* Cursor pointer garantizado en todos los elementos interactivos */
button,
.btn,
.sp-card,
.chip,
.seg button,
.avatars button,
.fab,
.explore-btn,
.close,
.badge,
.quest {
  cursor: pointer;
  user-select: none;
}

/* Enfoque visible de accesibilidad para navegación por teclado */
:focus-visible {
  outline: 3px solid var(--primary-light) !important;
  outline-offset: 3px !important;
}

h1, h2, h3 {
  font-family: var(--font-display);
  margin: 0 0 6px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  text-wrap: balance;
  color: var(--on-surface);
}

h3 {
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.muted { color: var(--on-surface-variant); font-size: 0.92rem; }
.small, small { font-size: 0.85rem; }
.hidden { display: none !important; }

/* Íconos SVG consistentes (Sin emojis como iconos UI) */
.modal-card:focus-visible { outline: none !important; }

.ic {
  width: 1.4em;
  height: 1.4em;
  fill: currentColor;
  flex: none;
  vertical-align: middle;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.08));
}
[data-icon] { display: inline-flex; align-items: center; }

/* =========================================================
   Controles Táctiles, Inputs y Segmentados
   ========================================================= */
.field-label {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--on-surface);
  margin: 16px 0 6px;
}

.input {
  width: 100%;
  padding: 14px 20px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  color: var(--on-surface);
  background: #ffffff;
  border: 3px solid var(--outline-variant);
  border-radius: var(--r-full);
  outline: none;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.04);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.22), inset 0 2px 4px rgba(0,0,0,0.04);
}

/* Switcher segmentado estilo consola táctil */
.seg {
  display: flex;
  gap: 6px;
  background: var(--surface-c);
  padding: 6px;
  border-radius: var(--r-full);
  border: 2.5px solid var(--surface-high);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.06);
}

.seg button {
  flex: 1;
  padding: 11px 16px;
  border-radius: var(--r-full);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--on-surface-variant);
  background: transparent;
  border: 0;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.seg button.active {
  background: #ffffff;
  color: var(--primary-dark);
  box-shadow: 0 4px 0 0 var(--surface-variant), 0 2px 8px rgba(0,0,0,0.08);
  transform: translateY(-2px);
}

/* =========================================================
   Botones 3D Táctiles (Arcade Claymorphism)
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 12px 26px;
  border: 0;
  border-radius: var(--r-full);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  background: #ffffff;
  color: var(--on-surface);
  box-shadow: 0 var(--btn-shadow-y) 0 0 #cbd5e1;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 42%;
  background: linear-gradient(180deg, rgba(255,255,255,0.35) 0%, transparent 100%);
  border-radius: var(--r-full) var(--r-full) 0 0;
  pointer-events: none;
}

.btn:hover {
  filter: brightness(1.03);
}

.btn:active {
  transform: translateY(var(--btn-shadow-y));
  box-shadow: 0 var(--btn-shadow-active-y) 0 0 transparent !important;
}

.btn.yellow {
  background: linear-gradient(180deg, #fcd34d 0%, #f59e0b 100%);
  color: #78350f;
  box-shadow: 0 var(--btn-shadow-y) 0 0 var(--sun-yellow-shadow);
  text-shadow: 0 1px 0 rgba(255,255,255,0.4);
}

.btn.green {
  background: linear-gradient(180deg, #34d399 0%, #059669 100%);
  color: #ffffff;
  box-shadow: 0 var(--btn-shadow-y) 0 0 #047857;
  text-shadow: 0 1px 2px rgba(0,0,0,0.25);
}

.btn.blue {
  background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%);
  color: #ffffff;
  box-shadow: 0 var(--btn-shadow-y) 0 0 #0369a1;
  text-shadow: 0 1px 2px rgba(0,0,0,0.25);
}

.btn.purple {
  background: linear-gradient(180deg, #a78bfa 0%, #4f46e5 100%);
  color: #ffffff;
  box-shadow: 0 var(--btn-shadow-y) 0 0 var(--purple-shadow);
}

.btn.soft {
  background: #ffffff;
  color: var(--on-surface-variant);
  border: 2.5px solid var(--outline-variant);
  box-shadow: 0 var(--btn-shadow-y) 0 0 var(--outline-variant);
}

.btn.danger {
  background: linear-gradient(180deg, #f87171 0%, #ef4444 100%);
  color: #ffffff;
  box-shadow: 0 var(--btn-shadow-y) 0 0 var(--error-shadow);
}

.btn.big {
  width: 100%;
  min-height: 62px;
  font-size: 1.2rem;
  letter-spacing: 0.02em;
  margin-top: 18px;
}

.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.row .btn { flex: 1; }

/* =========================================================
   HUD Superior (Topbar de Exploración)
   ========================================================= */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 1000;
  height: var(--top);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: env(safe-area-inset-top) 20px 0;
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 3px solid var(--surface-high);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand .title {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  background: linear-gradient(135deg, #059669 0%, #0284c7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.brand .sub {
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Avatar de juego con halo claymorphic */
.avatar {
  position: relative;
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 28px;
  background: radial-gradient(circle at 35% 30%, #d1fae5, #34d399);
  border: 3px solid #ffffff;
  box-shadow: 0 0 0 3px #10b981, 0 4px 10px rgba(16, 185, 129, 0.35);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.avatar:hover { transform: scale(1.08) rotate(3deg); }

.avatar.big {
  width: 88px;
  height: 88px;
  font-size: 48px;
  box-shadow: 0 0 0 4px #10b981, 0 8px 20px rgba(16, 185, 129, 0.35);
}

/* Medalla de nivel con bisel dorado */
.lvl-badge {
  position: absolute;
  right: -6px;
  bottom: -4px;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: var(--r-full);
  background: linear-gradient(180deg, #fde047 0%, #f59e0b 100%);
  border: 2px solid #ffffff;
  box-shadow: 0 3px 0 0 #b45309, 0 2px 6px rgba(0,0,0,0.25);
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  color: #78350f;
  display: grid;
  place-items: center;
  line-height: 1;
}

/* Píldora de XP con brillo */
.xp-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #fef08a 0%, #f59e0b 100%);
  color: #78350f;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.98rem;
  padding: 8px 16px 14px;
  border-radius: var(--r-full);
  border: 2px solid #ffffff;
  box-shadow: 0 4px 0 0 var(--sun-yellow-shadow), 0 4px 12px rgba(245, 158, 11, 0.3);
}

.xp-pill .ic {
  color: #b45309;
  filter: drop-shadow(0 1px 0 rgba(255,255,255,0.6));
}

.xpbar {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 5px;
  height: 5px;
  border-radius: var(--r-full);
  background: rgba(120, 53, 15, 0.22);
  overflow: hidden;
}

#hud-xp {
  height: 100%;
  width: 0;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, #059669, #34d399, #10b981);
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.8);
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* =========================================================
   Vistas y Contenedores de Pantalla
   ========================================================= */
main {
  position: fixed;
  top: 0; bottom: 0; left: 0; right: 0;
}

.view {
  position: absolute;
  inset: 0;
  display: none;
  overflow-y: auto;
  padding: calc(var(--top) + 20px) 20px calc(var(--dock) + 40px);
  -webkit-overflow-scrolling: touch;
}

.view.active {
  display: block;
  animation: view-fade-in 0.25s cubic-bezier(0.2, 0.8, 0.4, 1);
}
@keyframes view-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

#view-map { padding: 0; overflow: hidden; }
#map {
  position: absolute;
  inset: 0;
  background: #bae6fd;
}

.view-title {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--on-surface);
  margin: 12px 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card {
  background: var(--surface-lowest);
  border-radius: var(--r-lg);
  padding: 24px;
  margin-bottom: 20px;
  border: var(--clay-card-border);
  box-shadow: var(--clay-card-shadow);
  position: relative;
  overflow: hidden;
}

/* Realce visual para mapa interactivo tipo aventura */
.leaflet-tile-pane {
  filter: saturate(1.55) brightness(1.05) contrast(1.04) hue-rotate(-8deg);
}

.leaflet-control-attribution {
  border-radius: var(--r-full) 0 0 0;
  font-family: var(--font-body);
  font-size: 11px;
  background: rgba(255, 255, 255, 0.85) !important;
}

.leaflet-bottom.leaflet-right { bottom: calc(var(--dock) + 8px); }

.zone-tip {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.88rem;
  border-radius: var(--r-full);
  border: 3px solid #10b981;
  background: #ffffff;
  color: #064e3b;
  padding: 4px 12px;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

/* =========================================================
   HUD del Mapa (Píldoras y Herramientas Flotantes)
   ========================================================= */
.hud-pills {
  position: absolute;
  top: calc(var(--top) + 16px);
  left: 16px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
  max-width: calc(100% - 90px);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.97);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.92rem;
  border: 2.5px solid;
  box-shadow: 0 4px 0 0 rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.06);
  max-width: 100%;
}

.pill > span:last-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill.green {
  border-color: #34d399;
  color: #064e3b;
}
.pill.green .ic { color: #059669; }

.pill.yellow {
  border-color: #fcd34d;
  color: #78350f;
}
.pill.yellow .ic { color: #d97706; }

.pill.blue {
  border-color: #7dd3fc;
  color: #0369a1;
}
.pill.blue .ic { color: #0284c7; }

.map-tools {
  position: absolute;
  right: 16px;
  top: calc(var(--top) + 16px);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid #ffffff;
  background: #ffffff;
  color: var(--primary);
  font-size: 1.3rem;
  box-shadow: 0 5px 0 0 #cbd5e1, 0 8px 16px rgba(0, 0, 0, 0.12);
  display: grid;
  place-items: center;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 0 #cbd5e1, 0 10px 20px rgba(0, 0, 0, 0.15);
}

.fab:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 0 transparent;
}

.fab.on {
  background: linear-gradient(180deg, #fde047 0%, #f59e0b 100%);
  color: #78350f;
  border-color: #ffffff;
  box-shadow: 0 5px 0 0 var(--sun-yellow-shadow);
}

.demo-hint {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(var(--dock) + 48px);
  z-index: 500;
  background: linear-gradient(135deg, #fef08a 0%, #f59e0b 100%);
  color: #78350f;
  padding: 12px 18px;
  border-radius: var(--r-full);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  border: 2px solid #ffffff;
  box-shadow: 0 4px 0 0 var(--sun-yellow-shadow), 0 8px 20px rgba(245, 158, 11, 0.35);
  text-align: center;
  justify-content: center;
  display: flex;
  gap: 8px;
  align-items: center;
}

/* =========================================================
   Marcadores del Mapa (Aparición y Jugador)
   ========================================================= */
.spawn-icon, .me-icon { background: none; border: 0; }

.spawn {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 30px;
  background: #ffffff;
  border: 4px solid var(--primary-light);
  box-shadow: 0 6px 0 0 rgba(0, 0, 0, 0.14), 0 8px 16px rgba(16, 185, 129, 0.25);
  animation: float-spawn 2.8s ease-in-out infinite;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.spawn:hover { transform: scale(1.12); }
.spawn.blue {
  border-color: var(--secondary-light);
  box-shadow: 0 6px 0 0 rgba(0, 0, 0, 0.14), 0 8px 16px rgba(14, 165, 233, 0.25);
}
.spawn.pink {
  border-color: var(--coral-pink-light);
  box-shadow: 0 6px 0 0 rgba(0, 0, 0, 0.14), 0 8px 16px rgba(244, 63, 94, 0.3);
}

.spawn.far { opacity: 0.85; filter: saturate(0.9); }
.spawn.mystery { color: var(--primary); }
.spawn.mystery.blue { color: var(--secondary); }
.spawn.mystery.pink { color: var(--coral-pink); }
.spawn .ic { width: 32px; height: 32px; }

.spawn .rare-chip {
  position: absolute;
  top: -12px;
  right: -16px;
  background: linear-gradient(135deg, #f43f5e, #fbbf24);
  border: 2px solid #ffffff;
  border-radius: var(--r-full);
  padding: 1px 8px;
  font-size: 11px;
  font-family: var(--font-display);
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 1px 1px rgba(0,0,0,0.3);
  box-shadow: 0 3px 6px rgba(0,0,0,0.25);
}

/* Aura de proximidad cuando puedes abrir el encuentro */
.spawn.near::after {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 3.5px solid var(--primary-light);
  animation: sonar-ring 1.3s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}
@keyframes float-spawn {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes sonar-ring {
  0% { transform: scale(0.75); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* Marcador del Jugador (Avatar Explorer) */
.me {
  position: relative;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
}
.me::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.35);
  animation: sonar-ring 1.8s ease-out infinite;
}
.me span {
  position: relative;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 26px;
  background: #ffffff;
  border: 3px solid #ffffff;
  box-shadow: 0 0 0 5px var(--sun-yellow), 0 0 0 7px #ffffff, 0 6px 0 7px rgba(0,0,0,0.2);
}

/* =========================================================
   Dock de Navegación Flotante (Consola Portátil)
   ========================================================= */
.dock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1000;
  height: var(--dock);
  display: grid;
  grid-template-columns: 1fr 1fr 100px 1fr 1fr;
  align-items: center;
  gap: 6px;
  padding: 0 16px env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, 0.97);
  border-top: 3px solid var(--surface-high);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.08);
}

.dock > button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: transparent;
  color: var(--on-surface-variant);
  border-radius: var(--r-md);
  padding: 8px 4px;
  min-height: 60px;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dock > button small {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.8rem;
}

.dock > button:hover {
  transform: translateY(-2px);
  color: var(--primary);
}

.dock > button.active {
  background: linear-gradient(180deg, #fef08a 0%, #f59e0b 100%);
  color: #78350f;
  box-shadow: 0 4px 0 0 var(--sun-yellow-shadow);
  transform: translateY(-3px) scale(1.04);
}

.dock-center {
  position: relative;
  height: 100%;
}

/* Botón central de Radar con múltiples ondas sonar */
.explore-btn {
  position: absolute;
  left: 50%;
  top: -38px;
  transform: translateX(-50%);
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 6px solid #ffffff;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  box-shadow: 0 8px 0 0 #047857, 0 14px 24px rgba(5, 150, 105, 0.4);
  display: grid;
  place-items: center;
  transition: transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.12s ease;
}

.explore-btn .ic {
  width: 46px;
  height: 46px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.explore-btn:hover {
  transform: translate(-50%, -2px) scale(1.04);
}

.explore-btn:active {
  transform: translate(-50%, 6px);
  box-shadow: 0 1px 0 0 #047857, 0 4px 10px rgba(5, 150, 105, 0.2);
}

.explore-btn.spin .ic { animation: radar-spin 0.8s ease-out; }
@keyframes radar-spin { to { transform: rotate(360deg); } }

/* =========================================================
   Catálogo de Especies (Colección de Tarjetas TCG)
   ========================================================= */
.hero-card {
  background: linear-gradient(135deg, #ffffff 0%, var(--surface-low) 100%);
  border-radius: var(--r-lg);
  padding: 22px 24px;
  margin-bottom: 20px;
  border: var(--clay-card-border);
  box-shadow: var(--clay-card-shadow);
}

.hero-top { display: flex; justify-content: space-between; gap: 14px; }
.hero-card h2 {
  font-size: 1.6rem;
  color: var(--primary-dark);
}
.hero-card p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--on-surface-variant);
}

.count {
  text-align: right;
  color: #059669;
  flex: none;
}
.count b {
  font-family: var(--font-display);
  font-size: 1.9rem;
  line-height: 1;
  display: block;
}
.count small {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--on-surface-variant);
}

.bubbles {
  display: flex;
  gap: 6px;
  margin-top: 16px;
}
.bubbles i {
  flex: 1;
  height: 16px;
  border-radius: 8px;
  background: var(--surface-c);
  border: 2px solid var(--surface-high);
  transition: all 0.3s ease;
}
.bubbles i.on {
  background: linear-gradient(180deg, #34d399 0%, #059669 100%);
  border-color: #047857;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.6), 0 2px 6px rgba(5, 150, 105, 0.3);
}

/* Filtros en chips táctiles */
.filters {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 4px 12px;
  margin-bottom: 12px;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  min-height: 44px;
  border: 2.5px solid var(--outline-variant);
  background: #ffffff;
  padding: 8px 18px;
  border-radius: var(--r-full);
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--on-surface-variant);
  box-shadow: 0 3px 0 0 var(--outline-variant);
  transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chip:hover {
  transform: translateY(-2px);
  border-color: var(--primary-light);
  color: var(--primary-dark);
}

.chip:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 0 transparent;
}

.chip.active {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border-color: #047857;
  box-shadow: 0 3px 0 0 #047857, 0 4px 12px rgba(5, 150, 105, 0.25);
  transform: translateY(-2px);
}

/* Rejilla de Cartas Coleccionables */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr));
  gap: 14px;
}

.sp-card {
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 0;
  overflow: hidden;
  background: #ffffff;
  border-radius: var(--r-lg);
  border: 3px solid var(--surface-high);
  box-shadow: 0 6px 0 0 var(--surface-variant), 0 10px 20px rgba(0, 0, 0, 0.06);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease;
  position: relative;
}

.sp-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 0 0 var(--surface-variant), 0 16px 28px rgba(0, 0, 0, 0.1);
}

.sp-card:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 0 var(--surface-variant);
}

.sp-card .art {
  position: relative;
  height: 125px;
  margin: 6px 6px 0;
  border-radius: var(--r-md) var(--r-md) 0.9rem 0.9rem;
  display: grid;
  place-items: center;
  font-size: 3.8rem;
  overflow: hidden;
  background: #f8fafc;
}

.sp-card .art::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.5), transparent 60%);
}

.sp-card .body { padding: 12px 14px 16px; }

.sp-card .nm {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1.25;
  color: var(--on-surface);
}

.sp-card .sci {
  font-size: 0.82rem;
  color: var(--on-surface-variant);
  font-style: italic;
  margin: 2px 0 8px;
}

.sp-card .num {
  position: absolute;
  left: 10px;
  top: 8px;
  z-index: 2;
  font-family: var(--font-display);
  font-size: 0.76rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.92);
  color: #0f172a;
  border-radius: var(--r-full);
  padding: 2px 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Insignias de Rareza estilo TCG */
.rarity {
  position: absolute;
  right: 8px;
  top: 8px;
  z-index: 2;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--r-full);
  border: 1.5px solid #ffffff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.rarity.r1 {
  background: linear-gradient(135deg, #fef08a, #f59e0b);
  color: #78350f;
}
.rarity.r2 {
  background: linear-gradient(135deg, #7dd3fc, #0284c7);
  color: #ffffff;
}
.rarity.r3 {
  background: linear-gradient(135deg, #f43f5e, #fbbf24, #38bdf8, #a855f7);
  background-size: 300% 300%;
  animation: holo-glint 4s ease infinite;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
@keyframes holo-glint {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Tarjeta Misteriosa / Bloqueada */
.sp-card.locked {
  background: linear-gradient(145deg, #1e1b4b 0%, #312e81 100%);
  border: 3px dashed #6366f1;
  box-shadow: 0 6px 0 0 #1e1b4b;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 235px;
  padding: 20px;
}

.sp-card.locked:hover {
  transform: translateY(-3px);
  border-color: #818cf8;
}

.sp-card.locked .q {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  display: grid;
  place-items: center;
  color: #a5b4fc;
  margin-bottom: 12px;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.sp-card.locked .q .ic { width: 42px; height: 42px; }
.sp-card.locked .nm {
  color: #e0e7ff;
  font-size: 1.05rem;
}
.sp-card.locked small {
  color: #c7d2fe;
  display: block;
  margin-top: 4px;
}

/* Etiquetas de especie */
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-family: var(--font-display);
  font-size: 0.76rem;
  font-weight: 700;
  border: 1.5px solid;
}
.tag.nativa {
  color: #15803d;
  border-color: #86efac;
  background: #dcfce7;
}
.tag.introducida {
  color: #92400e;
  border-color: #fcd34d;
  background: #fef3c7;
}
.tag.invasora {
  color: #b91c1c;
  border-color: #fca5a5;
  background: #fee2e2;
}
.tag.plain {
  color: #0369a1;
  border-color: #bae6fd;
  background: #f0f9ff;
}

/* =========================================================
   Modales y Pantalla de Encuentro (¡Aparición Salvaje!)
   ========================================================= */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.72);
}
@media (min-height: 700px) { .overlay { align-items: center; } }

.modal-card {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;              /* el marco no se mueve; solo se desplaza #modal-body */
  background: #ffffff;
  border-radius: var(--r-xl);
  padding: 0;
  border: 4px solid var(--surface-high);
  box-shadow: 0 20px 48px -8px rgba(15, 23, 42, 0.35);
  animation: comic-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes comic-pop {
  from { transform: scale(0.88) translateY(30px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 4;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--outline-variant);
  background: #ffffff;
  color: var(--on-surface-variant);
  display: grid;
  place-items: center;
  box-shadow: 0 3px 0 0 var(--outline-variant);
  transition: transform 0.1s ease;
}
.close:active { transform: translateY(3px); box-shadow: none; }

/* Ficha Hero / Encuentro */
.sheet-hero {
  position: relative;
  border-radius: var(--r-lg);
  padding: 28px 16px 20px;
  text-align: center;
  color: #ffffff;
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: inset 0 0 0 3px rgba(255,255,255,0.3);
}

.sheet-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,255,255,0.4) 0%, transparent 70%);
  pointer-events: none;
}

.sheet-hero .big {
  font-size: 6rem;
  line-height: 1;
  display: inline-block;
  animation: creature-bob 2.8s ease-in-out infinite;
  filter: drop-shadow(0 10px 14px rgba(0,0,0,0.25));
  will-change: transform;
}
@keyframes creature-bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-8px) rotate(2deg); }
}

.sheet-title { text-align: center; margin-bottom: 14px; }
.sheet-title h2 { font-size: 1.8rem; margin-bottom: 2px; }
.sheet-title .sci {
  font-size: 0.88rem;
  font-style: italic;
  color: var(--on-surface-variant);
  margin-bottom: 10px;
}
.sheet-title .tags { justify-content: center; }

.discovery-chip {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  background: linear-gradient(135deg, #f43f5e 0%, #fb7185 100%);
  color: #ffffff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 4px 14px;
  border-radius: var(--r-full);
  border: 2px solid #ffffff;
  box-shadow: 0 4px 8px rgba(244, 63, 94, 0.4);
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  animation: xp-pop 0.45s 0.15s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.discovery-chip .ic { width: 18px; height: 18px; }
.discovery-chip.again {
  background: linear-gradient(135deg, #0284c7 0%, #38bdf8 100%);
  box-shadow: 0 4px 8px rgba(2, 132, 199, 0.4);
}
.encounter .sheet-hero.photo img { animation: creature-appear 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both; }

/* Pantalla de Encuentro y Quiz */
.encounter { text-align: center; }
.encounter .sheet-hero .big {
  font-size: 6.8rem;
  animation: creature-appear 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both, creature-bob 2.8s 0.6s ease-in-out infinite;
}
@keyframes creature-appear {
  from { transform: scale(0) rotate(-30deg); opacity: 0; }
  to { transform: scale(1) rotate(0deg); opacity: 1; }
}

.q-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.18rem;
  margin: 16px 0 6px;
  color: var(--on-surface);
}

.quiz {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.quiz button {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  color: var(--on-surface);
  padding: 12px 18px 12px 12px;
  border-radius: var(--r-md);
  border: 2.5px solid var(--surface-high);
  background: #ffffff;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1rem;
  text-align: left;
  box-shadow: 0 4px 0 0 var(--outline-variant);
  transition: transform 0.1s ease, box-shadow 0.1s ease, border-color 0.1s;
}

.quiz button:hover:not(:disabled) {
  border-color: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 0 0 var(--outline-variant);
}

.quiz button:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 0 0 0 transparent;
}

.opt-key {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  background: var(--surface-c);
  color: var(--primary-dark);
  border: 2px solid var(--surface-high);
}
.quiz button.ok .opt-key { background: #10b981; color: #ffffff; border-color: #059669; }
.quiz button.bad .opt-key { background: #f87171; color: #ffffff; border-color: #dc2626; }
.quiz button:disabled:not(.ok):not(.bad) { opacity: 0.6; }
.quiz button.ok { animation: answer-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }
.quiz button.bad { animation: answer-shake 0.4s ease; }
@keyframes answer-pop { 50% { transform: scale(1.03); } }
@keyframes answer-shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.quiz button.ok {
  border-color: #10b981;
  background: #ecfdf5;
  color: #064e3b;
  box-shadow: 0 4px 0 0 #059669;
}

.quiz button.bad {
  border-color: #f87171;
  background: #fef2f2;
  color: #991b1b;
  box-shadow: 0 4px 0 0 #dc2626;
}

.quiz button:disabled { cursor: default; }

.feedback {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 16px;
  padding: 14px 18px;
  border-radius: var(--r-md);
  background: var(--surface-low);
  text-align: left;
  font-weight: 600;
  border: 2px solid var(--surface-high);
  animation: xp-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.feedback > .ic { width: 28px; height: 28px; margin-top: 1px; }
.feedback b { display: block; font-family: var(--font-display); font-size: 1.05rem; }
.feedback.ok { background: #ecfdf5; border-color: #6ee7b7; color: #064e3b; }
.feedback.ok > .ic { color: #059669; }
.feedback.learn { background: #fffbeb; border-color: #fcd34d; color: #78350f; }
.feedback.learn > .ic { color: #d97706; }

.xp-gain {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #fef08a 0%, #f59e0b 100%);
  color: #78350f;
  padding: 6px 18px;
  border-radius: var(--r-full);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.08rem;
  margin-top: 14px;
  border: 2px solid #ffffff;
  box-shadow: 0 4px 0 0 var(--sun-yellow-shadow), 0 6px 16px rgba(245, 158, 11, 0.35);
  animation: xp-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes xp-pop {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Campos de Ficha Educativa */
.field {
  margin: 12px 0;
  background: var(--surface-low);
  border-radius: var(--r-md);
  padding: 14px 18px;
  border: 2px solid var(--surface-high);
}
.field b {
  display: block;
  font-family: var(--font-display);
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  margin-bottom: 2px;
}

.risk {
  padding: 14px 18px;
  border-radius: var(--r-md);
  margin: 12px 0;
  font-size: 0.98rem;
  border: 2px solid;
  font-weight: 600;
}
.risk.bajo { background: #dcfce7; border-color: #86efac; color: #166534; }
.risk.medio { background: #fef3c7; border-color: #fcd34d; color: #92400e; }
.risk.alto { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }

.funfact {
  background: #eff6ff;
  border: 2.5px solid #bfdbfe;
  padding: 14px 18px;
  border-radius: var(--r-md);
  margin: 14px 0;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
}
.funfact { display: flex; gap: 10px; align-items: flex-start; }
.funfact > [data-icon] { color: #ca8a04; flex: none; }
.funfact b { color: #1d4ed8; }

.draft {
  font-size: 0.8rem;
  color: var(--on-surface-variant);
  border-top: 2px dashed var(--surface-high);
  padding-top: 10px;
  margin-top: 14px;
}

/* =========================================================
   Retos e Insignias (Trophy Case)
   ========================================================= */
.list { display: grid; gap: 14px; margin: 16px 0 28px; }

.quest {
  background: #ffffff;
  padding: 18px 20px;
  border-radius: var(--r-lg);
  border: 3px solid var(--surface-high);
  box-shadow: var(--clay-card-shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.quest:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 0 rgba(15, 23, 42, 0.08), 0 18px 36px -8px rgba(15, 23, 42, 0.1);
}

.quest .top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.08rem;
}
.quest .top span:first-child { display: flex; align-items: center; gap: 8px; }
.quest .top .ic { color: var(--secondary); }
.quest.done .top .ic { color: #10b981; }

.quest .bubbles { margin-top: 12px; }
.quest .bubbles i { height: 14px; }
.quest .bar {
  height: 16px;
  background: var(--surface-c);
  border-radius: var(--r-full);
  margin-top: 12px;
  overflow: hidden;
  border: 2px solid var(--surface-high);
}
.quest .bar div {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #34d399);
  border-radius: var(--r-full);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}
.quest small {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  color: #b45309;
}
.quest.done {
  background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
  border-color: #86efac;
}

/* Vitrina de Medallas 3D */
.badges {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.badge {
  background: #ffffff;
  border-radius: var(--r-lg);
  padding: 16px 10px;
  text-align: center;
  font-size: 0.85rem;
  border: 3px solid var(--surface-high);
  box-shadow: var(--clay-card-shadow);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.badge:hover { transform: translateY(-4px); }

.badge .medal {
  --m1: #fef08a; --m2: #f59e0b; --m3: #b45309; --mi: #78350f;
  width: 66px;
  height: 66px;
  margin: 0 auto 8px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--m1), var(--m2));
  border: 3px solid #ffffff;
  color: var(--mi);
  box-shadow: 0 0 0 3px var(--m2), 0 5px 0 3px var(--m3), 0 8px 16px rgba(15, 23, 42, 0.15);
  position: relative;
  overflow: hidden;
}
.badge .medal .ic { width: 34px; height: 34px; }
.badge .medal::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 42%;
  background: linear-gradient(180deg, rgba(255,255,255,0.55) 0%, transparent 100%);
  border-radius: 50% 50% 0 0;
}
.medal.green  { --m1: #a7f3d0; --m2: #10b981; --m3: #047857; --mi: #064e3b; }
.medal.blue   { --m1: #bae6fd; --m2: #38bdf8; --m3: #0369a1; --mi: #0c4a6e; }
.medal.orange { --m1: #fed7aa; --m2: #f97316; --m3: #c2410c; --mi: #7c2d12; }
.medal.pink   { --m1: #fecdd3; --m2: #fb7185; --m3: #be123c; --mi: #881337; }
.medal.purple { --m1: #c7d2fe; --m2: #818cf8; --m3: #3730a3; --mi: #1e1b4b; }

.badge b {
  display: block;
  font-family: var(--font-display);
  font-size: 0.95rem;
  margin-bottom: 2px;
  color: var(--on-surface);
}

.badge.locked {
  background: var(--surface-low);
  border-style: dashed;
  box-shadow: none;
  color: var(--outline);
}
.badge.locked .medal {
  background: var(--surface-c);
  color: var(--outline);
  box-shadow: 0 0 0 3px var(--outline-variant);
}
.badge.locked b { color: var(--on-surface-variant); }
.badge.locked .small { color: var(--on-surface-variant); }

/* =========================================================
   Perfil y Estadísticas
   ========================================================= */
.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.stat {
  background: var(--surface-low);
  padding: 14px 16px;
  border-radius: var(--r-md);
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--on-surface-variant);
  font-size: 0.9rem;
  border: 2px solid var(--surface-high);
}
.stat b {
  display: block;
  font-size: 1.85rem;
  color: var(--on-surface);
  line-height: 1.1;
  margin-bottom: 2px;
}
.stat .ic {
  width: 34px; height: 34px;
  padding: 6px;
  border-radius: 12px;
  margin-bottom: 8px;
  filter: none;
  color: #ffffff;
  background: var(--primary);
  box-shadow: 0 3px 0 0 rgba(15, 23, 42, 0.18);
}
.stat.gold .ic   { background: var(--sun-yellow); }
.stat.blue .ic   { background: var(--secondary); }
.stat.pink .ic   { background: var(--coral-pink); }
.stat.orange .ic { background: var(--accent-orange); }
.stat.purple .ic { background: var(--purple-epic); }

/* =========================================================
   Onboarding (Pase Oficial de Explorador)
   ========================================================= */
.onboarding {
  position: fixed;
  inset: 0;
  z-index: 2500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: #0284c7 url(../img/playa-lapaz.webp) center / cover no-repeat;
  padding: 16px;
}
@media (min-height: 700px) { .onboarding { align-items: center; } }

.ob-sheet {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.97);
  border-radius: var(--r-xl);
  padding: 28px 24px;
  border: 4px solid var(--surface-high);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
  animation: comic-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ob-logo {
  display: flex;
  justify-content: center;
  margin-top: -12px;
}

.ob-sheet h1 {
  text-align: center;
  color: var(--primary);
  font-size: 2.3rem;
  margin-top: 10px;
}
.ob-sheet h1 span { color: #0284c7; }

.lead {
  text-align: center;
  color: var(--on-surface-variant);
  font-weight: 600;
  font-size: 1.05rem;
  margin-top: 2px;
}

.avatars {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
}
.avatars button {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid transparent;
  background: var(--surface-c);
  font-size: 1.6rem;
  display: grid;
  place-items: center;
  padding: 0;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.avatars button:hover { transform: scale(1.1); }
.avatars button.active {
  background: linear-gradient(135deg, #fef08a 0%, #f59e0b 100%);
  border-color: #ffffff;
  box-shadow: 0 4px 0 0 var(--sun-yellow-shadow), 0 4px 12px rgba(245, 158, 11, 0.4);
  transform: scale(1.12);
}
@media (max-width: 440px) {
  .avatars { grid-template-columns: repeat(4, 1fr); gap: 10px; }
  .avatars button { font-size: 1.8rem; }
}

.notice {
  background: #fefce8;
  border: 2.5px solid #fef08a;
  padding: 14px 18px;
  border-radius: var(--r-md);
  margin-top: 20px;
  font-size: 0.94rem;
  box-shadow: 0 4px 10px rgba(234, 179, 8, 0.1);
}
.notice strong {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #854d0e;
  font-family: var(--font-display);
  font-size: 1.05rem;
}
.notice ul { margin: 8px 0 0; padding-left: 20px; color: #713f12; }
.notice li { margin-bottom: 4px; }

/* =========================================================
   Toast y Notificaciones
   ========================================================= */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--dock) + 120px);
  transform: translate(-50%, 20px);
  z-index: 3000;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.02rem;
  padding: 14px 24px;
  border-radius: var(--r-full);
  border: 2px solid rgba(255, 255, 255, 0.2);
  width: max-content;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: calc(100% - 32px);
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast { display: flex; align-items: center; gap: 10px; text-align: left; }
.toast .ic { width: 26px; height: 26px; flex: none; }
.toast.ok .ic { color: #34d399; }
.toast.warn .ic { color: #fbbf24; }
.toast.reward {
  background: linear-gradient(135deg, #fde047 0%, #f59e0b 100%);
  color: #78350f;
  border-color: #ffffff;
  box-shadow: 0 5px 0 0 var(--sun-yellow-shadow), 0 10px 28px rgba(245, 158, 11, 0.45);
}
.toast.reward .ic { color: #b45309; }

/* Banner de Retos con Aventura */
.banner {
  position: relative;
  min-height: 180px;
  border-radius: var(--r-lg);
  overflow: hidden;
  margin: 4px 0 10px;
  background: #38bdf8 center 40% / cover no-repeat;
  display: flex;
  align-items: flex-end;
  border: 3px solid #ffffff;
  box-shadow: var(--clay-card-shadow);
}
.banner > div {
  width: 100%;
  padding: 50px 20px 16px;
  color: #ffffff;
  background: linear-gradient(transparent, rgba(6, 78, 59, 0.88));
}
.banner h2 {
  font-size: 1.7rem;
  margin: 0;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.banner p { margin: 4px 0 0; font-weight: 600; font-size: 0.98rem; }

/* Galería de Fotos */
.sheet-hero.photo { padding: 0; height: 250px; }
.sheet-hero.photo img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.ai-note {
  font-size: 0.78rem;
  color: var(--outline);
  text-align: center;
  margin: -4px 0 10px;
}
.gallery { display: flex; gap: 10px; margin: 14px 0; }
.gallery img {
  width: 100%;
  max-height: 190px;
  object-fit: cover;
  border-radius: var(--r-md);
  border: 3px solid var(--surface-high);
}
/* Más específico que la regla de Leaflet (.leaflet-marker-pane img { width: auto }),
   que dejaba la miniatura a su tamaño real (128 px) y tapaba otras apariciones */
.leaflet-container .leaflet-marker-pane .spawn img {
  width: 100%;
  height: 100%;
  max-width: 100% !important;
  max-height: 100% !important;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.tag.extra { color: #9d174d; border-color: #f9a8d4; background: #fce7f3; }

/* =========================================================
   Reglas de Accesibilidad y Responsividad (UI/UX Pro Max)
   ========================================================= */

/* Respeto estricto a preferencia de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Adaptación responsive para pantallas grandes y tablets */
@media (min-width: 900px) {
  .view:not(#view-map) {
    padding-left: max(40px, calc(50% - 460px));
    padding-right: max(40px, calc(50% - 460px));
  }
  .dock {
    max-width: 580px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: var(--r-xl);
    bottom: 18px;
    border: 3px solid var(--surface-high);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  }
}

/* =========================================================
   Mejoras v2 · Perfil, celebraciones, guía del mapa
   ========================================================= */

/* Tarjeta de explorador en el perfil */
.profile-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px;
  margin: 4px 0 20px;
  border-radius: var(--r-lg);
  color: #ffffff;
  background: linear-gradient(135deg, #10b981 0%, #059669 55%, #0284c7 100%);
  border: 3px solid #ffffff;
  box-shadow: 0 6px 0 0 var(--primary-dark), 0 16px 32px -8px rgba(5, 150, 105, 0.45);
  position: relative;
  overflow: hidden;
}
.profile-hero::before {
  content: "";
  position: absolute;
  right: -40px; top: -60px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
}
.profile-hero .avatar.big { box-shadow: 0 0 0 4px #fde047, 0 8px 20px rgba(0, 0, 0, 0.25); }
.pf-info { flex: 1; min-width: 0; position: relative; }
.pf-info h2 {
  color: #ffffff;
  font-size: 1.7rem;
  line-height: 1.1;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.pf-level {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0 10px;
  padding: 3px 12px 3px 8px;
  border-radius: var(--r-full);
  background: linear-gradient(180deg, #fef08a 0%, #f59e0b 100%);
  color: #78350f;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 3px 0 0 var(--sun-yellow-shadow);
}
.pf-level .ic { width: 20px; height: 20px; }
.pf-bar {
  height: 16px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.28);
  border: 2px solid rgba(255, 255, 255, 0.6);
  overflow: hidden;
}
.pf-bar > div {
  height: 100%;
  width: 0;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, #fde047, #fbbf24);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.6);
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.pf-info small {
  display: block;
  margin-top: 6px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.95);
}
.eval-bar { background: var(--surface-c); border-color: var(--surface-high); margin: 4px 0 14px; }
.eval-bar > div { background: linear-gradient(90deg, #10b981, #34d399); }
#pf-avatars { margin-top: 8px; }

/* El avatar del HUD celebra al subir de nivel */
.avatar.level-up { animation: level-up 0.9s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes level-up {
  0% { transform: scale(1); }
  30% { transform: scale(1.3) rotate(-10deg); box-shadow: 0 0 0 6px #fde047, 0 0 24px 8px rgba(253, 224, 71, 0.8); }
  60% { transform: scale(1.1) rotate(8deg); }
  100% { transform: scale(1); }
}

/* Confeti de celebración */
.confetti {
  position: fixed;
  inset: 0;
  z-index: 2600;
  pointer-events: none;
  overflow: hidden;
}
.confetti i {
  position: absolute;
  top: -16px;
  width: 10px;
  height: 14px;
  border-radius: 3px;
  opacity: 0;
  animation: confetti-fall var(--d, 1.4s) cubic-bezier(0.25, 0.6, 0.5, 1) forwards;
}
.confetti i:nth-child(3n) { border-radius: 50%; width: 10px; height: 10px; }
@keyframes confetti-fall {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx, 0), 85vh) rotate(var(--r, 360deg)); }
}

/* Caja de la pregunta del encuentro */
.q-box {
  margin-top: 6px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, #f0f9ff 0%, #ecfdf5 100%);
  border: 2.5px solid #bae6fd;
}
.q-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 12px 2px 8px;
  border-radius: var(--r-full);
  background: var(--secondary);
  color: #ffffff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: 0 3px 0 0 #0369a1;
}
.q-label .ic { width: 18px; height: 18px; }
.q-box .q-text { margin: 10px 0 4px; }

/* Guía del mapa */
.modal-title { display: flex; align-items: center; gap: 8px; font-size: 1.6rem; padding-right: 52px; }
.modal-title .ic { color: var(--primary); }
.legend { display: grid; gap: 10px; margin-top: 12px; }
.legend-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--surface-low);
  border: 2px solid var(--surface-high);
}
.legend-row b { display: block; font-family: var(--font-display); font-size: 1.02rem; }
.legend-row small { color: var(--on-surface-variant); display: block; line-height: 1.35; }
.legend-dot {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #ffffff;
  border: 4px solid var(--primary-light);
  color: var(--primary);
  box-shadow: 0 4px 0 0 rgba(0, 0, 0, 0.12);
}
.legend-dot .ic { width: 24px; height: 24px; }
.legend-dot.blue { border-color: var(--secondary-light); color: var(--secondary); }
.legend-dot.pink { border-color: var(--coral-pink-light); color: var(--coral-pink); }
.legend-dot.near { border-color: var(--sun-yellow); color: #b45309; box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.25), 0 4px 0 0 rgba(0, 0, 0, 0.12); }
.legend-dot.zone { border: 3px dashed #16a34a; background: rgba(74, 222, 128, 0.15); color: #15803d; }

/* Estado vacío del catálogo */
.empty {
  grid-column: 1 / -1;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 36px 16px;
  text-align: center;
  color: var(--on-surface-variant);
  border: 3px dashed var(--surface-high);
  border-radius: var(--r-lg);
}
.empty .ic { width: 48px; height: 48px; color: var(--secondary); }
.empty b { font-family: var(--font-display); font-size: 1.15rem; color: var(--on-surface); }

/* La leyenda de ayuda del mapa se distingue de las otras herramientas */
#btn-legend { color: var(--secondary); }

/* Hover solo en dispositivos con puntero (evita estados "pegados" en táctil) */
@media (hover: none) {
  .sp-card:hover, .quest:hover, .badge:hover, .chip:hover, .fab:hover,
  .dock > button:hover, .avatar:hover, .avatars button:hover { transform: none; }
  .dock > button.active { transform: translateY(-3px) scale(1.04); }
  .chip.active { transform: translateY(-2px); }
  .avatars button.active { transform: scale(1.12); }
}

@media (max-width: 400px) {
  .profile-hero { padding: 18px; gap: 14px; }
  .profile-hero .avatar.big { width: 72px; height: 72px; font-size: 40px; }
  .pf-info h2 { font-size: 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  .confetti { display: none; }
}

/* Onboarding: título y nivel sin cortes raros en pantallas angostas */
.ob-sheet h1 { font-size: clamp(1.9rem, 8.5vw, 2.3rem); line-height: 1.1; text-wrap: balance; }
.ob-sheet h1 span { white-space: nowrap; }
.seg button small { display: block; font-size: 0.78rem; font-weight: 600; opacity: 0.8; line-height: 1.2; }

/* Con un modal abierto el aviso sube para no tapar las respuestas ni los botones */
body:has(#modal:not(.hidden)) .toast { top: 12px; bottom: auto; transform: translate(-50%, -20px); }
body:has(#modal:not(.hidden)) .toast.show { transform: translate(-50%, 0); }
.badge .small, .badge b { overflow-wrap: anywhere; hyphens: auto; }
#pf-avatars { max-width: 560px; }

/* Rendimiento: con una ventana abierta se pausan las animaciones del mapa que quedan detrás */
body.modal-open .leaflet-marker-pane *,
body.modal-open .leaflet-marker-pane *::before,
body.modal-open .leaflet-marker-pane *::after { animation-play-state: paused !important; }
body.modal-open .leaflet-tile-pane { filter: none; }
.modal-card { contain: layout paint; }

/* Contenido desplazable de la ventana */
#modal-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;  /* no arrastra el catálogo/mapa de atrás */
  -webkit-overflow-scrolling: touch;
  padding: 24px 22px 28px;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-variant) transparent;
  scroll-padding-top: 16px;
  /* desvanecido suave arriba/abajo en lugar de un corte seco */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 14px, #000 calc(100% - 22px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 14px, #000 calc(100% - 22px), transparent 100%);
}
#modal-body::-webkit-scrollbar { width: 8px; }
#modal-body::-webkit-scrollbar-track { background: transparent; margin: 24px 0; }
#modal-body::-webkit-scrollbar-thumb { background: var(--surface-variant); border-radius: 8px; }
#modal-body > :first-child { margin-top: 0; }

/* El botón cerrar queda fijo en la esquina, siempre visible */
.modal-card > .close {
  top: 14px;
  right: 14px;
  z-index: 5;
  box-shadow: 0 3px 0 0 var(--outline-variant), 0 4px 12px rgba(15, 23, 42, 0.18);
}

/* =========================================================
   Realidad aumentada (RA)
   ========================================================= */

/* Botón "Ver en RA" dentro de la ficha y el encuentro */
.ar-btn {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 6px 16px 6px 12px;
  border: 2px solid #ffffff;
  border-radius: var(--r-full);
  background: linear-gradient(180deg, #fde047 0%, #f59e0b 100%);
  color: #78350f;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.95rem;
  box-shadow: 0 4px 0 0 var(--sun-yellow-shadow), 0 6px 14px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.ar-btn .ic { width: 22px; height: 22px; filter: none; }
.ar-btn:active { transform: translateY(4px); box-shadow: 0 0 0 0 transparent, 0 2px 6px rgba(0, 0, 0, 0.2); }
.ar-btn.locked {
  background: rgba(255, 255, 255, 0.92);
  color: var(--on-surface-variant);
  box-shadow: 0 4px 0 0 var(--outline-variant), 0 6px 14px rgba(0, 0, 0, 0.15);
}
.ar-btn .ar-lock { width: 16px; height: 16px; margin-left: -2px; color: var(--outline); }
.sheet-hero:not(.photo) { padding-bottom: 64px; }

/* Capa a pantalla completa */
body.ar-open { overflow: hidden; }
body.ar-open .leaflet-marker-pane *,
body.ar-open .leaflet-marker-pane *::before,
body.ar-open .leaflet-marker-pane *::after { animation-play-state: paused !important; }
.ar-layer {
  position: fixed;
  inset: 0;
  z-index: 3500;
  background: #0b1220;
  color: #ffffff;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  animation: view-fade-in 0.25s ease;
}
.ar-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Escenario: el ancla se mueve con el giroscopio */
.ar-stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.ar-anchor {
  display: grid;
  justify-items: center;
  will-change: transform;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.ar-layer.found .ar-anchor { opacity: 1; }
.ar-slot {
  position: relative;
  transform: scale(0);
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ar-layer.found .ar-slot { transform: scale(1); }
.ar-layer.found .ar-slot.hop { animation: ar-hop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes ar-hop {
  40% { transform: translateY(-36px) scale(1.06, 0.96); }
  70% { transform: translateY(0) scale(0.96, 1.05); }
}

.ar-creature {
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
  animation: creature-bob 3s ease-in-out infinite;
}
.ar-creature.photo {
  width: min(62vw, 300px);
  aspect-ratio: 1;
  border-radius: 28px;
  overflow: hidden;
  border: 5px solid #ffffff;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.7), 0 18px 40px rgba(0, 0, 0, 0.45);
}
.ar-creature.photo img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.ar-emoji {
  display: block;
  font-size: min(42vw, 200px);
  line-height: 1;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.45));
}
.ar-model { width: min(80vw, 380px); height: min(80vw, 380px); background: transparent; pointer-events: auto; }

.ar-ground {
  width: min(48vw, 230px);
  height: 26px;
  margin-top: 14px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(15, 23, 42, 0.45), transparent);
  animation: ar-shadow 3s ease-in-out infinite;
}
@keyframes ar-shadow { 50% { transform: scale(0.82); opacity: 0.7; } }

.ar-name {
  margin-bottom: 14px;
  padding: 6px 16px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.95);
  color: var(--primary-dark);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.05rem;
  border: 3px solid var(--primary-light);
  box-shadow: 0 4px 0 0 rgba(0, 0, 0, 0.18);
  max-width: 80vw;
  text-align: center;
}

.ar-pop {
  position: absolute;
  left: 50%;
  top: -10px;
  color: #fde047;
  animation: ar-pop 0.9s ease-out forwards;
}
.ar-pop .ic { width: 44px; height: 44px; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4)); }
@keyframes ar-pop {
  from { transform: translate(-50%, 0) scale(0.4); opacity: 1; }
  to { transform: translate(-50%, -80px) scale(1.3); opacity: 0; }
}

/* Búsqueda antes de que aparezca */
.ar-scan {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  text-align: center;
  font-family: var(--font-display);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.ar-scan b { font-size: 1.25rem; }
.ar-scan small { font-weight: 600; opacity: 0.9; }
.ar-scan-ring {
  width: 140px;
  height: 140px;
  margin-bottom: 14px;
  border-radius: 50%;
  border: 4px dashed rgba(255, 255, 255, 0.85);
  animation: radar-spin 2.4s linear infinite;
}
.ar-layer.found .ar-scan { opacity: 0; }

/* Flecha cuando el animal queda fuera de la pantalla */
.ar-edge {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(180deg, #fde047 0%, #f59e0b 100%);
  color: #78350f;
  border: 3px solid #ffffff;
  box-shadow: 0 4px 0 0 var(--sun-yellow-shadow);
  pointer-events: none;
}
.ar-edge .ic { width: 32px; height: 32px; }

/* Controles superiores */
.ar-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 14px) 14px 0;
}
.ar-round {
  width: 52px;
  height: 52px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 3px solid #ffffff;
  background: rgba(255, 255, 255, 0.95);
  color: var(--on-surface);
  box-shadow: 0 4px 0 0 rgba(0, 0, 0, 0.25);
  cursor: pointer;
}
.ar-round:active { transform: translateY(3px); box-shadow: none; }
.ar-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 8px 14px;
  border-radius: var(--r-full);
  background: rgba(15, 23, 42, 0.7);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.92rem;
}
.ar-hint span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-hint .ic { color: #fde047; width: 20px; height: 20px; }

/* Controles inferiores */
.ar-bottom {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 0 18px calc(env(safe-area-inset-bottom) + 22px);
  display: grid;
  justify-items: center;
  gap: 14px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.45));
}
.ar-safety {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--r-full);
  background: rgba(254, 240, 138, 0.95);
  color: #713f12;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
}
.ar-safety .ic { width: 18px; height: 18px; }
.ar-actions {
  width: 100%;
  max-width: 420px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}
.ar-actions > :first-child { justify-self: start; }
.ar-actions > :last-child { justify-self: end; grid-column: 3; }
.ar-side {
  min-width: 72px;
  min-height: 64px;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  border: 3px solid #ffffff;
  background: rgba(255, 255, 255, 0.95);
  color: var(--primary-dark);
  font-family: var(--font-display);
  font-weight: 800;
  box-shadow: 0 4px 0 0 rgba(0, 0, 0, 0.25);
  cursor: pointer;
}
.ar-side[hidden] { display: none; }
.ar-side small { font-size: 0.8rem; }
.ar-side .ic { width: 26px; height: 26px; }
.ar-side:active { transform: translateY(3px); box-shadow: none; }
.ar-shutter {
  grid-column: 2;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 6px solid #ffffff;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.45), 0 6px 0 0 var(--primary-dark), 0 10px 24px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.ar-shutter .ic { width: 40px; height: 40px; }
.ar-shutter:active { transform: translateY(5px) scale(0.96); box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.45), 0 1px 0 0 var(--primary-dark); }

.ar-flash { position: absolute; inset: 0; background: #ffffff; opacity: 0; pointer-events: none; }
.ar-flash.go { animation: ar-flash 0.45s ease-out; }
@keyframes ar-flash { from { opacity: 0.9; } to { opacity: 0; } }

/* Vista previa de la foto */
.ar-photo {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.75);
  touch-action: auto;
}
.ar-photo-card {
  width: 100%;
  max-width: 420px;
  padding: 14px;
  border-radius: var(--r-xl);
  background: #ffffff;
  border: 4px solid var(--surface-high);
  animation: comic-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ar-photo-card img {
  display: block;
  width: 100%;
  max-height: 58dvh;
  object-fit: contain;
  border-radius: var(--r-md);
  background: #0b1220;
}
.ar-photo-card .btn { text-decoration: none; }

/* Aviso: computadora / sin permiso */
.ar-notice {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: linear-gradient(160deg, #064e3b 0%, #0c4a6e 100%);
}
.ar-notice-card {
  width: 100%;
  max-width: 440px;
  padding: 28px 24px 22px;
  border-radius: var(--r-xl);
  background: #ffffff;
  color: var(--on-surface);
  text-align: center;
  border: 4px solid var(--surface-high);
  box-shadow: 0 20px 48px -8px rgba(0, 0, 0, 0.45);
  animation: comic-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ar-notice-card h2 { font-size: 1.5rem; margin: 14px 0 6px; }
.ar-notice-card p { color: var(--on-surface-variant); margin: 0 0 10px; }
.ar-notice-ic {
  position: relative;
  width: 92px;
  height: 92px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #d1fae5, #34d399);
  color: var(--primary-dark);
  box-shadow: 0 0 0 4px #10b981, 0 8px 20px rgba(16, 185, 129, 0.35);
}
.ar-notice-ic > .ic { width: 50px; height: 50px; }
.ar-notice-ic span {
  position: absolute;
  right: -6px;
  bottom: -4px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(180deg, #fde047 0%, #f59e0b 100%);
  color: #78350f;
  border: 3px solid #ffffff;
  box-shadow: 0 3px 0 0 var(--sun-yellow-shadow);
}
.ar-notice-ic span .ic { width: 20px; height: 20px; }
.ar-tip {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: #eff6ff;
  border: 2px solid #bfdbfe;
  color: #1e3a8a !important;
  font-weight: 600;
}
.ar-tip .ic { color: #ca8a04; flex: none; }

@media (prefers-reduced-motion: reduce) {
  .ar-creature, .ar-ground, .ar-scan-ring { animation: none; }
}

.ar-shutter:disabled { opacity: 0.5; filter: grayscale(0.6); cursor: default; }

/* Estado NOM-059 y barra de progreso del catálogo */
.tag.nom.P  { color: #9f1239; border-color: #fda4af; background: #ffe4e6; }
.tag.nom.A  { color: #9a3412; border-color: #fdba74; background: #ffedd5; }
.tag.nom.Pr { color: #3730a3; border-color: #a5b4fc; background: #e0e7ff; }
.cat-bar {
  flex: 1;
  height: 18px;
  border-radius: var(--r-full);
  background: var(--surface-c);
  border: 2px solid var(--surface-high);
  overflow: hidden;
}
.cat-bar > div {
  height: 100%;
  min-width: 0;
  border-radius: var(--r-full);
  background: linear-gradient(180deg, #34d399 0%, #059669 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5);
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (max-width: 400px) {
  .sp-card .art { height: 110px; }
  .sp-card .body { padding: 10px 12px 14px; }
  .sp-card .nm { font-size: 1rem; }
  .sp-card.locked { min-height: 200px; padding: 16px 10px; }
}
