/* =============================================
   Google Fonts
   ============================================= */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,700;1,400&family=Nunito:wght@400;500;600;700;800&display=swap');

/* =============================================
   Variables
   ============================================= */
:root {
  --pink-1: #fdf2f8;
  --pink-2: #fce7f3;
  --pink-3: #fbcfe8;
  --pink-4: #f9a8d4;
  --pink-5: #ec4899;
  --pink-6: #be185d;
  --gold:   #f59e0b;
  --white:  #ffffff;
  --text:   #831843;
  --text-2: #9d174d;
  --text-3: #be185d;
  --radius: 24px;
  --shadow: 0 8px 32px rgba(190, 24, 93, 0.15);
}

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

html, body {
  height: 100%;
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--pink-1);
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* =============================================
   Confetti canvas
   ============================================= */
#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 999;
}

/* =============================================
   Floating emojis background
   ============================================= */
.floaties {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.floaty {
  position: absolute;
  font-size: 1.5rem;
  opacity: 0.18;
  animation: floatUp 12s ease-in-out infinite;
  user-select: none;
}

.f1 { left: 8%;  top: 15%; animation-delay: 0s;    animation-duration: 11s; font-size: 1.8rem; }
.f2 { left: 82%; top: 10%; animation-delay: -3s;   animation-duration: 14s; font-size: 1.2rem; }
.f3 { left: 55%; top: 70%; animation-delay: -6s;   animation-duration: 10s; font-size: 2rem;   }
.f4 { left: 20%; top: 75%; animation-delay: -2s;   animation-duration: 13s; font-size: 1.4rem; }
.f5 { left: 90%; top: 55%; animation-delay: -8s;   animation-duration: 12s; font-size: 1.1rem; }
.f6 { left: 40%; top: 5%;  animation-delay: -4.5s; animation-duration: 15s; font-size: 1.6rem; }

@keyframes floatUp {
  0%, 100% { transform: translateY(0)   rotate(0deg);   opacity: 0.18; }
  33%       { transform: translateY(-20px) rotate(8deg);  opacity: 0.28; }
  66%       { transform: translateY(-10px) rotate(-5deg); opacity: 0.22; }
}

/* =============================================
   Page layout
   ============================================= */
.page {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: env(safe-area-inset-top, 16px) 16px env(safe-area-inset-bottom, 24px);
  gap: 0;
}

/* =============================================
   Hero header
   ============================================= */
.hero {
  width: 100%;
  text-align: center;
  padding: 36px 16px 24px;
  background: linear-gradient(160deg, #fce7f3 0%, #fdf2f8 100%);
  border-radius: 0 0 40px 40px;
  margin: -0px -0px 0 -0px;
  position: relative;
}

.hero::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--pink-3), transparent);
}

.hero-emoji {
  font-size: 3.2rem;
  line-height: 1;
  margin-bottom: 8px;
  display: block;
  animation: crownBob 2.8s ease-in-out infinite;
  filter: drop-shadow(0 4px 8px rgba(245, 158, 11, 0.35));
}

@keyframes crownBob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%       { transform: translateY(-7px) rotate(3deg); }
}

.hero h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 1.05;
  background: linear-gradient(135deg, var(--pink-6) 0%, var(--pink-5) 60%, #f472b6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.hero-sub {
  font-size: 1rem;
  color: var(--text-2);
  line-height: 1.55;
  font-weight: 500;
}

.hero-sub em {
  font-style: italic;
  font-family: 'Playfair Display', Georgia, serif;
  color: var(--pink-5);
  -webkit-text-fill-color: var(--pink-5);
}

/* =============================================
   Form card
   ============================================= */
.form-card {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 0 32px;
}

/* =============================================
   Steps
   ============================================= */
.step {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px 20px;
  box-shadow: var(--shadow);
  border: 1.5px solid var(--pink-3);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.step-label {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 8px;
}

.step-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--pink-5);
  color: var(--white);
  font-size: 0.72rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* =============================================
   Name input
   ============================================= */
#guest-name {
  width: 100%;
  padding: 16px 18px;
  font-family: 'Nunito', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  background: var(--pink-1);
  border: 2px solid var(--pink-3);
  border-radius: 16px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
}

#guest-name::placeholder {
  color: var(--pink-4);
  font-weight: 400;
}

#guest-name:focus {
  border-color: var(--pink-5);
  box-shadow: 0 0 0 4px rgba(236, 72, 153, 0.12);
}

/* =============================================
   Waveform
   ============================================= */
.wave-box {
  background: var(--pink-1);
  border: 1.5px solid var(--pink-3);
  border-radius: 16px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

#waveform {
  width: 100%;
  height: 56px;
  display: block;
}

.wave-idle-text {
  position: absolute;
  font-size: 0.85rem;
  color: var(--pink-4);
  font-weight: 600;
  text-align: center;
  padding: 0 12px;
  pointer-events: none;
}

/* =============================================
   Timer
   ============================================= */
.timer {
  text-align: center;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.8rem;
  font-style: italic;
  color: var(--pink-5);
  letter-spacing: 0.05em;
  line-height: 1;
}

/* =============================================
   Record / Stop buttons
   ============================================= */
.btn-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn-big {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 18px 12px;
  border: none;
  border-radius: 20px;
  font-family: 'Nunito', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.2s;
}

.btn-big:active:not(:disabled) {
  transform: scale(0.94);
}

.btn-big-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.btn-rec {
  background: linear-gradient(145deg, var(--pink-5), var(--pink-6));
  color: var(--white);
  box-shadow: 0 6px 20px rgba(236, 72, 153, 0.4);
}

.btn-rec:hover:not(:disabled) {
  box-shadow: 0 8px 28px rgba(236, 72, 153, 0.5);
  transform: translateY(-2px);
}

.btn-rec.recording {
  animation: recPulse 1.3s ease-in-out infinite;
  background: linear-gradient(145deg, #f43f5e, #be123c);
}

@keyframes recPulse {
  0%, 100% { box-shadow: 0 6px 20px rgba(244, 63, 94, 0.4); }
  50%       { box-shadow: 0 6px 36px rgba(244, 63, 94, 0.7), 0 0 0 10px rgba(244, 63, 94, 0.1); }
}

.btn-stop {
  background: var(--white);
  color: var(--pink-6);
  border: 2px solid var(--pink-3);
  box-shadow: 0 4px 14px rgba(190, 24, 93, 0.1);
}

.btn-stop:hover:not(:disabled) {
  box-shadow: 0 6px 20px rgba(190, 24, 93, 0.18);
  transform: translateY(-2px);
}

.btn-big:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* =============================================
   Playback step
   ============================================= */
.playback-step {
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.92) translateY(12px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

audio {
  width: 100%;
  border-radius: 12px;
  accent-color: var(--pink-5);
  background: var(--pink-1);
}

.btn-send {
  width: 100%;
  padding: 18px;
  border: none;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--gold), #d97706);
  color: var(--white);
  font-family: 'Nunito', sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(245, 158, 11, 0.45);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.2s;
}

.btn-send:active:not(:disabled) { transform: scale(0.95); }
.btn-send:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(245, 158, 11, 0.55);
}
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* =============================================
   Status message
   ============================================= */
.status {
  text-align: center;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-2);
  min-height: 1.4rem;
  padding: 0 8px;
  transition: opacity 0.3s;
}

.status.error   { color: #dc2626; }
.status.success { color: #16a34a; }

/* =============================================
   Success screen
   ============================================= */
.success-page {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: linear-gradient(150deg, #fce7f3 0%, #fbcfe8 50%, #fdf2f8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  animation: fadeIn 0.5s ease both;
}

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

.success-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.success-hearts {
  display: flex;
  gap: 12px;
  font-size: 3rem;
}

.success-hearts span {
  display: inline-block;
  animation: heartPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.success-hearts span:nth-child(1) { animation-delay: 0.0s; }
.success-hearts span:nth-child(2) { animation-delay: 0.1s; }
.success-hearts span:nth-child(3) { animation-delay: 0.2s; }

@keyframes heartPop {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.success-content h2 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--pink-6);
}

.success-content p {
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--text-2);
  font-weight: 500;
  max-width: 300px;
}

.btn-again {
  margin-top: 8px;
  padding: 16px 28px;
  border: none;
  border-radius: 50px;
  background: linear-gradient(135deg, var(--pink-5), var(--pink-6));
  color: var(--white);
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(236, 72, 153, 0.4);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
