:root {
  --rose: #c94f6d;
  --rose-deep: #9d304e;
  --pink: #f7c7d4;
  --peach: #ffd6bf;
  --cream: #fff6ee;
  --gold: #ffd67a;
  --gold-soft: rgba(255, 214, 122, 0.3);
  --wine: #412133;
  --night: #1d1220;
  --shadow: 0 25px 60px rgba(138, 51, 82, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Nunito", sans-serif;
  color: var(--wine);
  overflow-x: hidden;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

body.page-leaving {
  opacity: 0;
  transform: translateY(10px);
}

.auth-body,
.valentine-body {
  position: relative;
  background:
    radial-gradient(circle at top, rgba(255, 245, 231, 0.9), transparent 34%),
    linear-gradient(135deg, #fff6ee 0%, #ffd7d7 44%, #ffc7ba 100%);
}

.valentine-body.dinner-mode {
  background:
    radial-gradient(circle at top, rgba(255, 214, 122, 0.2), transparent 22%),
    linear-gradient(180deg, #180f1c 0%, #261824 42%, #3f2530 100%);
  color: #fff6f1;
  transition: background 1s ease, color 1s ease;
}

/* ─── Dynamic Background System ──────────────────────────────── */

/* Pseudo-element behind everything, fades in smoothly on class change */
.valentine-body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 1.1s ease, background-image 0s;
  pointer-events: none;
}

/* Dark overlay baked into each bg so text stays readable */
.valentine-body.bg-movie::before {
  background-image:
    linear-gradient(rgba(10, 6, 18, 0.62), rgba(10, 6, 18, 0.72)),
    url("images/bg_movie.png");
  opacity: 1;
}

.valentine-body.bg-stargazing::before {
  background-image:
    linear-gradient(rgba(4, 8, 28, 0.58), rgba(4, 8, 28, 0.7)),
    url("images/bg_stargazing.png");
  opacity: 1;
}

.valentine-body.bg-coffee::before {
  background-image:
    linear-gradient(rgba(30, 14, 8, 0.6), rgba(30, 14, 8, 0.72)),
    url("images/bg_coffee.png");
  opacity: 1;
}

.valentine-body.bg-candle::before {
  background-image:
    linear-gradient(rgba(20, 4, 10, 0.62), rgba(20, 4, 10, 0.74)),
    url("images/bg_candle.png");
  opacity: 1;
}

/* Custom card gets the existing wine-rose gradient, no photo needed */
.valentine-body.bg-custom::before {
  background-image:
    linear-gradient(135deg, rgba(68, 14, 40, 0.82), rgba(25, 8, 20, 0.88));
  opacity: 1;
}

/* Ensure all child content renders above the pseudo-element */
.valentine-body > * {
  position: relative;
  z-index: 1;
}

.fade-page {
  animation: fadeInUp 0.9s ease both;
}

.heart-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.heart {
  position: absolute;
  width: 18px;
  height: 18px;
  background: rgba(255, 122, 151, 0.28);
  transform: rotate(45deg);
  animation: floatHeart linear infinite;
  filter: blur(0.2px);
}

.heart::before,
.heart::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  background: inherit;
  border-radius: 50%;
}

.heart::before {
  top: -9px;
  left: 0;
}

.heart::after {
  top: 0;
  left: -9px;
}

.heart-1 { left: 8%; bottom: -10%; animation-duration: 15s; animation-delay: 0s; }
.heart-2 { left: 22%; bottom: -12%; animation-duration: 18s; animation-delay: 3s; width: 14px; height: 14px; }
.heart-3 { left: 41%; bottom: -8%; animation-duration: 16s; animation-delay: 6s; }
.heart-4 { left: 63%; bottom: -14%; animation-duration: 20s; animation-delay: 1s; width: 22px; height: 22px; }
.heart-5 { left: 79%; bottom: -11%; animation-duration: 17s; animation-delay: 5s; }
.heart-6 { left: 92%; bottom: -9%; animation-duration: 14s; animation-delay: 8s; width: 12px; height: 12px; }

.top-actions {
  position: fixed;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.75rem;
  z-index: 5;
}

.romantic-card {
  position: relative;
  z-index: 1;
  background: rgba(255, 250, 246, 0.8);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 32px;
  box-shadow: var(--shadow);
}

.auth-card {
  padding: 2.5rem 2rem;
}

.valentine-card {
  padding: 3rem 1.5rem;
  min-height: 560px;
}

.date-card-layout {
  min-height: 760px;
}

.view-section {
  opacity: 0;
  transform: translateY(18px);
  pointer-events: none;
  transition: opacity 0.6s ease, transform 0.6s ease;
  display: none;
}

.view-section.is-visible {
  display: block;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.card-hero-title {
  font-size: clamp(2.8rem, 6vw, 4.6rem);
}

.eyebrow {
  letter-spacing: 0.26em;
  text-transform: uppercase;
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(157, 48, 78, 0.72);
}

.display-title,
.hero-title {
  font-family: "Cormorant Garamond", serif;
  font-weight: 700;
  line-height: 1;
}

.display-title {
  font-size: clamp(2.25rem, 4vw, 3.5rem);
}

.hero-title {
  font-size: clamp(3rem, 7vw, 5.2rem);
}

.subtitle {
  color: rgba(65, 33, 51, 0.76);
  font-size: 1.05rem;
}

.hero-subtitle {
  max-width: 620px;
  margin: 0 auto;
  font-size: 1.1rem;
}

.custom-input {
  border-radius: 16px;
  border: 1px solid rgba(201, 79, 109, 0.16);
  padding: 0.9rem 1rem;
  background: rgba(255, 255, 255, 0.7);
}

.custom-input:focus {
  border-color: rgba(201, 79, 109, 0.5);
  box-shadow: 0 0 0 0.25rem rgba(201, 79, 109, 0.12);
}

.btn-romantic,
.btn-outline-romantic,
.logout-btn {
  border-radius: 999px;
  padding: 0.85rem 1.5rem;
  font-weight: 700;
  transition: transform 0.28s ease, box-shadow 0.28s ease, background-color 0.28s ease, color 0.28s ease;
}

.btn-romantic {
  background: linear-gradient(135deg, #e66a89, #c94f6d);
  color: #fff;
  border: none;
  box-shadow: 0 18px 30px rgba(201, 79, 109, 0.25);
}

.btn-romantic:hover,
.btn-romantic:focus {
  transform: translateY(-2px) scale(1.01);
  color: #fff;
  box-shadow: 0 22px 34px rgba(201, 79, 109, 0.32);
}

.btn-outline-romantic {
  position: relative;
  background: rgba(255, 255, 255, 0.68);
  color: var(--rose-deep);
  border: 1px solid rgba(201, 79, 109, 0.3);
}

.btn-outline-romantic:hover,
.btn-outline-romantic:focus {
  color: var(--rose-deep);
  transform: translateY(-2px);
}

.floating-no-button {
  position: fixed;
  z-index: 6;
  transition:
    left 0.95s ease-in-out,
    top 0.95s ease-in-out,
    box-shadow 0.35s ease,
    transform 0.35s ease,
    background-color 0.35s ease;
  will-change: left, top, transform;
}

.floating-no-button:hover,
.floating-no-button:focus-visible {
  box-shadow: 0 0 0 0.35rem rgba(201, 79, 109, 0.14), 0 16px 34px rgba(201, 79, 109, 0.2);
  animation: heartBeatGlow 1s ease-in-out infinite;
}

.floating-no-button.is-fleeing {
  box-shadow: 0 0 0 0.45rem rgba(255, 214, 122, 0.14), 0 18px 32px rgba(201, 79, 109, 0.22);
}

.floating-no-button.is-pausing {
  animation: temptPulse 0.9s ease-in-out infinite;
}

.no-popup {
  position: fixed;
  z-index: 7;
  width: min(220px, calc(100vw - 24px));
  padding: 0.8rem 0.95rem;
  border-radius: 18px;
  background: rgba(255, 250, 246, 0.9);
  color: var(--rose-deep);
  text-align: center;
  font-size: 0.92rem;
  font-weight: 700;
  box-shadow: 0 18px 32px rgba(138, 51, 82, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.68);
  backdrop-filter: blur(10px);
  opacity: 0;
  transform: translateY(8px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.no-popup.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.logout-btn {
  background: rgba(255, 250, 246, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: var(--wine);
  box-shadow: 0 12px 22px rgba(35, 14, 29, 0.08);
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.88);
  transform: translateY(-2px);
}

.soft-link {
  color: var(--rose-deep);
  text-decoration: none;
  font-weight: 700;
}

.soft-link:hover {
  color: var(--rose);
}

.soft-message {
  max-width: 360px;
  margin: 1.5rem auto 0;
  padding: 0.9rem 1rem;
  background: rgba(255, 255, 255, 0.52);
  border-radius: 18px;
  color: var(--rose-deep);
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.state-panel {
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.text-gold {
  color: var(--gold);
}

.text-light-soft {
  color: rgba(255, 244, 236, 0.85);
}

.ambient-glow {
  position: absolute;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 214, 122, 0.3) 0%, rgba(255, 214, 122, 0) 70%);
  filter: blur(4px);
}

.ambient-left {
  top: 8%;
  left: 8%;
}

.ambient-right {
  bottom: 12%;
  right: 10%;
}

.card-experience {
  width: min(100%, 560px);
  margin-inline: auto;
}

.story-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.story-toolbar-actions {
  display: flex;
  gap: 0.75rem;
}

.story-back {
  min-width: 100px;
}

.story-back.is-inactive {
  opacity: 0.55;
  transform: none;
}

.story-prompt {
  margin: 0;
  color: rgba(255, 244, 236, 0.86);
  font-weight: 700;
  text-align: right;
}

.card-stack {
  position: relative;
  width: min(100%, 520px);
  height: 280px;
  margin-inline: auto;
  perspective: 1200px;
}

.story-card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  padding: 2rem 1.5rem;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 250, 246, 0.96), rgba(255, 240, 234, 0.9)),
    rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.64);
  box-shadow: 0 24px 44px rgba(20, 9, 18, 0.22);
  opacity: 0;
  filter: blur(8px);
  transform: translateX(80px) scale(0.82);
  transition:
    transform 0.72s ease-in-out,
    opacity 0.72s ease-in-out,
    filter 0.72s ease-in-out,
    box-shadow 0.45s ease;
  pointer-events: none;
  cursor: pointer;
  overflow: hidden;
}

.story-card::before,
.story-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.32s ease, transform 0.32s ease, box-shadow 0.32s ease;
  pointer-events: none;
}

.story-card::before {
  background:
    linear-gradient(
      90deg,
      rgba(255, 214, 122, 0.14) 0%,
      rgba(255, 214, 122, 0.08) 20%,
      transparent 20%,
      transparent 80%,
      rgba(255, 214, 122, 0.08) 80%,
      rgba(255, 214, 122, 0.14) 100%
    );
}

.story-card::after {
  inset: 16%;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(255, 214, 122, 0.2), rgba(255, 176, 197, 0.18));
  box-shadow: inset 0 0 0 1px rgba(255, 214, 122, 0.28);
  transform: scale(0.98);
}

.story-card.is-active {
  opacity: 1;
  filter: blur(0);
  transform: translateX(0) scale(1);
  z-index: 4;
  pointer-events: auto;
}

.story-card.is-next {
  opacity: 0.72;
  filter: blur(3px);
  transform: translateX(38px) scale(0.92);
  z-index: 3;
}

.story-card.is-back {
  opacity: 0.46;
  filter: blur(6px);
  transform: translateX(68px) scale(0.86);
  z-index: 2;
}

.story-card.is-exiting {
  opacity: 0;
  filter: blur(8px);
  transform: translateX(-120px) scale(0.9);
  pointer-events: none;
}

.story-card.is-returning {
  opacity: 0;
  filter: blur(8px);
  transform: translateX(120px) scale(0.9);
  pointer-events: none;
}

.story-card.is-selectable.is-active {
  box-shadow: 0 0 0 0.35rem rgba(255, 214, 122, 0.12), 0 24px 54px rgba(255, 214, 122, 0.18);
}

.story-card.is-active.is-hover-left::before,
.story-card.is-active.is-hover-right::before {
  opacity: 1;
}

.story-card.is-selectable.is-active.is-hover-center::after,
.story-card.is-selectable.is-active:hover::after {
  opacity: 1;
  transform: scale(1);
}

.story-card.is-selectable.is-active.is-hover-center {
  box-shadow: 0 0 0 0.32rem rgba(255, 214, 122, 0.15), 0 28px 60px rgba(255, 176, 197, 0.2);
}

.story-icon {
  font-size: 2rem;
}

.story-title {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(2rem, 4vw, 2.8rem);
  line-height: 1;
  color: #5f3042;
}

.story-text {
  margin: 0;
  max-width: 360px;
  color: rgba(65, 33, 51, 0.78);
  font-size: 1rem;
}

.custom-date-form {
  display: none;
  margin-top: 1.5rem;
  padding: 1.35rem;
  border-radius: 24px;
  background: rgba(255, 248, 243, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.custom-date-form.visible {
  display: block;
  animation: fadeInUp 0.55s ease both;
}

.selected-scene {
  display: none;
  margin-top: 1.5rem;
  padding: 2rem 1.5rem;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255, 248, 240, 0.14), rgba(255, 220, 200, 0.08));
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 24px 44px rgba(10, 4, 12, 0.22);
}

.selected-scene.visible {
  display: block;
  animation: fadeInUp 0.7s ease both;
}

.selected-scene.scene-movie {
  background:
    radial-gradient(circle at top, rgba(255, 214, 122, 0.15), transparent 32%),
    linear-gradient(180deg, rgba(55, 30, 48, 0.9), rgba(27, 16, 29, 0.92));
}

.selected-scene.scene-stargazing {
  background:
    radial-gradient(circle at top, rgba(187, 213, 255, 0.2), transparent 34%),
    linear-gradient(180deg, rgba(18, 25, 54, 0.95), rgba(10, 15, 33, 0.96));
}

.selected-scene.scene-coffee {
  background:
    radial-gradient(circle at top, rgba(255, 209, 168, 0.18), transparent 34%),
    linear-gradient(180deg, rgba(99, 58, 38, 0.92), rgba(60, 34, 24, 0.96));
}

.selected-scene.scene-candlelight {
  background:
    radial-gradient(circle at top, rgba(255, 214, 122, 0.22), transparent 30%),
    linear-gradient(180deg, rgba(62, 26, 35, 0.95), rgba(28, 12, 18, 0.96));
}

.selected-scene.scene-custom {
  background:
    radial-gradient(circle at top, rgba(255, 188, 199, 0.18), transparent 34%),
    linear-gradient(180deg, rgba(68, 34, 56, 0.92), rgba(33, 16, 29, 0.96));
}

.scene-icon {
  font-size: 2.3rem;
  margin-bottom: 0.8rem;
}

.scene-title {
  margin: 0 0 0.55rem;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(2.2rem, 4vw, 3rem);
  color: #fff3ea;
}

.scene-text {
  margin: 0;
  color: rgba(255, 244, 236, 0.88);
  font-size: 1rem;
}

.scene-stars {
  letter-spacing: 0.4rem;
  font-size: 1.05rem;
  color: #ffe79d;
  margin-top: 0.9rem;
}

.scene-steam {
  margin-top: 0.9rem;
  font-size: 1rem;
  color: rgba(255, 234, 215, 0.82);
}

.scene-candles {
  margin-top: 1rem;
  color: #ffd67a;
  font-size: 1.3rem;
}

.scene-custom-text {
  color: #ffd6df;
  font-weight: 700;
  margin-top: 0.8rem;
}

.alert {
  border-radius: 18px;
  border: none;
}

@keyframes floatHeart {
  0% {
    transform: translateY(0) rotate(45deg) scale(0.9);
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  85% {
    opacity: 0.95;
  }
  100% {
    transform: translateY(-120vh) rotate(45deg) scale(1.15);
    opacity: 0;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes heartBeatGlow {
  0%, 100% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.05);
  }
  60% {
    transform: scale(0.99);
  }
}

@keyframes temptPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}

@media (max-width: 767.98px) {
  .auth-card,
  .valentine-card {
    padding: 2rem 1.25rem;
  }

  .top-actions {
    top: 0.75rem;
    right: 0.75rem;
    left: 0.75rem;
    justify-content: flex-end;
  }

  .button-area {
    align-items: center;
  }

  .button-area .btn {
    width: min(100%, 260px);
  }

  .card-stack {
    height: 300px;
  }

  .story-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .story-toolbar-actions {
    justify-content: center;
    flex-wrap: wrap;
  }

  .story-prompt {
    text-align: center;
  }
}
