/* Tema synthwave: fondo oscuro, neones, glow. Sin dependencias externas:
   fuente auto-hospedada (@font-face) y utilidades propias (reemplazo de Tailwind). */

/* Fuente auto-hospedada (Space Grotesk, subconjunto latino, variable 400-700) */
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/space-grotesk-latin.woff2") format("woff2");
}

/* Reset minimo (lo que antes aportaba el preflight de Tailwind) */
*, *::before, *::after { box-sizing: border-box; }
h1, h2, h3, h4, p, figure { margin: 0; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
input { font: inherit; }
svg { display: block; }

:root {
  --bg0: #0d0221;
  --ink: #f4eeff;
  --muted: #b69fe0;
  --pink: #ff2a6d;
  --cyan: #2de2e6;
  --purple: #b14bff;
  --gold: #ffc43d;
}

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg0);
  color: var(--ink);
  font-family: "Space Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.font-display { font-family: "Space Grotesk", system-ui, sans-serif; font-weight: 700; letter-spacing: 0.01em; }
.text-muted { color: var(--muted); }

.glass {
  background: rgba(18, 7, 38, 0.62);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.neon-border {
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: 0 0 0 1px rgba(45, 226, 230, 0.12), 0 -10px 50px rgba(177, 75, 255, 0.18);
}

/* Botones */
.btn-neon {
  background: linear-gradient(90deg, var(--pink), var(--purple));
  color: #fff;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  box-shadow: 0 0 22px rgba(255, 42, 109, 0.45);
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.12s;
}
.btn-neon:hover { transform: translateY(-1px); box-shadow: 0 0 30px rgba(255, 42, 109, 0.6); }
.btn-neon:disabled { opacity: 0.4; box-shadow: none; cursor: not-allowed; }

.btn-chip {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
}
.btn-chip:hover { background: rgba(255, 255, 255, 0.12); }
.btn-chip:disabled { opacity: 0.35; cursor: not-allowed; }

.lnk { color: var(--cyan); text-decoration: underline; text-underline-offset: 2px; }
.lnk:hover { color: #fff; }

.start-explain {
  color: #2ff3e0;
  font-weight: 600;
  text-shadow: 0 0 12px rgba(45, 226, 230, 0.45);
}

.factor-chip {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid currentColor;
  text-shadow: 0 0 10px currentColor;
}

/* Input de texto */
.field {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  color: var(--ink);
}
.field::placeholder { color: rgba(182, 159, 224, 0.6); }
.field:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 14px rgba(45, 226, 230, 0.35); }

/* Slider neon -------------------------------------------------------------- */
.slider { width: 100%; }
.slider-track {
  position: relative;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, #1c0e36, #120824);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.06);
  cursor: pointer;
  touch-action: none;
}
.slider-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan), var(--purple), var(--pink));
  box-shadow: 0 0 14px rgba(255, 42, 109, 0.5);
  transition: width 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.slider-thumb {
  position: absolute; top: 50%;
  width: 28px; height: 28px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 35%, #fff, #ffd6ec 38%, var(--pink) 78%);
  box-shadow: 0 0 16px var(--pink), 0 0 34px rgba(255, 42, 109, 0.6);
  transition: left 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.slider-tick {
  position: absolute; top: 50%;
  width: 4px; height: 4px; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.35);
}
.slider.untouched .slider-fill,
.slider.untouched .slider-thumb { opacity: 0; }
.slider.na .slider-fill,
.slider.na .slider-thumb { opacity: 0; }

.slider-labels {
  display: flex; justify-content: space-between;
  margin-top: 14px;
  font-size: 0.7rem;
  color: var(--muted);
}
.slider-labels span {
  flex: 1; text-align: center; cursor: pointer;
  padding: 4px 1px; white-space: nowrap;
  transition: color 0.12s, text-shadow 0.12s;
}
.slider-labels span:first-child { text-align: left; }
.slider-labels span:last-child { text-align: right; }
.slider-labels span:hover { color: var(--ink); }
.slider-labels span.active { color: var(--ink); text-shadow: 0 0 10px var(--cyan); }
@media (min-width: 640px) { .slider-labels { font-size: 0.82rem; } }

/* Infinito (logo) glow suave y pulso */
.inf-glow { filter: drop-shadow(0 0 8px rgba(45, 226, 230, 0.5)) drop-shadow(0 0 16px rgba(255, 42, 109, 0.35)); }
@keyframes infpulse {
  0%, 100% { filter: drop-shadow(0 0 10px rgba(45, 226, 230, 0.6)) drop-shadow(0 0 22px rgba(255, 42, 109, 0.4)); }
  50% { filter: drop-shadow(0 0 18px rgba(138, 92, 255, 0.7)) drop-shadow(0 0 34px rgba(255, 60, 166, 0.5)); }
}
.inf-pulse { animation: infpulse 4s ease-in-out infinite; }

/* Scrollbar fina para textos largos */
.thin-scroll { scrollbar-width: thin; scrollbar-color: rgba(177,75,255,0.5) transparent; }
.thin-scroll::-webkit-scrollbar { width: 6px; }
.thin-scroll::-webkit-scrollbar-thumb { background: rgba(177,75,255,0.5); border-radius: 999px; }

.fade-in { animation: fadein 0.35s ease both; }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Indicador de completitud: anillo que se llena (--p = porcentaje) */
.gate-ring {
  position: relative;
  width: min(46vw, 190px);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(
    from -90deg,
    var(--cyan) 0%,
    var(--purple) calc(var(--p) * 1%),
    rgba(255, 255, 255, 0.06) calc(var(--p) * 1%)
  );
  filter: drop-shadow(0 0 18px rgba(177, 75, 255, 0.35));
}
.gate-ring::before {
  content: "";
  position: absolute;
  inset: 16px;
  border-radius: 50%;
  background: var(--bg0);
}
.gate-count {
  position: relative;
  z-index: 1;
  font-weight: 700;
  font-size: 1.7rem;
  letter-spacing: 0.01em;
}

/* Promedio total (pantalla final) */
.avg-total {
  font-family: "Space Grotesk", system-ui, sans-serif;
  font-weight: 800;
  font-size: 2.4rem;
  line-height: 1.05;
  background: linear-gradient(90deg, var(--cyan), var(--purple), var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 16px rgba(177, 75, 255, 0.4));
}

/* ===== Utilidades propias (reemplazo de Tailwind) ===== */
.fixed { position: fixed; }
.absolute { position: absolute; }
.relative { position: relative; }
.flex { display: flex; }
.grid { display: grid; }
.flex-col { flex-direction: column; }
/* .hidden debe ir despues de los display para ganar cuando un elemento tiene
   ambas clases (p. ej. #start con "flex" + "hidden"). */
.hidden { display: none; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.inset-x-0 { left: 0; right: 0; }
.top-0 { top: 0; }
.bottom-0 { bottom: 0; }
.right-0 { right: 0; }
.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.z-30 { z-index: 30; }
.z-40 { z-index: 40; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.place-items-center { place-items: center; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.shrink-0 { flex-shrink: 0; }
.min-w-0 { min-width: 0; }
.mx-auto { margin-left: auto; margin-right: auto; }
.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; }
.pointer-events-none { pointer-events: none; }
.select-none { -webkit-user-select: none; user-select: none; }

.w-full { width: 100%; }
.h-full { height: 100%; }
.w-9 { width: 2.25rem; }
.h-9 { height: 2.25rem; }
.w-52 { width: 13rem; }
.max-w-xs { max-width: 20rem; }
.max-w-md { max-width: 28rem; }
.max-w-xl { max-width: 36rem; }
.h-\[270px\] { height: 270px; }
.h-\[4\.4em\] { height: 4.4em; }

.p-2 { padding: 0.5rem; }
.p-6 { padding: 1.5rem; }
.px-2\.5 { padding-left: 0.625rem; padding-right: 0.625rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-5 { padding-left: 1.25rem; padding-right: 1.25rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.px-8 { padding-left: 2rem; padding-right: 2rem; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-2\.5 { padding-top: 0.625rem; padding-bottom: 0.625rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.25rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-1\.5 { margin-top: 0.375rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-5 { margin-top: 1.25rem; }
.mt-8 { margin-top: 2rem; }
.mr-1 { margin-right: 0.25rem; }

.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-base { font-size: 1rem; line-height: 1.5rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.text-\[0\.6rem\] { font-size: 0.6rem; }
.text-\[0\.62rem\] { font-size: 0.62rem; }
.text-\[0\.98rem\] { font-size: 0.98rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-black { font-weight: 900; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.leading-none { line-height: 1; }
.leading-tight { line-height: 1.25; }
.leading-relaxed { line-height: 1.625; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-muted\/70 { color: rgba(182, 159, 224, 0.7); }
.text-muted\/90 { color: rgba(182, 159, 224, 0.9); }

.rounded-xl { border-radius: 0.75rem; }
.rounded-2xl { border-radius: 1rem; }
.rounded-t-3xl { border-top-left-radius: 1.5rem; border-top-right-radius: 1.5rem; }

.group:hover .group-hover\:underline { text-decoration: underline; }

@media (min-width: 640px) {
  .sm\:text-sm { font-size: 0.875rem; line-height: 1.25rem; }
  .sm\:text-lg { font-size: 1.125rem; line-height: 1.75rem; }
  .sm\:text-3xl { font-size: 1.875rem; line-height: 2.25rem; }
}

/* ===== Tema claro (toggle: clase .light en <html>) ===== */
html.light {
  --bg0: #ffffff;
  --ink: #1d1136;
  --muted: #6b5b8a;
}
html.light .glass { background: rgba(255, 255, 255, 0.72); }
html.light .neon-border {
  border: 1px solid rgba(20, 10, 40, 0.10);
  box-shadow: 0 0 0 1px rgba(45, 226, 230, 0.10), 0 -10px 40px rgba(177, 75, 255, 0.10);
}
html.light .btn-chip {
  background: rgba(20, 10, 40, 0.05);
  border: 1px solid rgba(20, 10, 40, 0.14);
}
html.light .btn-chip:hover { background: rgba(20, 10, 40, 0.10); }
html.light .field {
  background: rgba(20, 10, 40, 0.04);
  border: 1px solid rgba(20, 10, 40, 0.16);
}
html.light .field::placeholder { color: rgba(107, 91, 138, 0.7); }
html.light .slider-track {
  background: linear-gradient(180deg, #e6e0f2, #d7cfe8);
  box-shadow: inset 0 2px 6px rgba(60, 40, 100, 0.18), 0 0 0 1px rgba(20, 10, 40, 0.06);
}
html.light .slider-tick { background: rgba(40, 25, 70, 0.30); }
html.light .lnk { color: #1d8f96; }
html.light .lnk:hover { color: #0b5e63; }
html.light .start-explain { color: #1d8f96; text-shadow: none; }
html.light .gate-ring {
  background: conic-gradient(
    from -90deg,
    var(--cyan) 0%,
    var(--purple) calc(var(--p) * 1%),
    rgba(20, 10, 40, 0.08) calc(var(--p) * 1%)
  );
}
html.light #start {
  background: radial-gradient(120% 80% at 50% 30%, #f3edff 0%, #ffffff 70%) !important;
}
html.light #info { background: rgba(255, 255, 255, 0.55) !important; }
