* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 50%, #ff9a9e 100%);
  font-family: 'Quicksand', sans-serif;
  color: #5a3d4a;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  transition: background 1s ease;
  pointer-events: none;
  z-index: 5;
}

body.flying::after {
  background: rgba(0, 0, 0, 0.25);
}

.bg-orbs {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.8;
}

.orb-1 {
  width: 45vmax;
  height: 45vmax;
  background: #ff9a9e;
  top: -15vmax;
  left: -15vmax;
  animation: float 12s infinite ease-in-out;
}

.orb-2 {
  width: 50vmax;
  height: 50vmax;
  background: #fecfef;
  bottom: -20vmax;
  right: -20vmax;
  animation: float 15s infinite ease-in-out reverse;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(10vmax, -10vmax) scale(1.15); }
}

.state {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: absolute;
  width: 90%;
  max-width: 500px;
  z-index: 10;
}

.state.active {
  display: flex;
}

#initialState {
  opacity: 1;
  transform: scale(1);
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#initialState.hidden {
  opacity: 0;
  transform: scale(0.7);
  filter: blur(15px);
  pointer-events: none;
}

#heartState {
  opacity: 0;
  transform: scale(0.3);
  transition: opacity 0.5s ease, transform 0.9s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#heartState.active {
  opacity: 1;
  transform: scale(1);
}

.subtitle {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(2.5rem, 8vw, 4rem);
  margin-bottom: 3rem;
  color: #fff;
  text-shadow: 0 4px 20px rgba(255, 107, 107, 0.5);
  line-height: 1.2;
}

button {
  position: relative;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.1));
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 60px;
  padding: 22px 50px;
  font-size: clamp(1rem, 4vw, 1.3rem);
  font-family: 'Quicksand', sans-serif;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 
    0 10px 30px rgba(255, 107, 107, 0.4),
    inset 0 0 20px rgba(255, 255, 255, 0.2);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  overflow: hidden;
}

button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  transition: left 0.6s ease;
}

button:hover::before {
  left: 100%;
}

button:hover {
  transform: translateY(-6px) scale(1.05);
  box-shadow: 
    0 20px 40px rgba(255, 107, 107, 0.6),
    inset 0 0 30px rgba(255, 255, 255, 0.3);
  border-color: #fff;
}

button.popped {
  transform: scale(0) rotate(10deg);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#trailContainer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 98;
}

.trail-particle {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle at 45% 45%, var(--c2), var(--c) 55%, transparent 100%);
  filter: blur(1.5px);
  pointer-events: none;
  animation: trailFade var(--life) ease-out forwards;
}

@keyframes trailFade {
  0% {
    opacity: var(--o);
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.1);
  }
}

#explosionContainer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
}

#mergeGlow {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 220px;
  height: 220px;
  transform: translate(-50%, -50%) scale(0);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.9) 0%, rgba(255, 71, 87, 0.7) 35%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 99;
  opacity: 0;
}

#mergeGlow.pulse {
  animation: mergePulse 0.9s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes mergePulse {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  35% { transform: translate(-50%, -50%) scale(1.4); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
}

#mergeRing {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
  pointer-events: none;
  z-index: 99;
  box-shadow: 0 0 30px rgba(255, 71, 87, 0.8), inset 0 0 20px rgba(255, 71, 87, 0.6);
}

#mergeRing.pulse {
  animation: ringOut 0.9s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes ringOut {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(7); opacity: 0; }
}

.flyer {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  animation: flyerMain var(--dur) cubic-bezier(0.22, 1, 0.36, 1) var(--delay) forwards;
}

@keyframes flyerMain {
  0% {
    transform: translate(var(--start-x), var(--start-y)) scale(0);
    opacity: 0;
  }
  10% {
    transform: translate(var(--burst-x), var(--burst-y)) scale(1.25);
    opacity: 1;
  }
  24% {
    transform: translate(var(--burst-x), var(--burst-y)) scale(1);
  }
  82% {
    transform: translate(var(--end-x), var(--end-y)) scale(0.9);
    opacity: 1;
  }
  94% {
    transform: translate(var(--end-x), var(--end-y)) scale(0.35);
    opacity: 0.9;
  }
  100% {
    transform: translate(var(--end-x), var(--end-y)) scale(0);
    opacity: 0;
  }
}

.flyer-curve {
  animation: flyerCurve var(--dur) cubic-bezier(0.45, 0, 0.55, 1) var(--delay) forwards;
}

@keyframes flyerCurve {
  0%, 12%, 100% { transform: translate(0, 0); }
  45% { transform: translate(var(--curve-x), var(--curve-y)); }
  78% { transform: translate(calc(var(--curve-x) * -0.3), calc(var(--curve-y) * -0.3)); }
}

.flyer-orient {
  animation: flyerOrient var(--dur) ease-in-out var(--delay) forwards;
}

@keyframes flyerOrient {
  0%, 16% { transform: rotate(var(--out-rot)); }
  42%, 100% { transform: rotate(var(--in-rot)); }
}

.flyer-wobble {
  animation: flyerWobble 0.5s ease-in-out var(--delay) infinite alternate;
}

@keyframes flyerWobble {
  0% { transform: rotate(-10deg); }
  100% { transform: rotate(10deg); }
}

.flyer-breathe {
  animation: flyerBreathe 1.1s ease-in-out var(--delay) infinite alternate;
}

@keyframes flyerBreathe {
  0% { transform: scale(0.9); }
  100% { transform: scale(1.1); }
}

.heart-visual {
  position: absolute;
  left: -18px;
  top: -18px;
  width: 36px;
  height: 36px;
}

.heart-visual::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 35% 30%, var(--c2), var(--c) 65%);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z'/%3E%3C/svg%3E") center/contain no-repeat;
  filter: drop-shadow(0 0 10px var(--c)) drop-shadow(0 0 22px var(--c));
}

.heart-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.heart-container::before {
  content: '';
  position: absolute;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(255, 71, 87, 0.4) 0%, transparent 70%);
  border-radius: 50%;
  animation: pulseAura 1.5s infinite ease-in-out;
  z-index: -1;
}

@keyframes pulseAura {
  0%, 100% { transform: scale(0.8); opacity: 0.5; }
  50% { transform: scale(1.2); opacity: 0.9; }
}

.heart {
  width: 120px;
  position: relative;
  margin-top: 20px;
  animation: heartbeat 1.5s infinite ease-in-out;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.15); }
  30% { transform: scale(1); }
  45% { transform: scale(1.1); }
  60% { transform: scale(1); }
}

.heart-piece {
  top: -5px;
  width: 10px;
  height: 10px;
  position: absolute;
  border-radius: 5px;
  background: linear-gradient(180deg, #ff6b6b, #ff4757);
  box-shadow: 0 0 20px rgba(255, 71, 87, 0.8);
}

@keyframes assemble {
  0% { transform: translateX(var(--ax)) scale(0); opacity: 0; }
  55% { opacity: 1; }
  100% { transform: translateX(0) scale(1); opacity: 1; }
}

.heart-piece:nth-child(1), .heart-piece:nth-child(9) { animation: piece-1 3.2s infinite 0s, assemble 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.28s both; }
.heart-piece:nth-child(2), .heart-piece:nth-child(8) { animation: piece-2 3.2s infinite 0.15s, assemble 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.21s both; }
.heart-piece:nth-child(3), .heart-piece:nth-child(7) { animation: piece-3 3.2s infinite 0.3s, assemble 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.14s both; }
.heart-piece:nth-child(4), .heart-piece:nth-child(6) { animation: piece-4 3.2s infinite 0.45s, assemble 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.07s both; }
.heart-piece:nth-child(5) { animation: piece-5 3.2s infinite 0.6s, assemble 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0s both; }

.heart-piece:nth-child(1) { left: 0; --ax: 64px; }
.heart-piece:nth-child(2) { left: 16px; --ax: 48px; }
.heart-piece:nth-child(3) { left: 32px; --ax: 32px; }
.heart-piece:nth-child(4) { left: 48px; --ax: 16px; }
.heart-piece:nth-child(5) { left: 64px; --ax: 0px; }
.heart-piece:nth-child(6) { left: 80px; --ax: -16px; }
.heart-piece:nth-child(7) { left: 96px; --ax: -32px; }
.heart-piece:nth-child(8) { left: 112px; --ax: -48px; }
.heart-piece:nth-child(9) { left: 128px; --ax: -64px; }

@keyframes piece-5 {
  0%, 10%, 90%, 100% { height: 10px; top: -5px; }
  45%, 55% { height: 94px; top: -23px; }
}

@keyframes piece-4 {
  0%, 10%, 90%, 100% { height: 10px; top: -5px; }
  45%, 55% { height: 90px; top: -31px; }
}

@keyframes piece-3 {
  0%, 10%, 90%, 100% { height: 10px; top: -5px; }
  45%, 55% { height: 80px; top: -37px; }
}

@keyframes piece-2 {
  0%, 10%, 90%, 100% { height: 10px; top: -5px; }
  45%, 55% { height: 60px; top: -31px; }
}

@keyframes piece-1 {
  0%, 10%, 90%, 100% { height: 10px; top: -5px; }
  45%, 55% { height: 30px; top: -15px; }
}