@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,700;9..144,900&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #0b0a09;
  --bg-elev: #16130f;
  --bg-elev-2: #1c1812;
  --ink: #f4ede1;
  --ink-muted: #a89c8c;
  --ink-faint: #6f6559;
  --rule: #2b2620;
  --accent: #ff4433;
  --accent-bright: #ff6a52;
  --accent-dim: #4a1a12;
  --accent-glow: rgba(255, 68, 51, 0.35);
  --gold: #d9a544;
  --max-width: 560px;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  padding: 3.5rem 1.5rem 5rem;
  background:
    radial-gradient(ellipse 800px 500px at 50% -10%, var(--accent-dim) 0%, transparent 65%),
    var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  line-height: 1.55;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  z-index: 2;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Círculos blancos tenues flotando muy despacio de fondo. */
body::after {
  content: '';
  position: fixed;
  inset: -10%;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 70%) 12% 18% / 260px 260px no-repeat,
    radial-gradient(circle, rgba(255, 255, 255, 0.04) 0%, transparent 70%) 82% 12% / 340px 340px no-repeat,
    radial-gradient(circle, rgba(255, 255, 255, 0.06) 0%, transparent 70%) 28% 78% / 190px 190px no-repeat,
    radial-gradient(circle, rgba(255, 255, 255, 0.035) 0%, transparent 70%) 72% 82% / 380px 380px no-repeat,
    radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 70%) 50% 45% / 150px 150px no-repeat;
  animation: flotar-circulos 55s ease-in-out infinite alternate;
}

@keyframes flotar-circulos {
  0% {
    background-position: 12% 18%, 82% 12%, 28% 78%, 72% 82%, 50% 45%;
  }
  50% {
    background-position: 18% 28%, 76% 24%, 34% 66%, 66% 72%, 56% 54%;
  }
  100% {
    background-position: 8% 12%, 86% 8%, 22% 84%, 78% 88%, 44% 38%;
  }
}

@media (prefers-reduced-motion: reduce) {
  body::after {
    animation: none;
  }
}

.sheet {
  max-width: var(--max-width);
  margin: 0 auto;
  position: relative;
  z-index: 1;
  animation: aparecer 0.6s ease both;
}

@keyframes aparecer {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.eyebrow {
  text-align: center;
  color: var(--accent-bright);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  margin: 0 0 0.9rem;
}

h1 {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: clamp(2.1rem, 7vw, 3rem);
  text-align: center;
  margin: 0 0 0.35rem;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, var(--ink) 30%, var(--accent-bright) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  text-align: center;
  color: var(--ink-muted);
  margin: 0 0 2.25rem;
  font-size: 0.98rem;
}

.rule {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 2.25rem 0;
}

.field {
  margin-bottom: 1.5rem;
}

.field label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.45rem;
  color: var(--ink);
}

.field .hint {
  color: var(--ink-muted);
  font-size: 0.85rem;
  margin-top: 0.3rem;
}

input[type="date"],
input[type="number"],
input[type="text"] {
  width: 100%;
  padding: 0.75rem 0.95rem;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--bg-elev);
  color: var(--ink);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  color-scheme: dark;
}

input::placeholder { color: var(--ink-faint); }

input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.stat {
  text-align: center;
  margin: 2rem 0;
}

.stat .value {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: clamp(1.7rem, 6vw, 2.4rem);
  display: block;
  text-shadow: 0 0 40px var(--accent-glow);
  letter-spacing: -0.01em;
}

.stat .label {
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.stat.hero {
  margin: 1.4rem 0;
}

.stat.hero .value {
  font-size: clamp(2.4rem, 11vw, 3.6rem);
}

.stat.hero .value.accent {
  color: var(--gold);
  text-shadow: 0 0 40px rgba(217, 165, 68, 0.35);
}

.grid-vida {
  display: grid;
  grid-template-columns: repeat(52, 1fr);
  gap: 2px;
  margin: 1.75rem 0 0.7rem;
}

.grid-vida span {
  aspect-ratio: 1;
  min-width: 3px;
  border-radius: 1px;
  background: var(--bg-elev-2);
  border: 1px solid var(--rule);
}

.grid-vida span.vivida {
  background: var(--accent);
  border-color: var(--accent-bright);
}

.grid-vida span.actual {
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 6px var(--gold);
  animation: latido-punto 1.6s ease-in-out infinite;
}

@keyframes latido-punto {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.7); }
}

.grid-caption {
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.78rem;
  margin: 0 0 1.75rem;
}

.dot-leyenda {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  margin: 0 0.2rem 0 0.55rem;
  vertical-align: middle;
}

.dot-leyenda.vivida { background: var(--accent); }
.dot-leyenda.actual { background: var(--gold); }
.dot-leyenda.futura { background: var(--bg-elev-2); border: 1px solid var(--rule); }

.reto-hero {
  text-align: center;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 2rem 1.5rem;
  margin: 2rem 0;
  position: relative;
  overflow: hidden;
}

.reto-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, var(--accent-glow), transparent 70%);
  opacity: 0.6;
  pointer-events: none;
}

.reto-hero .eyebrow,
.reto-hero .actions {
  position: relative;
}

.reto-texto {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 1.4rem;
  line-height: 1.4;
  margin: 0.5rem 0 1.5rem;
  position: relative;
}

.bar-track {
  height: 8px;
  background: var(--bg-elev-2);
  border-radius: 4px;
  overflow: hidden;
  margin: 0.7rem 0;
  border: 1px solid var(--rule);
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--accent));
  width: 0%;
  box-shadow: 0 0 12px var(--accent-glow);
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.alert-box {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--ink);
  border-radius: 8px;
  padding: 1.1rem;
  text-align: center;
  font-weight: 500;
  margin: 1.5rem 0;
  box-shadow: 0 0 24px var(--accent-glow);
  animation: latido 3s ease-in-out infinite;
}

@keyframes latido {
  0%, 100% { box-shadow: 0 0 18px var(--accent-glow); }
  50% { box-shadow: 0 0 32px var(--accent-glow); }
}

.instalar-banner {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  color: var(--ink);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  text-align: center;
  font-size: 0.9rem;
  margin: 1.5rem 0;
  animation: aparecer 0.4s ease both;
}

.instalar-banner .actions {
  margin-top: 0.7rem;
  justify-content: center;
}

.frase {
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-weight: 400;
  text-align: center;
  font-size: 1.3rem;
  line-height: 1.4;
  margin: 2rem 0;
  min-height: 3.2em;
  color: var(--ink);
  position: relative;
  padding: 1.9rem 2.2rem;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
}

.frase::before,
.frase::after {
  font-family: Georgia, serif;
  font-style: normal;
  color: var(--accent);
  opacity: 0.55;
  font-size: 1.6em;
  position: absolute;
}

.frase::before { content: '“'; top: -0.1em; left: -0.15em; }
.frase::after { content: '”'; bottom: -0.6em; right: -0.15em; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  justify-content: center;
}

button {
  padding: 0.8rem 1.5rem;
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 600;
  border: 1px solid var(--accent);
  border-radius: 6px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

button:hover:not(:disabled) {
  background: var(--accent-bright);
  border-color: var(--accent-bright);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--accent-glow);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule);
}

button.secondary:hover:not(:disabled) {
  background: var(--bg-elev);
  border-color: var(--ink-muted);
  box-shadow: none;
}

button:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
  box-shadow: none;
}

h2 {
  color: var(--ink);
}

ul.goals {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
}

ul.goals li {
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--rule);
}

.goal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
  width: 100%;
}

ul.goals li .goal-text {
  font-weight: 600;
  color: var(--ink);
}

.streak-toggle {
  background: none;
  border: none;
  padding: 0;
  color: var(--gold);
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline dotted;
}

.streak-toggle:hover {
  color: var(--accent-bright);
  background: none;
  transform: none;
  box-shadow: none;
}

.streak-toggle.bump-streak {
  display: inline-block;
  animation: bump-racha 0.4s ease;
}

.empty {
  text-align: center;
  color: var(--ink-muted);
  padding: 1.5rem 0;
}

.empty a { color: var(--accent-bright); }

.heatmap {
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  grid-auto-flow: column;
  gap: 3px;
  margin: 0.9rem 0 1.3rem;
  overflow-x: auto;
  padding-bottom: 0.3rem;
}

.heatmap-celda {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: var(--bg-elev-2);
  border: 1px solid var(--rule);
}

.heatmap-celda.hecha {
  background: var(--accent);
  border-color: var(--accent-bright);
  box-shadow: 0 0 6px var(--accent-glow);
}

.rachas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 1.1rem;
  margin: 1.75rem 0;
}

.racha-card {
  text-align: center;
  opacity: 0;
  animation: aparecer-racha 0.5s ease forwards;
  animation-delay: calc(var(--indice) * 0.08s);
}

@keyframes aparecer-racha {
  from { opacity: 0; transform: translateY(10px) scale(0.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.racha-anillo {
  --progreso: 0%;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--progreso), var(--bg-elev-2) 0deg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  margin: 0 auto 0.7rem;
  box-shadow: 0 0 18px var(--accent-glow);
}

.racha-anillo::before {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: var(--bg-elev);
}

.racha-emoji {
  position: relative;
  z-index: 1;
  font-size: 1.3rem;
  line-height: 1;
  display: inline-block;
  animation: parpadeo-llama 1.8s ease-in-out infinite;
}

.racha-num {
  position: relative;
  z-index: 1;
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 1rem;
  margin-top: 0.15rem;
}

@keyframes parpadeo-llama {
  0%, 100% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.08) rotate(-3deg); }
  50% { transform: scale(0.96) rotate(2deg); }
  75% { transform: scale(1.05) rotate(-1deg); }
}

.racha-nombre {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--ink);
  margin-bottom: 0.15rem;
}

.racha-meta {
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.racha-card.bump .racha-anillo {
  animation: bump-racha 0.4s ease;
}

@keyframes bump-racha {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

.tragaperras-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 50;
  animation: aparecer 0.2s ease both;
}

.tragaperras-overlay[hidden] {
  display: none;
}

.tragaperras-caja {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 1.75rem 1.5rem;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.tragaperras-ventana {
  height: 264px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--bg-elev-2);
  contain: paint;
}

.tragaperras-ventana::before,
.tragaperras-ventana::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--rule);
  z-index: 1;
  pointer-events: none;
}

.tragaperras-ventana::before { top: 88px; }
.tragaperras-ventana::after { top: 176px; }

.tragaperras-fila {
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 1.25rem;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 1.2rem;
  line-height: 1.4;
  color: var(--ink-muted);
  text-align: center;
  text-shadow: 0 0 14px rgba(255, 255, 255, 0.16);
}

.tragaperras-fila.tragaperras-fila-ganadora {
  color: var(--ink);
  text-shadow: 0 0 4px rgba(255, 255, 255, 0.6), 0 0 30px var(--accent-glow);
  animation: bump-racha 0.4s ease;
}

.volver-manana {
  text-align: center;
}

.volver-texto {
  color: var(--ink-muted);
  font-size: 0.95rem;
  max-width: 420px;
  margin: 0 auto 1.4rem;
}

.confeti-contenedor {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 999;
}

.confeti {
  position: absolute;
  top: -10px;
  width: 8px;
  height: 14px;
  opacity: 0.95;
  animation: caida-confeti linear forwards;
}

@keyframes caida-confeti {
  to {
    transform: translateY(100vh) rotate(360deg);
    opacity: 0.5;
  }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.9rem;
  margin: 2rem 0;
}

.stat-card {
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 1.3rem 0.8rem;
  text-align: center;
  background: var(--bg-elev);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.stat-card-emoji {
  font-size: 1.6rem;
  margin-bottom: 0.35rem;
}

.stat-card-valor {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 1.6rem;
  color: var(--ink);
}

.stat-card-etiqueta {
  color: var(--ink-muted);
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

.tarjeta-wrap {
  text-align: center;
  margin-top: 1.5rem;
}

.grafica {
  width: 100%;
  height: auto;
  display: block;
  margin: 1.25rem 0 0.5rem;
}

.tarjeta-wrap canvas {
  width: 100%;
  max-width: 380px;
  height: auto;
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

@media (max-width: 420px) {
  h1 { font-size: 1.85rem; }
  .actions { flex-direction: column; }
  .actions button { width: 100%; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
