.shana-pet {
  --pet-width: 294px;
  --pet-height: 357px;
  --pet-safe-top: env(safe-area-inset-top, 0px);
  --pet-safe-right: env(safe-area-inset-right, 0px);
  --pet-safe-bottom: env(safe-area-inset-bottom, 0px);
  --pet-safe-left: env(safe-area-inset-left, 0px);
  position: fixed;
  left: max(8px, env(safe-area-inset-left));
  bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 2147482000;
  width: var(--pet-width);
  height: var(--pet-height);
  pointer-events: none;
  contain: style;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  transition: opacity 160ms ease, transform 160ms ease;
}

.shana-pet[hidden],
.shana-pet.is-unavailable,
.shana-pet.is-keyboard-open {
  display: none !important;
}

.shana-pet__restore[hidden] {
  display: none !important;
}

.shana-pet__stage {
  position: absolute;
  inset: 0;
  pointer-events: none;
  filter: drop-shadow(0 12px 12px rgba(15, 23, 42, 0.2));
}

.shana-pet__stage canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  pointer-events: none;
}

.shana-pet__hit {
  appearance: none;
  position: absolute;
  inset: 0;
  z-index: 2;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  touch-action: none;
  clip-path: polygon(
    34% 3%, 66% 3%, 77% 19%, 82% 39%, 100% 65%, 82% 73%,
    76% 97%, 20% 97%, 8% 84%, 24% 61%, 18% 40%, 29% 20%
  );
}

.shana-pet__hit:focus-visible {
  outline: 2px solid #b91c1c;
  outline-offset: -5px;
}

.shana-pet__close,
.shana-pet__sound,
.shana-pet__restore {
  appearance: none;
  border: 1px solid rgba(127, 29, 29, 0.28);
  background: rgba(255, 255, 255, 0.94);
  color: #7f1d1d;
  box-shadow: 0 5px 16px rgba(15, 23, 42, 0.14);
  cursor: pointer;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.shana-pet__close {
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 3;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  opacity: 0;
  transition: opacity 150ms ease;
}

.shana-pet__sound {
  position: absolute;
  right: 38px;
  top: 2px;
  z-index: 3;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
  opacity: 0;
  transition: opacity 150ms ease;
}

.shana-pet__sound::before { content: "\1F50A"; }
.shana-pet.is-muted .shana-pet__sound::before { content: "\1F507"; }

.shana-pet:hover .shana-pet__close,
.shana-pet:hover .shana-pet__sound,
.shana-pet:focus-within .shana-pet__close,
.shana-pet:focus-within .shana-pet__sound {
  opacity: 1;
}

.shana-pet.is-dragging {
  transition: none;
  user-select: none;
}

.shana-pet.is-dragging .shana-pet__hit { cursor: grabbing; }

.shana-pet__dialog {
  position: absolute;
  left: 93px;
  bottom: 18px;
  width: min(340px, calc(100vw - 90px));
  min-height: 86px;
  padding: 20px 22px 17px 28px;
  border: 1px solid rgba(127, 29, 29, 0.76);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(185, 28, 28, 0.12), transparent 32%) border-box,
    rgba(255, 255, 255, 0.96);
  color: #2b1111;
  box-shadow:
    inset 0 0 0 2px rgba(250, 204, 21, 0.3),
    0 14px 30px rgba(15, 23, 42, 0.2);
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  visibility: hidden;
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms;
}

.shana-pet.is-right-side .shana-pet__dialog {
  left: auto;
  right: 93px;
}

.shana-pet__dialog::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 15px;
  width: 7px;
  height: 7px;
  background: #b91c1c;
  border: 1px solid #facc15;
  transform: rotate(45deg);
}

.shana-pet__dialog.is-visible {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

.shana-pet__name {
  display: block;
  margin: 0 0 5px;
  color: #991b1b;
  font-size: 12px;
  font-weight: 800;
}

.shana-pet__line {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.shana-pet__restore {
  --pet-safe-top: env(safe-area-inset-top, 0px);
  --pet-safe-right: env(safe-area-inset-right, 0px);
  --pet-safe-bottom: env(safe-area-inset-bottom, 0px);
  --pet-safe-left: env(safe-area-inset-left, 0px);
  position: fixed;
  left: max(8px, env(safe-area-inset-left));
  top: max(8px, env(safe-area-inset-top));
  bottom: auto;
  z-index: 2147482000;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
  touch-action: none;
  transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.shana-pet__restore:hover {
  border-color: rgba(153, 27, 27, 0.48);
  background: #fff;
}

.shana-pet__restore:focus-visible {
  outline: 2px solid #b91c1c;
  outline-offset: 2px;
}

.shana-pet__restore.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.shana-pet__restore svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

@media (max-width: 1100px) {
  .shana-pet {
    --pet-width: 186px;
    --pet-height: 227px;
    left: max(2px, env(safe-area-inset-left));
    bottom: max(2px, env(safe-area-inset-bottom));
  }

  .shana-pet__close {
    width: 36px;
    height: 36px;
    font-size: 18px;
    opacity: 1;
  }

  .shana-pet__sound {
    right: 42px;
    width: 36px;
    height: 36px;
    opacity: 1;
  }

  .shana-pet__restore {
    width: 36px;
    height: 36px;
  }

  .shana-pet__restore svg {
    width: 18px;
    height: 18px;
  }

  .shana-pet__dialog {
    position: fixed;
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: calc(213px + env(safe-area-inset-bottom));
    width: auto;
    min-height: 74px;
    padding: 17px 18px 15px 25px;
  }

  .shana-pet.is-right-side .shana-pet__dialog {
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
  }

  .shana-pet__line {
    font-size: 13px;
  }
}

@media (max-width: 720px) {
  .shana-pet {
    --pet-width: 162px;
    --pet-height: 198px;
  }

  .shana-pet__dialog {
    bottom: calc(184px + env(safe-area-inset-bottom));
  }
}

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