.yin-assistant {
  position: fixed;
  right: clamp(10px, 2vw, 24px);
  bottom: clamp(10px, 2vw, 24px);
  z-index: 9999;
  width: clamp(128px, 12vw, 220px);
  height: auto;
  aspect-ratio: 1 / 1;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  isolation: isolate;
  outline-offset: 8px;
}

.yin-assistant::after {
  content: "";
  position: absolute;
  left: 14%;
  right: 14%;
  bottom: -7px;
  height: 12px;
  border-radius: 999px;
  background: radial-gradient(circle at center, rgba(0, 0, 0, 0.38), rgba(0, 0, 0, 0));
  filter: blur(5px);
  opacity: 0.64;
  pointer-events: none;
}

.yin-assistant__body {
  position: absolute;
  inset: 0;
  display: block;
  transform-origin: 50% 96%;
  animation: yinAssistantBreath 4.8s ease-in-out infinite;
}

.yin-assistant__image {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: auto;
  filter:
    drop-shadow(0 12px 14px rgba(0, 0, 0, 0.36))
    drop-shadow(0 0 13px rgba(242, 198, 61, 0.16));
  transition: filter 0.12s ease, transform 0.12s ease;
}

.yin-assistant__bubble {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  width: max-content;
  max-width: min(clamp(200px, 28vw, 320px), calc(100vw - 32px));
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: clamp(12px, 1vw, 15px);
  font-weight: 800;
  line-height: 1.45;
  text-align: left;
  white-space: pre-line;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.yin-assistant__bubble.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.yin-assistant.is-wave .yin-assistant__body,
.yin-assistant[data-state="wave"] .yin-assistant__body {
  animation: yinAssistantWave 0.65s ease 1;
}

.yin-assistant[data-state="talk"] .yin-assistant__body,
.yin-assistant[data-state="easterEgg"] .yin-assistant__body {
  animation: yinAssistantBreath 4.8s ease-in-out infinite;
}

.yin-assistant.is-blink .yin-assistant__image {
  filter:
    brightness(0.82)
    drop-shadow(0 12px 14px rgba(0, 0, 0, 0.36))
    drop-shadow(0 0 13px rgba(242, 198, 61, 0.16));
  transform: scaleY(0.985);
}

@keyframes yinAssistantBreath {
  0%, 100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.025);
  }
}

@keyframes yinAssistantWave {
  0%, 100% {
    transform: rotate(0deg) scale(1);
  }

  25% {
    transform: rotate(-5deg) scale(1.03);
  }

  50% {
    transform: rotate(5deg) scale(1.03);
  }

  75% {
    transform: rotate(-2deg) scale(1.01);
  }
}

@media (prefers-reduced-motion: reduce) {
  .yin-assistant__body,
  .yin-assistant.is-wave .yin-assistant__body,
  .yin-assistant[data-state="wave"] .yin-assistant__body,
  .yin-assistant[data-state="talk"] .yin-assistant__body,
  .yin-assistant[data-state="easterEgg"] .yin-assistant__body {
    animation: none;
  }
}

@media (max-width: 768px) {
  .yin-assistant {
    right: 12px;
    bottom: 12px;
    width: clamp(96px, 28vw, 130px);
  }

  .yin-assistant__bubble {
    max-width: min(220px, calc(100vw - 24px));
    padding: 7px 9px;
    font-size: 12px;
  }
}
