/* =============================================
   MYSTERY BUTTON — Playful Explosion of Joy
   ============================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --btn-color: #ff6b9d;
  --btn-shadow: #c94f7a;
  --bg-primary: #1a0a2e;
  --bg-secondary: #16213e;
  --text-primary: #fff;
  --text-secondary: #ffecd2;
  --accent1: #ff6b9d;
  --accent2: #ffd93d;
  --accent3: #6bcbff;
  --accent4: #a66cff;
  --accent5: #ff8a5c;
  --glow-color: #ff6b9d;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Fredoka', 'Quicksand', system-ui, sans-serif;
  background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary), #0f3460);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  overflow: hidden;
  cursor: default;
}

.canvas {
  position: fixed; inset: 0; z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='40' fill='none' stroke='%23ffffff' stroke-width='0.5' opacity='0.06'/%3E%3C/svg%3E");
  background-size: 80px 80px;
  opacity: 0.5;
  pointer-events: none;
  animation: canvasDrift 20s linear infinite;
}

@keyframes canvasDrift {
  0% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(20px, -15px) rotate(2deg); }
  50% { transform: translate(-10px, 20px) rotate(-1deg); }
  75% { transform: translate(15px, 10px) rotate(3deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

#particle-canvas {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

main {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  width: 100%;
}

/* ===== MYSTERY CONTAINER ===== */
.mystery-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  animation: containerAppear 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) both;
}

@keyframes containerAppear {
  0% { opacity: 0; transform: scale(0.3) rotate(-10deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

.surround-text {
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: clamp(1rem, 2.5vw, 1.6rem);
  color: var(--text-secondary);
  text-shadow: 0 0 30px rgba(255, 107, 157, 0.3);
  letter-spacing: 0.05em;
  transition: all 0.3s;
}

.top-text {
  animation: floatText 3s ease-in-out infinite;
}

.bottom-text {
  animation: floatText 3s ease-in-out infinite reverse;
}

.wiggle-text {
  display: inline-block;
  animation: wiggle 1.5s ease-in-out infinite;
  color: var(--accent2);
}

@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-5deg) scale(1.05); }
  50% { transform: rotate(3deg) scale(1.1); }
  75% { transform: rotate(-3deg) scale(1.05); }
}

@keyframes floatText {
  0%, 100% { transform: translateY(0); opacity: 0.8; }
  50% { transform: translateY(-6px); opacity: 1; }
}

/* ===== BUTTON WRAPPER ===== */
.button-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 220px;
  height: 220px;
}

.ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid;
  opacity: 0;
  pointer-events: none;
}

.ring-1 {
  width: 100%; height: 100%;
  border-color: var(--accent1);
}

.ring-2 {
  width: 85%; height: 85%;
  border-color: var(--accent2);
}

.ring-3 {
  width: 70%; height: 70%;
  border-color: var(--accent3);
}

.ring.active {
  animation: ringExpand 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

@keyframes ringExpand {
  0% { opacity: 0.8; transform: scale(0.5); }
  100% { opacity: 0; transform: scale(1.8); }
}

/* ===== MYSTERY BUTTON ===== */
.mystery-btn {
  position: relative;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: none;
  background: radial-gradient(circle at 35% 30%, #ff8eb5, var(--btn-color) 50%, var(--btn-shadow));
  color: white;
  font-family: 'Fredoka', sans-serif;
  font-size: 4.5rem;
  font-weight: 700;
  cursor: pointer;
  z-index: 2;
  box-shadow:
    0 12px 0 var(--btn-shadow),
    0 0 40px rgba(255, 107, 157, 0.4),
    inset 0 -4px 8px rgba(0,0,0,0.2),
    inset 0 4px 8px rgba(255,255,255,0.3);
  transition:
    transform 0.15s cubic-bezier(0.68, -0.55, 0.265, 1.55),
    box-shadow 0.15s ease,
    background 0.3s ease,
    border-radius 0.4s ease,
    width 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55),
    height 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

.mystery-btn::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  background: conic-gradient(
    var(--accent1), var(--accent2), var(--accent3),
    var(--accent4), var(--accent5), var(--accent1)
  );
  z-index: -1;
  opacity: 0;
  transition: opacity 0.4s;
  animation: spinGradient 2s linear infinite;
}

@keyframes spinGradient {
  to { transform: rotate(360deg); }
}

.mystery-btn:hover {
  transform: scale(1.08) translateY(-4px);
  box-shadow:
    0 16px 0 var(--btn-shadow),
    0 0 60px rgba(255, 107, 157, 0.6),
    inset 0 -4px 8px rgba(0,0,0,0.2),
    inset 0 4px 8px rgba(255,255,255,0.3);
}

.mystery-btn:active {
  transform: scale(0.92) translateY(6px);
  box-shadow:
    0 4px 0 var(--btn-shadow),
    0 0 30px rgba(255, 107, 157, 0.3);
}

.mystery-btn.glow-active::before {
  opacity: 1;
}

.btn-label {
  position: relative;
  z-index: 1;
  display: block;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  text-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.btn-glow {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.3), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}

.mystery-btn:hover .btn-glow {
  opacity: 1;
}

/* ===== BUTTON TRANSFORM STATES ===== */
.mystery-btn.spinning {
  animation: btnSpin 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes btnSpin {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.3); }
  100% { transform: rotate(360deg) scale(1); }
}

.mystery-btn.bouncing {
  animation: btnBounce 0.8s cubic-bezier(0.68, -0.55, 0.265, 2);
}

@keyframes btnBounce {
  0% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-120px) scale(1.2) rotate(10deg); }
  50% { transform: translateY(-60px) scale(1.1) rotate(-5deg); }
  70% { transform: translateY(-100px) scale(1.15) rotate(8deg); }
  85% { transform: translateY(-50px) scale(1.05) rotate(-3deg); }
  100% { transform: translateY(0) scale(1) rotate(0deg); }
}

.mystery-btn.square-morph {
  border-radius: 30px !important;
  animation: shapeShift 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes shapeShift {
  0% { border-radius: 50%; }
  50% { border-radius: 10px; transform: scale(0.9) rotate(45deg); }
  100% { border-radius: 50%; }
}

.mystery-btn.pulse-wild {
  animation: pulseWild 0.8s ease-in-out;
}

@keyframes pulseWild {
  0% { transform: scale(1); }
  25% { transform: scale(1.4); }
  50% { transform: scale(0.7); }
  75% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* ===== MESSAGE AREA ===== */
.message-area {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  pointer-events: none;
  text-align: center;
}

.message {
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: clamp(2rem, 6vw, 5rem);
  color: white;
  text-shadow:
    0 0 20px rgba(255,107,157,0.8),
    0 0 60px rgba(255,107,157,0.4),
    0 4px 0 var(--btn-shadow);
  animation: messagePop 2s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
  white-space: nowrap;
}

@keyframes messagePop {
  0% { opacity: 0; transform: scale(0.1) rotate(-20deg); }
  30% { opacity: 1; transform: scale(1.3) rotate(5deg); }
  50% { transform: scale(0.95) rotate(-2deg); }
  70% { transform: scale(1.05) rotate(1deg); }
  100% { opacity: 0; transform: scale(0.5) rotate(10deg) translateY(-80px); }
}

/* ===== EMOJI RAIN ===== */
.emoji-rain {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  overflow: hidden;
}

.emoji-drop {
  position: absolute;
  top: -60px;
  font-size: clamp(1.5rem, 4vw, 3rem);
  animation: emojiFall linear forwards;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

@keyframes emojiFall {
  0% { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
  80% { opacity: 0.9; }
  100% { transform: translateY(110vh) rotate(720deg) scale(0.5); opacity: 0; }
}

/* ===== FIREWORKS ===== */
.fireworks-container {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.firework {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  animation: fireworkBurst 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes fireworkBurst {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { opacity: 0; }
}

/* ===== SPARKLES ===== */
.sparkles-container {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
}

.sparkle {
  position: absolute;
  width: 12px;
  height: 12px;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  animation: sparkleFade 1.5s ease-out forwards;
  filter: drop-shadow(0 0 6px currentColor);
}

@keyframes sparkleFade {
  0% { transform: scale(0) rotate(0deg); opacity: 1; }
  50% { transform: scale(1.5) rotate(180deg); opacity: 1; }
  100% { transform: scale(0) rotate(360deg); opacity: 0; }
}

/* ===== GLITCH OVERLAY ===== */
#glitch-overlay {
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(0deg, rgba(0,255,255,0.1) 0%, transparent 10%, rgba(255,0,255,0.1) 20%, transparent 30%, rgba(0,255,255,0.1) 40%, transparent 50%, rgba(255,0,255,0.1) 60%, transparent 70%, rgba(0,255,255,0.1) 80%, transparent 90%, rgba(255,0,255,0.1) 100%);
  background-size: 100% 8px;
  mix-blend-mode: overlay;
  transition: opacity 0.1s;
}

#glitch-overlay.active {
  animation: glitchFlash 0.4s ease-in-out 3;
}

@keyframes glitchFlash {
  0% { opacity: 0; transform: translate(0); }
  20% { opacity: 0.8; transform: translate(-3px, 2px); }
  40% { opacity: 0; transform: translate(3px, -2px); }
  60% { opacity: 0.6; transform: translate(-2px, -1px); }
  80% { opacity: 0.9; transform: translate(2px, 3px); }
  100% { opacity: 0; transform: translate(0); }
}

/* ===== MASCOT ===== */
.mascot {
  position: fixed;
  bottom: -80px;
  right: 40px;
  font-size: 5rem;
  z-index: 7;
  pointer-events: none;
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  filter: drop-shadow(0 8px 20px rgba(0,0,0,0.4));
}

.mascot.active {
  opacity: 1;
  bottom: 60px;
  animation: mascotDance 0.6s ease-in-out 3;
}

@keyframes mascotDance {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-20px) rotate(-15deg) scale(1.2); }
  50% { transform: translateY(-10px) rotate(10deg) scale(1.1); }
  75% { transform: translateY(-25px) rotate(-5deg) scale(1.3); }
}

/* ===== COUNTER ===== */
.counter-display {
  position: fixed;
  top: 24px;
  right: 30px;
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 2.5rem;
  color: rgba(255,255,255,0.15);
  z-index: 8;
  transition: all 0.3s;
  user-select: none;
}

.counter-display.pop {
  animation: counterPop 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  color: rgba(255,255,255,0.6);
}

@keyframes counterPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.8); color: var(--accent2); }
  100% { transform: scale(1); }
}

/* ===== FOOTER ===== */
footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 3;
  text-align: center;
  padding: 16px;
}

.footer-text {
  font-family: 'Quicksand', sans-serif;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.25);
  letter-spacing: 0.15em;
  transition: color 0.3s;
}

/* ===== SHAKE EFFECT ON BODY ===== */
body.shaking {
  animation: screenShake 0.5s ease-in-out;
}

@keyframes screenShake {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-8px, 6px); }
  20% { transform: translate(8px, -4px); }
  30% { transform: translate(-6px, 8px); }
  40% { transform: translate(6px, -7px); }
  50% { transform: translate(-9px, 5px); }
  60% { transform: translate(7px, -3px); }
  70% { transform: translate(-5px, 9px); }
  80% { transform: translate(5px, -6px); }
  90% { transform: translate(-7px, 4px); }
}

/* ===== SCREEN FLASH OVERLAY ===== */
.screen-flash {
  position: fixed;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
}

.screen-flash.active {
  animation: flashBurst 0.6s ease-out forwards;
}

@keyframes flashBurst {
  0% { opacity: 0.9; }
  100% { opacity: 0; }
}

/* ===== CONFETTI CANVAS (legacy support) ===== */
#confetti-canvas {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .mystery-btn {
    width: 120px;
    height: 120px;
    font-size: 3.5rem;
  }
  .button-wrapper {
    width: 170px;
    height: 170px;
  }
  .mascot {
    font-size: 3.5rem;
    right: 16px;
  }
  .mascot.active { bottom: 40px; }
  .counter-display {
    font-size: 1.8rem;
    top: 16px;
    right: 16px;
  }
}