:root {
  --black: #000000;
  --pink: #ff4d79;
  --pink-soft: #ff8fab;
  --rose: #ff2d55;
  --crimson: #c8102e;
  --ink: #ffe6ec;
  --muted: rgba(255, 214, 224, 0.68);
  --serif: "Playfair Display", "Times New Roman", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--black);
}

body {
  color: var(--ink);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--black);
}

#gl {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

#gl.dragging {
  cursor: grabbing;
}

/* ------------------------------------------------------------ intro card */

.intro {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background:
    radial-gradient(120% 80% at 20% 0%, rgba(120, 18, 52, 0.55), transparent 60%),
    radial-gradient(90% 70% at 100% 100%, rgba(90, 10, 40, 0.5), transparent 60%),
    rgba(0, 0, 0, 0.45);
  transition: opacity 1.1s ease, visibility 1.1s;
}

.intro.leaving {
  opacity: 0;
  visibility: hidden;
}

.intro-card {
  width: min(88vw, 380px);
  padding: 38px 28px 30px;
  text-align: center;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(48, 10, 22, 0.82), rgba(22, 4, 10, 0.86));
  border: 1px solid rgba(255, 110, 150, 0.16);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.6),
    0 0 60px rgba(255, 45, 85, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  animation: card-in 1.2s cubic-bezier(.2, .8, .2, 1) both;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.97);
  }
}

.intro-card h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(28px, 8vw, 36px);
  line-height: 1.15;
  color: #fff3f6;
  text-shadow: 0 0 22px rgba(255, 80, 120, 0.35);
}

.intro-art {
  display: block;
  width: 132px;
  height: auto;
  margin: 22px auto 14px;
  overflow: visible;
}

.intro-heart {
  transform-origin: 60px 40px;
  animation: art-beat 1.4s ease-in-out infinite;
  filter: drop-shadow(0 0 8px rgba(255, 45, 85, 0.7));
}

@keyframes art-beat {
  0%, 100% { transform: scale(1); }
  12% { transform: scale(1.08); }
  24% { transform: scale(1); }
  36% { transform: scale(1.05); }
}

.intro-sub {
  margin: 0 0 24px;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

.enter {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 12px 44px 12px 26px;
  border: 0;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(90deg, #ff7aa0, #ff3d6e 60%, #ff2d55);
  box-shadow: 0 8px 28px rgba(255, 45, 85, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.enter:hover,
.enter:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 12px 36px rgba(255, 45, 85, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  outline: none;
}

.enter-badge {
  position: absolute;
  right: -10px;
  top: 50%;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-top: -18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.enter-badge svg {
  width: 18px;
  height: 18px;
  fill: var(--rose);
  animation: art-beat 1.4s ease-in-out infinite;
}

/* -------------------------------------------------------- heart bubbles */

/* soft shade behind the bottom caption so it stays readable */
#stage::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 22%;
  z-index: 4;
  pointer-events: none;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
}

#bubbles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.bubble {
  position: absolute;
  left: 0;
  top: 0;
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  pointer-events: auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45), 0 0 18px rgba(255, 60, 100, 0.35);
  opacity: 0;
  transition: opacity 0.6s ease;
  will-change: transform, opacity;
}

.bubble.show {
  opacity: 1;
}

.bubble::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 120, 160, 0.7);
  animation: ripple 2.2s ease-out infinite;
}

.bubble::after {
  content: "";
  position: absolute;
  left: 4px;
  bottom: -5px;
  border: 6px solid transparent;
  border-top-color: #fff;
  border-left-color: #fff;
  transform: rotate(10deg);
  border-radius: 2px;
}

.bubble svg {
  width: 18px;
  height: 18px;
  fill: var(--rose);
}

.bubble:focus-visible {
  outline: 2px solid var(--pink-soft);
  outline-offset: 4px;
}

@keyframes ripple {
  from { transform: scale(0.85); opacity: 0.9; }
  to { transform: scale(1.6); opacity: 0; }
}

/* ------------------------------------------------------------- hint/caption */

.hint {
  position: absolute;
  left: 50%;
  top: calc(var(--safe-t) + 18px);
  z-index: 6;
  margin: 0;
  transform: translateX(-50%);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 200, 214, 0.7);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 1s ease;
  pointer-events: none;
}

.hint.show {
  opacity: 1;
}

.caption {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-b) + 26px);
  z-index: 6;
  width: min(92vw, 900px);
  margin: 0;
  transform: translateX(-50%);
  text-align: center;
  font-size: clamp(14px, 3.4vw, 21px);
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: 0.02em;
  color: #ff3b57;
  text-shadow:
    0 0 4px rgba(255, 40, 80, 0.85),
    0 0 14px rgba(255, 10, 60, 0.45),
    0 0 30px rgba(200, 16, 46, 0.35);
  pointer-events: none;
}

.cursor {
  display: inline-block;
  width: 0.6em;
  height: 1.08em;
  margin-left: 0.14em;
  vertical-align: -0.17em;
  background: #ff4d6a;
  box-shadow: 0 0 6px rgba(255, 40, 80, 0.9), 0 0 16px rgba(255, 0, 60, 0.5);
  opacity: 0;
}

.cursor.on {
  opacity: 1;
}

.cursor.blink {
  animation: blink 1.06s steps(1, end) infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ------------------------------------------------------------------ sound */

.sound {
  position: absolute;
  right: 16px;
  top: calc(var(--safe-t) + 14px);
  z-index: 7;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 120, 160, 0.25);
  background: rgba(30, 6, 14, 0.55);
  display: grid;
  place-items: center;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.sound[hidden] {
  display: none;
}

.sound svg {
  width: 18px;
  height: 18px;
  fill: var(--pink-soft);
}

.sound .off,
.sound.muted .on {
  display: none;
}

.sound.muted .off {
  display: inline;
}

/* ------------------------------------------------------------ memory card */

.modal {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: fade 0.4s ease both;
}

.memory {
  position: relative;
  width: min(90vw, 400px);
  max-height: calc(100% - 32px);
  overflow: auto;
  padding: 14px 14px 22px;
  text-align: center;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(44, 8, 20, 0.95), rgba(18, 3, 8, 0.96));
  border: 1px solid rgba(255, 110, 150, 0.16);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7), 0 0 50px rgba(255, 45, 85, 0.14);
  animation: pop 0.5s cubic-bezier(.2, .9, .25, 1.15) both;
}

.memory::before {
  content: "❤";
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 16px;
  color: rgba(255, 220, 230, 0.8);
}

@keyframes pop {
  from { opacity: 0; transform: translateY(14px) scale(0.94); }
}

@keyframes fade {
  from { opacity: 0; }
}

.memory-photo {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: 14px;
  overflow: hidden;
  background:
    radial-gradient(60% 70% at 50% 45%, rgba(255, 60, 110, 0.55), transparent 70%),
    radial-gradient(100% 100% at 50% 100%, #3b0718, #12020a);
}

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

.memory-photo .ph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.memory-photo .ph svg {
  width: 30%;
  fill: #ff4d79;
  filter: drop-shadow(0 0 18px rgba(255, 45, 85, 0.8));
  animation: art-beat 1.4s ease-in-out infinite;
}

.memory h2 {
  margin: 20px 0 8px;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 22px;
  color: #fff1f5;
}

.memory p {
  margin: 0 8px 20px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--muted);
}

.back {
  min-height: 36px;
  padding: 8px 22px;
  border-radius: 999px;
  border: 1px solid rgba(255, 120, 160, 0.35);
  background: transparent;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #ffd6e0;
}

.back span {
  color: var(--rose);
}

.back:hover,
.back:focus-visible {
  background: rgba(255, 45, 85, 0.12);
  outline: none;
}

/* ------------------------------------------------------------------ misc */

.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;
}

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 16px;
  text-align: center;
  color: #ff2b4a;
}

@media (prefers-reduced-motion: reduce) {
  .intro-card,
  .intro-heart,
  .enter-badge svg,
  .bubble::before,
  .memory-photo .ph svg,
  .cursor.blink,
  .memory,
  .modal-backdrop {
    animation: none;
  }
}
