/* Breathing Idle State */
#hamster-body, #hamster-belly {
  transform-origin: bottom center;
  animation: breathing 4s ease-in-out infinite;
}

/* Eyes Blinking State */
#eye-left-group, #eye-right-group {
  transform-origin: 115px 150px;
  animation: blinking 5s infinite;
}
#eye-right-group {
  transform-origin: 185px 150px;
}

/* State Class Triggers */

/* 1. Chewing Mode */
.hamster-svg.chewing {
  animation: chewing-cheeks 0.35s ease-in-out infinite;
}

/* 2. Happy Mode (Fullness 100%) */
.hamster-svg.happy {
  animation: happy-bounce 0.75s ease-in-out infinite;
}

/* 3. Spicy Mode */
.hamster-svg.spicy-shake {
  animation: spicy-shudder 0.12s ease-in-out infinite;
}

/* 4. Thief Bird Wing Flaps */
.thief-bird .bird-wing {
  transform-origin: 16px 16px;
  animation: wing-flap 0.15s ease-in-out infinite alternate;
}

/* ---------------------------------------------------- */
/* Animation Keyframes */
/* ---------------------------------------------------- */

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

@keyframes wave {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-8deg); }
  75% { transform: rotate(8deg); }
}

@keyframes guide-tap {
  0%, 100% { transform: translateY(0) scale(1); }
  45% { transform: translateY(3px) scale(0.94); }
  70% { transform: translateY(0) scale(1.03); }
}

/* Idle Breathing (Body slightly expands and contracts) */
@keyframes breathing {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.025, 0.98);
  }
}

/* Idle Eye Blink */
@keyframes blinking {
  0%, 96%, 100% {
    transform: scaleY(1);
  }
  98% {
    transform: scaleY(0.1);
  }
}

/* Chew Animation (Pulsating cheeks & minor body wobble) */
@keyframes chewing-cheeks {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04, 0.95);
  }
}

/* Happy Satiety Jumping Bounce */
@keyframes happy-bounce {
  0%, 100% {
    transform: translateY(0) scale(1);
  }
  40% {
    transform: translateY(-28px) scale(0.95, 1.05);
  }
  65% {
    transform: translateY(4px) scale(1.06, 0.9);
  }
  80% {
    transform: translateY(-4px) scale(0.98, 1.02);
  }
}

/* Heart particles fly away path */
@keyframes heart-fly {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(0.5) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(1.2) rotate(var(--rot));
  }
}

/* Spicy shuddering shake */
@keyframes spicy-shudder {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
  20% { transform: translate3d(-4px, 2px, 0) rotate(-1.5deg); }
  40% { transform: translate3d(3px, -2px, 0) rotate(2deg); }
  60% { transform: translate3d(-3px, -3px, 0) rotate(-1.5deg); }
  80% { transform: translate3d(4px, 3px, 0) rotate(1.5deg); }
}

/* Wing flapping sparrow wing */
@keyframes wing-flap {
  0% { transform: scaleY(1.0) translateY(0px); }
  100% { transform: scaleY(0.1) translateY(4px); }
}

/* Crisis Mode pulsing alarm - Intensified */
@keyframes crisis-bg-pulse {
  0% {
    filter: saturate(1.0) brightness(1.0) hue-rotate(0deg);
    box-shadow: inset 0 0 40px rgba(255, 40, 40, 0.2);
  }
  12% {
    filter: saturate(2.2) brightness(0.72) hue-rotate(-8deg);
    box-shadow: inset 0 0 180px rgba(255, 20, 20, 0.85);
  }
  25% {
    filter: saturate(1.1) brightness(1.0) hue-rotate(0deg);
    box-shadow: inset 0 0 50px rgba(255, 77, 77, 0.25);
  }
  38% {
    filter: saturate(2.5) brightness(0.65) hue-rotate(-12deg);
    box-shadow: inset 0 0 220px rgba(255, 0, 0, 0.95);
  }
  55% {
    filter: saturate(1.0) brightness(1.02) hue-rotate(0deg);
    box-shadow: inset 0 0 30px rgba(255, 77, 77, 0.15);
  }
  70% {
    filter: saturate(2.0) brightness(0.75) hue-rotate(-6deg);
    box-shadow: inset 0 0 160px rgba(255, 30, 30, 0.78);
  }
  85% {
    filter: saturate(1.05) brightness(0.98) hue-rotate(0deg);
    box-shadow: inset 0 0 40px rgba(255, 77, 77, 0.2);
  }
  100% {
    filter: saturate(2.8) brightness(0.60) hue-rotate(-15deg);
    box-shadow: inset 0 0 250px rgba(255, 0, 0, 1.0);
  }
}

@keyframes crisis-card-pulse {
  0% {
    box-shadow: 
      0 20px 40px -15px hsla(356, 50%, 30%, 0.15),
      0 0 8px rgba(255, 77, 77, 0.1),
      inset 0 1px 2px 0 rgba(255, 255, 255, 0.8);
    border-color: rgba(255, 77, 77, 0.25);
  }
  50% {
    box-shadow: 
      0 20px 40px -15px hsla(356, 80%, 25%, 0.35),
      0 0 50px rgba(255, 40, 40, 0.7),
      0 0 0 3px rgba(255, 60, 60, 0.3),
      inset 0 1px 2px 0 rgba(255, 255, 255, 0.8);
    border-color: rgba(255, 60, 60, 0.8);
  }
  100% {
    box-shadow: 
      0 20px 40px -15px hsla(356, 50%, 30%, 0.2),
      0 0 20px rgba(255, 77, 77, 0.45),
      inset 0 1px 2px 0 rgba(255, 255, 255, 0.8);
    border-color: rgba(255, 77, 77, 0.6);
  }
}

/* Bad Ending - Hamster Turns Around & Trots Away */
/* Step 1: hesitate/turn in place, Step 2: trot left with body bob */
@keyframes hamster-turn {
  0%   { transform: scaleX(1) translateX(0);   }
  18%  { transform: scaleX(0.85) translateX(-8px);  }
  35%  { transform: scaleX(-1) translateX(-14px); }
  100% { transform: scaleX(-1) translateX(-14px); }
}

@keyframes hamster-trot {
  0%   { transform: scaleX(-1) translateX(-14px) translateY(0);    }
  12%  { transform: scaleX(-1) translateX(-80px) translateY(-5px); }
  25%  { transform: scaleX(-1) translateX(-145px) translateY(0);   }
  37%  { transform: scaleX(-1) translateX(-200px) translateY(-5px);}
  50%  { transform: scaleX(-1) translateX(-260px) translateY(0);   }
  62%  { transform: scaleX(-1) translateX(-310px) translateY(-4px);}
  75%  { transform: scaleX(-1) translateX(-355px) translateY(0);   }
  88%  { transform: scaleX(-1) translateX(-390px) translateY(-3px); opacity: 1; }
  100% { transform: scaleX(-1) translateX(-430px) translateY(0);   opacity: 0; }
}

.hamster-wrapper.running-away .hamster-svg {
  animation:
    hamster-turn 0.4s cubic-bezier(0.4, 0, 0.6, 1) forwards,
    hamster-trot 1.1s 0.35s cubic-bezier(0.4, 0, 0.6, 1) forwards;
  pointer-events: none;
}

/* Floating dust motes (arena background) */
@keyframes dust-float {
  0%   { transform: translate(0, 0)   scale(1);   opacity: 0.55; }
  25%  { transform: translate(6px, -8px)  scale(1.1); opacity: 0.7;  }
  50%  { transform: translate(-4px,-14px) scale(0.9); opacity: 0.6;  }
  75%  { transform: translate(8px, -20px) scale(1.05); opacity: 0.4; }
  100% { transform: translate(2px, -28px) scale(0.8); opacity: 0;   }
}

/* Good Ending Overlay pop-in */
@keyframes good-ending-pop {
  0%   { opacity: 0; transform: scale(0.7) translateY(30px); }
  55%  { opacity: 1; transform: scale(1.06) translateY(-6px); }
  75%  { transform: scale(0.97) translateY(2px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
