:root {
  --primary-pink: #ff6584;
  --primary-hover: #ff4770;
  --secondary-peach: #ffb199;
  --accent-gold: #ffd166;
  --bg-gradient-start: #fff1f3;
  --bg-gradient-end: #ffe4eb;
  --text-dark: #2d132c;
  --text-muted: #805b75;
  --card-bg: rgba(255, 255, 255, 0.88);
  --card-border: rgba(255, 182, 193, 0.45);
  --shadow-soft: 0 20px 40px -15px rgba(255, 101, 132, 0.25);
  --shadow-strong: 0 25px 50px -12px rgba(218, 98, 125, 0.35);
  --radius-pill: 9999px;
  --radius-card: 32px;
  --font-display: 'Fredoka', cursive, sans-serif;
  --font-body: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html, body {
  height: 100%;
  width: 100%;
  overflow-x: hidden;
  font-family: var(--font-body);
  background: linear-gradient(135deg, var(--bg-gradient-start) 0%, #ffe9ef 50%, var(--bg-gradient-end) 100%);
  color: var(--text-dark);
}

/* Canvas Confetti */
#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 100;
}

/* Background floating decorative blobs */
.background-decorations {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.floating-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
  animation: floatAmbient 12s ease-in-out infinite alternate;
}

.blob-1 {
  width: 380px;
  height: 380px;
  background: radial-gradient(circle, #ffccd5, #ffb3c1);
  top: -80px;
  left: -80px;
  animation-duration: 14s;
}

.blob-2 {
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, #ffe5d9, #ffd166);
  bottom: -100px;
  right: -100px;
  animation-duration: 18s;
}

.blob-3 {
  width: 250px;
  height: 250px;
  background: radial-gradient(circle, #e8dff5, #fce1e4);
  top: 40%;
  left: 65%;
  animation-duration: 10s;
}

@keyframes floatAmbient {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(25px, -30px) scale(1.08); }
  100% { transform: translate(-20px, 20px) scale(0.96); }
}

/* Audio control toggle */
.audio-control {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 50;
}

.sound-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-dark);
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  transition: all 0.25s ease;
}

.sound-btn:hover {
  background: rgba(255, 255, 255, 0.95);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(255, 101, 132, 0.2);
}

.sound-btn.muted {
  opacity: 0.7;
  border-color: #e0d0d8;
}

/* App Container */
.app-container {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px;
}

/* Stage container transitions using modern @starting-style */
.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 580px;
  transition: opacity 0.45s cubic-bezier(0.16, 1, 0.3, 1), transform 0.45s cubic-bezier(0.16, 1, 0.3, 1), display 0.45s;
  transition-behavior: allow-discrete;
}

.stage.hidden {
  display: none;
  opacity: 0;
  transform: scale(0.92);
}

@starting-style {
  .stage:not(.hidden) {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
}

/* Mystery Button (State 1) */
.candy-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px 48px;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 4vw, 1.85rem);
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(135deg, #ff758c 0%, #ff527b 100%);
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  outline: none;
  box-shadow: 0 14px 28px -6px rgba(255, 71, 112, 0.45),
              0 6px 0 #d9335b,
              inset 0 2px 4px rgba(255, 255, 255, 0.4);
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.15s ease,
              background 0.3s ease;
  user-select: none;
  overflow: hidden;
  animation: pulseGentle 2.6s ease-in-out infinite;
}

.candy-btn:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 20px 35px -6px rgba(255, 71, 112, 0.55),
              0 8px 0 #d9335b,
              inset 0 2px 5px rgba(255, 255, 255, 0.5);
  background: linear-gradient(135deg, #ff8da1 0%, #ff4770 100%);
}

.candy-btn:active,
.candy-btn.squash {
  transform: translateY(4px) scale(0.96);
  box-shadow: 0 4px 10px rgba(255, 71, 112, 0.3),
              0 2px 0 #d9335b,
              inset 0 1px 2px rgba(0, 0, 0, 0.15);
}

.candy-btn .btn-icon {
  font-size: 1.4em;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
  animation: wiggleIcon 3s ease-in-out infinite;
}

.candy-btn .btn-badge {
  position: absolute;
  top: -10px;
  right: 18px;
  background: #ffd166;
  color: #573a00;
  font-size: 0.65em;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 12px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.12);
  transform: rotate(8deg);
}

.btn-shine {
  position: absolute;
  top: 0;
  left: -120%;
  width: 80%;
  height: 100%;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.45) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: skewX(-25deg);
  animation: shineLoop 4s infinite 1s;
}

.hint-text {
  margin-top: 24px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.2px;
  animation: fadeInHint 1s ease-in;
}

@keyframes pulseGentle {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.025); }
}

@keyframes wiggleIcon {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-12deg) scale(1.15); }
  75% { transform: rotate(12deg) scale(1.15); }
}

@keyframes shineLoop {
  0% { left: -120%; }
  35%, 100% { left: 160%; }
}

@keyframes fadeInHint {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Reveal Stage (Bonjour mon cochon) */
.pig-card {
  width: 100%;
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 2px solid var(--card-border);
  border-radius: var(--radius-card);
  padding: clamp(28px, 6vw, 48px) clamp(20px, 5vw, 40px);
  text-align: center;
  box-shadow: var(--shadow-strong);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

/* Piglet Character Animation */
.pig-container {
  position: relative;
  margin-bottom: 20px;
  animation: pigBounce 2.4s ease-in-out infinite alternate;
}

.pig-svg {
  filter: drop-shadow(0 12px 18px rgba(255, 101, 132, 0.22));
}

.pig-ear {
  transform-origin: 50% 70%;
  animation: earTwitch 3.5s ease-in-out infinite;
}

.ear-right {
  animation-delay: 1.7s;
}

.blush {
  animation: blushPulse 2s ease-in-out infinite alternate;
}

.pig-beret {
  transform-origin: 85px 52px;
  animation: beretTip 4s ease-in-out infinite alternate;
}

.pig-snout-group {
  transform-origin: 100px 124px;
  animation: snoutWiggle 2.8s ease-in-out infinite;
}

.pig-mustache {
  animation: mustacheWiggle 2.8s ease-in-out infinite;
}

@keyframes pigBounce {
  0% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-8px) rotate(-1deg); }
  100% { transform: translateY(2px) rotate(1deg); }
}

@keyframes earTwitch {
  0%, 88%, 100% { transform: rotate(0deg); }
  92% { transform: rotate(-15deg); }
  96% { transform: rotate(8deg); }
}

@keyframes blushPulse {
  0% { opacity: 0.35; transform: scale(0.95); }
  100% { opacity: 0.65; transform: scale(1.1); }
}

@keyframes beretTip {
  0% { transform: translateY(0); }
  100% { transform: translateY(-3px) rotate(2deg); }
}

@keyframes snoutWiggle {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04, 0.96); }
}

@keyframes mustacheWiggle {
  0%, 100% { transform: translate(100px, 145px) scale(0.65) rotate(0deg); }
  50% { transform: translate(100px, 145px) scale(0.68) rotate(-3deg); }
}

/* Reveal Typography */
.reveal-title {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 7vw, 3.4rem);
  font-weight: 700;
  line-height: 1.15;
  color: var(--text-dark);
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px 14px;
}

.reveal-title .word {
  display: inline-block;
  animation: popInWord 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.word-bonjour {
  color: #ff4770;
  animation-delay: 0.05s;
}

.word-mon {
  color: #5a2e52;
  animation-delay: 0.18s;
}

.word-cochon {
  background: linear-gradient(135deg, #ff527b 0%, #d8315b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation-delay: 0.32s;
  text-shadow: 0 4px 12px rgba(255, 82, 123, 0.2);
}

.title-emoji {
  display: inline-block;
  font-size: 0.85em;
  animation: popInWord 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both 0.45s;
}

@keyframes popInWord {
  0% {
    opacity: 0;
    transform: translateY(24px) scale(0.75);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.reveal-subtitle {
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 28px;
  max-width: 440px;
}

/* Action Buttons (Replay) */
.action-buttons {
  display: flex;
  justify-content: center;
  margin-top: 6px;
}

.replay-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  color: #5a2e52;
  background: #ffffff;
  border: 2px solid rgba(255, 101, 132, 0.3);
  border-radius: var(--radius-pill);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.replay-btn:hover {
  border-color: var(--primary-pink);
  color: var(--primary-pink);
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 8px 20px rgba(255, 101, 132, 0.2);
}

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

/* Accessibility: Prefers Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .candy-btn, .pig-container, .pig-ear, .blush, .pig-beret, .pig-snout-group, .pig-mustache {
    animation: none !important;
  }

  .stage {
    transform: none !important;
  }
}
