.shell {
  position: relative;
  overflow: visible;
}

.pet-buddy {
  position: absolute;
  top: clamp(28px, 5vw, 50px);
  right: clamp(24px, 4.8vw, 54px);
  z-index: 2;
  width: 74px;
  height: 80px;
  pointer-events: none;
  transform-origin: 50% 100%;
  animation: pet-buddy-float 2600ms ease-in-out infinite;
  border-radius: 8px;
  user-select: none;
}

.pet-buddy__menu[hidden],
.pet-buddy__actions[hidden] {
  display: none;
}

.pet-buddy__sprite {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: grab;
  filter: drop-shadow(0 12px 9px rgba(16, 32, 51, 0.2));
  image-rendering: auto;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
}

.pet-buddy:focus-visible {
  outline: 3px solid var(--focus, #f2b84b);
  outline-offset: 6px;
}

.pet-buddy.is-dragging .pet-buddy__sprite,
.pet-buddy.is-dragging .pet-buddy__drag-handle {
  cursor: grabbing;
}

.pet-buddy.is-dragging,
.pet-buddy.is-settling {
  animation: none;
}

.pet-buddy.is-dragging .pet-buddy__sprite,
.pet-buddy.is-dragging .pet-buddy__drag-handle {
  touch-action: none;
}

.pet-buddy__drag-handle {
  position: absolute;
  right: -30px;
  bottom: 2px;
  width: 30px;
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid rgba(16, 32, 51, 0.12);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 6px 18px rgba(16, 32, 51, 0.14);
  color: var(--navy, #1f3550);
  cursor: grab;
  font-size: 0;
  opacity: 0;
  pointer-events: none;
  touch-action: none;
  transform: translate(4px, 3px) scale(0.9);
  transition:
    opacity 140ms ease,
    transform 140ms ease;
}

.pet-buddy__drag-handle::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 13px;
  height: 13px;
  content: "";
  background:
    radial-gradient(circle at 3px 3px, currentColor 1.45px, transparent 1.55px),
    radial-gradient(circle at 10px 3px, currentColor 1.45px, transparent 1.55px),
    radial-gradient(circle at 3px 10px, currentColor 1.45px, transparent 1.55px),
    radial-gradient(circle at 10px 10px, currentColor 1.45px, transparent 1.55px);
  opacity: 0.72;
  transform: translate(-50%, -50%);
}

.pet-buddy__drag-handle:focus-visible {
  outline: 3px solid var(--focus, #f2b84b);
  outline-offset: 3px;
}

.pet-buddy:hover .pet-buddy__drag-handle,
.pet-buddy:focus-within .pet-buddy__drag-handle,
.pet-buddy[data-pet-near] .pet-buddy__drag-handle,
.pet-buddy.is-dragging .pet-buddy__drag-handle,
.pet-buddy.is-menu-open .pet-buddy__drag-handle {
  opacity: 1;
  pointer-events: auto;
  transform: translate(0, 0) scale(1);
}

.pet-buddy__menu {
  position: absolute;
  top: calc(100% + 17px);
  right: -6px;
  display: grid;
  gap: 8px;
  width: 184px;
  padding: 10px;
  border: 1px solid rgba(16, 32, 51, 0.13);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 42px rgba(16, 32, 51, 0.18);
  pointer-events: auto;
}

.pet-buddy__actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.pet-buddy__actions[data-action-count="1"] {
  grid-template-columns: 1fr;
}

.pet-buddy__menu-button,
.pet-buddy__pet-name,
.pet-buddy__pet-switch {
  font: 700 0.78rem/1.1 Inter, ui-sans-serif, system-ui, sans-serif;
}

.pet-buddy__menu-button,
.pet-buddy__pet-switch {
  border: 1px solid rgba(16, 32, 51, 0.12);
  border-radius: 7px;
  background: #ffffff;
  color: var(--navy, #1f3550);
  cursor: pointer;
}

.pet-buddy__menu-button {
  min-height: 36px;
  padding: 0 7px;
  line-height: 1.05;
}

.pet-buddy__menu-button:hover,
.pet-buddy__pet-switch:hover {
  border-color: rgba(0, 137, 150, 0.45);
  background: rgba(0, 137, 150, 0.08);
}

.pet-buddy__menu-button:focus-visible,
.pet-buddy__pet-switch:focus-visible {
  outline: 3px solid var(--focus, #f2b84b);
  outline-offset: 2px;
  border-color: rgba(0, 137, 150, 0.55);
}

.pet-buddy__pet-switch:disabled {
  cursor: default;
  opacity: 0.45;
}

.pet-buddy__pet-field {
  display: grid;
  gap: 5px;
}

.pet-buddy__pet-field > span:first-child {
  color: var(--muted, #627185);
  font: 700 0.68rem/1 Inter, ui-sans-serif, system-ui, sans-serif;
  text-transform: uppercase;
}

.pet-buddy__pet-switcher {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 6px;
}

.pet-buddy__pet-switch {
  display: grid;
  min-height: 32px;
  padding: 0;
  place-items: center;
}

.pet-buddy__pet-name {
  display: flex;
  min-width: 0;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  overflow: hidden;
  border: 1px solid rgba(16, 32, 51, 0.14);
  border-radius: 7px;
  background: rgba(0, 137, 150, 0.06);
  color: var(--ink, #102033);
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes pet-buddy-float {
  0%,
  100% {
    transform: translateY(0) rotate(-1deg);
  }

  50% {
    transform: translateY(-4px) rotate(1deg);
  }
}

@media (max-width: 660px) {
  .pet-buddy {
    position: fixed;
    top: auto;
    right: 14px;
    bottom: 14px;
    width: 62px;
    height: 67px;
  }

  .pet-buddy__menu {
    top: auto;
    right: 0;
    bottom: calc(100% + 18px);
    width: min(184px, calc(100vw - 28px));
  }

  .pet-buddy__menu-button,
  .pet-buddy__pet-switch {
    min-height: 36px;
  }

}

@media (prefers-reduced-motion: reduce) {
  .pet-buddy {
    animation: none;
  }

  .pet-buddy__drag-handle,
  .pet-buddy__menu-button,
  .pet-buddy__pet-switch {
    transition: none;
  }

  .pet-buddy.is-dragging,
  .pet-buddy.is-settling {
    animation: none;
  }
}
