/* ============================================
   SURPRISE SCRATCH CARD — PREMIUM CSS
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;500;600;700&family=Great+Vibes&family=Lora:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=Outfit:wght@200;300;400;500;600&display=swap');

/* ── Design Tokens ── */
:root {
  --blush:       #F8C8DC;
  --blush-deep:  #E8A0B8;
  --lavender:    #D8C4E9;
  --lavender-deep:#B89FD4;
  --cream:       #FFF8F0;
  --cream-warm:  #FFF1E6;
  --gold:        #D4A853;
  --gold-soft:   #E8C97A;
  --rose:        #C76B8A;
  --rose-dark:   #A04060;
  --plum:        #6E3B5C;
  --midnight:    #1A0E2E;
  --soft-white:  rgba(255,255,255,0.92);

  --font-display: 'Great Vibes', 'Georgia', cursive;
  --font-body:    'Lora', Georgia, serif;
  --font-ui:      'Outfit', -apple-system, sans-serif;

  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-spring:   cubic-bezier(0.22, 1.2, 0.36, 1);

  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 32px;
  --radius-xl: 48px;

  --shadow-soft: 0 4px 30px rgba(200,100,140,0.15);
  --shadow-glow: 0 0 60px rgba(248,200,220,0.4), 0 0 120px rgba(216,196,233,0.2);
  --shadow-card: 0 20px 60px rgba(30,10,40,0.25), 0 4px 20px rgba(200,100,140,0.15);
}

/* ── Reset & Base ── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-body);
  color: var(--cream);
  background: var(--midnight);
  overflow: hidden;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Background Layers ── */
#bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 30% 20%, rgba(110,59,92,0.5) 0%, transparent 70%),
    radial-gradient(ellipse 60% 80% at 70% 80%, rgba(168,120,200,0.3) 0%, transparent 60%),
    radial-gradient(ellipse 90% 70% at 50% 50%, rgba(26,14,46,1) 0%, #0D0618 100%);
}

/* Bokeh lights */
.bokeh {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
  will-change: transform, opacity;
  filter: blur(1px);
}

.bokeh--warm {
  background: radial-gradient(circle, rgba(248,200,220,0.6) 0%, rgba(248,200,220,0) 70%);
}

.bokeh--cool {
  background: radial-gradient(circle, rgba(216,196,233,0.5) 0%, rgba(216,196,233,0) 70%);
}

.bokeh--gold {
  background: radial-gradient(circle, rgba(232,201,122,0.5) 0%, rgba(232,201,122,0) 70%);
}

/* Fireflies */
.firefly {
  position: fixed;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--gold-soft);
  box-shadow: 0 0 8px 3px rgba(232,201,122,0.6), 0 0 20px 6px rgba(232,201,122,0.2);
  pointer-events: none;
  z-index: 2;
  will-change: transform, opacity;
  animation: fireflyGlow 2s ease-in-out infinite alternate;
}

@keyframes fireflyGlow {
  0%   { opacity: 0.3; transform: scale(0.8); }
  100% { opacity: 1;   transform: scale(1.2); }
}

/* ── Main Container ── */
#app {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 20px;
}

/* ── Scratch Card Phase ── */
#scratch-phase {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  transition: opacity 0.8s var(--ease-out-expo), transform 0.8s var(--ease-out-expo);
}

#scratch-phase.hidden {
  opacity: 0;
  transform: scale(0.9) translateY(30px);
  pointer-events: none;
  position: absolute;
}

/* Title above card */
.scratch-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: 400;
  text-align: center;
  background: linear-gradient(135deg, #FFD1E3, #FFFFFF, #FFE4B5, #FFB6D9);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px rgba(255,180,210,0.5)) drop-shadow(0 2px 4px rgba(0,0,0,0.3));
  letter-spacing: 0.02em;
  animation: fadeSlideIn 1.2s var(--ease-out-expo) both, titleShimmer 4s ease-in-out infinite;
}

@keyframes titleShimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.scratch-subtitle {
  font-family: 'Cinzel', Georgia, serif;
  font-size: clamp(0.65rem, 1.8vw, 0.8rem);
  font-weight: 500;
  color: var(--gold-soft);
  text-shadow: 0 0 15px rgba(232,201,122,0.4), 0 1px 2px rgba(0,0,0,0.3);
  letter-spacing: 0.35em;
  text-transform: uppercase;
  margin-top: -2px;
  animation: fadeSlideIn 1.2s var(--ease-out-expo) 0.3s both;
}

/* Card wrapper */
.scratch-card-wrapper {
  position: relative;
  animation: cardEntrance 1.5s var(--ease-spring) 0.5s both;
}

.scratch-card-wrapper::before {
  content: '';
  position: absolute;
  inset: -20px;
  border-radius: var(--radius-xl);
  background: conic-gradient(
    from 0deg,
    rgba(248,200,220,0.3),
    rgba(216,196,233,0.3),
    rgba(232,201,122,0.3),
    rgba(248,200,220,0.3)
  );
  filter: blur(30px);
  animation: glowRotate 8s linear infinite;
  z-index: -1;
}

@keyframes glowRotate {
  to { filter: blur(30px) hue-rotate(360deg); }
}

@keyframes cardEntrance {
  0% {
    opacity: 0;
    transform: scale(0.7) translateY(60px) rotateX(15deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0) rotateX(0);
  }
}

/* Canvas container */
.scratch-card {
  position: relative;
  width: clamp(280px, 80vw, 380px);
  height: clamp(380px, 110vw, 520px);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  cursor: grab;
  touch-action: none;
}

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

/* Hidden image beneath */
.scratch-card__under {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, var(--cream-warm), var(--blush));
  padding: 30px;
  text-align: center;
}

.scratch-card__under-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  animation: heartPulse 1.5s ease-in-out infinite;
}

@keyframes heartPulse {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.15); }
  30% { transform: scale(1); }
  45% { transform: scale(1.1); }
}

.scratch-card__under-text {
  font-family: var(--font-body);
  font-size: 1.15rem;
  font-weight: 600;
  font-style: italic;
  color: var(--rose-dark);
  line-height: 1.7;
  text-shadow: 0 1px 2px rgba(160,64,96,0.15);
}

/* Scratch canvas overlay */
#scratch-canvas {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  width: 100% !important;
  height: 100% !important;
  border-radius: var(--radius-lg);
  z-index: 5;
}

/* Progress bar */
.progress-wrapper {
  width: clamp(280px, 80vw, 380px);
  animation: fadeSlideIn 1.2s var(--ease-out-expo) 1s both;
}

.progress-label {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--blush);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
}

.progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--blush), var(--lavender), var(--gold-soft));
  border-radius: 4px;
  transition: width 0.3s ease;
  box-shadow: 0 0 12px rgba(248,200,220,0.5);
}

/* Scratch particles */
.scratch-particle {
  position: fixed;
  pointer-events: none;
  z-index: 100;
  will-change: transform, opacity;
}

.scratch-particle--sparkle {
  width: 6px;
  height: 6px;
  background: var(--gold-soft);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(232,201,122,0.8);
}

.scratch-particle--heart {
  font-size: 16px;
  line-height: 1;
}

.scratch-particle--dust {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--blush);
  box-shadow: 0 0 4px rgba(248,200,220,0.6);
}

/* ── Reveal Phase ── */
#reveal-phase {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s var(--ease-out-expo);
  overflow-y: auto;
  overflow-x: hidden;
}

#reveal-phase.active {
  opacity: 1;
  pointer-events: all;
}

/* Light burst */
.light-burst {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255,255,255,0.9) 0%,
    rgba(248,200,220,0.4) 40%,
    transparent 70%
  );
  transform: translate(-50%, -50%);
  z-index: 51;
  pointer-events: none;
}

.light-burst.active {
  animation: burstExpand 1.5s var(--ease-out-expo) forwards;
}

@keyframes burstExpand {
  0%   { width: 0;    height: 0;    opacity: 1; }
  50%  { width: 200vmax; height: 200vmax; opacity: 0.6; }
  100% { width: 250vmax; height: 250vmax; opacity: 0; }
}

/* Countdown */
#countdown-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26,14,46,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

#countdown-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.countdown-number {
  font-family: var(--font-display);
  font-size: clamp(5rem, 20vw, 12rem);
  font-weight: 700;
  color: var(--cream);
  text-shadow: 0 0 60px rgba(248,200,220,0.6), 0 0 120px rgba(216,196,233,0.3);
  animation: countPop 0.8s var(--ease-spring) both;
}

@keyframes countPop {
  0%   { opacity: 0; transform: scale(2); }
  60%  { opacity: 1; transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1); }
}

.countdown-number.exit {
  animation: countExit 0.4s ease-in forwards;
}

@keyframes countExit {
  to { opacity: 0; transform: scale(0.5); }
}

/* Reveal background */
.reveal-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 100% 80% at 50% 30%, rgba(110,59,92,0.6) 0%, transparent 60%),
    radial-gradient(ellipse 80% 100% at 50% 80%, rgba(100,60,140,0.4) 0%, transparent 50%),
    linear-gradient(180deg, #1A0E2E 0%, #0D0618 100%);
  z-index: 52;
}

/* Reveal content */
.reveal-content {
  position: relative;
  z-index: 55;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  max-width: 560px;
  padding: 40px 20px;
  width: 100%;
  margin: auto;
}

/* Photo container wrapper (no overflow so butterflies can fly outside) */
.reveal-photo-container {
  position: relative;
  width: clamp(260px, 75vw, 420px);
  margin: 0 auto;
}

/* Photo container */
.reveal-photo-wrap {
  position: relative;
  width: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow:
    0 30px 80px rgba(26,14,46,0.5),
    0 0 0 1px rgba(255,255,255,0.1),
    0 0 80px rgba(248,200,220,0.2);
  opacity: 0;
  transform: scale(0.85) translateY(40px);
  animation: photoReveal 1.8s var(--ease-out-expo) 0.5s forwards;
}

@keyframes photoReveal {
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.reveal-photo-wrap::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--blush), var(--lavender), var(--gold-soft));
  z-index: -1;
  opacity: 0.6;
}

.reveal-photo {
  width: 100%;
  display: block;
  border-radius: var(--radius-lg);
  animation: photoFloat 6s ease-in-out infinite;
}

@keyframes photoFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-8px) scale(1.01); }
}

/* Reveal message */
.reveal-message-wrap {
  text-align: center;
  opacity: 0;
  transform: translateY(30px);
  animation: messageFadeIn 1.5s var(--ease-out-expo) 1.5s forwards;
}

@keyframes messageFadeIn {
  to { opacity: 1; transform: translateY(0); }
}

.reveal-message {
  font-family: var(--font-body);
  font-size: clamp(1.1rem, 3.5vw, 1.5rem);
  font-weight: 400;
  font-style: italic;
  color: #FFF0F5;
  line-height: 1.8;
  text-shadow: 0 0 30px rgba(255,180,210,0.5), 0 2px 4px rgba(0,0,0,0.2);
  letter-spacing: 0.01em;
}

.reveal-message .cursor-blink {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--gold-soft);
  margin-left: 3px;
  vertical-align: text-bottom;
  animation: blink 0.8s step-end infinite;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.reveal-signature {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 3.5vw, 1.6rem);
  color: var(--gold-soft);
  filter: drop-shadow(0 0 10px rgba(232,201,122,0.4));
  margin-top: 4px;
  opacity: 0;
  animation: fadeIn 1s ease 4s forwards;
}

/* Floating hearts */
.floating-heart {
  position: fixed;
  font-size: 20px;
  z-index: 60;
  pointer-events: none;
  will-change: transform, opacity;
  animation: floatUp var(--dur, 6s) var(--delay, 0s) linear forwards;
}

@keyframes floatUp {
  0%   { opacity: 0; transform: translateY(100vh) translateX(0) rotate(0deg) scale(0.5); }
  10%  { opacity: 1; }
  90%  { opacity: 0.8; }
  100% { opacity: 0; transform: translateY(-20vh) translateX(var(--drift, 30px)) rotate(var(--rot, 180deg)) scale(1); }
}

/* Butterflies */
.butterfly {
  position: fixed;
  font-size: 22px;
  z-index: 60;
  pointer-events: none;
  will-change: transform;
  animation: butterflyPath var(--dur, 8s) var(--delay, 0s) ease-in-out forwards;
}

/* Premium 3D Flapping Butterflies */
.real-butterfly {
  position: absolute;
  width: 44px;
  height: 44px;
  pointer-events: none;
  z-index: 70;
  transform-style: preserve-3d;
  will-change: transform;
  top: 0;
  left: 0;
}

.butterfly-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform: rotateX(30deg) rotateY(15deg);
}

.butterfly-body {
  position: absolute;
  width: 3px;
  height: 22px;
  background: #23120b;
  left: 50%;
  top: 11px;
  transform: translateX(-50%);
  border-radius: 2px;
  z-index: 10;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.butterfly-body::before,
.butterfly-body::after {
  content: '';
  position: absolute;
  width: 0.8px;
  height: 8px;
  background: #23120b;
  top: -5px;
  transform-origin: bottom center;
}
.butterfly-body::before {
  left: -1px;
  transform: rotate(-25deg);
}
.butterfly-body::after {
  right: -1px;
  transform: rotate(25deg);
}

.wing {
  position: absolute;
  width: 22px;
  height: 33px;
  top: 5px;
  transform-style: preserve-3d;
  will-change: transform;
}

.wing-left {
  right: 50%;
  transform-origin: right center;
  animation: flap-left var(--flap-dur, 0.18s) infinite alternate ease-in-out;
}

.wing-right {
  left: 50%;
  transform-origin: left center;
  animation: flap-right var(--flap-dur, 0.18s) infinite alternate ease-in-out;
}

.wing svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.25)) drop-shadow(0 0 8px rgba(255,255,255,0.2));
}

@keyframes flap-left {
  0% {
    transform: rotateY(10deg);
  }
  100% {
    transform: rotateY(70deg);
  }
}

@keyframes flap-right {
  0% {
    transform: rotateY(-10deg);
  }
  100% {
    transform: rotateY(-70deg);
  }
}

@keyframes butterflyPath {
  0%   { opacity: 0; transform: translate(0, 0) scale(0.6); }
  10%  { opacity: 1; }
  25%  { transform: translate(calc(var(--dx1, 50px)), calc(var(--dy1, -80px))) scale(0.9) rotate(10deg); }
  50%  { transform: translate(calc(var(--dx2, -30px)), calc(var(--dy2, -160px))) scale(1) rotate(-10deg); }
  75%  { transform: translate(calc(var(--dx3, 60px)), calc(var(--dy3, -240px))) scale(0.8) rotate(5deg); }
  90%  { opacity: 0.6; }
  100% { opacity: 0; transform: translate(calc(var(--dx4, -20px)), calc(var(--dy4, -320px))) scale(0.5) rotate(-15deg); }
}

/* Confetti */
.confetti-piece {
  position: fixed;
  width: 8px;
  height: 12px;
  z-index: 80;
  pointer-events: none;
  will-change: transform, opacity;
  animation: confettiFall var(--dur, 4s) var(--delay, 0s) ease-out forwards;
}

@keyframes confettiFall {
  0%   { opacity: 1; transform: translateY(-10vh) translateX(0) rotate(0deg) scale(1); }
  100% { opacity: 0; transform: translateY(100vh) translateX(var(--drift, 40px)) rotate(var(--rot, 720deg)) scale(0.3); }
}

/* Sparkle dots in reveal */
.reveal-sparkle {
  position: fixed;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--gold-soft);
  pointer-events: none;
  z-index: 65;
  will-change: transform, opacity;
  animation: sparklePop var(--dur, 2s) var(--delay, 0s) ease-out forwards;
}

@keyframes sparklePop {
  0%   { opacity: 0; transform: scale(0); }
  30%  { opacity: 1; transform: scale(1.5); }
  100% { opacity: 0; transform: scale(0) translateY(-40px); }
}

/* ── Replay Button ── */
.replay-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 36px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-xl);
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: var(--cream);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.4s var(--ease-out-expo);
  opacity: 0;
  animation: fadeIn 1s ease 3s forwards;
  z-index: 70;
  position: relative;
  overflow: hidden;
}

.replay-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(248,200,220,0.15), rgba(216,196,233,0.1));
  opacity: 0;
  transition: opacity 0.4s ease;
}

.replay-btn:hover {
  border-color: rgba(248,200,220,0.4);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(248,200,220,0.15);
}

.replay-btn:hover::before {
  opacity: 1;
}

.replay-btn:active {
  transform: translateY(0) scale(0.97);
}

.replay-btn span {
  position: relative;
  z-index: 1;
}

/* ── Audio Toggle ── */
.audio-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--cream);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  opacity: 0;
}

.audio-toggle.visible {
  opacity: 1;
}

.audio-toggle:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(248,200,220,0.3);
  transform: scale(1.08);
}

/* ── Utility Animations ── */
@keyframes fadeSlideIn {
  0%   { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  to { opacity: 1; }
}

/* Heartbeat sync */
.heartbeat-sync {
  animation: heartbeatSync 1.2s ease-in-out infinite;
}

@keyframes heartbeatSync {
  0%   { transform: scale(1); }
  14%  { transform: scale(1.06); }
  28%  { transform: scale(1); }
  42%  { transform: scale(1.04); }
  56%  { transform: scale(1); }
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .scratch-card {
    width: clamp(260px, 85vw, 340px);
    height: clamp(340px, 115vw, 460px);
  }

  .reveal-photo-wrap {
    width: clamp(240px, 85vw, 360px);
  }

  .replay-btn {
    padding: 12px 28px;
    font-size: 0.78rem;
  }
}

@media (min-width: 768px) {
  .scratch-card {
    width: 380px;
    height: 520px;
  }

  .reveal-photo-wrap {
    width: 420px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(248,200,220,0.2); border-radius: 3px; }
