:root {
  color-scheme: dark;
  --ink: #fff7f1;
  --muted: rgba(255, 247, 241, 0.68);
  --red: #ff174d;
  --rose: #ff6f91;
  --wine: #430010;
  --gold: #f5c56f;
  --teal: #72ead6;
  --shadow: rgba(0, 0, 0, 0.36);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #000;
  color: var(--ink);
}

button,
input,
textarea,
select {
  font: inherit;
}

.stage {
  position: relative;
  min-height: 100svh;
  isolation: isolate;
  overflow: hidden;
}

.stage::before {
  display: none;
}

.stage::after {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background: radial-gradient(circle at 50% 48%, transparent 0%, transparent 46%, rgba(0, 0, 0, 0.62) 82%);
}

#heart-scene {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
  touch-action: manipulation;
}

.memory-field {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  perspective: 1200px;
  transform-style: preserve-3d;
  opacity: 0;
  cursor: default;
  transition: opacity 420ms ease;
}

.memory-field.is-active {
  pointer-events: auto;
  opacity: 1;
}

.memory-card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--card-width, clamp(90px, 8vw, 128px));
  --photo-ratio: 0.78;
  display: block;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  color: #201316;
  background: #fff7f1;
  box-shadow:
    0 24px 72px rgba(0, 0, 0, 0.34),
    inset 0 0 0 1px rgba(255, 255, 255, 0.72);
  opacity: 0;
  transform:
    translate3d(-50%, -50%, 0)
    scale(0.16)
    rotate(var(--start-rotate));
  will-change: transform, opacity;
  transform-style: preserve-3d;
  cursor: pointer;
  transition:
    opacity 460ms ease,
    transform 900ms cubic-bezier(0.16, 1, 0.3, 1);
}

.memory-card.is-visible {
  pointer-events: auto;
  opacity: 1;
  transform: var(--card-transform);
}

.memory-card:hover {
  z-index: 10;
  transform: var(--card-transform-hover);
}

.memory-photo {
  position: relative;
  width: 100%;
  aspect-ratio: var(--photo-ratio);
  overflow: hidden;
  border-radius: 5px;
  background:
    linear-gradient(135deg, rgba(255, 23, 77, 0.22), rgba(114, 234, 214, 0.18)),
    #21070d;
}

.memory-photo::before {
  position: absolute;
  inset: -12%;
  content: "";
  background-image: var(--photo-src);
  background-position: center;
  background-size: cover;
  filter: blur(14px) saturate(1.12);
  opacity: 0.52;
  transform: scale(1.08);
}

.memory-photo::after {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(to bottom, transparent 62%, rgba(23, 10, 13, 0.54)),
    inset 0 0 0 1px rgba(255, 255, 255, 0.2);
  pointer-events: none;
}

.memory-photo img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: var(--photo-position, center);
}

.memory-card:nth-child(3n) {
  background: #f9fbff;
}

.memory-card:nth-child(4n) {
  background: #fff4e1;
}

.memory-card:nth-child(5n) {
  background: #f3fffb;
}

@media (max-width: 720px) {
  .memory-card {
    width: var(--card-width, clamp(64px, 18vw, 86px));
    padding: 4px;
  }
}

.photo-lightbox {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: clamp(18px, 4vw, 54px);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px);
  transition:
    opacity 240ms ease,
    visibility 0s linear 240ms;
}

.photo-lightbox.is-open {
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
  transition:
    opacity 240ms ease,
    visibility 0s;
}

.photo-lightbox img {
  max-width: min(88vw, 980px);
  max-height: min(72vh, 720px);
  border: 8px solid rgba(255, 247, 241, 0.95);
  border-radius: 8px;
  object-fit: contain;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.54);
  background: #111;
}

.lightbox-meta {
  width: min(88vw, 980px);
  margin-top: 14px;
  color: #fff7f1;
  text-align: center;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.7);
}

.lightbox-meta time {
  display: block;
  color: #ffb7d7;
  font-size: clamp(0.9rem, 2vw, 1.08rem);
  font-weight: 800;
}

.lightbox-meta p {
  margin: 8px auto 0;
  max-width: 44rem;
  font-size: clamp(1rem, 2.2vw, 1.24rem);
  line-height: 1.6;
}

.lightbox-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 247, 241, 0.34);
  border-radius: 50%;
  background: rgba(20, 6, 12, 0.72);
  cursor: pointer;
}

.lightbox-close::before,
.lightbox-close::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 2px;
  content: "";
  background: #fff7f1;
}

.lightbox-close::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.lightbox-close::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

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