:root {
  --ink: #6b2345;
  --ink-soft: #a0577a;
  --accent: #e8467c;
  --accent-soft: #ff8fb4;
  --card: rgba(255, 255, 255, 0.82);
  --cell: #ffe4ee;
  --shadow: 0 10px 30px rgba(214, 51, 108, 0.18);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Mali', system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, #ffe0ec 0%, #ffc2d6 45%, #f7b2cf 75%, #ffd6e6 100%) fixed;
}

.page {
  width: min(100% - 32px, 640px);
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 0 max(88px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.title {
  margin: 8px 0 0;
  font-family: 'Dancing Script', cursive;
  font-size: clamp(2.1rem, 8.6vw, 3.6rem);
  text-align: center;
  text-wrap: balance;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.subtitle {
  margin: 0;
  color: var(--ink-soft);
  text-align: center;
}

.card {
  width: 100%;
  background: var(--card);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.card {
  padding: 24px 18px;
  text-align: center;
}

.couple {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 4vw, 28px);
}

.person {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.avatar {
  width: clamp(92px, 28vw, 136px);
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
  border: 4px solid #fff;
  box-shadow: var(--shadow);
  background: var(--cell);
}

.name {
  font-weight: 600;
}

.heart {
  font-size: clamp(2rem, 9vw, 3rem);
  color: var(--accent);
  animation: beat 1.2s ease-in-out infinite;
}

@keyframes beat {
  0%, 100% { transform: scale(0.92); }
  40% { transform: scale(1.12); }
  60% { transform: scale(0.98); }
}

.counter {
  margin-top: 22px;
}

.total {
  margin: 0;
  font-size: clamp(2rem, 10vw, 3.4rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  overflow-wrap: anywhere;
}

.total-label {
  margin: 2px 0 0;
  color: var(--ink-soft);
}

.breakdown {
  list-style: none;
  margin: 22px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.breakdown li {
  padding: 12px 4px;
  border-radius: 18px;
  background: var(--cell);
  display: flex;
  flex-direction: column;
  box-shadow: inset 0 0 0 1px rgba(232, 70, 124, 0.12);
}

.unit-value {
  font-size: 1.6rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

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

@media (min-width: 560px) {
  .breakdown {
    grid-template-columns: repeat(6, 1fr);
  }
}

.since {
  margin: 20px 0 0;
  color: var(--ink-soft);
}

.closing {
  margin: 14px 0 0;
  font-family: 'Dancing Script', cursive;
  font-size: 1.6rem;
  color: var(--accent);
}




.start {
  font: inherit;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-soft), var(--accent));
}





.intro {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 214, 230, 0.75);
  backdrop-filter: blur(10px);
  transition: opacity 0.5s ease;
}

.intro.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.start {
  padding: 16px 30px;
  font-size: 1.2rem;
  box-shadow: var(--shadow);
  animation: beat 1.6s ease-in-out infinite;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

/* Floating hearts behind everything. */
.hearts {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.hearts span {
  position: absolute;
  bottom: -40px;
  color: var(--accent-soft);
  opacity: 0;
  animation: rise linear infinite;
}

@keyframes rise {
  0% { transform: translateY(0) translateX(0) rotate(-10deg); opacity: 0; }
  10% { opacity: 0.7; }
  50% { transform: translateY(-55vh) translateX(24px) rotate(10deg); }
  90% { opacity: 0.5; }
  100% { transform: translateY(-110vh) translateX(-12px) rotate(-6deg); opacity: 0; }
}

/* Word-synced lyrics: words rise in, fill with colour as they are sung,
   a heart hops along, and the finished line melts into hearts. */
.lyrics {
  position: relative;
  width: 100%;
  /* Fixed height, room for three wrapped rows, so a longer line never moves the counter. */
  height: 10.5rem;
  margin-top: 6px;
  display: grid;
  place-items: center;
  text-align: center;
  padding-top: 1.2rem;
}

.lyric {
  grid-area: 1 / 1;
  margin: 0;
  padding: 0 8px;
  font-family: 'Dancing Script', cursive;
  font-size: clamp(1.6rem, 6.8vw, 2.3rem);
  font-weight: 700;
  line-height: 1.25;
}

.word {
  display: inline-block;
  white-space: nowrap;
  animation: word-in 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: calc(var(--i) * 45ms);
  transition: filter 0.4s ease, transform 0.3s ease;
}

.syl {
  --p: 0;
  display: inline-block;
  color: transparent;
  background-image: linear-gradient(90deg, var(--accent) calc(var(--p) * 100%), rgba(160, 87, 122, 0.35) calc(var(--p) * 100%));
  -webkit-background-clip: text;
  background-clip: text;
}

.syl.is-sung {
  animation: word-pop 0.35s ease-out;
}

.word.is-love .syl {
  background-image: linear-gradient(90deg, #ff2e74 calc(var(--p) * 100%), rgba(160, 87, 122, 0.35) calc(var(--p) * 100%));
}

.word.is-sung {
  filter: drop-shadow(0 0 6px rgba(255, 143, 180, 0.85)) drop-shadow(0 0 14px rgba(255, 255, 255, 0.9));
  animation: word-in 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both, word-pop 0.35s ease-out;
  animation-delay: calc(var(--i) * 45ms), 0s;
}

.word.is-love.is-sung {
  animation: word-in 0.7s both, heartbeat 1.1s ease-in-out infinite;
  animation-delay: calc(var(--i) * 45ms), 0s;
}

.lyric.is-leaving {
  animation: line-melt 1.2s ease-in both;
}

.hopper {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  color: #ff2e74;
  font-size: 1.1rem;
  opacity: 0;
  pointer-events: none;
  transform: translate(calc(var(--x, 0px) - 50%), calc(var(--y, 0px) - 100% - 8px));
  transition: transform 0.22s cubic-bezier(0.3, 0.7, 0.4, 1), opacity 0.3s ease;
  filter: drop-shadow(0 2px 4px rgba(214, 51, 108, 0.4));
}

.hopper.is-on {
  opacity: 1;
}

.hopper.is-hopping {
  animation: hop 0.32s ease-out;
}

.particle {
  position: absolute;
  z-index: 1;
  color: #ff5c8d;
  font-size: 0.9rem;
  pointer-events: none;
  animation: float-away 1.4s ease-out forwards;
}

.particle.is-pop {
  color: #ff2e74;
  animation-duration: 1s;
}

@keyframes word-in {
  from { opacity: 0; transform: translateY(22px) scale(0.9); filter: blur(6px); }
  to { opacity: 1; transform: none; filter: none; }
}

@keyframes word-pop {
  40% { transform: translateY(-4px) scale(1.12); }
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.18); }
  30% { transform: scale(1.02); }
  45% { transform: scale(1.12); }
}

@keyframes line-melt {
  from { opacity: 1; filter: blur(0); transform: none; letter-spacing: 0; }
  to { opacity: 0; filter: blur(8px); transform: translateY(-30px) scale(1.06); letter-spacing: 0.15em; }
}

@keyframes hop {
  0% { margin-top: 0; }
  45% { margin-top: -14px; }
  100% { margin-top: 0; }
}

@keyframes float-away {
  from { opacity: 1; transform: translate(-50%, -50%) scale(var(--s)) rotate(0); }
  to { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(calc(var(--s) * 0.4)) rotate(var(--r)); }
}

.interlude {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.interlude > * {
  opacity: 0;
  transition: opacity 0.6s ease;
}

.interlude[data-mode='title'] .interlude-title,
.interlude[data-mode='dots'] > * {
  opacity: 1;
}

/* In a break the hearts lead and the title sits small under them. */
.interlude[data-mode='dots'] .interlude-title {
  font-size: 1.15rem;
  opacity: 0.75;
}

.interlude[data-mode='title'] .interlude-dots {
  display: none;
}

.interlude-title {
  font-family: 'Dancing Script', cursive;
  font-size: 1.7rem;
  color: var(--accent-soft);
  transition: opacity 0.6s ease, font-size 0.6s ease;
}

.interlude-dots {
  --p: 0;
  display: flex;
  gap: 18px;
}

.interlude-dots i {
  font-style: normal;
  font-size: 2rem;
  color: var(--accent);
  animation: breathe 2.4s ease-in-out infinite;
}

/* Each heart lights up for a third of the break. */
.interlude-dots i:nth-child(1) { opacity: calc(0.25 + min(1, var(--p) * 3) * 0.75); }
.interlude-dots i:nth-child(2) { opacity: calc(0.25 + clamp(0, var(--p) * 3 - 1, 1) * 0.75); animation-delay: 0.2s; }
.interlude-dots i:nth-child(3) { opacity: calc(0.25 + clamp(0, var(--p) * 3 - 2, 1) * 0.75); animation-delay: 0.4s; }

@keyframes breathe {
  0%, 100% { transform: scale(0.85); }
  50% { transform: scale(1.15); }
}

.lyrics-credit {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.75rem;
  text-align: center;
}

/* The YouTube player plays the sound out of sight. */
.player-offstage {
  position: fixed;
  right: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

/* A small spinning record shows that the song is playing. */
.disc {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 5;
  width: 58px;
  height: 58px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
}

.disc-vinyl {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle, transparent 0 30%, rgba(255, 255, 255, 0.08) 31% 32%, transparent 33% 45%, rgba(255, 255, 255, 0.08) 46% 47%, transparent 48% 60%, rgba(255, 255, 255, 0.08) 61% 62%, transparent 63%),
    conic-gradient(from 20deg, #2a1420, #4a2236 25%, #2a1420 50%, #4a2236 75%, #2a1420);
  box-shadow: var(--shadow), 0 0 0 3px #fff;
  display: grid;
  place-items: center;
  animation: spin 4s linear infinite;
  animation-play-state: paused;
}

.disc-label {
  width: 40%;
  height: 40%;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 0.75rem;
  background: linear-gradient(135deg, var(--accent-soft), var(--accent));
}

.disc.is-playing .disc-vinyl {
  animation-play-state: running;
}

.disc.is-failed .disc-vinyl {
  filter: grayscale(0.6);
}

.disc-note {
  position: absolute;
  left: 10%;
  top: 0;
  color: var(--accent);
  font-size: 1rem;
  opacity: 0;
  pointer-events: none;
}

.disc.is-playing .disc-note {
  animation: note-rise 2.4s ease-out infinite;
}

.disc.is-playing .disc-note-2 {
  left: 55%;
  animation-delay: 1.2s;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes note-rise {
  0% { opacity: 0; transform: translateY(0) rotate(-10deg); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-38px) translateX(-10px) rotate(12deg); }
}

@media (prefers-reduced-motion: reduce) {
  .heart,
  .start,
  .word,
  .word.is-sung,
  .syl.is-sung,
  .word.is-love.is-sung,
  .lyric.is-leaving,
  .hopper.is-hopping,
  .disc.is-playing .disc-note,
  .interlude-dots i {
    animation: none;
  }

  .lyric.is-leaving,
  .hearts,
  .hopper,
  .disc-note {
    display: none;
  }

  /* The record turns slowly instead of spinning. */
  .disc-vinyl {
    animation-duration: 20s;
  }

  .intro {
    transition: none;
  }
}
