/* ══════════════════════════════════════════
   PET CREATURE — Pure CSS, no images
   Built with border-radius, gradients,
   box-shadow, and pseudo-elements
   ══════════════════════════════════════════ */

/* ── Pet container ── */
.pet {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  /* Sits below .particles (z-index 27) so floating XP/crit popups render in
     front of the creature. The thought bubble lives outside this stacking
     context (sibling of .pet) so it can rise above the popups. */
  z-index: 26;
  transform: translateX(-50%);
  transition: filter 0.5s ease, transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Scale the pet up as it evolves — bigger creatures fill more of the scene.
   Capped at adult+ so the speech bubble + scene can fit the larger evolutions. */
.pet                 { --pet-scale: 1; }
.pet.stage-egg       { --pet-scale: 0.8;  transform: translateX(-50%) scale(0.8); }
.pet.stage-baby      { --pet-scale: 1.0;  transform: translateX(-50%) scale(1.0); }
.pet.stage-child     { --pet-scale: 1.15; transform: translateX(-50%) scale(1.15); }
.pet.stage-teen      { --pet-scale: 1.3;  transform: translateX(-50%) scale(1.3); }
.pet.stage-adult     { --pet-scale: 1.4;  transform: translateX(-50%) scale(1.4); }
.pet.stage-elder     { --pet-scale: 1.45; transform: translateX(-50%) scale(1.45); }
.pet.stage-ancient   { --pet-scale: 1.5;  transform: translateX(-50%) scale(1.5); }
.pet.stage-mythic    { --pet-scale: 1.55; transform: translateX(-50%) scale(1.55); }
.pet.stage-celestial { --pet-scale: 1.6;  transform: translateX(-50%) scale(1.6); }

/* Mirror --pet-scale onto the scene so siblings of .pet (e.g. the
   thought-bubble, which lives outside the pet's stacking context) can
   anchor themselves above the visually-scaled creature. */
.pet-card__scene:has(.pet.stage-egg)       { --pet-scale: 0.8; }
.pet-card__scene:has(.pet.stage-baby)      { --pet-scale: 1.0; }
.pet-card__scene:has(.pet.stage-child)     { --pet-scale: 1.15; }
.pet-card__scene:has(.pet.stage-teen)      { --pet-scale: 1.3; }
.pet-card__scene:has(.pet.stage-adult)     { --pet-scale: 1.4; }
.pet-card__scene:has(.pet.stage-elder)     { --pet-scale: 1.45; }
.pet-card__scene:has(.pet.stage-ancient)   { --pet-scale: 1.5; }
.pet-card__scene:has(.pet.stage-mythic)    { --pet-scale: 1.55; }
.pet-card__scene:has(.pet.stage-celestial) { --pet-scale: 1.6; }

.pet:active {
  filter: brightness(1.2);
}

/* ── Shared idle animations ── */
.pet-body {
  position: relative;
  animation: breathe var(--breathe-speed) ease-in-out infinite;
  transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes breathe {
  0%, 100% { transform: scaleY(1) scaleX(1); }
  50% { transform: scaleY(1.04) scaleX(0.97); }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

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

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  33% { transform: translateY(-6px) rotate(1deg); }
  66% { transform: translateY(-3px) rotate(-1deg); }
}

/* ══════════════════════════════════════════
   STAGE 0: EGG
   ══════════════════════════════════════════ */
.pet-egg {
  width: 70px;
  height: 90px;
  background: linear-gradient(
    160deg,
    hsl(45, 90%, 85%) 0%,
    hsl(35, 80%, 75%) 40%,
    hsl(25, 70%, 65%) 100%
  );
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  position: relative;
  animation: egg-wobble 2s ease-in-out infinite;
  box-shadow:
    inset -8px -8px 20px hsla(25, 60%, 50%, 0.3),
    inset 5px 5px 15px hsla(45, 100%, 95%, 0.4),
    0 8px 25px hsla(25, 50%, 30%, 0.3);
}

/* Egg spots */
.pet-egg::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: hsl(175, 60%, 65%);
  border-radius: 50%;
  top: 30%;
  left: 20%;
  box-shadow:
    25px 15px 0 4px hsl(340, 60%, 70%),
    10px 30px 0 2px hsl(45, 80%, 70%),
    30px -5px 0 1px hsl(260, 50%, 70%);
}

/* Egg crack (appears before hatching) */
.pet-egg.hatching::after {
  content: '';
  position: absolute;
  width: 40px;
  height: 30px;
  top: 25%;
  left: 25%;
  border-top: 3px solid hsla(25, 40%, 40%, 0.6);
  border-radius: 0;
  clip-path: polygon(0% 0%, 30% 80%, 50% 20%, 70% 90%, 100% 10%);
  animation: crack-grow 1s ease-out forwards;
}

@keyframes egg-wobble {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  20% { transform: rotate(-5deg) translateY(-2px); }
  40% { transform: rotate(4deg) translateY(0); }
  60% { transform: rotate(-3deg) translateY(-1px); }
  80% { transform: rotate(2deg) translateY(0); }
}

@keyframes crack-grow {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: scale(1); }
}

/* ══════════════════════════════════════════
   STAGE 1: BABY — tiny round blob
   ══════════════════════════════════════════ */
.pet-baby {
  width: 60px;
  height: 55px;
  background: radial-gradient(
    ellipse at 40% 35%,
    hsl(175, 70%, 75%) 0%,
    hsl(175, 60%, 55%) 60%,
    hsl(175, 50%, 40%) 100%
  );
  border-radius: 50% 50% 45% 45% / 55% 55% 40% 40%;
  position: relative;
  animation: bounce var(--bounce-speed) ease-in-out infinite;
  box-shadow:
    inset -5px -5px 15px hsla(175, 40%, 30%, 0.3),
    inset 3px 3px 10px hsla(175, 80%, 85%, 0.3),
    0 6px 20px hsla(175, 40%, 20%, 0.3);
}

/* Baby eyes */
.pet-baby::before {
  content: '';
  position: absolute;
  width: 10px;
  height: 12px;
  background: hsl(0, 0%, 10%);
  border-radius: 50%;
  top: 30%;
  left: 25%;
  box-shadow:
    22px 0 0 0 hsl(0, 0%, 10%),
    2px -2px 0 3px hsl(0, 0%, 100%),
    24px -2px 0 3px hsl(0, 0%, 100%);
  animation: blink var(--blink-speed) ease-in-out infinite;
}

/* Baby mouth */
.pet-baby::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 6px;
  border-bottom: 2.5px solid hsl(350, 60%, 55%);
  border-radius: 0 0 50% 50%;
  bottom: 28%;
  left: calc(50% - 6px);
}

/* Baby feet (separate elements needed) */
.pet-baby .foot-left,
.pet-baby .foot-right {
  position: absolute;
  width: 16px;
  height: 10px;
  background: hsl(175, 55%, 48%);
  border-radius: 50% 50% 50% 50% / 30% 30% 70% 70%;
  bottom: -5px;
}
.pet-baby .foot-left { left: 10px; }
.pet-baby .foot-right { right: 10px; }

@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.1); }
}

/* ══════════════════════════════════════════
   STAGE 2: CHILD — rounder, small limbs
   ══════════════════════════════════════════ */
.pet-child {
  width: 75px;
  height: 70px;
  background: radial-gradient(
    ellipse at 40% 30%,
    hsl(175, 75%, 75%) 0%,
    hsl(175, 65%, 55%) 50%,
    hsl(175, 55%, 40%) 100%
  );
  border-radius: 50% 50% 42% 42% / 55% 55% 38% 38%;
  position: relative;
  animation: float 3.5s ease-in-out infinite;
  box-shadow:
    inset -6px -6px 18px hsla(175, 40%, 25%, 0.3),
    inset 4px 4px 12px hsla(175, 80%, 85%, 0.3),
    0 8px 25px hsla(175, 40%, 20%, 0.3);
}

/* Child eyes — bigger, more expressive */
.pet-child::before {
  content: '';
  position: absolute;
  width: 13px;
  height: 15px;
  background: hsl(0, 0%, 10%);
  border-radius: 50%;
  top: 25%;
  left: 22%;
  box-shadow:
    28px 0 0 0 hsl(0, 0%, 10%),
    2px -2px 0 4px hsl(0, 0%, 100%),
    30px -2px 0 4px hsl(0, 0%, 100%),
    4px -5px 0 2px hsl(0, 0%, 100%);
  animation: blink var(--blink-speed) ease-in-out infinite;
}

/* Child cheeks + mouth */
.pet-child::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 7px;
  border-bottom: 2.5px solid hsl(350, 60%, 55%);
  border-radius: 0 0 50% 50%;
  bottom: 25%;
  left: calc(50% - 7px);
  box-shadow:
    -18px -3px 0 3px hsla(350, 70%, 70%, 0.4),
    18px -3px 0 3px hsla(350, 70%, 70%, 0.4);
}

/* Child arms */
.pet-child .arm-left,
.pet-child .arm-right {
  position: absolute;
  width: 14px;
  height: 20px;
  background: hsl(175, 58%, 48%);
  border-radius: 50%;
  top: 45%;
}
.pet-child .arm-left {
  left: -8px;
  transform: rotate(15deg);
  animation: wave-left 2s ease-in-out infinite;
}
.pet-child .arm-right {
  right: -8px;
  transform: rotate(-15deg);
  animation: wave-right 2s ease-in-out infinite;
}

.pet-child .foot-left,
.pet-child .foot-right {
  position: absolute;
  width: 20px;
  height: 12px;
  background: hsl(175, 50%, 45%);
  border-radius: 50% 50% 50% 50% / 30% 30% 70% 70%;
  bottom: -6px;
}
.pet-child .foot-left { left: 10px; }
.pet-child .foot-right { right: 10px; }

@keyframes wave-left {
  0%, 100% { transform: rotate(15deg); }
  50% { transform: rotate(25deg) translateY(-3px); }
}

@keyframes wave-right {
  0%, 100% { transform: rotate(-15deg); }
  50% { transform: rotate(-25deg) translateY(-3px); }
}

/* ══════════════════════════════════════════
   STAGE 3: TEEN — taller, ears, tail
   ══════════════════════════════════════════ */
.pet-teen {
  width: 80px;
  height: 85px;
  background: radial-gradient(
    ellipse at 45% 30%,
    hsl(175, 80%, 78%) 0%,
    hsl(175, 70%, 55%) 45%,
    hsl(175, 60%, 38%) 100%
  );
  border-radius: 45% 45% 40% 40% / 50% 50% 35% 35%;
  position: relative;
  animation: float 4s ease-in-out infinite;
  box-shadow:
    inset -7px -7px 20px hsla(175, 40%, 22%, 0.3),
    inset 5px 5px 14px hsla(175, 80%, 85%, 0.3),
    0 10px 30px hsla(175, 40%, 18%, 0.3);
}

/* Teen ears */
.pet-teen .ear-left,
.pet-teen .ear-right {
  position: absolute;
  width: 20px;
  height: 28px;
  background: linear-gradient(
    to top,
    hsl(175, 60%, 50%),
    hsl(175, 70%, 65%)
  );
  top: -18px;
  border-radius: 50% 50% 0 0;
}
.pet-teen .ear-left {
  left: 10px;
  transform: rotate(-10deg);
  animation: ear-wiggle 3s ease-in-out infinite;
}
.pet-teen .ear-right {
  right: 10px;
  transform: rotate(10deg);
  animation: ear-wiggle 3s ease-in-out infinite reverse;
}

/* Inner ear */
.pet-teen .ear-left::after,
.pet-teen .ear-right::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 16px;
  background: hsl(350, 50%, 72%);
  border-radius: 50% 50% 0 0;
  top: 4px;
  left: 5px;
}

/* Teen eyes */
.pet-teen::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 16px;
  background: hsl(0, 0%, 8%);
  border-radius: 50%;
  top: 22%;
  left: 22%;
  box-shadow:
    30px 0 0 0 hsl(0, 0%, 8%),
    3px -3px 0 4px hsl(0, 0%, 100%),
    33px -3px 0 4px hsl(0, 0%, 100%),
    5px -6px 0 2px hsla(0, 0%, 100%, 0.8),
    35px -6px 0 2px hsla(0, 0%, 100%, 0.8);
  animation: blink var(--blink-speed) ease-in-out infinite;
}

/* Teen mouth + cheeks */
.pet-teen::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 8px;
  border-bottom: 3px solid hsl(350, 55%, 55%);
  border-radius: 0 0 50% 50%;
  bottom: 25%;
  left: calc(50% - 8px);
  box-shadow:
    -22px -4px 0 4px hsla(350, 65%, 70%, 0.35),
    22px -4px 0 4px hsla(350, 65%, 70%, 0.35);
}

/* Teen tail */
.pet-teen .tail {
  position: absolute;
  width: 30px;
  height: 16px;
  background: hsl(175, 55%, 48%);
  border-radius: 0 80% 80% 0;
  right: -22px;
  top: 55%;
  transform-origin: left center;
  animation: tail-wag 1.5s ease-in-out infinite;
}

.pet-teen .tail::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  background: hsl(175, 65%, 62%);
  border-radius: 50%;
  right: -4px;
  top: 2px;
}

/* Teen arms */
.pet-teen .arm-left,
.pet-teen .arm-right {
  position: absolute;
  width: 16px;
  height: 24px;
  background: hsl(175, 55%, 46%);
  border-radius: 50%;
  top: 45%;
}
.pet-teen .arm-left {
  left: -9px;
  transform: rotate(12deg);
  animation: wave-left 2.5s ease-in-out infinite;
}
.pet-teen .arm-right {
  right: -9px;
  transform: rotate(-12deg);
  animation: wave-right 2.5s ease-in-out infinite;
}

.pet-teen .foot-left,
.pet-teen .foot-right {
  position: absolute;
  width: 22px;
  height: 14px;
  background: hsl(175, 48%, 42%);
  border-radius: 50% 50% 50% 50% / 30% 30% 70% 70%;
  bottom: -7px;
}
.pet-teen .foot-left { left: 10px; }
.pet-teen .foot-right { right: 10px; }

@keyframes ear-wiggle {
  0%, 100% { transform: rotate(-10deg); }
  50% { transform: rotate(-5deg) translateY(-2px); }
}

@keyframes tail-wag {
  0%, 100% { transform: rotate(0deg); }
  30% { transform: rotate(15deg); }
  60% { transform: rotate(-10deg); }
}

/* ══════════════════════════════════════════
   STAGE 4: ADULT — full detailed creature
   Multiple forms based on care quality
   ══════════════════════════════════════════ */

/* ── Adult Form A: "Shimmerling" (Good care) ── */
.pet-adult {
  width: 90px;
  height: 95px;
  background: radial-gradient(
    ellipse at 45% 28%,
    hsl(175, 85%, 80%) 0%,
    hsl(175, 75%, 55%) 40%,
    hsl(180, 65%, 35%) 100%
  );
  border-radius: 48% 48% 38% 38% / 50% 50% 32% 32%;
  position: relative;
  animation: float 4.5s ease-in-out infinite;
  box-shadow:
    inset -8px -8px 22px hsla(180, 40%, 20%, 0.3),
    inset 6px 6px 16px hsla(175, 80%, 85%, 0.3),
    0 12px 35px hsla(180, 40%, 15%, 0.3);
}

/* Adult crown/crest */
.pet-adult .crest {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-bottom: 22px solid hsl(175, 65%, 60%);
  filter: drop-shadow(0 -3px 4px hsla(175, 80%, 70%, 0.5));
}

.pet-adult .crest::before,
.pet-adult .crest::after {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 18px solid hsl(175, 55%, 55%);
  top: 6px;
}
.pet-adult .crest::before { left: -20px; }
.pet-adult .crest::after { left: 2px; }

/* Adult ears */
.pet-adult .ear-left,
.pet-adult .ear-right {
  position: absolute;
  width: 24px;
  height: 32px;
  background: linear-gradient(
    to top,
    hsl(175, 60%, 48%),
    hsl(175, 75%, 68%)
  );
  top: -14px;
  border-radius: 50% 50% 0 0;
}
.pet-adult .ear-left {
  left: 5px;
  transform: rotate(-15deg);
  animation: ear-wiggle 3.5s ease-in-out infinite;
}
.pet-adult .ear-right {
  right: 5px;
  transform: rotate(15deg);
  animation: ear-wiggle 3.5s ease-in-out infinite reverse;
}
.pet-adult .ear-left::after,
.pet-adult .ear-right::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 18px;
  background: hsl(340, 45%, 72%);
  border-radius: 50% 50% 0 0;
  top: 5px;
  left: 6px;
}

/* Adult eyes — large, detailed */
.pet-adult::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 18px;
  background: radial-gradient(
    circle at 45% 40%,
    hsl(175, 90%, 50%) 30%,
    hsl(175, 80%, 30%) 60%,
    hsl(0, 0%, 5%) 65%
  );
  border-radius: 50%;
  top: 22%;
  left: 20%;
  box-shadow:
    34px 0 0 0 hsl(0, 0%, 5%),
    3px -3px 0 5px hsl(0, 0%, 100%),
    37px -3px 0 5px hsl(0, 0%, 100%),
    5px -7px 0 2px hsla(0, 0%, 100%, 0.9),
    39px -7px 0 2px hsla(0, 0%, 100%, 0.9);
  animation: blink var(--blink-speed) ease-in-out infinite;
}

/* Right eye colored pupil via separate element */
.pet-adult .eye-right-pupil {
  position: absolute;
  width: 16px;
  height: 18px;
  background: radial-gradient(
    circle at 45% 40%,
    hsl(175, 90%, 50%) 30%,
    hsl(175, 80%, 30%) 60%,
    transparent 65%
  );
  border-radius: 50%;
  top: 22%;
  right: 20%;
  pointer-events: none;
  animation: blink var(--blink-speed) ease-in-out infinite;
}

/* Adult mouth + cheeks */
.pet-adult::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 9px;
  border-bottom: 3px solid hsl(350, 50%, 55%);
  border-radius: 0 0 50% 50%;
  bottom: 22%;
  left: calc(50% - 9px);
  box-shadow:
    -24px -5px 0 5px hsla(350, 60%, 70%, 0.3),
    24px -5px 0 5px hsla(350, 60%, 70%, 0.3);
}

/* Adult tail — more elaborate */
.pet-adult .tail {
  position: absolute;
  width: 40px;
  height: 18px;
  background: linear-gradient(
    90deg,
    hsl(175, 55%, 46%),
    hsl(175, 70%, 60%)
  );
  border-radius: 0 80% 50% 0;
  right: -28px;
  top: 50%;
  transform-origin: left center;
  animation: tail-wag 2s ease-in-out infinite;
}
.pet-adult .tail::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 20px;
  background: hsl(175, 75%, 65%);
  border-radius: 0 50% 50% 0;
  right: -8px;
  top: -5px;
  transform: rotate(-15deg);
}

/* Adult arms + legs */
.pet-adult .arm-left,
.pet-adult .arm-right {
  position: absolute;
  width: 18px;
  height: 28px;
  background: hsl(175, 52%, 44%);
  border-radius: 50% 50% 40% 40%;
  top: 42%;
}
.pet-adult .arm-left {
  left: -10px;
  transform: rotate(10deg);
  animation: wave-left 3s ease-in-out infinite;
}
.pet-adult .arm-right {
  right: -10px;
  transform: rotate(-10deg);
  animation: wave-right 3s ease-in-out infinite;
}

.pet-adult .foot-left,
.pet-adult .foot-right {
  position: absolute;
  width: 24px;
  height: 16px;
  background: hsl(175, 45%, 38%);
  border-radius: 50% 50% 50% 50% / 30% 30% 70% 70%;
  bottom: -8px;
}
.pet-adult .foot-left { left: 10px; }
.pet-adult .foot-right { right: 10px; }

/* ══════════════════════════════════════════
   STAGE 5: ELDER — larger, wiser creature with horns
   ══════════════════════════════════════════ */
.pet-elder {
  width: 100px;
  height: 105px;
  background: radial-gradient(
    ellipse at 45% 28%,
    hsl(260, 70%, 78%) 0%,
    hsl(265, 60%, 55%) 40%,
    hsl(270, 50%, 35%) 100%
  );
  border-radius: 48% 48% 38% 38% / 50% 50% 32% 32%;
  position: relative;
  animation: float 5s ease-in-out infinite;
  box-shadow:
    inset -8px -8px 22px hsla(270, 40%, 20%, 0.3),
    inset 6px 6px 16px hsla(260, 80%, 85%, 0.3),
    0 12px 35px hsla(270, 40%, 15%, 0.3),
    0 0 20px hsla(265, 60%, 60%, 0.2);
}

.pet-elder .crest {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-bottom: 26px solid hsl(265, 55%, 58%);
  filter: drop-shadow(0 -3px 6px hsla(265, 80%, 70%, 0.5));
}
.pet-elder .crest::before,
.pet-elder .crest::after {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 20px solid hsl(265, 45%, 52%);
  top: 6px;
}
.pet-elder .crest::before { left: -22px; }
.pet-elder .crest::after { left: 2px; }

.pet-elder .horn-left,
.pet-elder .horn-right {
  position: absolute;
  width: 8px;
  height: 28px;
  background: linear-gradient(to top, hsl(45, 60%, 55%), hsl(45, 80%, 80%));
  border-radius: 4px 4px 2px 2px;
  top: -26px;
}
.pet-elder .horn-left {
  left: 15px;
  transform: rotate(-20deg);
}
.pet-elder .horn-right {
  right: 15px;
  transform: rotate(20deg);
}

.pet-elder .ear-left,
.pet-elder .ear-right {
  position: absolute;
  width: 26px;
  height: 34px;
  background: linear-gradient(to top, hsl(265, 50%, 46%), hsl(260, 65%, 66%));
  top: -14px;
  border-radius: 50% 50% 0 0;
}
.pet-elder .ear-left {
  left: 3px;
  transform: rotate(-15deg);
  animation: ear-wiggle 3.5s ease-in-out infinite;
}
.pet-elder .ear-right {
  right: 3px;
  transform: rotate(15deg);
  animation: ear-wiggle 3.5s ease-in-out infinite reverse;
}
.pet-elder .ear-left::after,
.pet-elder .ear-right::after {
  content: '';
  position: absolute;
  width: 13px;
  height: 19px;
  background: hsl(300, 40%, 70%);
  border-radius: 50% 50% 0 0;
  top: 5px;
  left: 6px;
}

.pet-elder::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 20px;
  background: radial-gradient(
    circle at 45% 40%,
    hsl(265, 90%, 60%) 30%,
    hsl(270, 80%, 35%) 60%,
    hsl(0, 0%, 5%) 65%
  );
  border-radius: 50%;
  top: 22%;
  left: 18%;
  box-shadow:
    38px 0 0 0 hsl(0, 0%, 5%),
    3px -3px 0 5px hsl(0, 0%, 100%),
    41px -3px 0 5px hsl(0, 0%, 100%),
    5px -7px 0 2px hsla(0, 0%, 100%, 0.9),
    43px -7px 0 2px hsla(0, 0%, 100%, 0.9);
  animation: blink var(--blink-speed) ease-in-out infinite;
}

.pet-elder .eye-right-pupil {
  position: absolute;
  width: 18px;
  height: 20px;
  background: radial-gradient(
    circle at 45% 40%,
    hsl(265, 90%, 60%) 30%,
    hsl(270, 80%, 35%) 60%,
    transparent 65%
  );
  border-radius: 50%;
  top: 22%;
  right: 18%;
  pointer-events: none;
  animation: blink var(--blink-speed) ease-in-out infinite;
}

.pet-elder::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 10px;
  border-bottom: 3px solid hsl(300, 45%, 55%);
  border-radius: 0 0 50% 50%;
  bottom: 22%;
  left: calc(50% - 10px);
  box-shadow:
    -26px -5px 0 5px hsla(300, 55%, 68%, 0.3),
    26px -5px 0 5px hsla(300, 55%, 68%, 0.3);
}

.pet-elder .tail {
  position: absolute;
  width: 45px;
  height: 20px;
  background: linear-gradient(90deg, hsl(265, 45%, 44%), hsl(260, 60%, 58%));
  border-radius: 0 80% 50% 0;
  right: -32px;
  top: 48%;
  transform-origin: left center;
  animation: tail-wag 2s ease-in-out infinite;
}

.pet-elder .arm-left,
.pet-elder .arm-right {
  position: absolute;
  width: 20px;
  height: 30px;
  background: hsl(265, 42%, 42%);
  border-radius: 50% 50% 40% 40%;
  top: 42%;
}
.pet-elder .arm-left {
  left: -12px;
  transform: rotate(10deg);
  animation: wave-left 3s ease-in-out infinite;
}
.pet-elder .arm-right {
  right: -12px;
  transform: rotate(-10deg);
  animation: wave-right 3s ease-in-out infinite;
}

.pet-elder .foot-left,
.pet-elder .foot-right {
  position: absolute;
  width: 26px;
  height: 18px;
  background: hsl(270, 40%, 36%);
  border-radius: 50% 50% 50% 50% / 30% 30% 70% 70%;
  bottom: -10px;
}
.pet-elder .foot-left { left: 10px; }
.pet-elder .foot-right { right: 10px; }

/* ══════════════════════════════════════════
   STAGE 6: ANCIENT — imposing with wings
   ══════════════════════════════════════════ */
.pet-ancient {
  width: 105px;
  height: 110px;
  background: radial-gradient(
    ellipse at 45% 28%,
    hsl(30, 80%, 75%) 0%,
    hsl(25, 70%, 50%) 40%,
    hsl(15, 60%, 30%) 100%
  );
  border-radius: 46% 46% 36% 36% / 48% 48% 30% 30%;
  position: relative;
  animation: float 5.5s ease-in-out infinite;
  box-shadow:
    inset -10px -10px 24px hsla(20, 40%, 15%, 0.3),
    inset 6px 6px 18px hsla(30, 80%, 80%, 0.3),
    0 14px 40px hsla(20, 40%, 10%, 0.3),
    0 0 30px hsla(25, 70%, 55%, 0.25);
}

.pet-ancient .crest {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-bottom: 30px solid hsl(25, 60%, 55%);
  filter: drop-shadow(0 -4px 8px hsla(30, 80%, 65%, 0.5));
}
.pet-ancient .crest::before,
.pet-ancient .crest::after {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-bottom: 22px solid hsl(25, 50%, 48%);
  top: 6px;
}
.pet-ancient .crest::before { left: -24px; }
.pet-ancient .crest::after { left: 2px; }

.pet-ancient .horn-left,
.pet-ancient .horn-right {
  position: absolute;
  width: 10px;
  height: 35px;
  background: linear-gradient(to top, hsl(40, 55%, 50%), hsl(45, 80%, 85%));
  border-radius: 5px 5px 2px 2px;
  top: -32px;
}
.pet-ancient .horn-left {
  left: 12px;
  transform: rotate(-25deg);
}
.pet-ancient .horn-right {
  right: 12px;
  transform: rotate(25deg);
}

.pet-ancient .ear-left,
.pet-ancient .ear-right {
  position: absolute;
  width: 28px;
  height: 36px;
  background: linear-gradient(to top, hsl(25, 50%, 42%), hsl(30, 65%, 62%));
  top: -12px;
  border-radius: 50% 50% 0 0;
}
.pet-ancient .ear-left {
  left: 0;
  transform: rotate(-18deg);
  animation: ear-wiggle 4s ease-in-out infinite;
}
.pet-ancient .ear-right {
  right: 0;
  transform: rotate(18deg);
  animation: ear-wiggle 4s ease-in-out infinite reverse;
}

.pet-ancient .wing-left,
.pet-ancient .wing-right {
  position: absolute;
  width: 40px;
  height: 55px;
  background: linear-gradient(
    135deg,
    hsla(30, 70%, 65%, 0.8) 0%,
    hsla(35, 60%, 50%, 0.5) 60%,
    hsla(40, 50%, 40%, 0.3) 100%
  );
  border-radius: 80% 0 60% 20%;
  top: 5%;
}
.pet-ancient .wing-left {
  left: -35px;
  transform: rotate(-5deg);
  transform-origin: right center;
  animation: wing-flap 3s ease-in-out infinite;
}
.pet-ancient .wing-right {
  right: -35px;
  transform: rotate(5deg) scaleX(-1);
  transform-origin: left center;
  animation: wing-flap 3s ease-in-out infinite reverse;
}

.pet-ancient::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 22px;
  background: radial-gradient(
    circle at 45% 40%,
    hsl(30, 90%, 60%) 30%,
    hsl(20, 80%, 35%) 60%,
    hsl(0, 0%, 5%) 65%
  );
  border-radius: 50%;
  top: 20%;
  left: 17%;
  box-shadow:
    40px 0 0 0 hsl(0, 0%, 5%),
    3px -3px 0 6px hsl(0, 0%, 100%),
    43px -3px 0 6px hsl(0, 0%, 100%),
    5px -7px 0 3px hsla(0, 0%, 100%, 0.9),
    45px -7px 0 3px hsla(0, 0%, 100%, 0.9);
  animation: blink var(--blink-speed) ease-in-out infinite;
}

.pet-ancient .eye-right-pupil {
  position: absolute;
  width: 20px;
  height: 22px;
  background: radial-gradient(
    circle at 45% 40%,
    hsl(30, 90%, 60%) 30%,
    hsl(20, 80%, 35%) 60%,
    transparent 65%
  );
  border-radius: 50%;
  top: 20%;
  right: 17%;
  pointer-events: none;
  animation: blink var(--blink-speed) ease-in-out infinite;
}

.pet-ancient::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 11px;
  border-bottom: 3px solid hsl(10, 50%, 50%);
  border-radius: 0 0 50% 50%;
  bottom: 20%;
  left: calc(50% - 11px);
  box-shadow:
    -28px -5px 0 6px hsla(15, 55%, 65%, 0.3),
    28px -5px 0 6px hsla(15, 55%, 65%, 0.3);
}

.pet-ancient .tail {
  position: absolute;
  width: 50px;
  height: 22px;
  background: linear-gradient(90deg, hsl(25, 45%, 40%), hsl(30, 65%, 55%));
  border-radius: 0 80% 50% 0;
  right: -36px;
  top: 46%;
  transform-origin: left center;
  animation: tail-wag 1.8s ease-in-out infinite;
}

.pet-ancient .arm-left,
.pet-ancient .arm-right {
  position: absolute;
  width: 22px;
  height: 32px;
  background: hsl(25, 42%, 38%);
  border-radius: 50% 50% 40% 40%;
  top: 40%;
}
.pet-ancient .arm-left {
  left: -14px;
  transform: rotate(10deg);
  animation: wave-left 3s ease-in-out infinite;
}
.pet-ancient .arm-right {
  right: -14px;
  transform: rotate(-10deg);
  animation: wave-right 3s ease-in-out infinite;
}

.pet-ancient .foot-left,
.pet-ancient .foot-right {
  position: absolute;
  width: 28px;
  height: 18px;
  background: hsl(20, 38%, 32%);
  border-radius: 50% 50% 50% 50% / 30% 30% 70% 70%;
  bottom: -10px;
}
.pet-ancient .foot-left { left: 10px; }
.pet-ancient .foot-right { right: 10px; }

/* ══════════════════════════════════════════
   STAGE 7: MYTHIC — radiant with halo
   ══════════════════════════════════════════ */
.pet-mythic {
  width: 110px;
  height: 115px;
  background: radial-gradient(
    ellipse at 45% 28%,
    hsl(200, 85%, 82%) 0%,
    hsl(220, 75%, 58%) 40%,
    hsl(240, 65%, 35%) 100%
  );
  border-radius: 46% 46% 36% 36% / 48% 48% 30% 30%;
  position: relative;
  animation: float 6s ease-in-out infinite;
  box-shadow:
    inset -10px -10px 26px hsla(230, 40%, 18%, 0.3),
    inset 8px 8px 20px hsla(200, 80%, 85%, 0.3),
    0 16px 45px hsla(230, 40%, 10%, 0.3),
    0 0 40px hsla(220, 70%, 60%, 0.3);
}

.pet-mythic .halo {
  position: absolute;
  width: 60px;
  height: 12px;
  background: radial-gradient(ellipse, hsla(45, 100%, 75%, 0.8), transparent);
  border: 2px solid hsla(45, 90%, 70%, 0.6);
  border-radius: 50%;
  top: -35px;
  left: 50%;
  transform: translateX(-50%) rotateX(60deg);
  animation: halo-glow 2s ease-in-out infinite alternate;
}

@keyframes halo-glow {
  0% { box-shadow: 0 0 8px hsla(45, 100%, 70%, 0.5); opacity: 0.8; }
  100% { box-shadow: 0 0 20px hsla(45, 100%, 75%, 0.8); opacity: 1; }
}

.pet-mythic .crest {
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-bottom: 32px solid hsl(220, 60%, 55%);
  filter: drop-shadow(0 -4px 10px hsla(210, 80%, 70%, 0.6));
}
.pet-mythic .crest::before,
.pet-mythic .crest::after {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-bottom: 24px solid hsl(220, 48%, 50%);
  top: 6px;
}
.pet-mythic .crest::before { left: -26px; }
.pet-mythic .crest::after { left: 2px; }

.pet-mythic .horn-left,
.pet-mythic .horn-right {
  position: absolute;
  width: 10px;
  height: 38px;
  background: linear-gradient(to top, hsl(45, 60%, 55%), hsl(50, 90%, 88%));
  border-radius: 5px 5px 2px 2px;
  top: -36px;
  filter: drop-shadow(0 0 4px hsla(45, 80%, 70%, 0.5));
}
.pet-mythic .horn-left {
  left: 12px;
  transform: rotate(-25deg);
}
.pet-mythic .horn-right {
  right: 12px;
  transform: rotate(25deg);
}

.pet-mythic .ear-left,
.pet-mythic .ear-right {
  position: absolute;
  width: 28px;
  height: 38px;
  background: linear-gradient(to top, hsl(225, 50%, 45%), hsl(210, 65%, 65%));
  top: -12px;
  border-radius: 50% 50% 0 0;
}
.pet-mythic .ear-left {
  left: 0;
  transform: rotate(-18deg);
  animation: ear-wiggle 4s ease-in-out infinite;
}
.pet-mythic .ear-right {
  right: 0;
  transform: rotate(18deg);
  animation: ear-wiggle 4s ease-in-out infinite reverse;
}

.pet-mythic .wing-left,
.pet-mythic .wing-right {
  position: absolute;
  width: 50px;
  height: 65px;
  background: linear-gradient(
    135deg,
    hsla(210, 80%, 75%, 0.85) 0%,
    hsla(220, 70%, 60%, 0.6) 50%,
    hsla(230, 60%, 45%, 0.3) 100%
  );
  border-radius: 80% 0 60% 20%;
  top: 0;
}
.pet-mythic .wing-left {
  left: -44px;
  transform: rotate(-5deg);
  transform-origin: right center;
  animation: wing-flap 2.5s ease-in-out infinite;
}
.pet-mythic .wing-right {
  right: -44px;
  transform: rotate(5deg) scaleX(-1);
  transform-origin: left center;
  animation: wing-flap 2.5s ease-in-out infinite reverse;
}

.pet-mythic::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 24px;
  background: radial-gradient(
    circle at 45% 40%,
    hsl(210, 90%, 65%) 30%,
    hsl(230, 80%, 40%) 60%,
    hsl(0, 0%, 5%) 65%
  );
  border-radius: 50%;
  top: 20%;
  left: 16%;
  box-shadow:
    42px 0 0 0 hsl(0, 0%, 5%),
    3px -3px 0 6px hsl(0, 0%, 100%),
    45px -3px 0 6px hsl(0, 0%, 100%),
    5px -8px 0 3px hsla(0, 0%, 100%, 0.9),
    47px -8px 0 3px hsla(0, 0%, 100%, 0.9);
  animation: blink var(--blink-speed) ease-in-out infinite;
}

.pet-mythic .eye-right-pupil {
  position: absolute;
  width: 22px;
  height: 24px;
  background: radial-gradient(
    circle at 45% 40%,
    hsl(210, 90%, 65%) 30%,
    hsl(230, 80%, 40%) 60%,
    transparent 65%
  );
  border-radius: 50%;
  top: 20%;
  right: 16%;
  pointer-events: none;
  animation: blink var(--blink-speed) ease-in-out infinite;
}

.pet-mythic::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 12px;
  border-bottom: 3px solid hsl(340, 50%, 55%);
  border-radius: 0 0 50% 50%;
  bottom: 20%;
  left: calc(50% - 12px);
  box-shadow:
    -30px -5px 0 6px hsla(340, 55%, 68%, 0.3),
    30px -5px 0 6px hsla(340, 55%, 68%, 0.3);
}

.pet-mythic .tail {
  position: absolute;
  width: 55px;
  height: 24px;
  background: linear-gradient(90deg, hsl(225, 48%, 42%), hsl(210, 65%, 58%));
  border-radius: 0 80% 50% 0;
  right: -40px;
  top: 44%;
  transform-origin: left center;
  animation: tail-wag 1.6s ease-in-out infinite;
}

.pet-mythic .arm-left,
.pet-mythic .arm-right {
  position: absolute;
  width: 22px;
  height: 34px;
  background: hsl(225, 42%, 40%);
  border-radius: 50% 50% 40% 40%;
  top: 40%;
}
.pet-mythic .arm-left {
  left: -14px;
  transform: rotate(10deg);
  animation: wave-left 3s ease-in-out infinite;
}
.pet-mythic .arm-right {
  right: -14px;
  transform: rotate(-10deg);
  animation: wave-right 3s ease-in-out infinite;
}

.pet-mythic .foot-left,
.pet-mythic .foot-right {
  position: absolute;
  width: 30px;
  height: 20px;
  background: hsl(235, 38%, 34%);
  border-radius: 50% 50% 50% 50% / 30% 30% 70% 70%;
  bottom: -12px;
}
.pet-mythic .foot-left { left: 10px; }
.pet-mythic .foot-right { right: 10px; }

/* ══════════════════════════════════════════
   STAGE 8: CELESTIAL — transcendent, glowing aura
   ══════════════════════════════════════════ */
.pet-celestial {
  width: 115px;
  height: 120px;
  background: radial-gradient(
    ellipse at 45% 28%,
    hsl(310, 80%, 85%) 0%,
    hsl(280, 70%, 60%) 35%,
    hsl(260, 60%, 38%) 70%,
    hsl(240, 50%, 25%) 100%
  );
  border-radius: 46% 46% 36% 36% / 48% 48% 30% 30%;
  position: relative;
  animation: float 6.5s ease-in-out infinite;
  box-shadow:
    inset -12px -12px 28px hsla(260, 40%, 15%, 0.3),
    inset 8px 8px 22px hsla(310, 80%, 85%, 0.3),
    0 18px 50px hsla(260, 40%, 10%, 0.3),
    0 0 50px hsla(280, 70%, 60%, 0.35),
    0 0 80px hsla(310, 60%, 65%, 0.15);
}

.pet-celestial .aura {
  position: absolute;
  width: 160px;
  height: 165px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(
    circle,
    hsla(280, 70%, 70%, 0.15) 0%,
    hsla(300, 60%, 65%, 0.08) 40%,
    transparent 70%
  );
  animation: aura-pulse 3s ease-in-out infinite;
  pointer-events: none;
}

@keyframes aura-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
  50% { transform: translate(-50%, -50%) scale(1.12); opacity: 1; }
}

.pet-celestial .halo {
  position: absolute;
  width: 70px;
  height: 14px;
  background: radial-gradient(ellipse, hsla(45, 100%, 80%, 0.9), transparent);
  border: 2px solid hsla(45, 95%, 75%, 0.7);
  border-radius: 50%;
  top: -40px;
  left: 50%;
  transform: translateX(-50%) rotateX(60deg);
  animation: halo-glow 1.5s ease-in-out infinite alternate;
  filter: drop-shadow(0 0 6px hsla(45, 100%, 75%, 0.6));
}

.pet-celestial .crest {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 18px solid transparent;
  border-right: 18px solid transparent;
  border-bottom: 34px solid hsl(280, 55%, 55%);
  filter: drop-shadow(0 -5px 12px hsla(300, 80%, 70%, 0.6));
}
.pet-celestial .crest::before,
.pet-celestial .crest::after {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
  border-left: 13px solid transparent;
  border-right: 13px solid transparent;
  border-bottom: 26px solid hsl(280, 45%, 50%);
  top: 6px;
}
.pet-celestial .crest::before { left: -28px; }
.pet-celestial .crest::after { left: 2px; }

.pet-celestial .horn-left,
.pet-celestial .horn-right {
  position: absolute;
  width: 11px;
  height: 42px;
  background: linear-gradient(to top, hsl(50, 60%, 55%), hsl(55, 95%, 90%));
  border-radius: 5px 5px 2px 2px;
  top: -40px;
  filter: drop-shadow(0 0 6px hsla(50, 90%, 75%, 0.6));
}
.pet-celestial .horn-left {
  left: 10px;
  transform: rotate(-28deg);
}
.pet-celestial .horn-right {
  right: 10px;
  transform: rotate(28deg);
}

.pet-celestial .ear-left,
.pet-celestial .ear-right {
  position: absolute;
  width: 30px;
  height: 40px;
  background: linear-gradient(to top, hsl(275, 50%, 42%), hsl(290, 65%, 65%));
  top: -12px;
  border-radius: 50% 50% 0 0;
}
.pet-celestial .ear-left {
  left: -2px;
  transform: rotate(-18deg);
  animation: ear-wiggle 4.5s ease-in-out infinite;
}
.pet-celestial .ear-right {
  right: -2px;
  transform: rotate(18deg);
  animation: ear-wiggle 4.5s ease-in-out infinite reverse;
}

.pet-celestial .wing-left,
.pet-celestial .wing-right {
  position: absolute;
  width: 58px;
  height: 75px;
  background: linear-gradient(
    135deg,
    hsla(290, 80%, 80%, 0.9) 0%,
    hsla(280, 70%, 65%, 0.65) 40%,
    hsla(260, 60%, 50%, 0.35) 80%,
    hsla(240, 50%, 40%, 0.15) 100%
  );
  border-radius: 80% 0 60% 20%;
  top: -5%;
  filter: drop-shadow(0 0 8px hsla(290, 70%, 70%, 0.3));
}
.pet-celestial .wing-left {
  left: -52px;
  transform: rotate(-5deg);
  transform-origin: right center;
  animation: wing-flap 2.2s ease-in-out infinite;
}
.pet-celestial .wing-right {
  right: -52px;
  transform: rotate(5deg) scaleX(-1);
  transform-origin: left center;
  animation: wing-flap 2.2s ease-in-out infinite reverse;
}

.pet-celestial::before {
  content: '';
  position: absolute;
  width: 24px;
  height: 26px;
  background: radial-gradient(
    circle at 45% 40%,
    hsl(290, 90%, 70%) 25%,
    hsl(280, 80%, 45%) 55%,
    hsl(0, 0%, 5%) 65%
  );
  border-radius: 50%;
  top: 18%;
  left: 15%;
  box-shadow:
    44px 0 0 0 hsl(0, 0%, 5%),
    3px -3px 0 7px hsl(0, 0%, 100%),
    47px -3px 0 7px hsl(0, 0%, 100%),
    6px -8px 0 3px hsla(0, 0%, 100%, 0.9),
    50px -8px 0 3px hsla(0, 0%, 100%, 0.9);
  animation: blink var(--blink-speed) ease-in-out infinite;
}

.pet-celestial .eye-right-pupil {
  position: absolute;
  width: 24px;
  height: 26px;
  background: radial-gradient(
    circle at 45% 40%,
    hsl(290, 90%, 70%) 25%,
    hsl(280, 80%, 45%) 55%,
    transparent 65%
  );
  border-radius: 50%;
  top: 18%;
  right: 15%;
  pointer-events: none;
  animation: blink var(--blink-speed) ease-in-out infinite;
}

.pet-celestial::after {
  content: '';
  position: absolute;
  width: 26px;
  height: 13px;
  border-bottom: 3px solid hsl(320, 50%, 58%);
  border-radius: 0 0 50% 50%;
  bottom: 18%;
  left: calc(50% - 13px);
  box-shadow:
    -32px -5px 0 7px hsla(320, 55%, 68%, 0.3),
    32px -5px 0 7px hsla(320, 55%, 68%, 0.3);
}

.pet-celestial .tail {
  position: absolute;
  width: 60px;
  height: 26px;
  background: linear-gradient(90deg, hsl(270, 48%, 40%), hsl(290, 65%, 58%));
  border-radius: 0 80% 50% 0;
  right: -44px;
  top: 42%;
  transform-origin: left center;
  animation: tail-wag 1.4s ease-in-out infinite;
  filter: drop-shadow(0 0 4px hsla(290, 60%, 60%, 0.3));
}

.pet-celestial .arm-left,
.pet-celestial .arm-right {
  position: absolute;
  width: 24px;
  height: 36px;
  background: hsl(270, 42%, 38%);
  border-radius: 50% 50% 40% 40%;
  top: 38%;
}
.pet-celestial .arm-left {
  left: -16px;
  transform: rotate(10deg);
  animation: wave-left 3s ease-in-out infinite;
}
.pet-celestial .arm-right {
  right: -16px;
  transform: rotate(-10deg);
  animation: wave-right 3s ease-in-out infinite;
}

.pet-celestial .foot-left,
.pet-celestial .foot-right {
  position: absolute;
  width: 32px;
  height: 22px;
  background: hsl(260, 38%, 32%);
  border-radius: 50% 50% 50% 50% / 30% 30% 70% 70%;
  bottom: -14px;
}
.pet-celestial .foot-left { left: 10px; }
.pet-celestial .foot-right { right: 10px; }

/* Wing flap animation */
@keyframes wing-flap {
  0%, 100% { transform: rotate(-5deg) scaleY(1); }
  50% { transform: rotate(-15deg) scaleY(0.9); }
}

/* ══════════════════════════════════════════
   EMOTION OVERLAYS
   Applied via JS toggling classes on .pet
   ══════════════════════════════════════════ */

/* Happy — eyes become ^_^ */
.pet.emotion-happy .pet-body::before {
  border-radius: 50%;
  height: 4px !important;
  transform: scaleY(1) translateY(4px);
  animation: none;
}

/* Sleeping — ZZZ */
.pet.emotion-sleeping .pet-body {
  animation: breathe 5s ease-in-out infinite;
  opacity: 0.85;
}

/* Sick — greenish tint */
.pet.emotion-sick .pet-body {
  filter: hue-rotate(60deg) saturate(0.6) brightness(0.85);
}

/* Dead — desaturated, dimmed, slumped */
.pet.emotion-dead .pet-body {
  filter: grayscale(1) brightness(0.55);
  opacity: 0.7;
  animation: none;
}
.pet.emotion-dead {
  transform: rotate(-4deg);
}

/* Hungry — slight droop */
.pet.emotion-hungry .pet-body {
  animation: bounce 4s ease-in-out infinite;
  filter: saturate(0.7);
}

/* ══════════════════════════════════════════
   SLEEPING ZZZ BUBBLES
   ══════════════════════════════════════════ */
.zzz {
  position: absolute;
  top: -10px;
  right: -15px;
  font-size: 14px;
  font-weight: 900;
  color: hsl(240, 50%, 70%);
  opacity: 0;
  pointer-events: none;
}
.zzz span {
  display: inline-block;
  animation: zzz-float 2.5s ease-in-out infinite;
}
.zzz span:nth-child(1) { animation-delay: 0s; font-size: 10px; }
.zzz span:nth-child(2) { animation-delay: 0.5s; font-size: 14px; }
.zzz span:nth-child(3) { animation-delay: 1s; font-size: 18px; }

.pet.emotion-sleeping .zzz {
  opacity: 1;
}

@keyframes zzz-float {
  0% { opacity: 0; transform: translateY(0) translateX(0); }
  50% { opacity: 1; transform: translateY(-15px) translateX(8px); }
  100% { opacity: 0; transform: translateY(-30px) translateX(16px); }
}

/* ══════════════════════════════════════════
   POOP
   ══════════════════════════════════════════ */
.poop {
  position: absolute;
  bottom: 15px;
  font-size: 22px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.poop.visible { opacity: 1; }

.poop .stink {
  position: absolute;
  top: -12px;
  left: 50%;
  width: 3px;
  height: 10px;
  background: hsl(60, 40%, 55%);
  border-radius: 50%;
  opacity: 0.6;
  animation: stink-wave 1.2s ease-in-out infinite;
}
.poop .stink:nth-child(2) {
  left: calc(50% - 8px);
  animation-delay: 0.3s;
  height: 8px;
}
.poop .stink:nth-child(3) {
  left: calc(50% + 8px);
  animation-delay: 0.6s;
  height: 12px;
}

@keyframes stink-wave {
  0%, 100% { transform: translateY(0) scaleX(1); opacity: 0.6; }
  50% { transform: translateY(-8px) scaleX(1.5); opacity: 0.2; }
}

/* ══════════════════════════════════════════
   FLIES — buzz around when pet is dirty / has pooped
   ══════════════════════════════════════════ */
.flies {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
  /* Sit ABOVE the pet (z-index: 26) so the buzzing flies are clearly visible
     instead of disappearing behind the creature. */
  z-index: 28;
}

.flies.visible { opacity: 1; }

.fly {
  position: absolute;
  font-size: 18px;
  filter: drop-shadow(0 1px 2px hsla(0, 0%, 0%, 0.6));
  will-change: transform;
}

.fly--1 {
  left: 38%;
  bottom: 55%;
  animation: fly-buzz-a 3.4s ease-in-out infinite;
}

.fly--2 {
  left: 55%;
  bottom: 48%;
  animation: fly-buzz-b 4.1s ease-in-out infinite;
  animation-delay: -0.8s;
}

.fly--3 {
  left: 46%;
  bottom: 60%;
  animation: fly-buzz-c 3.8s ease-in-out infinite;
  animation-delay: -1.6s;
}

@keyframes fly-buzz-a {
  0%   { transform: translate(0, 0) rotate(-8deg); }
  25%  { transform: translate(14px, -10px) rotate(12deg); }
  50%  { transform: translate(22px, 6px) rotate(-4deg); }
  75%  { transform: translate(6px, 14px) rotate(8deg); }
  100% { transform: translate(0, 0) rotate(-8deg); }
}

@keyframes fly-buzz-b {
  0%   { transform: translate(0, 0) rotate(6deg); }
  25%  { transform: translate(-12px, 8px) rotate(-10deg); }
  50%  { transform: translate(-20px, -4px) rotate(6deg); }
  75%  { transform: translate(-4px, -14px) rotate(-6deg); }
  100% { transform: translate(0, 0) rotate(6deg); }
}

@keyframes fly-buzz-c {
  0%   { transform: translate(0, 0) rotate(0deg); }
  25%  { transform: translate(10px, 10px) rotate(-12deg); }
  50%  { transform: translate(-8px, 16px) rotate(10deg); }
  75%  { transform: translate(-14px, 4px) rotate(-4deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

/* ══════════════════════════════════════════
   REACTIONS — temporary animations on events
   Applied via .react-* class on .pet element,
   removed after duration by JS.
   ══════════════════════════════════════════ */

/* Joy: jump up + squish on landing */
.pet.react-joy .pet-body {
  animation: react-jump 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 2 !important;
}

@keyframes react-jump {
  0%, 100% { transform: translateY(0) scaleX(1) scaleY(1); }
  30% { transform: translateY(-25px) scaleX(0.9) scaleY(1.12); }
  50% { transform: translateY(-28px) scaleX(0.88) scaleY(1.14); }
  80% { transform: translateY(0) scaleX(1.12) scaleY(0.88); }
}

/* Petted: nuzzle side-to-side */
.pet.react-petted .pet-body {
  animation: react-nuzzle 0.35s ease-in-out 3 !important;
}

@keyframes react-nuzzle {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  30% { transform: rotate(8deg) translateY(-2px); }
  70% { transform: rotate(-8deg) translateY(-2px); }
}

/* Eating: chomp motion */
.pet.react-eating .pet-body {
  animation: react-chomp 0.3s ease-in-out 4 !important;
}

@keyframes react-chomp {
  0%, 100% { transform: scaleY(1) scaleX(1); }
  50% { transform: scaleY(0.88) scaleX(1.08); }
}

/* Playing: spin-bounce */
.pet.react-playing .pet-body {
  animation: react-spin 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 2 !important;
}

@keyframes react-spin {
  0% { transform: translateY(0) rotate(0deg); }
  40% { transform: translateY(-20px) rotate(180deg); }
  100% { transform: translateY(0) rotate(360deg); }
}

/* Sad: droop down + flatten */
.pet.react-sad .pet-body {
  animation: react-droop 1.5s ease-in-out forwards !important;
}

@keyframes react-droop {
  0% { transform: translateY(0) scaleY(1); }
  40% { transform: translateY(8px) scaleY(0.9); }
  100% { transform: translateY(8px) scaleY(0.9); }
}

/* Angry: rapid shake + red tint */
.pet.react-angry .pet-body {
  animation: react-shake 0.12s ease-in-out 10 !important;
  filter: hue-rotate(-30deg) saturate(1.6) brightness(0.9);
}

@keyframes react-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Sick: wobbly sway + green tint */
.pet.react-sick .pet-body {
  animation: react-wobble-sick 0.5s ease-in-out 3 !important;
  filter: hue-rotate(60deg) saturate(0.5) brightness(0.8);
}

@keyframes react-wobble-sick {
  0%, 100% { transform: rotate(0deg) translateX(0); }
  25% { transform: rotate(-6deg) translateX(-3px); }
  75% { transform: rotate(6deg) translateX(3px); }
}

/* Evolving: scale pulse + brightness flash */
.pet.react-evolving .pet-body {
  animation: react-evolve 1.8s ease-in-out forwards !important;
}

@keyframes react-evolve {
  0% { transform: scale(1); filter: brightness(1); }
  25% { transform: scale(1.3); filter: brightness(2); }
  50% { transform: scale(0.7); filter: brightness(2.5); }
  75% { transform: scale(1.15); filter: brightness(1.5); }
  100% { transform: scale(1); filter: brightness(1); }
}

/* Scared: rapid shake + crouch */
.pet.react-scared .pet-body {
  animation: react-scared 0.125s ease-in-out 8 !important;
  transform: translateY(5px) scaleY(0.9) !important;
}

@keyframes react-scared {
  0%, 100% { transform: translateX(0) translateY(5px) scaleY(0.9); }
  25% { transform: translateX(-5px) translateY(5px) scaleY(0.9); }
  75% { transform: translateX(5px) translateY(5px) scaleY(0.9); }
}

/* Amazed: float up + scale */
.pet.react-amazed .pet-body {
  animation: react-amazed 1.2s ease-in-out !important;
}

@keyframes react-amazed {
  0% { transform: translateY(0) scale(1); }
  25% { transform: translateY(-12px) scale(1.1); }
  60% { transform: translateY(-12px) scale(1.1); }
  100% { transform: translateY(0) scale(1); }
}

/* Curious: head tilt side to side */
.pet.react-curious .pet-body {
  animation: react-curious 0.6s ease-in-out 2 !important;
}

@keyframes react-curious {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(12deg); }
  75% { transform: rotate(-12deg); }
}

/* Sleepy: droop with slow sway */
.pet.react-sleepy .pet-body {
  animation: react-sleepy 1.5s ease-in-out forwards !important;
}

@keyframes react-sleepy {
  0% { transform: translateY(0) scaleY(1) rotate(0deg); }
  40% { transform: translateY(6px) scaleY(0.92) rotate(-3deg); }
  60% { transform: translateY(6px) scaleY(0.92) rotate(3deg); }
  100% { transform: translateY(6px) scaleY(0.92) rotate(0deg); }
}

/* Dance: rhythmic bounce with rotation */
.pet.react-dance .pet-body {
  animation: react-dance 0.5s ease-in-out 4 !important;
}

@keyframes react-dance {
  0%, 100% { transform: translateY(0) rotate(0deg) scaleX(1); }
  25% { transform: translateY(-10px) rotate(-8deg) scaleX(0.95); }
  50% { transform: translateY(0) rotate(0deg) scaleX(1.05); }
  75% { transform: translateY(-10px) rotate(8deg) scaleX(0.95); }
}

/* Brace: hunker down for impact */
.pet.react-brace .pet-body {
  animation: react-brace 0.15s ease-in-out 7 !important;
  transform: scaleX(1.1) scaleY(0.85) translateY(4px) !important;
}

@keyframes react-brace {
  0%, 100% { transform: translateX(0) scaleX(1.1) scaleY(0.85) translateY(4px); }
  50% { transform: translateX(3px) scaleX(1.1) scaleY(0.85) translateY(4px); }
}

/* ══════════════════════════════════════════
   RANDOM TRAITS — generated per creature
   ══════════════════════════════════════════ */

/* ── Eye size variation (uses scale, not transform, to avoid blink anim conflict) ── */
.pet .active-stage::before {
  scale: var(--trait-eye-size, 1);
}

/* ── Ear styles (applied on teen+ stages that have ears) ── */
/* 0 = round (default) */

/* 1 = pointed */
.pet.trait-ears-1 .ear-left,
.pet.trait-ears-1 .ear-right {
  border-radius: 50% 50% 50% 0 !important;
}
.pet.trait-ears-1 .ear-left {
  border-radius: 50% 50% 0 50% !important;
}

/* 2 = floppy */
.pet.trait-ears-2 .ear-left {
  transform: rotate(25deg) !important;
  transform-origin: top right;
}
.pet.trait-ears-2 .ear-right {
  transform: rotate(-25deg) !important;
  transform-origin: top left;
}

/* 3 = long */
.pet.trait-ears-3 .ear-left,
.pet.trait-ears-3 .ear-right {
  height: 180% !important;
  border-radius: 40% 40% 50% 50% !important;
}

/* ── Tail styles (applied on teen+ stages with tails) ── */
/* 0 = default */

/* 1 = curly */
.pet.trait-tail-1 .tail {
  border-radius: 50% !important;
  width: 18px !important;
  height: 18px !important;
  animation: trait-tail-curl 2s ease-in-out infinite !important;
}
@keyframes trait-tail-curl {
  0%, 100% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(0.9); }
}

/* 2 = bushy */
.pet.trait-tail-2 .tail {
  width: 150% !important;
  height: 130% !important;
  border-radius: 50% !important;
  filter: blur(1px);
}

/* ── Extra feet ── */
.foot-extra {
  position: absolute;
  width: 14px;
  height: 10px;
  background: hsl(175, 50%, 45%);
  border-radius: 50%;
  bottom: -8px;
  box-shadow:
    inset -2px -2px 4px hsla(0, 0%, 0%, 0.2),
    0 2px 3px hsla(0, 0%, 0%, 0.15);
  z-index: 2;
}

/* ── Trait patterns (overlay inside mutations-container) ── */
.trait-pattern {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
  opacity: 0.7;
}

/* 1 = spots */
.trait-pattern.trait-pattern-1 {
  background-image:
    radial-gradient(circle 5px, hsla(0, 0%, 100%, 0.25) 40%, transparent 41%),
    radial-gradient(circle 3px, hsla(0, 0%, 100%, 0.2) 40%, transparent 41%),
    radial-gradient(circle 4px, hsla(0, 0%, 100%, 0.22) 40%, transparent 41%);
  background-size: 22px 20px, 16px 18px, 19px 22px;
  background-position: 3px 2px, 10px 11px, 0 7px;
}

/* 2 = stripes */
.trait-pattern.trait-pattern-2 {
  background-image: repeating-linear-gradient(
    -30deg,
    transparent 0px,
    transparent 5px,
    hsla(0, 0%, 100%, 0.15) 5px,
    hsla(0, 0%, 100%, 0.15) 8px
  );
}

/* 3 = patches */
.trait-pattern.trait-pattern-3 {
  background-image:
    radial-gradient(ellipse 18px 14px at 25% 30%, hsla(0, 0%, 0%, 0.1) 40%, transparent 41%),
    radial-gradient(ellipse 14px 18px at 70% 65%, hsla(0, 0%, 0%, 0.1) 40%, transparent 41%),
    radial-gradient(ellipse 16px 12px at 55% 20%, hsla(0, 0%, 0%, 0.08) 40%, transparent 41%);
}

/* 4 = rings */
.trait-pattern.trait-pattern-4 {
  background-image:
    radial-gradient(circle 8px at 30% 35%, transparent 50%, hsla(0, 0%, 100%, 0.15) 52%, transparent 54%),
    radial-gradient(circle 6px at 65% 55%, transparent 50%, hsla(0, 0%, 100%, 0.12) 52%, transparent 54%),
    radial-gradient(circle 10px at 50% 75%, transparent 50%, hsla(0, 0%, 100%, 0.1) 52%, transparent 54%);
}
