/* Floating pet: links the homepage to the mini game (game/index.html). */
.pet {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
}

.pet-body {
  position: relative;
  width: 112px;
  height: 118px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.pet-body:hover {
  transform: translateY(-3px);
}

.pet-body:active {
  transform: scale(0.96);
}

.pet.is-dragging .pet-body {
  cursor: grabbing;
  transform: scale(1.06);
  transition: none;
}

.pet.is-dragging .pet-body::after {
  opacity: 0.5;
}

.pet-body:focus-visible {
  outline: 2px solid var(--accent-strong, #e0ae51);
  outline-offset: 4px;
  border-radius: 20px;
}

.pet-body::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 1px;
  width: 46px;
  height: 7px;
  border-radius: 50%;
  background: rgba(20, 20, 20, 0.14);
  filter: blur(3px);
  transform: translateX(-50%);
  z-index: -1;
}

.pet-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.pet-bubble {
  position: relative;
  margin: 0 18px 6px 0;
  padding: 12px 16px 11px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  box-shadow: 0 12px 32px rgba(31, 18, 8, 0.12);
  color: var(--text, #141414);
  font-family: var(--font-ui, -apple-system, sans-serif);
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(8px) scale(0.92);
  transform-origin: bottom right;
  transition: opacity 0.28s ease, transform 0.4s cubic-bezier(0.2, 0.9, 0.25, 1.2);
}

.pet-bubble::after {
  content: "";
  position: absolute;
  right: 30px;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: inherit;
  border-right: 1px solid rgba(255, 255, 255, 0.7);
  border-bottom: 1px solid rgba(255, 255, 255, 0.7);
  transform: rotate(45deg);
}

.pet.is-open .pet-bubble {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.pet-bubble strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.pet-bubble span {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-muted, rgba(20, 20, 20, 0.58));
}

@media (max-width: 640px) {
  .pet {
    right: 10px;
    bottom: 10px;
  }

  .pet-body {
    width: 88px;
    height: 93px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pet-body,
  .pet-bubble {
    transition: none;
  }
}

.pet-canvas {
  transform-origin: 50% 100%;
}

/* Dangling from the head while dragged. */
.pet.is-lifted .pet-canvas {
  transform-origin: 50% 6%;
}

/* Small reaction line (shy / lifted / landed); not clickable. */
.pet-say {
  position: absolute;
  left: 50%;
  bottom: calc(100% - 4px);
  padding: 6px 11px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(16px) saturate(1.5);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  box-shadow: 0 8px 22px rgba(31, 18, 8, 0.1);
  color: var(--text, #141414);
  font-family: var(--font-ui, -apple-system, sans-serif);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 6px) scale(0.9);
  transition: opacity 0.2s ease, transform 0.3s cubic-bezier(0.2, 0.9, 0.25, 1.3);
}

.pet.is-saying .pet-say {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

@media (max-width: 640px) {
  .pet-say {
    font-size: 12px;
  }
}

/* The reaction line follows the head: lower when crouching, higher when dangling. */
.pet.is-shy .pet-say {
  bottom: calc(100% - 20px);
}

.pet.is-lifted .pet-say {
  bottom: calc(100% + 8px);
}
