:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --header-h: 58px;
  --quiz-toolbar-h: 64px;

  /* Paleta Día: Piedra Caliza y Monte */
  --bg-canvas: #f3f2ed;
  --bg-surface: #ffffff;
  --bg-subtle: #e9e7df;
  --border-subtle: #dcd8ce;
  --text-primary: #121a15;
  --text-secondary: #48574d;
  --text-muted: #738278;
  --card-shadow: 0 2px 8px -2px rgba(11, 34, 21, 0.06), 0 1px 3px rgba(11, 34, 21, 0.04);
}

html.dark {
  /* Paleta Noche: Aguardo Nocturno */
  --bg-canvas: #080f0b;
  --bg-surface: #101c16;
  --bg-subtle: #16261e;
  --border-subtle: #22382c;
  --text-primary: #eceae4;
  --text-secondary: #a3b5aa;
  --text-muted: #6c8275;
  --card-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.55);
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Jerarquía tipográfica: Outfit (Display) + JetBrains Mono (Telemetría/Códigos) */
h1, h2, h3, h4, .font-display {
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  letter-spacing: -0.015em;
}

.font-mono, kbd, code {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

body.layout-iphone {
  padding-bottom: calc(4.75rem + var(--sab));
}

body.layout-pc {
  padding-bottom: 0;
}

.safe-top-header {
  padding-top: max(0.5rem, var(--sat));
}

.safe-bottom-bar {
  padding-bottom: max(0.35rem, var(--sab));
}

/* Posicionamiento dinámico de barras flotantes */
.sticky-quiz-toolbar {
  position: sticky;
  top: calc(var(--header-h) + 4px);
  z-index: 20;
}

.question-scroll-target {
  scroll-margin-top: calc(var(--header-h) + var(--quiz-toolbar-h) + 14px);
}

@media (min-width: 1024px) {
  .sticky-pc-sidebar {
    position: sticky;
    top: calc(var(--header-h) + var(--quiz-toolbar-h) + 16px);
    z-index: 10;
  }
  .sticky-pc-sidebar-inner {
    max-height: calc(100vh - var(--header-h) - var(--quiz-toolbar-h) - 24px);
    overflow-y: auto;
  }
}

/* Acentos semánticos superiores para tarjetas de pregunta */
.card-accent-neutral {
  border-top: 3px solid #1b4b30 !important;
}
.card-accent-correct {
  border-top: 4px solid #10b981 !important;
}
.card-accent-wrong {
  border-top: 4px solid #d95d39 !important;
}
.card-accent-blind {
  border-top: 4px solid #d1a847 !important;
}

/* Color de acento de marca en checkboxes y radios (adiós azul sistema) */
input[type="checkbox"],
input[type="radio"] {
  accent-color: #133622;
}

html.dark input[type="checkbox"],
html.dark input[type="radio"] {
  accent-color: #d1a847;
}

/* Adaptación automática de superficies en Modo Oscuro (Aguardo Nocturno) */
html.dark .bg-white,
html.dark .bg-white\/70 {
  background-color: var(--bg-surface) !important;
}
html.dark .bg-white\/95 {
  background-color: rgba(16, 28, 22, 0.95) !important;
}
html.dark .bg-slate-50,
html.dark .bg-slate-50\/40,
html.dark .bg-slate-50\/50,
html.dark .bg-slate-50\/70,
html.dark .bg-slate-50\/80,
html.dark .bg-slate-50\/90,
html.dark .bg-slate-100,
html.dark .bg-slate-100\/60,
html.dark .bg-slate-100\/70,
html.dark .bg-slate-200,
html.dark .bg-slate-200\/70,
html.dark .bg-slate-200\/80 {
  background-color: var(--bg-subtle) !important;
}
html.dark .border-slate-200,
html.dark .border-slate-200\/80,
html.dark .border-slate-100,
html.dark .border-slate-300,
html.dark .divide-slate-100 > :not([hidden]) ~ :not([hidden]) {
  border-color: var(--border-subtle) !important;
}

/* Estados hover seguros en Modo Oscuro (evita fondos blancos sobre texto claro) */
html.dark .hover\:bg-white:hover,
html.dark .hover\:bg-slate-50:hover,
html.dark .hover\:bg-slate-50\/90:hover,
html.dark .hover\:bg-slate-100:hover,
html.dark .hover\:bg-slate-200:hover {
  background-color: #1c3126 !important;
}
html.dark .hover\:bg-gc-50:hover,
html.dark .hover\:bg-gc-100:hover {
  background-color: rgba(37, 99, 64, 0.34) !important;
}
html.dark .hover\:bg-red-50:hover,
html.dark .hover\:bg-red-100:hover {
  background-color: rgba(217, 93, 57, 0.24) !important;
}
html.dark .hover\:bg-gold-100:hover,
html.dark .hover\:bg-gold-100\/80:hover {
  background-color: rgba(184, 141, 43, 0.26) !important;
}
html.dark .hover\:text-slate-900:hover,
html.dark .hover\:text-slate-800:hover,
html.dark .hover\:text-slate-700:hover {
  color: var(--text-primary) !important;
}

/* Pestaña activa clara en cabecera PC y dock móvil en Modo Oscuro */
html.dark #pc-top-nav .nav-btn.bg-white {
  background-color: #133622 !important;
  color: #f7f0dc !important;
  border: 1px solid rgba(209, 168, 71, 0.58) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35) !important;
}
html.dark #mobile-bottom-nav button.bg-gc-50 {
  background-color: #133622 !important;
  color: #d1a847 !important;
}

html.dark .text-slate-900,
html.dark .text-slate-800,
html.dark .text-gc-950 {
  color: var(--text-primary) !important;
}
html.dark .bg-gold-500.text-gc-950,
html.dark .bg-gold-400.text-gc-950 {
  color: #06140c !important;
}
html.dark .text-slate-700,
html.dark .text-slate-600,
html.dark .text-slate-500 {
  color: var(--text-secondary) !important;
}
html.dark .bg-gc-50 {
  background-color: rgba(37, 99, 64, 0.22) !important;
  border-color: rgba(37, 99, 64, 0.45) !important;
}
html.dark .text-gc-900,
html.dark .text-gc-800 {
  color: #6ee7b7 !important;
}
html.dark .bg-emerald-50,
html.dark .bg-emerald-50\/50,
html.dark .bg-emerald-50\/70,
html.dark .bg-emerald-50\/90,
html.dark .bg-emerald-100 {
  background-color: rgba(16, 185, 129, 0.14) !important;
  border-color: rgba(16, 185, 129, 0.35) !important;
}
html.dark .text-emerald-950,
html.dark .text-emerald-900,
html.dark .text-emerald-800,
html.dark .text-emerald-700 {
  color: #6ee7b7 !important;
}
html.dark .bg-red-50,
html.dark .bg-red-50\/70,
html.dark .bg-clay-100 {
  background-color: rgba(217, 93, 57, 0.15) !important;
  border-color: rgba(217, 93, 57, 0.42) !important;
}
html.dark .border-red-200,
html.dark .border-red-200\/90,
html.dark .border-red-300\/80 {
  border-color: rgba(217, 93, 57, 0.42) !important;
}
html.dark .text-red-950,
html.dark .text-red-900,
html.dark .text-red-800,
html.dark .text-red-700,
html.dark .text-clay-600 {
  color: #f48c6c !important;
}
html.dark .bg-gold-100,
html.dark .bg-gold-100\/40,
html.dark .bg-gold-100\/45,
html.dark .bg-gold-100\/60,
html.dark .bg-gold-100\/70,
html.dark .bg-gold-100\/80,
html.dark .bg-amber-50 {
  background-color: rgba(184, 141, 43, 0.16) !important;
  border-color: rgba(184, 141, 43, 0.4) !important;
}
html.dark .text-gold-600,
html.dark .text-amber-800,
html.dark .text-amber-900 {
  color: #e2bd6b !important;
}

/* Globo Flotante Global de Tooltips */
#encare-floating-tooltip {
  position: fixed;
  top: 0;
  left: 0;
  background-color: #0b2215;
  color: #f4f3ef;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.45;
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px solid rgba(184, 141, 43, 0.45);
  box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.45);
  max-width: min(260px, 86vw);
  width: max-content;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
  z-index: 9999;
}

#encare-floating-tooltip.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Animaciones de entrada para tarjetas, cajones laterales y bandejas inferiores */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideUpSheet {
  from { opacity: 0; transform: translateY(100%); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-explanation {
  animation: fadeSlideIn 0.18s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-drawer-right {
  animation: slideInRight 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-sheet-up {
  animation: slideUpSheet 0.24s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
.touch-option { min-height: 56px; }

/* ========================================================================= */
/* LA SENDA DEL TIRADOR: TEXTURAS METÁLICAS Y CONDECORACIONES TÁCTICAS       */
/* ========================================================================= */
.senda-hero-panel {
  background: radial-gradient(circle at 85% 15%, rgba(184, 141, 43, 0.16), transparent 55%),
              linear-gradient(145deg, #0b2215 0%, #06140c 100%);
  border: 1px solid rgba(184, 141, 43, 0.45);
  box-shadow: 0 14px 32px -8px rgba(6, 20, 12, 0.55);
}

.medal-card-unlocked {
  background: linear-gradient(160deg, rgba(19, 54, 34, 0.92) 0%, rgba(6, 20, 12, 0.98) 100%);
  border: 1px solid rgba(209, 168, 71, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 8px 20px -6px rgba(0, 0, 0, 0.5);
}

.medal-card-locked {
  background: linear-gradient(180deg, rgba(11, 34, 21, 0.72) 0%, rgba(6, 20, 12, 0.82) 100%);
  border: 1px dashed rgba(255, 255, 255, 0.22);
}

.rank-crest-glow {
  filter: drop-shadow(0 6px 16px rgba(209, 168, 71, 0.28));
}

.aguardo-fire-glow {
  filter: drop-shadow(0 0 10px rgba(217, 93, 57, 0.55));
}

/* ========================================================================= */
/* TELEMETRÍA TÁCTICA, RADAR HEPTAGONAL Y SELECTOR SEGMENTADO                */
/* ========================================================================= */
.telemetry-dark-panel {
  background: radial-gradient(circle at 18% 18%, rgba(16, 185, 129, 0.12), transparent 50%),
              radial-gradient(circle at 85% 80%, rgba(209, 168, 71, 0.12), transparent 55%),
              linear-gradient(155deg, #0b2215 0%, #06140c 100%);
  border: 1px solid rgba(184, 141, 43, 0.42);
  box-shadow: 0 14px 32px -8px rgba(6, 20, 12, 0.55);
}

.stats-subtab-btn {
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.stats-subtab-active,
.stats-subtab-active:hover {
  background-color: #0b2215;
  color: #d1a847 !important;
  border-color: rgba(209, 168, 71, 0.55);
  box-shadow: 0 2px 8px -2px rgba(11, 34, 21, 0.25);
}

html.dark .stats-subtab-active,
html.dark .stats-subtab-active:hover {
  background-color: #133622;
  color: #f7f0dc !important;
  border-color: rgba(209, 168, 71, 0.65);
}

.telemetry-gauge-ring {
  filter: drop-shadow(0 0 10px rgba(16, 185, 129, 0.28));
}

.radar-polygon-user {
  fill: rgba(209, 168, 71, 0.24);
  stroke: #d1a847;
  stroke-width: 2.2;
  filter: drop-shadow(0 0 8px rgba(209, 168, 71, 0.35));
}

.radar-polygon-national {
  fill: rgba(163, 181, 170, 0.08);
  stroke: #6c8275;
  stroke-width: 1.4;
  stroke-dasharray: 3 3;
}

/* ========================================================================= */
/* ARQUITECTURA HÍBRIDA DE INSIGNIAS: BASE WEBP + OVERLAY SVG + TILT 3D      */
/* ========================================================================= */
.badge-tilt-stage {
  perspective: 900px;
}

.badge-tilt-card {
  position: relative;
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform 0.16s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
  overflow: hidden;
}

.badge-tilt-card img {
  position: relative;
  z-index: 1;
  display: block;
}

.badge-tilt-card img.hidden {
  display: none !important;
}

.badge-specular-glare {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(
    circle at var(--mx, 50%) var(--my, 50%),
    rgba(255, 250, 235, 0.28) 0%,
    rgba(209, 168, 71, 0.08) 45%,
    transparent 72%
  );
  opacity: 0;
  transition: opacity 0.2s ease;
}

.badge-tilt-stage:hover .badge-specular-glare,
.badge-tilt-stage:active .badge-specular-glare {
  opacity: 1;
}

.badge-webp-relief {
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.55));
  user-select: none;
  -webkit-user-drag: none;
}

/* Medalla bloqueada: apariencia de troquel en acero bruto con alto contraste (paridad iOS) */
.medal-unminted-img {
  filter: grayscale(1) contrast(1.06) brightness(0.85) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.35));
  opacity: 0.72;
}

.eibar-masterwork-banner {
  background: radial-gradient(circle at 20% 50%, rgba(209, 168, 71, 0.2), transparent 60%),
              linear-gradient(135deg, #102b1b 0%, #06140c 100%);
  border: 1px solid rgba(209, 168, 71, 0.6);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 12px 28px -6px rgba(0, 0, 0, 0.6);
}

/* ========================================================================= */
/* PILAR 3: MANIOBRA DE FIN DE SEMANA, CUADRANTE Y RUTAS DE TRANSFERENCIA    */
/* ========================================================================= */
.maneuver-hero-panel {
  background: radial-gradient(circle at 88% 12%, rgba(209, 168, 71, 0.18), transparent 52%),
              radial-gradient(circle at 12% 88%, rgba(16, 185, 129, 0.12), transparent 50%),
              linear-gradient(150deg, #0b2215 0%, #06140c 100%);
  border: 1px solid rgba(209, 168, 71, 0.48);
  box-shadow: 0 14px 32px -8px rgba(6, 20, 12, 0.55);
}

.quadrant-cell {
  background: rgba(6, 20, 12, 0.55);
  border: 1px solid rgba(163, 181, 170, 0.16);
  transition: all 0.2s ease;
}

.quadrant-cell-active {
  background: rgba(209, 168, 71, 0.18);
  border: 1px solid rgba(209, 168, 71, 0.75);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 0 14px rgba(209, 168, 71, 0.22);
}

.transfer-route-card {
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.transfer-route-card:hover {
  border-color: rgba(184, 141, 43, 0.55);
}

.transfer-route-locked {
  background: rgba(15, 23, 42, 0.03);
  border-style: dashed;
}

html.dark .transfer-route-locked {
  background: rgba(6, 20, 12, 0.55);
}

/* ========================================================================= */
/* BLOQUE 1 · IDENTIDAD BASE -> PRO, TABULAR-NUMS Y PORTADA EDITORIAL        */
/* ========================================================================= */
.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* Placa metálica troquelada PRO con destello especular único */
.encare-pro-badge {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #133622 0%, #0b2215 100%);
  border: 1px solid rgba(209, 168, 71, 0.72);
  color: #f7f0dc;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 2px 6px rgba(0, 0, 0, 0.28);
}

.encare-pro-badge::after {
  content: '';
  position: absolute;
  top: 0;
  left: -130%;
  width: 65%;
  height: 100%;
  background: linear-gradient(110deg, transparent 0%, rgba(255, 248, 224, 0.45) 50%, transparent 100%);
  pointer-events: none;
}

.encare-pro-badge.pro-sheen-once::after {
  animation: proSheenOnce 1.15s cubic-bezier(0.22, 1, 0.36, 1) 0.25s 1 forwards;
}

@keyframes proSheenOnce {
  from { left: -130%; }
  to { left: 165%; }
}

/* Cápsula dúo BASE | ↗ */
.encare-base-capsule {
  display: inline-flex;
  align-items: stretch;
  overflow: hidden;
  border-radius: 9999px;
  border: 1px solid rgba(209, 168, 71, 0.48);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.24);
}

.encare-base-capsule-left {
  background: linear-gradient(180deg, #334039 0%, #242f29 100%);
  color: #e9e7df;
}

.encare-base-capsule-right {
  background: linear-gradient(180deg, #d1a847 0%, #b88d2b 100%);
  color: #06140c;
}

.avatar-pro-ring {
  box-shadow: 0 0 0 1.5px #d1a847, 0 0 8px rgba(209, 168, 71, 0.35);
}

/* Portada editorial cinematográfica (Híbrido Garmin + Strava) */
.portal-hero-vignette {
  background: linear-gradient(
    180deg,
    rgba(6, 20, 12, 0.62) 0%,
    rgba(6, 20, 12, 0.16) 34%,
    rgba(6, 20, 12, 0.56) 68%,
    rgba(6, 20, 12, 0.94) 100%
  );
}

.portal-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 450ms cubic-bezier(0.22, 1, 0.36, 1), transform 450ms cubic-bezier(0.22, 1, 0.36, 1);
}

.portal-slide.is-active {
  position: relative;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.portal-glass-card {
  background: rgba(11, 34, 21, 0.78);
  border: 1px solid rgba(209, 168, 71, 0.38);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 16px 36px -10px rgba(0, 0, 0, 0.6);
}

.portal-indicator-dot {
  height: 5px;
  width: 8px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.32);
  transition: width 260ms ease, background-color 260ms ease;
}

.portal-indicator-dot.is-active {
  width: 26px;
  background: #d1a847;
}

/* Contraste blindado para botones primarios dentro de modales de acceso en Modo Oscuro */
html.dark .auth-modal-card {
  background-color: #101c16 !important;
  border-color: rgba(209, 168, 71, 0.35) !important;
}

html.dark .auth-modal-primary-btn {
  background-color: #b88d2b !important;
  color: #06140c !important;
}

html.dark .auth-modal-primary-btn:hover {
  background-color: #d1a847 !important;
}

@media (prefers-reduced-motion: reduce) {
  .encare-pro-badge.pro-sheen-once::after {
    animation: none;
  }
  .portal-slide {
    transition: none;
    transform: none;
  }
  .portal-indicator-dot {
    transition: none;
  }
}