:root {
  --background-cream: #fff8f5;
  --soft-pink: #f8d7df;
  --blush-pink: #efb6c4;
  --rose: #d96b86;
  --deep-rose: #9f3d59;
  --burgundy: #67283d;
  --white: #ffffff;
  --text-dark: #3d2630;
  --text-soft: #76535f;
  --gold: #c99a5b;
  --shadow: 0 18px 50px rgba(103, 40, 61, 0.16);
  --soft-shadow: 0 10px 28px rgba(103, 40, 61, 0.12);
  --radius: 20px;
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 0;
  overflow-x: hidden;
  color: var(--text-dark);
  background:
    radial-gradient(circle at top left, rgba(248, 215, 223, 0.9), transparent 30rem),
    linear-gradient(180deg, var(--background-cream), #fff1f5 48%, var(--background-cream));
  font-family: var(--sans);
  line-height: 1.6;
}

body.locked {
  overflow: hidden;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

img,
iframe {
  max-width: 100%;
}

.hidden {
  display: none !important;
}

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

.skip-link {
  position: fixed;
  left: 1rem;
  top: 1rem;
  z-index: 50;
  transform: translateY(-150%);
  padding: 0.75rem 1rem;
  border-radius: 999px;
  background: var(--burgundy);
  color: var(--white);
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 3px solid var(--deep-rose);
  outline-offset: 4px;
}

.passcode-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  min-height: 100svh;
  overflow: auto;
  padding: max(0.75rem, env(safe-area-inset-top)) 1rem max(0.75rem, env(safe-area-inset-bottom));
  color: var(--white);
  transition: opacity 0.55s ease, visibility 0.55s ease;
  --key-size: clamp(3.45rem, min(14vw, 9.5svh), 4.35rem);
  --key-gap: clamp(0.45rem, min(2vw, 1.5svh), 0.75rem);
}

.passcode-screen.is-unlocking {
  opacity: 0;
  visibility: hidden;
}

.passcode-bg {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(103, 40, 61, 0.18), rgba(103, 40, 61, 0.34)),
    radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.45), transparent 14rem),
    radial-gradient(circle at 85% 25%, rgba(239, 182, 196, 0.8), transparent 18rem),
    linear-gradient(145deg, #f8d7df, #d96b86 55%, #67283d);
}

.passcode-bg::before,
.passcode-bg::after {
  content: "♡";
  position: absolute;
  font-size: clamp(8rem, 28vw, 22rem);
  opacity: 0.13;
}

.passcode-bg::before {
  left: -2rem;
  top: 9%;
}

.passcode-bg::after {
  right: -2rem;
  bottom: 5%;
}

.passcode-panel {
  position: relative;
  width: min(100%, 24rem);
  text-align: center;
}

.lock-time {
  font-size: clamp(2.85rem, min(16vw, 12svh), 6.4rem);
  font-weight: 200;
  line-height: 1;
  letter-spacing: 0;
}

.heart-lock {
  width: 3.25rem;
  height: 3.25rem;
  display: grid;
  place-items: center;
  margin: clamp(0.65rem, 2svh, 1.25rem) auto 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  font-size: 1.7rem;
  backdrop-filter: blur(10px);
}

.heart-lock.unlocked {
  animation: heart-pop 0.55s ease both;
}

.passcode-panel h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.45rem, min(7vw, 5svh), 2.55rem);
  font-weight: 500;
}

.passcode-subtitle,
.passcode-status {
  min-height: 1.6rem;
  margin: 0.25rem 0 clamp(0.55rem, 1.8svh, 1rem);
  color: rgba(255, 255, 255, 0.9);
}

.passcode-dots {
  display: flex;
  justify-content: center;
  gap: clamp(0.38rem, 2vw, 0.7rem);
  margin: clamp(0.55rem, 1.8svh, 1rem) 0 clamp(0.7rem, 2svh, 1.25rem);
}

.passcode-dot {
  width: 0.82rem;
  height: 0.82rem;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  background: transparent;
}

.passcode-dot.filled {
  background: var(--white);
}

.passcode-dots.shake {
  animation: shake 0.38s ease;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, var(--key-size));
  justify-content: center;
  gap: var(--key-gap);
  max-width: 100%;
  margin: 0 auto;
}

.key-button,
.key-spacer {
  width: var(--key-size);
  min-height: var(--key-size);
}

.key-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 50%;
  color: var(--white);
  background: rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  cursor: pointer;
  backdrop-filter: blur(14px);
}

.key-number {
  font-size: 1.45rem;
  line-height: 1;
}

.key-letters {
  min-height: 0.8rem;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
}

.hint-button {
  min-height: 2.8rem;
  margin-top: clamp(0.6rem, 1.8svh, 1rem);
  border: 0;
  border-radius: 999px;
  color: var(--white);
  background: rgba(255, 255, 255, 0.16);
  padding: 0.65rem 1.2rem;
  cursor: pointer;
}

.site-shell {
  overflow: hidden;
}

.section,
.hero-section {
  position: relative;
  padding: clamp(4.5rem, 11vw, 8rem) 1rem;
}

.hero-section {
  min-height: 100svh;
  display: grid;
  align-items: center;
}

.section-inner {
  width: min(100%, 86rem);
  margin: 0 auto;
}

.hero-inner {
  width: min(100%, 62rem);
}

.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--deep-rose);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.25rem, 10vw, 5.5rem);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: 0;
  color: var(--burgundy);
}

h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.5rem;
  color: var(--burgundy);
}

.hero-copy,
.section-heading p,
.final-message {
  color: var(--text-soft);
  font-size: clamp(1rem, 3vw, 1.22rem);
}

.primary-button,
.secondary-button,
.small-button,
.text-button {
  min-height: 2.9rem;
  border-radius: 999px;
  border: 0;
  padding: 0.85rem 1.2rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.primary-button {
  color: var(--white);
  background: linear-gradient(135deg, var(--deep-rose), var(--rose));
  box-shadow: var(--soft-shadow);
}

.secondary-button,
.small-button {
  color: var(--burgundy);
  background: var(--white);
  border: 1px solid rgba(159, 61, 89, 0.18);
  box-shadow: 0 7px 18px rgba(103, 40, 61, 0.08);
}

.text-button {
  color: var(--deep-rose);
  background: transparent;
}

.primary-button:hover,
.secondary-button:hover,
.small-button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.progress-nav {
  position: sticky;
  top: 0.7rem;
  z-index: 30;
  display: flex;
  gap: 0.35rem;
  width: min(calc(100% - 1rem), 58rem);
  margin: 0.7rem auto -3.5rem;
  padding: 0.35rem;
  overflow-x: auto;
  border: 1px solid rgba(159, 61, 89, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(16px);
}

.progress-nav a {
  flex: 1 0 auto;
  padding: 0.58rem 0.72rem;
  border-radius: 999px;
  color: var(--text-soft);
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.progress-nav a.is-active {
  color: var(--white);
  background: var(--deep-rose);
}

.progress-nav a.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.puzzle-layout {
  display: grid;
  gap: 1.2rem;
  align-items: start;
}

.puzzle-card,
.letter-lock-card,
.song-card,
.timer-card {
  border: 1px solid rgba(159, 61, 89, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: var(--shadow);
}

.puzzle-card {
  padding: clamp(0.75rem, 3vw, 1.25rem);
}

.puzzle-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.9rem;
}

.move-counter {
  min-height: 2.5rem;
  display: inline-flex;
  align-items: center;
  margin-right: auto;
  color: var(--burgundy);
  font-weight: 900;
}

.puzzle-stage {
  position: relative;
}

.puzzle-board,
.puzzle-preview {
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 14px;
}

.puzzle-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--soft-pink);
  border: 1px solid rgba(103, 40, 61, 0.16);
}

.tile {
  position: relative;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.58);
  background-repeat: no-repeat;
  background-size: 300% 300%;
  cursor: pointer;
}

.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 1px rgba(103, 40, 61, 0.05);
}

.tile.empty {
  background: rgba(255, 255, 255, 0.45);
  cursor: default;
}

.puzzle-board.is-complete .tile.empty {
  background-repeat: no-repeat;
  background-size: 300% 300%;
}

.puzzle-preview {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: start center;
  padding-top: 1rem;
  background-position: center;
  background-size: cover;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.puzzle-preview span {
  border-radius: 999px;
  background: rgba(103, 40, 61, 0.82);
  color: var(--white);
  padding: 0.5rem 0.9rem;
  font-weight: 900;
}

.puzzle-preview.show {
  opacity: 1;
}

.completion-status {
  min-height: 1.8rem;
  color: var(--deep-rose);
  font-weight: 800;
}

.letter-lock-card {
  padding: 1.25rem;
}

.lock-symbol {
  width: 3rem;
  height: 3rem;
  display: grid;
  place-items: center;
  margin-bottom: 0.75rem;
  border-radius: 50%;
  background: var(--soft-pink);
}

.letter-inner {
  display: grid;
  justify-items: center;
  gap: 1.25rem;
}

.envelope-wrap {
  position: relative;
  width: min(100%, 58rem);
  min-height: 23rem;
  display: grid;
  place-items: end center;
  transition: filter 0.3s ease, opacity 0.3s ease;
}

.letter-section.is-locked .envelope-wrap {
  filter: blur(1.5px);
  opacity: 0.72;
}

.envelope {
  position: absolute;
  bottom: 0;
  width: min(100%, 36rem);
  aspect-ratio: 1.65;
}

.pocket {
  position: absolute;
  inset: 30% 0 0;
  border-radius: 0 0 18px 18px;
  background: linear-gradient(135deg, var(--blush-pink), var(--rose));
  box-shadow: var(--shadow);
}

.flap {
  position: absolute;
  left: 0;
  right: 0;
  top: 8%;
  height: 52%;
  clip-path: polygon(0 0, 50% 86%, 100% 0);
  background: #f3aabc;
  transform-origin: top;
  transition: transform 0.55s ease;
  z-index: 3;
}

.paper-shadow {
  position: absolute;
  left: 7%;
  right: 7%;
  bottom: 13%;
  height: 32%;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.4);
}

.letter-paper {
  position: relative;
  z-index: 2;
  width: min(100%, 54rem);
  max-height: 0;
  overflow: hidden;
  border-radius: 18px;
  background: var(--white);
  box-shadow: var(--shadow);
  transform: translateY(7rem);
  opacity: 0;
  transition: max-height 0.65s ease, transform 0.65s ease, opacity 0.35s ease, padding 0.35s ease;
}

.letter-section.is-open .flap {
  transform: rotateX(180deg);
}

.letter-section.is-open .letter-paper {
  z-index: 5;
  max-height: 90rem;
  padding: clamp(1.25rem, 4vw, 2.2rem);
  transform: translateY(-1rem);
  opacity: 1;
}

.letter-paper h2 {
  font-size: clamp(2rem, 8vw, 3.3rem);
}

.letter-body p {
  margin: 1rem 0;
  color: var(--text-dark);
}

.letter-signature,
.final-signature {
  white-space: pre-line;
  color: var(--deep-rose);
  font-family: var(--serif);
  font-size: 1.25rem;
}

.song-grid,
.memory-grid,
.timer-grid {
  display: grid;
  gap: 1rem;
}

.song-card {
  padding: 1rem;
}

.spotify-placeholder {
  display: grid;
  min-height: 9.5rem;
  place-items: center;
  border: 1px dashed rgba(159, 61, 89, 0.38);
  border-radius: 14px;
  background: rgba(248, 215, 223, 0.32);
  color: var(--deep-rose);
  font-weight: 900;
  text-align: center;
}

.song-card iframe {
  display: block;
  width: 100%;
  min-height: 152px;
  border: 0;
  border-radius: 12px;
}

.song-card p {
  margin-bottom: 0;
  color: var(--text-soft);
}

.memory-grid {
  position: relative;
  display: block;
  min-height: clamp(28rem, 62vw, 42rem);
  margin-top: 1.5rem;
  overflow: hidden;
  perspective: 90rem;
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
}

.memory-grid.is-dragging {
  cursor: grabbing;
}

.memory-grid.is-dragging .memory-card {
  transition-duration: 0s;
}

.memory-card {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(72vw, 21rem);
  border: 0;
  border-radius: 10px;
  background: var(--white);
  box-shadow: var(--shadow);
  padding: 0.75rem 0.75rem 1.1rem;
  color: inherit;
  text-align: left;
  transform-origin: center;
  transition: transform 0.55s ease, opacity 0.55s ease;
  will-change: transform, opacity;
}

.memory-card img {
  display: block;
  width: 100%;
  height: auto;
  max-height: clamp(17rem, 48vw, 29rem);
  object-fit: contain;
  border-radius: 6px;
  background: var(--soft-pink);
}

.memory-meta {
  margin: 0.85rem 0 0.35rem;
  color: var(--deep-rose);
  font-size: 0.86rem;
  font-weight: 900;
}

.memory-card p:last-child {
  margin: 0;
  color: var(--text-soft);
}

.timer-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.timer-card {
  padding: 1rem;
  text-align: center;
}

.timer-value {
  display: block;
  color: var(--burgundy);
  font-family: var(--serif);
  font-size: clamp(2rem, 9vw, 3.7rem);
  line-height: 1;
}

.timer-label {
  color: var(--text-soft);
  font-weight: 900;
}

.final-section {
  text-align: center;
}

.final-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.7rem;
  margin-top: 1.5rem;
}

.floating-hearts {
  position: fixed;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}

.float-heart,
.burst-heart,
.confetti-heart,
.sparkle {
  position: fixed;
  pointer-events: none;
  color: rgba(217, 107, 134, 0.58);
}

.float-heart {
  animation: float-up 12s linear infinite;
}

.burst-heart,
.confetti-heart {
  z-index: 120;
  animation: burst 1.1s ease-out forwards;
}

.sparkle {
  z-index: 4;
  animation: sparkle 1.6s ease-out forwards;
}

.reveal {
  opacity: 0;
  transform: translateY(1rem);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-0.55rem); }
  50% { transform: translateX(0.55rem); }
  75% { transform: translateX(-0.35rem); }
}

@keyframes heart-pop {
  45% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

@keyframes float-up {
  from { transform: translateY(105vh) rotate(0deg); opacity: 0; }
  10%, 80% { opacity: 0.75; }
  to { transform: translateY(-10vh) rotate(18deg); opacity: 0; }
}

@keyframes burst {
  to {
    transform: translate(var(--dx), var(--dy)) scale(0.7) rotate(24deg);
    opacity: 0;
  }
}

@keyframes sparkle {
  from { opacity: 0; transform: scale(0.5); }
  45% { opacity: 0.9; }
  to { opacity: 0; transform: scale(1.5); }
}

@media (min-width: 48rem) {
  .puzzle-layout {
    grid-template-columns: minmax(0, 1.65fr) minmax(18rem, 0.7fr);
    gap: clamp(1.5rem, 3vw, 2.5rem);
  }

  .song-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .timer-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (min-width: 72rem) {
  .section,
  .hero-section {
    padding-inline: 2.5rem;
  }

  .song-grid {
    grid-template-columns: repeat(3, minmax(18rem, 1fr));
  }

  .memory-card {
    width: min(30vw, 24rem);
  }
}

@media (max-width: 26rem) {
  .keypad {
    --key-size: clamp(3.35rem, min(25vw, 9.2svh), 3.9rem);
    --key-gap: 0.55rem;
  }

  .progress-nav a {
    font-size: 0.75rem;
    padding-inline: 0.55rem;
  }

  .memory-card {
    width: min(82vw, 19rem);
  }
}

@media (max-height: 42rem) {
  .passcode-screen {
    align-items: start;
    --key-size: clamp(3.1rem, 8.3svh, 3.75rem);
    --key-gap: 0.42rem;
  }

  .heart-lock {
    width: 2.75rem;
    height: 2.75rem;
    font-size: 1.45rem;
  }

  .passcode-subtitle {
    margin-bottom: 0.35rem;
  }

  .key-letters {
    font-size: 0.56rem;
  }

  .hint-button {
    min-height: 2.45rem;
    padding-block: 0.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  .floating-hearts {
    display: none;
  }

  .memory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
    min-height: 0;
    overflow: visible;
  }

  .memory-card {
    position: static;
    width: 100%;
    animation: none;
    transform: none;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}
