:root {
  --cream: #eddecf;
  --paper: #fff9f2;
  --paper-deep: #fdeede;
  --rose: #ff5c8a;
  --rose-dark: #c04070;
  --brown: #7a4a3a;
  --brown-dark: #5a3428;
  --muted: #a06a5a;
  --shadow: 0 20px 60px rgba(180, 100, 120, 0.22);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--brown-dark);
  background: var(--cream);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
html, body { min-height: 100%; margin: 0; }
body {
  min-width: 280px;
  overflow-x: hidden;
  background: var(--cream);
}
body.bloqueado,
body.rompecabezas-bloqueado { overflow: hidden; }
button, iframe { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 3px solid rgba(192, 64, 112, .55); outline-offset: 3px; }

.solo-lector-pantalla {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.mensaje-sin-script {
  position: fixed;
  z-index: 1000;
  inset: 1rem 1rem auto;
  padding: 1rem;
  border-radius: .75rem;
  background: #fff;
  color: #5a3428;
  box-shadow: var(--shadow);
  text-align: center;
}

.pantalla-bloqueo {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px;
  background: #C493C3;
  opacity: 0;
  transition: opacity 800ms ease;
}
.pantalla-bloqueo.visible { opacity: 1; }
.pantalla-bloqueo.saliendo { opacity: 0; visibility: hidden; pointer-events: none; }
.tarjeta-bloqueo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.corazon-pixel {
  display: grid;
  grid-template-columns: repeat(9, 10px);
  grid-template-rows: repeat(8, 10px);
  filter: drop-shadow(0 7px 14px rgba(255, 92, 138, .25));
}
.corazon-pixel span {
  width: 10px;
  height: 10px;
}
.corazon-pixel .relleno {
  background: #960DF2;
  box-shadow: inset 0 0 0 1px rgba(220, 47, 98, .12);
}
.corazon-pixel.sacudir { animation: sacudir 480ms ease; }

.puntos-pin { display: flex; gap: 12px; }
.punto-pin {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: rgba(122, 74, 58, .25);
  transition: background 180ms ease, transform 180ms ease;
}
.punto-pin.activo { background: var(--rose); transform: scale(1.08); }

.teclado {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  gap: 12px;
}
.boton-teclado {
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, .72);
  color: var(--brown);
  font-size: 24px;
  font-weight: 350;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(180, 120, 100, .15);
  backdrop-filter: blur(8px);
  transition: transform 140ms ease, background 140ms ease, box-shadow 140ms ease;
}
.boton-teclado:hover { background: #fff; box-shadow: 0 7px 18px rgba(180, 120, 100, .2); }
.boton-teclado:active { transform: scale(.94); }
.espacio-teclado { width: 64px; height: 64px; }
.error-pin {
  min-height: 1.25rem;
  margin: -12px 0 0;
  color: var(--rose-dark);
  font-size: .9rem;
}

.interior {
  position: relative;
  min-height: 100vh;
  opacity: 0;
  background: #f8e8dd url("assets/wallpaper.png") repeat;
  transition: opacity 700ms ease;
}
.interior.visible { opacity: 1; }
.interior.saliendo { opacity: 0; }

.petalos-cayendo,
.capa-explosion {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.petalos-cayendo { z-index: 0; opacity: .52; }
.capa-explosion { z-index: 50; }
.petalo-cayendo,
.petalo-explosion {
  position: absolute;
  top: -12vh;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
  will-change: transform;
}
.petalo-cayendo {
  animation: petal-fall var(--duration) linear var(--delay) infinite;
}
.petalo-explosion {
  animation: burst-fall var(--duration) cubic-bezier(.12, .58, .26, 1) var(--delay) forwards;
}

.seccion {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 96px 24px;
}
.contenido-seccion { width: min(100%, 960px); text-align: center; }
h1, h2 {
  margin: 0;
  color: #491d1d;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: .01em;
}
h1 { font-size: clamp(1.7rem, 5vw, 2.2rem); }
h2 { font-size: clamp(2rem, 5vw, 2.5rem); }
.introduccion-seccion {
  max-width: 560px;
  margin: 12px auto 0;
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.6;
}

.revelar-seccion > * {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 700ms ease, transform 700ms ease;
}
.revelar-seccion.revelada > * { opacity: 1; transform: translateY(0); }

.interior-rompecabezas { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.marco-rompecabezas {
  width: min(90vw, 480px);
  margin-top: 10px;
  padding: 8px;
  border-radius: 18px;
  background: rgba(255,255,255,.62);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.rompecabezas {
  display: grid;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 12px;
}
.pieza-rompecabezas {
  position: relative;
  min-width: 0;
  min-height: 0;
  border: 0;
  border-radius: 6px;
  background-color: #e9c7c5;
  background-repeat: no-repeat;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  transition: transform 130ms ease, outline-color 150ms ease, filter 150ms ease, box-shadow 150ms ease;
}
.pieza-rompecabezas.arrastrando {
  cursor: grabbing;
  opacity: .88;
  box-shadow: 0 12px 24px rgba(90, 52, 40, .26);
  transition: none;
}
.pieza-rompecabezas:hover { filter: brightness(1.035); }
.pieza-rompecabezas:active { transform: scale(.96); }
.pieza-rompecabezas.seleccionada { outline: 3px solid var(--rose); outline-offset: -3px; }
.pieza-rompecabezas.correcta:not(.seleccionada) { outline: 2px solid rgba(255, 92, 138, .32); outline-offset: -2px; }
.rompecabezas.completado .pieza-rompecabezas { cursor: default; outline: 0; }
.estado-rompecabezas {
  min-height: 1.5rem;
  margin: 0;
  color: var(--rose-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.15rem;
}
.estado-rompecabezas.resuelto { animation: pulso 1.4s ease-in-out infinite; }

.papel-carta {
  position: relative;
  width: min(100%, 720px);
  padding: clamp(38px, 7vw, 58px);
  border-radius: 3px;
  background:
    repeating-linear-gradient(0deg, rgba(200,150,130,.06) 0, rgba(200,150,130,.06) 1px, transparent 1px, transparent 32px),
    linear-gradient(180deg, var(--paper), var(--paper-deep));
  box-shadow: 0 30px 60px -20px rgba(180,100,120,.35), inset 0 0 60px rgba(200,150,130,.15);
}
.carta-amor {
  margin: 0;
  color: var(--brown-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.05rem, 2.5vw, 1.25rem);
  line-height: 1.75;
  text-align: left;
  white-space: pre-wrap;
}
.palabra-carta-amor {
  opacity: 0;
  transition: opacity 500ms ease;
}
.palabra-carta-amor.visible { opacity: 1; }

.contenido-lista { display: flex; flex-direction: column; gap: 32px; }
.cuadricula-lista {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}
.tarjeta-spotify {
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border-radius: 12px;
  background: rgba(255,255,255,.5);
  box-shadow: 0 12px 28px rgba(180,100,120,.15);
}
.tarjeta-spotify iframe { display: block; width: 100%; height: 152px; border: 0; }
.enlace-alternativo-spotify { display: block; padding: 12px; color: var(--rose-dark); }

.seccion-contador { display: flex; flex-direction: column; align-items: center; gap: 34px; }
.seccion-contador-reloj { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
.reloj-amor { display: flex; flex-direction: column; align-items: center; }
.reloj-amor strong {
  min-width: clamp(80px, 18vw, 120px);
  padding: 8px 14px;
  border-radius: 13px;
  background: rgba(255,255,255,.62);
  color: var(--rose-dark);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(2.3rem, 7vw, 4rem);
  line-height: 1.12;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 8px 20px rgba(200,120,140,.2);
  backdrop-filter: blur(8px);
}
.reloj-amor span {
  margin-top: 8px;
  color: var(--brown);
  font-size: .75rem;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.mensaje-reloj {
  max-width: 620px;
  margin: 0;
  color: var(--brown-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.05rem, 3vw, 1.3rem);
  font-style: italic;
  line-height: 1.6;
}
.boton-volver {
  margin-top: 10px;
  padding: 12px 32px;
  border: 0;
  border-radius: 999px;
  background: var(--rose);
  color: white;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(255,92,138,.4);
  transition: transform 140ms ease, background 140ms ease;
}
.boton-volver:hover { background: #ff4478; }
.boton-volver:active { transform: scale(.96); }

@keyframes sacudir {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}
@keyframes pulso {
  0%, 100% { opacity: .65; }
  50% { opacity: 1; }
}
@keyframes petal-fall {
  from { transform: translate3d(0, -5vh, 0) rotate(0deg); }
  to { transform: translate3d(var(--drift), 120vh, 0) rotate(var(--spin)); }
}
@keyframes burst-fall {
  0% { transform: translate3d(var(--start-x), -25vh, 0) rotate(0); opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translate3d(var(--end-x), 125vh, 0) rotate(var(--spin)); opacity: 0; }
}

@media (max-width: 680px) {
  .cuadricula-lista { grid-template-columns: 1fr; }
  .seccion { padding-inline: 18px; }
  .papel-carta { padding-inline: 28px; }
}

@media (max-width: 360px) {
  .teclado { grid-template-columns: repeat(3, 58px); gap: 10px; }
  .boton-teclado, .espacio-teclado { width: 58px; height: 58px; }
  .corazon-pixel { transform: scale(.9); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .palabra-carta-amor { opacity: 1; }
}