* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body, html {
  width: 100%;
  height: 100dvh;
  font-family: 'Lato', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  background-color: #111;
  color: #fff;
}

/* Dynamic Gradient Background */
body.gradient-bg {
  background-size: 400% 400%;
}

.hidden {
  display: none !important;
}

/* Error Container */
#error-container {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: center;
}
.error-card {
  background: rgba(255, 255, 255, 0.1);
  padding: 2rem;
  border-radius: 12px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  text-align: center;
}

/* App Container */
#app-container {
  width: 100%;
  height: 100%;
  position: relative;
}

/* Top Bar */
.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 12px 8px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.5), transparent);
}

.progress-container {
  display: flex;
  gap: 4px;
  width: 100%;
}

.progress-segment {
  flex: 1;
  height: 3px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: #fff;
  transition: width 0.1s linear;
}

.header-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
}

#recipient-name {
  font-weight: 600;
  font-size: 14px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.mute-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Swiper Configuration */
.swiper {
  width: 100%;
  height: 100%;
}
.swiper-slide {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
  padding: 72px 24px 32px 24px;
}

/* Envelope Animation Sequence */
.envelope-wrapper {
  position: relative;
  width: 320px;
  height: 220px;
  perspective: 1000px;
  animation: flyUpEnvelope 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  transform: translateY(100vh);
  z-index: 10;
}

@keyframes flyUpEnvelope {
  0% { transform: translateY(100vh) scale(0.8); }
  100% { transform: translateY(0) scale(1); }
}

.envelope {
  position: relative;
  width: 100%;
  height: 100%;
  background: #cba135; /* Premium gold base */
  border-radius: 6px;
  box-shadow: 0 15px 40px rgba(0,0,0,0.4);
}

.envelope::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #a67c00; /* Darker inside */
  border-radius: 6px;
  z-index: 1;
}

.envelope-pocket {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #e4c568 0%, #cba135 100%);
  border-radius: 6px;
  z-index: 3;
  clip-path: polygon(0 0, 50% 45%, 100% 0, 100% 100%, 0 100%);
  box-shadow: inset 0 2px 5px rgba(255,255,255,0.2);
}

.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #d4af37;
  clip-path: polygon(0 0, 100% 0, 50% 55%);
  z-index: 4;
  transform-origin: top;
  border-radius: 6px 6px 0 0;
  animation: openFlap 0.8s 1.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes openFlap {
  to { 
    transform: rotateX(180deg); 
    z-index: 0; 
  }
}

.envelope-letter {
  position: absolute;
  top: 10px;
  height: 200px;
  box-sizing: border-box;
  left: 10px;
  right: 10px;
  background: #fff;
  border-radius: 8px;
  padding: 30px 20px;
  z-index: 2;
  box-shadow: 0 -5px 15px rgba(0,0,0,0.1);
  color: #222;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  /* Letter slides out and scales slightly so the button is clickable and prominent */
  animation: extractLetter 1.2s 1.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes extractLetter {
  0% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-130%) scale(1); z-index: 2; }
  100% { transform: translateY(-100px) scale(1.1); z-index: 5; }
}

.slide-intro {
  text-align: center;
  width: 100%;
}

.slide-intro h1 {
  font-family: 'Hammersmith One', sans-serif;
  font-size: 2rem;
  margin-bottom: 0.8rem;
  color: #111;
  text-shadow: none;
}

.slide-intro p {
  font-family: 'Lato', sans-serif;
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
  color: #555;
  font-weight: 300;
}

.start-btn {
  background: #111;
  color: #fff;
  border: none;
  padding: 14px 36px;
  font-family: 'Lato', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s;
  pointer-events: auto;
  position: relative;
  z-index: 200;
}

.start-btn:active {
  transform: scale(0.92);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.media-container {
  width: 100%;
  height: 100%;
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  transform: translateZ(0); /* Force clip for ken burns inside */
}

.slide-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0;
  left: 0;
  transform: scale(1.01);
  transition: opacity 0.5s ease;
}

/* High Class fluidity: Apply Ken Burns on active slide */
.swiper-slide-active .slide-image {
  animation: kenBurns 8s ease-out forwards;
}

@keyframes kenBurns {
  0% { transform: scale(1.01) translateZ(0); }
  100% { transform: scale(1.08) translateZ(0); }
}

.caption {
  position: absolute;
  bottom: 40px;
  left: 20px;
  right: 20px;
  text-align: center;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 14px;
  border-radius: 16px;
  font-size: 1rem;
  font-weight: 400;
  color: #fff;
  z-index: 10;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  opacity: 0;
  transform: translateY(10px);
}

.swiper-slide-active .caption {
  animation: fadeUpCaption 0.8s 0.3s forwards ease-out;
}

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

.slide-quote .quote-container {
  padding: 2.5rem;
  text-align: center;
  position: relative;
  z-index: 10;
}

.slide-quote blockquote {
  font-family: 'Playwrite NL', cursive;
  font-size: 2.2rem;
  margin-bottom: 1.5rem;
  line-height: 1.4;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.slide-quote .quote-caption {
  font-family: 'Lato', sans-serif;
  font-size: 1.1rem;
  font-weight: 300;
  opacity: 0.9;
  letter-spacing: 0.5px;
}

/* Confetti */
.confetti-container {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  z-index: 20; 
}
.confetti {
  position: absolute;
  width: 16px;
  height: 24px;
  border-radius: 2px;
  opacity: 0;
  animation: confettiBurst ease-out forwards;
}
@keyframes confettiBurst {
  0% { transform: translate(0, 0) scale(0) rotate(0deg); opacity: 1; }
  20% { transform: translate(calc(var(--tx) * 0.5), calc(var(--ty) * 0.5)) scale(1) rotate(calc(var(--rot) * 0.5)); opacity: 1; }
  100% { transform: translate(var(--tx), var(--ty)) rotate(var(--rot)); opacity: 0; }
}
