/* La Chispa — hoja única. Paleta "Amanecer" heredada de acim-companion:
 * azul UCDM profundo, dorado estrella, cielos de alba. Tipografía Lexend si
 * está en el sistema (anti-dislexia), fallback system-ui. Sin fuentes
 * remotas, sin CDNs: todo vive en el repo. */

:root {
  --font-body: "Lexend", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;

  --night-1: #070d24;
  --night-2: #101a3e;
  --night-3: #1c2850;
  --ink: #f2ecdd;
  --ink-muted: #b9c0d8;
  --star: #f9e6b6;
  --star-strong: #f3d49a;
  --gold: #c79a2e;
  --accent: #ffe6a8;
  --danger-soft: #d8a0a0;

  --sun-core: #fff8e6;
  --sun-mid: #ffe6a8;
  --sun-edge: #e7a953;
  --dawn-a: #37548c;
  --dawn-b: #a081a0;
  --dawn-c: #f6c992;

  --radius: 0.9rem;
  --tap: 3rem; /* 48px mínimo táctil */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--night-1);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  letter-spacing: 0.005em;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  touch-action: manipulation; /* sin doble-tap zoom en iOS */
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ── pantallas ─────────────────────────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: calc(1rem + var(--safe-top)) calc(1rem + var(--safe-right))
           calc(1rem + var(--safe-bottom)) calc(1rem + var(--safe-left));
  background: linear-gradient(180deg, var(--night-1) 0%, var(--night-2) 60%, var(--night-3) 100%);
}
.screen.is-active { display: flex; }
.screen-overlay {
  background: rgba(7, 13, 36, 0.86);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 30;
}
.screen-game { padding: 0; background: var(--night-1); }

.panel {
  width: min(34rem, 100%);
  text-align: center;
  animation: panel-in 480ms cubic-bezier(0.16, 1, 0.3, 1);
}
.panel-scroll {
  max-height: calc(100dvh - 2rem - var(--safe-top) - var(--safe-bottom));
  overflow-y: auto;
  padding: 0.5rem 0.25rem;
  text-align: left;
  scrollbar-width: thin;
}
.panel-scroll .h-display { text-align: center; }
.panel-title { position: relative; z-index: 2; }

@keyframes panel-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* ── tipografía ────────────────────────────────────────────────────────── */
.eyebrow {
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--gold);
  margin-bottom: 0.75rem;
  text-align: center;
}
.title-display, .h-display {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.12;
  color: var(--star);
}
.title-display { font-size: clamp(3rem, 11vw, 4.75rem); margin-bottom: 1rem; }
.h-display { font-size: clamp(1.9rem, 7vw, 2.6rem); margin-bottom: 1.25rem; }

.title-tagline {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.3rem;
  color: var(--ink-muted);
  margin-bottom: 2rem;
}
.title-progress { margin-top: 1.5rem; font-size: 0.9rem; color: var(--ink-muted); text-align: center; }

p + p { margin-top: 0.9rem; }

/* ── botones ───────────────────────────────────────────────────────────── */
.btn-col {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  align-items: center;
  margin-top: 1.75rem;
}
.btn {
  font: inherit;
  min-height: var(--tap);
  min-width: 16rem;
  max-width: 100%;
  padding: 0.7rem 1.6rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(180deg, var(--sun-mid), var(--sun-edge));
  color: #2a1e08;
  font-weight: 600;
  box-shadow: 0 4px 26px rgba(255, 230, 168, 0.25);
}
.btn-ghost {
  background: rgba(249, 230, 182, 0.06);
  border-color: rgba(249, 230, 182, 0.22);
  color: var(--ink);
}
.btn-ghost:hover, .btn-primary:hover { filter: brightness(1.06); }
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.btn-icon {
  font: inherit;
  width: var(--tap);
  height: var(--tap);
  border-radius: 50%;
  border: 1px solid rgba(249, 230, 182, 0.3);
  background: rgba(7, 13, 36, 0.55);
  color: var(--star);
  font-size: 1.1rem;
  cursor: pointer;
}

/* ── portada: amanecer CSS ─────────────────────────────────────────────── */
.dawn-backdrop {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(120% 60% at 50% 108%, rgba(231, 169, 83, 0.35) 0%, rgba(231, 169, 83, 0) 60%),
    linear-gradient(180deg, var(--night-1) 0%, var(--night-2) 55%, #2b3560 100%);
}
.dawn-sun {
  position: absolute;
  left: 50%;
  bottom: -6rem;
  width: 14rem;
  height: 14rem;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, var(--sun-core) 0%, var(--sun-mid) 42%, rgba(231, 169, 83, 0) 72%);
  filter: blur(2px);
  animation: sun-breathe 7s ease-in-out infinite;
}
.dawn-final {
  background:
    radial-gradient(130% 80% at 50% 100%, rgba(246, 201, 146, 0.7) 0%, rgba(246, 201, 146, 0) 65%),
    linear-gradient(180deg, var(--dawn-a) 0%, var(--dawn-b) 55%, var(--dawn-c) 100%);
}
.dawn-sun-final { bottom: -3rem; width: 20rem; height: 20rem; opacity: 0.95; }
@keyframes sun-breathe {
  0%, 100% { opacity: 0.85; transform: translateX(-50%) scale(1); }
  50% { opacity: 1; transform: translateX(-50%) scale(1.05); }
}

/* ── acerca de ─────────────────────────────────────────────────────────── */
.about-list { margin: 1rem 0 1rem 1.25rem; display: grid; gap: 0.6rem; }
.about-note { font-size: 0.9rem; color: var(--ink-muted); margin-top: 1rem; }
a { color: var(--accent); }
kbd {
  font-family: inherit;
  font-size: 0.85em;
  border: 1px solid rgba(249, 230, 182, 0.35);
  border-radius: 0.3rem;
  padding: 0 0.35rem;
}

/* ── sendero ───────────────────────────────────────────────────────────── */
.sendero-totales { text-align: center; color: var(--ink-muted); font-size: 0.9rem; margin-bottom: 1.25rem; }
.sendero-lista { list-style: none; display: grid; gap: 0.55rem; }
.sendero-cap {
  margin: 1.1rem 0 0.35rem;
  font-size: 0.8125rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}
.mision-btn {
  font: inherit;
  width: 100%;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  gap: 0.9rem;
  text-align: left;
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  border: 1px solid rgba(249, 230, 182, 0.16);
  background: rgba(249, 230, 182, 0.05);
  color: var(--ink);
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}
.mision-btn:hover:not(:disabled) { background: rgba(249, 230, 182, 0.11); }
.mision-btn:active:not(:disabled) { transform: scale(0.99); }
.mision-btn:disabled { opacity: 0.38; cursor: default; }
.mision-node {
  flex: 0 0 auto;
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  background: rgba(249, 230, 182, 0.1);
  border: 1px solid rgba(249, 230, 182, 0.3);
}
.mision-btn.is-done .mision-node {
  background: linear-gradient(180deg, var(--sun-mid), var(--sun-edge));
  color: #2a1e08;
  border-color: transparent;
}
.mision-meta { display: block; font-size: 0.8rem; color: var(--ink-muted); }
.mision-title { font-weight: 500; }

/* ── intro de misión ───────────────────────────────────────────────────── */
.intro-subtitle {
  text-align: center;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.2rem;
  color: var(--ink-muted);
  margin-bottom: 1.5rem;
}
.intro-idea {
  font-family: var(--font-display);
  font-size: 1.35rem;
  line-height: 1.4;
  color: var(--star);
  border-left: 3px solid var(--gold);
  padding-left: 1rem;
  margin: 1.25rem 0;
}
.intro-leccion { font-size: 0.85rem; color: var(--gold); margin-bottom: 1.25rem; }
.intro-lines p { color: var(--ink-muted); margin-top: 0.5rem; }

/* ── juego: canvas + HUD ───────────────────────────────────────────────── */
#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hud {
  position: absolute;
  top: calc(0.6rem + var(--safe-top));
  left: calc(0.75rem + var(--safe-left));
  right: calc(0.75rem + var(--safe-right));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  pointer-events: none;
  z-index: 10;
}
.hud-left { display: grid; gap: 0.3rem; }
.hud-right { display: flex; align-items: center; gap: 0.6rem; }
.hud-right .btn-icon { pointer-events: auto; }

.luz-bar {
  width: 9.5rem;
  height: 0.65rem;
  border-radius: 999px;
  background: rgba(249, 230, 182, 0.14);
  border: 1px solid rgba(249, 230, 182, 0.25);
  overflow: hidden;
}
.luz-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--sun-edge), var(--sun-mid));
  transition: width 300ms ease;
}
.hud-counters {
  font-size: 0.85rem;
  color: var(--star);
  text-shadow: 0 1px 6px rgba(7, 13, 36, 0.9);
}
.hud-objective {
  font-size: 0.85rem;
  color: var(--ink-muted);
  text-align: right;
  max-width: 14rem;
  text-shadow: 0 1px 6px rgba(7, 13, 36, 0.9);
}

/* ── toast ─────────────────────────────────────────────────────────────── */
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(7.5rem + var(--safe-bottom));
  transform: translateX(-50%) translateY(12px);
  max-width: min(26rem, 88vw);
  padding: 0.65rem 1.2rem;
  border-radius: var(--radius);
  background: rgba(7, 13, 36, 0.82);
  border: 1px solid rgba(249, 230, 182, 0.3);
  color: var(--star);
  font-size: 0.95rem;
  text-align: center;
  opacity: 0;
  transition: opacity 320ms ease, transform 320ms ease;
  pointer-events: none;
  z-index: 12;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── controles táctiles ────────────────────────────────────────────────── */
.touch-controls {
  position: absolute;
  left: calc(0.9rem + var(--safe-left));
  right: calc(0.9rem + var(--safe-right));
  bottom: calc(0.9rem + var(--safe-bottom));
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  z-index: 11;
}
.touch-controls.is-on { display: flex; }
.touch-group { display: flex; gap: 0.7rem; align-items: flex-end; }
.touch-btn {
  font: inherit;
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  border: 1px solid rgba(249, 230, 182, 0.35);
  background: rgba(7, 13, 36, 0.45);
  color: var(--star);
  font-size: 1.5rem;
  touch-action: none;
  -webkit-touch-callout: none;
}
.touch-btn.is-down { background: rgba(249, 230, 182, 0.28); }
.touch-btn-presence {
  width: 4.6rem;
  height: 4.6rem;
  font-size: 1.8rem;
  border-color: rgba(249, 230, 182, 0.6);
  box-shadow: 0 0 18px rgba(249, 230, 182, 0.18);
}

/* ── pausa / completada ────────────────────────────────────────────────── */
.pause-idea {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.2rem;
  color: var(--ink-muted);
}
.done-stats {
  display: flex;
  justify-content: center;
  gap: 1.75rem;
  margin: 1.25rem 0;
  font-size: 1.05rem;
  color: var(--star);
}
.done-stats span { display: grid; text-align: center; gap: 0.15rem; }
.done-stats small { color: var(--ink-muted); font-size: 0.78rem; }
.done-deeper { font-size: 0.9rem; color: var(--ink-muted); text-align: center; margin-top: 0.75rem; }

/* ── accesibilidad ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .panel { animation: none; }
  .dawn-sun { animation: none; }
  .luz-fill { transition: none; }
}
@media (max-width: 24rem) {
  .btn { min-width: 100%; }
  .hud-objective { max-width: 9.5rem; font-size: 0.78rem; }
  .luz-bar { width: 7.5rem; }
}

/* móvil apaisado (p. ej. iPhone jugando): compactar menús y permitir scroll */
@media (max-height: 32rem) {
  .panel { max-height: 100%; overflow-y: auto; }
  .title-display { font-size: 2.4rem; margin-bottom: 0.4rem; }
  .h-display { font-size: 1.5rem; margin-bottom: 0.6rem; }
  .title-tagline { font-size: 1rem; margin-bottom: 0.8rem; }
  .btn-col { gap: 0.45rem; margin-top: 0.8rem; }
  .btn { min-height: 2.6rem; padding: 0.45rem 1.2rem; }
  .eyebrow { margin-bottom: 0.3rem; }
  .title-progress { margin-top: 0.7rem; }
  .intro-idea { font-size: 1.1rem; margin: 0.8rem 0; }
}
