:root {
  --bg: #f7eef2;
  --surface: #fff7f9;
  --text: #3f2f2b;
  --muted: #84686f;
  --accent: #e2a6b7;
  --text-box: #e9c2ce;
  --text-box-border: #cf9aaa;
  --maxw: 760px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: radial-gradient(circle at 20% 10%, #fffdfd 0%, var(--bg) 42%, #f4e1ea 100%);
  color: var(--text);
  font-family: 'Trebuchet MS', 'Segoe UI', Tahoma, sans-serif;
  line-height: 1.6;
}

body.is-page-transitioning {
  overflow: hidden;
}

header {
  width: min(100% - 2rem, var(--maxw));
  margin-inline: auto;
  text-align: center;
  min-height: 80vh;
  padding: 1.5rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

main {
  width: min(100% - 2rem, var(--maxw));
  margin-inline: auto;
}

section {
  min-height: 80vh;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(80, 58, 50, 0.12);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

section:not(#intro) {
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

#intro {
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

h1 {
  line-height: 1.2;
  margin: 0 0 0.35rem 0;
  font-size: clamp(1.5rem, 4vw, 2rem);
  text-align: center;
}

h2, h3 {
  line-height: 1.2;
  margin-bottom: 0.25rem;
  font-size: clamp(1.1rem, 3vw, 1.3rem);
  text-align: center;
}

p {
  color: var(--muted);
  font-size: clamp(0.8rem, 1.8vw, 0.9rem);
  max-width: 60ch;
  margin-inline: auto;
}

header h1,
section h2,
section > p,
.story-kicker,
.memory-item h3,
.memory-item p,
#secret-feedback,
#secret-content p,
#final-message p {
  background: color-mix(in srgb, var(--text-box) 72%, #ffffff 28%);
  border: 1px solid color-mix(in srgb, var(--text-box-border) 70%, #ffffff 30%);
  border-radius: 12px;
  box-shadow: 0 8px 16px rgba(112, 74, 61, 0.1);
  padding: 0.35rem 0.6rem;
}

section h2,
header h1,
.memory-item h3,
.story-kicker {
  color: #3b2722;
}

.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.45s ease-out, transform 0.45s ease-out;
}

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

#inside-joke {
  overflow: hidden;
}

.vault-entry {
  width: 100%;
  transition: transform 520ms ease, opacity 520ms ease;
  will-change: transform, opacity;
}

#inside-joke.vault-unlocked .vault-entry {
  transform: translateY(-22px);
  opacity: 0.28;
}

#secret-content {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 900ms ease, transform 900ms ease;
  will-change: opacity, transform;
}

#secret-content.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.section-transition-veil {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 20% 10%, #fffdfb 0%, var(--bg) 45%, #f2ebe5 100%);
  transition: opacity 180ms ease;
}

.section-transition-veil.is-visible {
  opacity: 1;
}

.page-transition-floating {
  position: fixed !important;
  z-index: 50;
  width: var(--page-width, 100%);
  height: var(--page-height, 100vh);
  left: var(--page-left, 0);
  top: var(--page-top, 0);
  margin: 0 !important;
}

.page-transition-floating.page-leave-up {
  animation: leaveUp 420ms ease-out both;
}

.page-transition-floating.page-leave-down {
  animation: leaveDown 420ms ease-out both;
}

.page-transition-hidden {
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.page-transition-enter-up {
  animation: enterUp 420ms ease-out both;
}

.page-transition-enter-down {
  animation: enterDown 420ms ease-out both;
}

@keyframes leaveUp {
  0% {
    opacity: 1;
    transform: translateY(0);
  }

  100% {
    opacity: 0;
    transform: translateY(-20px) scale(0.985);
  }
}

@keyframes leaveDown {
  0% {
    opacity: 1;
    transform: translateY(0);
  }

  100% {
    opacity: 0;
    transform: translateY(20px) scale(0.985);
  }
}

@keyframes enterUp {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.99);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes enterDown {
  0% {
    opacity: 0;
    transform: translateY(-18px) scale(0.99);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

form {
  display: grid;
  gap: 0.4rem;
  max-width: 320px;
  width: min(100%, 320px);
  margin-inline: auto;
  margin: 0.5rem auto;
}

label {
  font-weight: 600;
  color: var(--text);
  font-size: 0.85rem;
}

input,
button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid rgba(99, 73, 64, 0.18);
  padding: 0.45rem 0.65rem;
  font-size: 0.85rem;
}

input {
  background: #fff;
  color: var(--text);
}

button {
  background: var(--accent);
  color: #3b2a24;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid #d88f78;
  outline-offset: 2px;
}

.music-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.85rem;
  width: 100%;
  margin-top: 1rem;
}

.track-card {
  min-height: 230px;
  padding: 1rem;
  border: 1px solid rgba(99, 73, 64, 0.16);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(38, 26, 22, 0.52)),
    var(--cover-image) center / cover no-repeat;
  box-shadow: 0 14px 28px rgba(108, 78, 69, 0.18);
  display: flex;
  flex-direction: column;
  justify-content: end;
  align-items: flex-start;
  text-align: left;
  gap: 0.25rem;
  color: #fff;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform 180ms ease, filter 180ms ease, box-shadow 180ms ease;
}

.track-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(27, 17, 15, 0.65));
  pointer-events: none;
}

.track-card > * {
  position: relative;
  z-index: 1;
}

.track-card__title {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.15;
}

.track-card__artist {
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.86);
}

.track-card:hover,
.track-card:focus-visible {
  transform: translateY(-3px) scale(1.01);
  filter: brightness(1.06);
  box-shadow: 0 18px 32px rgba(108, 78, 69, 0.22);
}

.track-card.is-active {
  outline: 2px solid #fff;
  outline-offset: -6px;
}

.music-player-shell {
  width: min(100%, 720px);
  margin-top: 1rem;
  display: grid;
  gap: 0.75rem;
}

.music-now-playing {
  margin: 0;
  font-weight: 700;
}

#countdown {
  gap: 0.6rem;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.2rem 1.25rem !important;
}

.time-story {
  display: grid;
  gap: 0.5rem;
  width: min(100%, 600px);
  margin-inline: auto;
  padding: 0.6rem 0.7rem;
  border: 1px solid rgba(118, 89, 80, 0.14);
  border-radius: 16px;
  background: linear-gradient(180deg, #fffdfb, #fff7f2);
  box-shadow: 0 14px 28px rgba(108, 78, 69, 0.14);
  justify-items: center;
  text-align: center;
}

.story-kicker {
  margin: 0;
  font-size: clamp(0.9rem, 2.2vw, 1.25rem);
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.01em;
  padding: 0.3rem 0.5rem !important;
}

.time-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  width: 100%;
}

.time-unit {
  display: grid;
  place-items: center;
  gap: 0.1rem;
  min-height: 50px;
  padding: 0.55rem 0.45rem;
  border-radius: 14px;
  background: rgba(244, 221, 212, 0.35);
  border: 1px solid rgba(118, 89, 80, 0.14);
  text-align: center;
}

.time-unit strong {
  font-size: clamp(0.9rem, 2.2vw, 1.35rem);
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.time-unit span {
  font-size: 0.6rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.time-story.reveal {
  opacity: 0;
  transform: translateY(18px) scale(0.995);
}

.time-story.reveal.is-visible {
  animation: flyIn 520ms ease-out both;
}

.time-story.reveal:nth-of-type(1).is-visible {
  animation-delay: 40ms;
}

.time-story.reveal:nth-of-type(2).is-visible {
  animation-delay: 120ms;
}

@keyframes flyIn {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.995);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

#memories {
  height: 80vh;
  overflow: hidden;
  padding: 1rem 0 0 0;
  display: flex;
  flex-direction: column;
  overscroll-behavior: contain;
}

#memories h2 {
  padding: 0.75rem 0.75rem 0;
  flex: 0 0 auto;
  margin: 0;
  width: 100%;
  text-align: center;
}

#memories > p {
  padding: 0 0.75rem 0.75rem;
  flex: 0 0 auto;
  margin: 0;
  width: 100%;
  text-align: center;
  font-size: 0.85rem;
}

.memories-list {
  display: flex;
  gap: 0;
  overflow-x: scroll;
  scroll-snap-type: x proximity;
  scroll-behavior: smooth;
  flex: 1;
  width: 100%;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
    padding-right: 0.5rem;
  touch-action: pan-x;
}

.memories-list::-webkit-scrollbar {
  display: none;
}

.memory-item {
  flex-shrink: 0;
  min-width: 100%;
  max-width: none;
  height: 80vh;
  scroll-snap-align: start;
  scroll-snap-stop: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 1.25rem 0.75rem;
  overflow: hidden;
}

.memory-item figure {
  margin: 0.4rem 0;
  text-align: center;
}

.memory-item img {
  width: 100%;
  height: auto;
  max-width: 85%;
  max-height: 45vh;
  object-fit: cover;
  border-radius: 10px;
}

@media (max-width: 360px) {
  section {
    padding: 1.2rem 0.75rem;
  }

  h2, h3 {
    font-size: clamp(1.1rem, 3vw, 1.35rem);
  }

  p {
    font-size: clamp(0.8rem, 1.8vw, 0.9rem);
  }

  form {
    max-width: 280px;
  }

  input,
  button {
    padding: 0.4rem 0.55rem;
    font-size: 0.8rem;
  }
}