/* ============ Reset & base ============ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --pink-900: #d6547e;
  --pink-700: #ff6fa8;
  --pink-500: #ff9fc4;
  --pink-300: #ffc9dc;
  --pink-100: #ffe8f1;
  --cream: #fff6fa;
  --gold: #ffd400;
  --shadow-pink: rgba(196, 97, 143, 0.35);
  --font-display: 'Dancing Script', cursive;
  --font-body: 'Poppins', sans-serif;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font-body);
  background: #f7b8cf url('/background.png') center top / cover no-repeat fixed;
  color: #6b2f47;
  overflow-x: hidden;
  min-height: 100vh;
}

img {
  display: block;
  max-width: 100%;
  user-select: none;
  -webkit-user-drag: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

/* ============ Scene layout ============ */
.scene {
  position: relative;
  min-height: 100vh;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 48px 20px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

/* ============ Decorations (floating hearts/stars/petals) ============ */
.decorations {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.deco {
  position: absolute;
  opacity: 0.75;
  will-change: transform, opacity;
  animation-name: floatUp, sway;
  animation-timing-function: ease-in-out, ease-in-out;
  animation-iteration-count: infinite, infinite;
}

.deco.sparkle-twinkle {
  animation-name: twinkle;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}

@keyframes floatUp {
  0%   { transform: translateY(10vh); opacity: 0; }
  10%  { opacity: 0.8; }
  90%  { opacity: 0.6; }
  100% { transform: translateY(-115vh); opacity: 0; }
}

@keyframes sway {
  0%, 100% { margin-left: 0; }
  50% { margin-left: 24px; }
}

@keyframes twinkle {
  0%, 100% { opacity: 0.15; transform: scale(0.8); }
  50% { opacity: 0.9; transform: scale(1.15); }
}

/* ============ Hero ============ */
.hero {
  position: relative;
  z-index: 2;
  text-align: center;
  margin-bottom: 18px;
}

.hero-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.6rem, 12vw, 3.6rem);
  line-height: 1.05;
  color: #fff3f8;
  text-shadow:
    0 0 6px rgba(255, 255, 255, 0.9),
    0 0 18px rgba(255, 154, 195, 0.9),
    0 0 34px rgba(255, 110, 170, 0.75),
    0 3px 10px rgba(120, 20, 60, 0.35);
  letter-spacing: 0.5px;
}

.hero-subtitle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 6px 18px rgba(150, 40, 80, 0.18);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--pink-900);
}

.beat {
  display: inline-block;
  animation: heartbeat 1.4s ease-in-out infinite;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.25); }
  40% { transform: scale(1); }
}

/* ============ Items ============ */
.items {
  position: relative;
  z-index: 2;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 34px;
  margin-top: 12px;
}

.item {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  outline: none;
}

.item-stage {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  transition: transform 0.25s ease;
}

.item:hover .item-stage,
.item:focus-visible .item-stage {
  transform: translateY(-4px) scale(1.02);
}

.item:active .item-stage {
  transform: scale(0.97);
}

.item-img {
  filter: drop-shadow(0 18px 22px var(--shadow-pink));
}

/* gentle floating for all staged art */
.cake-img {
  width: 78%;
  animation: bob 4.5s ease-in-out infinite, candleGlow 2.2s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes candleGlow {
  0%, 100% { filter: drop-shadow(0 18px 22px var(--shadow-pink)) drop-shadow(0 -6px 18px rgba(255, 224, 140, 0.55)); }
  50% { filter: drop-shadow(0 18px 22px var(--shadow-pink)) drop-shadow(0 -6px 30px rgba(255, 224, 140, 0.95)); }
}

/* Envelope */
.envelope-stage {
  width: 74%;
  perspective: 900px;
  animation: bob 5s ease-in-out infinite 0.3s;
}

.envelope-body {
  position: relative;
  width: 100%;
  z-index: 1;
}

.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  transform-origin: 50% 67%;
  transform: rotateX(0deg);
  z-index: 3;
  transition: transform 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
  backface-visibility: hidden;
}

.heart-seal {
  position: absolute;
  top: 34%;
  left: 50%;
  width: 20%;
  transform: translate(-50%, -50%) scale(1);
  z-index: 4;
  transition: opacity 0.4s ease, transform 0.4s ease;
  animation: pulseSeal 2.4s ease-in-out infinite;
}

@keyframes pulseSeal {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(255, 212, 0, 0.6)); }
  50% { filter: drop-shadow(0 0 16px rgba(255, 212, 0, 0.95)); }
}

.item.is-open .envelope-flap {
  transform: rotateX(-165deg);
  z-index: 0;
}

.item.is-open .heart-seal {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.4);
}

/* Gift */
.gift-stage {
  width: 72%;
  position: relative;
  animation: bob 4.8s ease-in-out infinite 0.6s;
}

.gift-glow {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 70%;
  height: 60%;
  transform: translate(-50%, -50%) scale(0.6);
  background: radial-gradient(circle, rgba(255, 240, 190, 0.95) 0%, rgba(255, 240, 190, 0) 70%);
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.6s ease;
  pointer-events: none;
  z-index: 1;
}

.gift-box {
  position: relative;
  width: 100%;
  z-index: 2;
}

.gift-lid {
  position: absolute;
  top: -6%;
  left: 0;
  width: 100%;
  z-index: 3;
  transform-origin: 50% 100%;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.item.is-open .gift-lid {
  transform: translateY(-38%) rotate(-18deg);
}

.item.is-open .gift-glow {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.item-label {
  margin-top: 16px;
  padding: 7px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 6px 16px rgba(150, 40, 80, 0.16);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--pink-900);
  letter-spacing: 0.3px;
}

.arrow {
  opacity: 0.6;
  color: var(--pink-700);
}

/* ============ Footer ============ */
.scene-footer {
  position: relative;
  z-index: 2;
  margin-top: 40px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--pink-900);
  text-align: center;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 6px 16px rgba(150, 40, 80, 0.16);
  padding: 9px 18px;
  border-radius: 999px;
}

/* ============ Modal (code entry) ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(107, 30, 62, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
  z-index: 100;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 360px;
  background: linear-gradient(180deg, #fff6fa 0%, #ffe4ef 100%);
  border-radius: 28px;
  padding: 36px 26px 28px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(120, 20, 60, 0.4);
  transform: translateY(24px) scale(0.94);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-card {
  transform: translateY(0) scale(1);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  font-size: 1.1rem;
  color: var(--pink-900);
  opacity: 0.6;
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.modal-close:hover {
  opacity: 1;
  background: rgba(255, 111, 168, 0.15);
}

.modal-icon {
  font-size: 2.4rem;
  margin-bottom: 6px;
  animation: heartbeat 1.6s ease-in-out infinite;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.9rem;
  color: var(--pink-900);
  font-weight: 700;
}

.modal-subtitle {
  margin-top: 6px;
  font-size: 0.85rem;
  color: #9a5a75;
}

.code-form {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.code-input {
  width: 100%;
  padding: 14px 18px;
  border-radius: 16px;
  border: 2px solid var(--pink-300);
  background: #fff;
  font-size: 1.15rem;
  letter-spacing: 4px;
  text-align: center;
  color: var(--pink-900);
  outline: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.code-input:focus {
  border-color: var(--pink-700);
  box-shadow: 0 0 0 4px rgba(255, 111, 168, 0.18);
}

.code-input.shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

.code-submit {
  padding: 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--pink-700), var(--pink-900));
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.3px;
  box-shadow: 0 10px 22px rgba(214, 84, 126, 0.45);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.code-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(214, 84, 126, 0.5);
}

.code-submit:active {
  transform: translateY(0);
}

.code-submit:disabled {
  opacity: 0.65;
  cursor: default;
  transform: none;
}

.code-error {
  min-height: 20px;
  margin-top: 12px;
  font-size: 0.85rem;
  color: #e34b78;
  font-weight: 500;
}

/* ============ Reveal overlay (secret message) ============ */
.reveal-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 30%, #ffd7e8 0%, #ff8fbb 60%, #e8608f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
  z-index: 200;
}

.reveal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.reveal-card {
  max-width: 380px;
  text-align: center;
  transform: scale(0.9);
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.reveal-overlay.active .reveal-card {
  transform: scale(1);
}

.reveal-hearts {
  font-size: 2.2rem;
  margin-bottom: 8px;
  animation: heartbeat 1.6s ease-in-out infinite;
}

.reveal-title {
  font-family: var(--font-display);
  font-size: 3rem;
  color: #fff;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.8), 0 4px 18px rgba(150, 30, 70, 0.4);
}

.reveal-message {
  margin-top: 18px;
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.65;
  color: #6b2f47;
  background: rgba(255, 250, 253, 0.96);
  padding: 22px 24px;
  border-radius: 22px;
  box-shadow: 0 10px 26px rgba(120, 20, 60, 0.25);
}

.reveal-close {
  margin-top: 26px;
  padding: 13px 26px;
  border-radius: 999px;
  background: #fff;
  color: var(--pink-900);
  font-weight: 600;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease;
}

.reveal-close:hover {
  transform: translateY(-2px);
}

/* ============ Confetti (created dynamically in JS) ============ */
.confetti-piece {
  position: fixed;
  top: -5vh;
  z-index: 210;
  pointer-events: none;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(540deg); opacity: 0.4; }
}

/* ============ Responsive tweaks ============ */
@media (min-width: 560px) {
  .scene { padding-top: 64px; }
  .items { gap: 44px; }
}

@media (max-width: 340px) {
  .hero-title { font-size: 2.3rem; }
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
