/* Romantic Velvet Glassmorphism & Tactile Micro-Interactions */

:root {
  --bg-deep: #180220;
  --bg-plum: #3b0433;
  --bg-berry: #7d083b;
  --rose-primary: #ff2d87;
  --rose-soft: #ff9bc5;
  --gold-accent: #f3c68f;
  --glass-bg: rgba(255, 255, 255, 0.075);
  --glass-border: rgba(255, 255, 255, 0.18);
  --muted: rgba(255, 240, 246, 0.76);
  --accent: #fff7fa;
  --glass-radius: 24px;
  --font-serif: "Cormorant Garamond", Georgia, serif;
  --font-sans: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background-color: var(--bg-deep);
}

html,
body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  height: 100%;
  margin: 0;
}

body {
  background: transparent;
  color: var(--accent);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(58px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(46px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  overflow: hidden;
}

/* Interactive Ambient Canvas & Soft Aurora Layer */
#ambientCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.breath-bg {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(650px 500px at 15% 20%, rgba(255, 45, 135, 0.2), transparent 60%),
    radial-gradient(600px 480px at 85% 80%, rgba(243, 198, 143, 0.14), transparent 60%);
  animation: breathe 9s ease-in-out infinite alternate;
}

@keyframes breathe {
  0% { transform: scale(1) translateY(0); opacity: 0.85; }
  100% { transform: scale(1.05) translateY(-10px); opacity: 1; }
}

#gift-content,
#app {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Initial Blur State */
.initial-blur {
  filter: blur(12px) brightness(0.8);
  transform: scale(1.05);
  transition: filter 1.4s ease, transform 1.4s ease;
}

/* Top HUD: Audio Control */
.top-hud {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: calc(14px + env(safe-area-inset-right));
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  pointer-events: none;
}

.sound-toggle {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform 0.16s ease, background-color 0.2s ease;
}

.sound-toggle:hover {
  background: rgba(255, 255, 255, 0.16);
}

.sound-toggle:active {
  transform: scale(0.95);
}

.eq-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 11px;
}

.eq-bars i {
  display: block;
  width: 2.5px;
  height: 100%;
  border-radius: 2px;
  background: var(--rose-soft);
  animation: eqPulse 0.85s ease-in-out infinite alternate;
}

.eq-bars i:nth-child(2) { animation-delay: 0.25s; }
.eq-bars i:nth-child(3) { animation-delay: 0.5s; }

.sound-toggle.muted .eq-bars i {
  animation: none;
  height: 3px;
  opacity: 0.45;
}

@keyframes eqPulse {
  0% { height: 3px; }
  100% { height: 11px; }
}

/* Container & Scenes */
.container {
  width: 100%;
  max-width: 470px;
  z-index: 5;
  position: relative;
}

.scene {
  display: none;
}

.scene.active {
  display: block;
}

/* Glass Card & Editorial Typography */
.card {
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--glass-border);
  border-radius: var(--glass-radius);
  padding: 22px;
  backdrop-filter: blur(16px) saturate(135%);
  -webkit-backdrop-filter: blur(16px) saturate(135%);
  box-shadow:
    0 20px 50px rgba(10, 0, 18, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
  color: var(--accent);
  position: relative;
}

.big-card {
  padding: clamp(20px, 4.5vw, 28px);
  min-height: clamp(340px, 56dvh, 430px);
  gap: 8px;
}

.eyebrow {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold-accent);
  margin-bottom: 2px;
}

.big-card h2,
.overlay-title {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 700;
  margin: 0;
  font-size: clamp(1.75rem, 5.5vw, 2.2rem);
  line-height: 1.15;
  letter-spacing: 0.01em;
  color: #ffffff;
}

.big-card p {
  margin: 0;
}

.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* Start Overlay */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 20px;
  background: radial-gradient(circle at 50% 40%, rgba(45, 5, 42, 0.45), rgba(12, 1, 18, 0.78));
}

.overlay-card {
  max-width: 360px;
  width: 100%;
  text-align: center;
  padding: 32px 24px;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--glass-radius);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.overlay-emoji {
  font-size: 2.9rem;
  line-height: 1.1;
  margin: 10px 0 6px;
}

#startBtn {
  margin-block-start: 16px;
}

.overlay-sub {
  margin: 10px 0 24px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

#demo-label {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: calc(14px + env(safe-area-inset-left));
  z-index: 60;
  margin: 0;
  padding: 7px 12px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: var(--bg-plum);
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
  pointer-events: none;
}

/* Recipient access screen */
.pin-lock {
  z-index: 50;
  overflow-y: auto;
  align-items: flex-start;
}

.pin-card {
  margin: auto;
}

.pin-form {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pin-label {
  margin-bottom: 9px;
  color: var(--gold-accent);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.pin-input {
  width: 190px;
  max-width: 100%;
  height: 54px;
  padding: 0 0 0 0.55em;
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  outline: none;
  background: rgba(18, 2, 24, 0.4);
  color: var(--accent);
  font: 600 1.45rem var(--font-sans);
  letter-spacing: 0.55em;
  text-align: center;
  user-select: text;
}

.pin-input::placeholder {
  color: rgba(255, 240, 246, 0.3);
}

.pin-input:focus-visible {
  border-color: var(--gold-accent);
  box-shadow: 0 0 0 2px rgba(243, 198, 143, 0.22);
}

.pin-hint {
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 26px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.09);
  color: var(--accent);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 0.18s ease, background-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.16);
  box-shadow: 0 8px 24px rgba(255, 45, 135, 0.3);
}

.btn:active:not(:disabled) {
  transform: scale(0.96);
}

.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #ff2d87 0%, #a2166c 100%);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 10px 28px rgba(255, 45, 135, 0.38);
}

/* Scene 1: Radial Ring + Progress Bar */
.charge-stage {
  position: relative;
  width: 112px;
  height: 112px;
  margin: 8px 0 2px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.charge-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  pointer-events: none;
}

.charge-ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 5;
}

.charge-ring-fill {
  fill: none;
  stroke: url(#ringGrad);
  stroke: var(--rose-primary);
  stroke-width: 5.5;
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: 326.73;
  filter: drop-shadow(0 0 8px rgba(255, 45, 135, 0.65));
  transition: stroke-dashoffset 0.16s ease-out;
}

.charge-heart {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: radial-gradient(circle at 30% 30%, rgba(255, 155, 197, 0.36), rgba(255, 45, 135, 0.18));
  box-shadow: 0 10px 26px rgba(255, 45, 135, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  font-size: 2.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.charge-heart:active {
  transform: scale(0.91);
}

.charge-status {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.08rem;
  color: var(--gold-accent);
  min-height: 1.4em;
}

.meter-wrap {
  width: 100%;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.meter-track {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.3);
}

.meter-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff9bc5 0%, #ff2d87 55%, #f3c68f 100%);
  box-shadow: 0 0 18px rgba(255, 45, 135, 0.45);
  transition: width 0.14s ease-out;
}

.meter-tips {
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.06em;
}

/* Scene 2: 3D Satin Wax-Sealed Envelope */
.envelope-stage {
  margin: 18px 0 10px;
  padding-top: 14px;
}

.envelope {
  width: min(245px, 70vw);
  height: 156px;
  position: relative;
  cursor: pointer;
  perspective: 950px;
  transform-style: preserve-3d;
  transition: transform 0.25s ease;
}

.envelope:hover {
  transform: translateY(-3px);
}

.env-back {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(165, 20, 95, 0.55), rgba(85, 8, 55, 0.75));
  border: 1px solid rgba(243, 198, 143, 0.35);
}

.env-letter-peek {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 14px;
  height: 110px;
  z-index: 1;
  border-radius: 10px;
  background: linear-gradient(180deg, #fff8f2, #f7e6dc);
  color: #5c1638;
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 700;
  font-size: 1.15rem;
  padding-top: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.env-top {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 88px;
  z-index: 3;
  background: linear-gradient(180deg, rgba(255, 145, 195, 0.48), rgba(190, 35, 110, 0.32));
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  backface-visibility: visible;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  pointer-events: none;
}

.env-body {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.05));
  border-radius: 16px;
  border: 1px solid rgba(243, 198, 143, 0.38);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.env-seal {
  position: relative;
  z-index: 4;
  width: 52px;
  height: 52px;
  margin-top: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #f5cfa0, #c88746 70%, #995c24);
  border: 1.5px solid rgba(255, 245, 225, 0.65);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

/* Scene 3: Swipeable Polaroid Deck */
.deck-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.deck-counter {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--gold-accent);
}

.deck {
  position: relative;
  width: 100%;
  max-width: 330px;
  height: clamp(245px, 42dvh, 285px);
  margin: 6px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1000px;
  touch-action: pan-y;
}

.card-item {
  position: absolute;
  width: min(285px, 100%);
  height: clamp(228px, 38dvh, 264px);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  padding: 12px 12px 14px;
  justify-content: space-between;
  cursor: grab;
  transform-origin: center;
  transform-style: preserve-3d;
  box-shadow: 0 14px 32px rgba(8, 0, 16, 0.42);
}

.card-item:active {
  cursor: grabbing;
}

.card-image-box {
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: radial-gradient(circle, rgba(255, 155, 197, 0.16), rgba(40, 5, 35, 0.4));
}

.card-image-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.card-meta {
  padding-top: 10px;
  text-align: center;
}

.card-item .title {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 700;
  font-size: 1.22rem;
  line-height: 1.15;
  color: #ffffff;
}

.card-item .body {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 2px;
}

/* Scene 4: GPU-Safe Teddy Stage */
.video-card {
  padding: 18px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: clamp(260px, 45dvh, 340px);
  background: radial-gradient(circle at 50% 42%, rgba(255, 225, 238, 0.34), rgba(255, 255, 255, 0.08));
  border: 1px solid rgba(255, 255, 255, 0.38);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  position: relative;
}

.video-card img {
  width: 100%;
  height: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: 14px;
  display: block;
}

.scene-caption {
  margin-top: 14px;
  text-align: center;
  color: #ffffff;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.25rem;
  font-weight: 600;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

/* Floating Emoji & Tap Particles */
.emoji-particle {
  position: fixed;
  left: 0;
  top: 0;
  pointer-events: none;
  font-size: 32px;
  z-index: 100;
  opacity: 1;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.5));
  will-change: transform, opacity;
}

/* Final Keepsake Overlay */
#finalOverlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  background: rgba(14, 1, 20, 0.32);
}

#finalOverlay.visible {
  pointer-events: auto;
}

.final-msg-card {
  width: 100%;
  max-width: 440px;
  text-align: center;
  padding: clamp(28px, 5vw, 38px) clamp(22px, 5vw, 32px);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.05));
  border: 1px solid rgba(243, 198, 143, 0.35);
  border-radius: var(--glass-radius);
  backdrop-filter: blur(18px) saturate(135%);
  -webkit-backdrop-filter: blur(18px) saturate(135%);
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.52), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.gold-divider {
  width: 56px;
  height: 1px;
  margin: 14px auto;
  background: linear-gradient(90deg, transparent, var(--gold-accent), transparent);
}

.final-text {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(1.65rem, 6vw, 2.35rem);
  font-weight: 700;
  line-height: 1.32;
  color: #ffffff;
  text-shadow: 0 5px 20px rgba(255, 45, 135, 0.4);
}

.final-credit {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 20px;
  border: 1px solid rgba(243, 198, 143, 0.42);
  border-radius: 999px;
  background: rgba(36, 4, 34, 0.76);
  color: var(--gold-accent);
  font: italic 600 1.3rem/1.35 var(--font-serif);
  text-decoration: none;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.final-credit:hover,
.final-credit:focus-visible {
  background-color: var(--bg-plum);
  border-color: var(--gold-accent);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.final-credit:focus-visible {
  outline: 2px solid var(--gold-accent);
  outline-offset: 3px;
}

/* Footer & Utilities */
.footer {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 15;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 240, 246, 0.55);
  font-size: 11px;
  letter-spacing: 0.08em;
  pointer-events: none;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.small {
  font-size: 11px;
}

button:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--gold-accent);
  outline-offset: 3px;
}

