:root {
  --glass: rgba(18, 6, 22, 0.42);
  --line: rgba(255, 190, 230, 0.18);
  --text: #fff4fa;
  --soft: #ffe3f2;
  --gap: 14px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #000;
  color: var(--text);
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: 'Quicksand', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

button {
  font: inherit;
  color: inherit;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
  outline: none;
}

/* ───────── black hole & supernova ───────── */
.vignette {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at 50% 52%, rgba(0, 0, 0, 0) 32%, rgba(0, 0, 0, 0.88) 100%);
}

.nova-flash {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    circle at 50% 55%,
    #ffffff 0%,
    #fff2f9 16%,
    rgba(255, 175, 218, 0.9) 38%,
    rgba(255, 95, 172, 0.6) 68%,
    rgba(255, 60, 150, 0.4) 100%
  );
  mix-blend-mode: screen;
}

.flare {
  position: fixed;
  left: 0;
  right: 0;
  top: 50%;
  height: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  mix-blend-mode: screen;
}

.flare::before,
.flare::after {
  content: '';
  position: absolute;
  left: -10%;
  right: -10%;
  border-radius: 50%;
  background: linear-gradient(
    90deg,
    rgba(255, 120, 200, 0),
    rgba(255, 175, 228, 0.85) 30%,
    #ffffff 50%,
    rgba(255, 175, 228, 0.85) 70%,
    rgba(255, 120, 200, 0)
  );
}

.flare::before {
  top: -2px;
  height: 4px;
  box-shadow: 0 0 18px 6px rgba(255, 120, 200, 0.45);
}

.flare::after {
  top: -16px;
  height: 32px;
  opacity: 0.28;
  filter: blur(12px);
}

/* ───────── story text ───────── */
.story {
  position: fixed;
  left: 0;
  right: 0;
  top: calc(env(safe-area-inset-top, 0px) + clamp(26px, 7vh, 84px));
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
}

.story::before {
  content: '';
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  height: 36vh;
  background: radial-gradient(120% 100% at 50% 0%, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0) 70%);
  z-index: -1;
  pointer-events: none;
}

.story-inner {
  position: relative;
  max-width: min(94vw, 980px);
  padding: 0 18px;
  text-align: center;
}

.story-sparkles {
  position: absolute;
  inset: -18% 0 0 0;
  pointer-events: none;
}

.spark {
  position: absolute;
  font-family: 'Segoe UI Symbol', 'Apple Symbols', system-ui, sans-serif;
  font-size: var(--s);
  line-height: 1;
  color: #fff6fb;
  text-shadow: 0 0 6px #ff9ad6, 0 0 14px #ff5fb4;
  opacity: 0;
  transform: scale(0.2);
  animation: twinkle var(--d) ease-in-out var(--delay) infinite;
}

.spark.is-red {
  text-shadow: 0 0 6px #ff7a9a, 0 0 16px #ff2d55;
}

.float-heart {
  position: absolute;
  bottom: 0;
  font-size: var(--s);
  line-height: 1;
  color: #ff6b93;
  text-shadow: 0 0 8px rgba(255, 60, 110, 0.9), 0 0 18px rgba(255, 30, 80, 0.6);
  opacity: 0;
  animation: rise var(--d) ease-out var(--delay) infinite;
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0;
    transform: scale(0.2) rotate(0deg);
  }
  45% {
    opacity: 1;
    transform: scale(1) rotate(35deg);
  }
  60% {
    opacity: 0.9;
    transform: scale(0.85) rotate(45deg);
  }
}

@keyframes rise {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.4);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(var(--x), -90px) scale(1.15);
  }
}

.story-line {
  margin: 0;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: clamp(23px, 1.7vw + 15px, 44px);
  line-height: 1.28;
  letter-spacing: 0.005em;
  color: var(--text);
  text-shadow: 0 0 10px rgba(255, 140, 205, 0.55), 0 0 26px rgba(255, 90, 180, 0.32);
  text-wrap: balance;
}

.story-line .w {
  display: inline-block;
  white-space: nowrap;
}

.story-line .c {
  display: inline-block;
  opacity: 0;
}

.story-line.is-emph {
  font-weight: 600;
  font-size: clamp(26px, 2vw + 17px, 52px);
  color: #ffe9f5;
  text-shadow: 0 0 12px rgba(255, 120, 200, 0.75), 0 0 34px rgba(255, 70, 170, 0.45);
}

.story-line.is-script,
.story-line.is-love {
  font-family: 'Great Vibes', cursive;
  font-style: normal;
  font-weight: 400;
  font-size: clamp(64px, 7vw + 34px, 132px);
  line-height: 1.15;
  letter-spacing: 0;
  padding: 0 0.15em;
}

.story-line.is-script {
  color: #ffeef8;
  text-shadow: 0 0 14px rgba(255, 140, 210, 0.75), 0 0 42px rgba(255, 90, 190, 0.45);
}

.story-line.is-love {
  color: #ffe1ea;
  text-shadow: 0 0 14px rgba(255, 60, 110, 0.85), 0 0 40px rgba(255, 30, 80, 0.6), 0 0 90px rgba(255, 20, 60, 0.35);
}

.story-rule {
  width: min(56vw, 400px);
  height: 1px;
  margin: 14px auto 0;
  background: linear-gradient(90deg, transparent, rgba(255, 175, 225, 0.75), transparent);
  transform: scaleX(0);
}

/* ───────── music player ───────── */
.player {
  position: fixed;
  z-index: 6;
  left: calc(env(safe-area-inset-left, 0px) + var(--gap));
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--gap));
  display: flex;
  align-items: center;
  gap: 11px;
  max-width: calc(100vw - 2 * var(--gap));
  padding: 6px 16px 6px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  backdrop-filter: blur(12px) saturate(140%);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  cursor: pointer;
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity 0.9s ease, transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.player.is-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.player.is-visible:active {
  transform: scale(0.97);
  transition-duration: 0.15s;
}

.disc {
  position: relative;
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1), 0 0 16px rgba(255, 120, 200, 0.35);
}

.vinyl {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
  background: radial-gradient(circle, #2a1830 0 22%, #120a16 23% 100%);
  animation: spin 8s linear infinite;
  animation-play-state: paused;
}

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

.vinyl img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.player.no-cover .vinyl img {
  display: none;
}

.player.no-cover .vinyl {
  background: repeating-radial-gradient(circle, #1b0f20 0 2px, #241429 2px 4px),
    radial-gradient(circle, #ff8fd0 0 30%, transparent 31%);
  background-blend-mode: screen;
}

/* sheen + center hole stay still while the record spins */
.disc::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 50%;
  background: repeating-radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0) 0 2px, rgba(0, 0, 0, 0.07) 2px 3px),
    conic-gradient(
      from 30deg,
      rgba(255, 255, 255, 0.2),
      rgba(255, 255, 255, 0) 25%,
      rgba(255, 255, 255, 0.12) 50%,
      rgba(255, 255, 255, 0) 75%,
      rgba(255, 255, 255, 0.2)
    );
  pointer-events: none;
}

.disc::after {
  content: '';
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  border-radius: 50%;
  background: #0b0710;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  text-align: left;
  line-height: 1.2;
}

.song-title {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.song-artist {
  font-weight: 500;
  font-size: 12px;
  opacity: 0.72;
  white-space: nowrap;
}

.state {
  position: relative;
  flex: none;
  width: 16px;
  height: 16px;
  margin-left: 2px;
}

.eq {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  transition: opacity 0.3s;
}

.eq i {
  display: block;
  width: 3px;
  height: 30%;
  border-radius: 2px;
  background: #ff9fd6;
  animation: eq 0.9s ease-in-out infinite alternate;
  animation-play-state: paused;
}

.eq i:nth-child(2) {
  animation-delay: -0.35s;
  animation-duration: 0.7s;
}

.eq i:nth-child(3) {
  animation-delay: -0.6s;
  animation-duration: 1.1s;
}

.eq i:nth-child(4) {
  animation-delay: -0.2s;
  animation-duration: 0.8s;
}

.player.is-playing .eq i {
  animation-play-state: running;
}

.play {
  position: absolute;
  inset: 0;
  width: 16px;
  height: 16px;
  fill: #ffd2ea;
  opacity: 0;
  transition: opacity 0.3s;
}

.player:not(.is-playing) .eq {
  opacity: 0;
}

.player:not(.is-playing) .play {
  opacity: 1;
}

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

@keyframes eq {
  from {
    height: 18%;
  }
  to {
    height: 100%;
  }
}

/* ───────── small buttons ───────── */
.icon-btn {
  position: fixed;
  z-index: 6;
  top: calc(env(safe-area-inset-top, 0px) + var(--gap));
  right: calc(env(safe-area-inset-right, 0px) + var(--gap));
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s;
}

.icon-btn.is-visible {
  opacity: 0.85;
  pointer-events: auto;
}

.icon-btn svg,
.replay svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--soft);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fs-exit,
.is-fullscreen .fs-enter {
  display: none;
}

.is-fullscreen .fs-exit {
  display: block;
}

.hint {
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 84px);
  transform: translateX(-50%);
  margin: 0;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--soft);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s;
}

.hint.is-visible {
  opacity: 1;
}

.replay {
  position: fixed;
  z-index: 6;
  right: calc(env(safe-area-inset-right, 0px) + var(--gap));
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--gap) + 6px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-weight: 600;
  font-size: 13px;
  color: var(--soft);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s;
}

.replay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* ───────── "presiona el corazón del centro" ───────── */
.prompt {
  position: fixed;
  left: 0;
  right: 0;
  top: calc(env(safe-area-inset-top, 0px) + clamp(26px, 7vh, 84px));
  z-index: 6;
  margin: 0;
  padding: 0 20px;
  text-align: center;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: clamp(22px, 1.5vw + 16px, 34px);
  color: #fff1f8;
  text-shadow: 0 0 12px rgba(255, 120, 200, 0.8), 0 0 30px rgba(255, 80, 170, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.2s ease;
}

.prompt.is-visible {
  opacity: 1;
  animation: prompt-breathe 2.6s ease-in-out infinite;
}

.prompt span {
  color: #ff6b9c;
}

@keyframes prompt-breathe {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.045);
  }
}

.heart-target {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 6;
  width: 120px;
  height: 120px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 120, 190, 0.12), rgba(255, 120, 190, 0) 70%);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease;
}

.heart-target.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.heart-target::before,
.heart-target::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 175, 222, 0.8);
  box-shadow: 0 0 18px rgba(255, 90, 180, 0.6), inset 0 0 18px rgba(255, 90, 180, 0.35);
  animation: target-ring 2.2s ease-out infinite;
}

.heart-target::after {
  animation-delay: 1.1s;
}

@keyframes target-ring {
  0% {
    transform: scale(0.72);
    opacity: 0.95;
  }
  100% {
    transform: scale(1.35);
    opacity: 0;
  }
}

/* ───────── the letter ───────── */
.letter {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + 40px) 14px calc(env(safe-area-inset-bottom, 0px) + 84px);
  pointer-events: none;
}

.letter-paper {
  position: relative;
  width: min(100%, 640px);
  height: min(100%, 800px);
  border-radius: 22px;
  background: radial-gradient(120% 80% at 50% 0%, rgba(70, 16, 56, 0.42), rgba(14, 4, 18, 0.5));
  box-shadow: inset 0 0 70px rgba(255, 120, 190, 0.12);
  opacity: 0;
  transform: scale(0.97);
  transition: opacity 1s ease, transform 1s ease;
}

.letter.is-shown .letter-paper {
  opacity: 1;
  transform: none;
}

.letter.is-active.is-shown .letter-paper {
  pointer-events: auto;
}

.letter-scroll {
  position: absolute;
  inset: 70px 18px 18px;
  padding: 6px 12px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 20px, #000 calc(100% - 26px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 20px, #000 calc(100% - 26px), transparent 100%);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 160, 210, 0.45) transparent;
  user-select: text;
  -webkit-user-select: text;
}

.letter-body p {
  margin: 0 0 1em;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: clamp(17px, 0.8vw + 13.5px, 21px);
  line-height: 1.62;
  color: #fff2f9;
  text-shadow: 0 0 8px rgba(255, 110, 190, 0.5), 0 1px 2px rgba(0, 0, 0, 0.6);
  hyphens: auto;
}

.lw {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.35em);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.letter.is-writing .lw {
  opacity: 1;
  transform: none;
  transition: opacity 0.9s ease var(--d), transform 0.9s ease var(--d);
}

.lw.letter-first {
  font-family: 'Great Vibes', cursive;
  font-style: normal;
  font-size: 1.9em;
  line-height: 0.9;
  color: #ffd9ec;
  text-shadow: 0 0 12px rgba(255, 120, 200, 0.85), 0 0 30px rgba(255, 80, 170, 0.45);
  margin-right: 0.08em;
}

.letter-body .letter-closing {
  margin-top: 0.5em;
  text-align: right;
  font-family: 'Great Vibes', cursive;
  font-style: normal;
  font-size: clamp(30px, 2.5vw + 20px, 46px);
  line-height: 1.2;
  color: #ffd6e6;
  text-shadow: 0 0 14px rgba(255, 60, 120, 0.85), 0 0 34px rgba(255, 40, 100, 0.5);
}

.letter-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 190, 230, 0.35);
  background: rgba(30, 8, 30, 0.6);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.letter-close:hover {
  background: rgba(70, 16, 56, 0.75);
}

.letter-close:active {
  transform: scale(0.92);
}

.letter-close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: #ffe3f2;
  stroke-width: 2.2;
  stroke-linecap: round;
}

@media (max-width: 480px) {
  .letter {
    padding-top: calc(env(safe-area-inset-top, 0px) + 34px);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 78px);
  }
  .letter-scroll {
    inset: 58px 8px 12px;
  }
}

.veil {
  position: fixed;
  inset: 0;
  z-index: 15;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.1s ease;
}

.veil.is-on {
  opacity: 1;
  pointer-events: auto;
}

/* ───────── start screen ───────── */
.start {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
  background: #000;
  cursor: pointer;
  transition: opacity 1.4s ease;
}

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

.start-heart {
  width: 96px;
  height: 96px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  animation: beat 1.3s ease-in-out infinite;
  filter: drop-shadow(0 0 14px rgba(255, 80, 170, 0.75)) drop-shadow(0 0 40px rgba(255, 60, 150, 0.4));
}

.start-heart svg {
  width: 64px;
  height: 58px;
  fill: #ff5fb4;
}

.start.is-loading .start-heart {
  opacity: 0.45;
  pointer-events: none;
}

.start-text {
  margin: 0;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-size: 26px;
  color: #ffe8f4;
  letter-spacing: 0.02em;
}

.start-sub {
  margin: 0;
  font-size: 11.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 220, 240, 0.5);
}

@keyframes beat {
  0%,
  100% {
    transform: scale(1);
  }
  14% {
    transform: scale(1.12);
  }
  28% {
    transform: scale(1);
  }
  42% {
    transform: scale(1.08);
  }
  70% {
    transform: scale(1);
  }
}

.noscript {
  position: fixed;
  inset: auto 0 40% 0;
  z-index: 30;
  text-align: center;
  color: var(--soft);
}

@media (max-width: 480px) {
  :root {
    --gap: 12px;
  }
  .player {
    gap: 9px;
    padding-right: 13px;
  }
  .disc {
    width: 40px;
    height: 40px;
  }
  .song-title {
    font-size: 13px;
  }
  .song-artist {
    font-size: 11px;
  }
  .hint {
    font-size: 12px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 76px);
  }
}

@media (max-width: 420px) {
  .replay span {
    display: none;
  }
  .replay {
    padding: 12px;
  }
}
