/* ─────────────────────────────────────────────
   右下角桌面宠物挂件
   播放器本体是 /pet/pet_frames.html，用 iframe 隔离，
   隐藏时直接移除 iframe —— 图像和声音一起停。
   ───────────────────────────────────────────── */

.pet-root {
  position: fixed;
  right: 16px;
  bottom: 10px;
  /* 高度给够人物，宽度留够气泡（她原本的气泡最大 240px 宽） */
  width: 268px;
  height: 356px;
  z-index: 75;   /* 高于台词气泡：鼠标移上去时工具条要能盖住气泡 */
  pointer-events: none;
}

.pet-frame {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
  background: transparent;
  pointer-events: auto;
}

/* 工具条：默认隐藏，鼠标移到宠物上才出现 */
.pet-tools {
  position: absolute;
  top: 6px;
  right: 4px;
  display: flex;
  gap: 5px;
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.16s ease;
}

.pet-root:hover .pet-tools,
.pet-root:focus-within .pet-tools {
  opacity: 1;
}

.pet-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.84);
  color: #333;
  font: 14px/1 system-ui, "Segoe UI", sans-serif;
  cursor: pointer;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transition: background 0.15s ease, transform 0.15s ease;
}

.pet-btn:hover {
  background: #fff;
  transform: scale(1.08);
}

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

.pet-btn:focus-visible {
  outline: 2px solid #b4553c;
  outline-offset: 1px;
}

/* ── 台词气泡（画在页面层，不受 iframe 宽度限制） ── */
.pet-bubble {
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 70;
  box-sizing: border-box;
  width: max-content;
  max-width: min(380px, calc(100vw - 24px));
  padding: 8px 14px;
  border: 1px solid rgba(200, 220, 255, 0.35);
  border-radius: 14px;
  background: rgba(20, 24, 36, 0.82);
  color: #eaf2ff;
  font: 13px/1.5 "Segoe UI", system-ui, "Microsoft YaHei", sans-serif;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.67);
  white-space: pre-line;
  overflow-wrap: break-word;
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.pet-bubble.show {
  opacity: 1;
  transform: translateY(0);
}

.pet-bubble::after {
  content: "";
  position: absolute;
  left: var(--arrow-x, 50%);
  top: 100%;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: rgba(20, 24, 36, 0.82);
}

@media (prefers-color-scheme: dark) {
  .pet-bubble {
    border-color: rgba(255, 255, 255, 0.14);
  }
}

/* 隐藏后留在角落的小召唤按钮 */.pet-recall {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.7);
  font: 16px/1 system-ui, sans-serif;
  cursor: pointer;
  opacity: 0.32;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.pet-recall:hover {
  opacity: 1;
  transform: scale(1.08);
}

.pet-recall:focus-visible {
  opacity: 1;
  outline: 2px solid #b4553c;
  outline-offset: 2px;
}

@media (prefers-color-scheme: dark) {
  .pet-btn {
    background: rgba(42, 39, 37, 0.84);
    color: #e6e1da;
    border-color: rgba(255, 255, 255, 0.14);
  }
  .pet-btn:hover {
    background: rgba(62, 58, 54, 0.96);
  }
  .pet-recall {
    background: rgba(42, 39, 37, 0.8);
    border-color: rgba(255, 255, 255, 0.12);
  }
}

/* 触屏没有 hover，工具条常驻 */
@media (hover: none) {
  .pet-tools {
    opacity: 1;
  }
}

@media (max-width: 640px) {
  .pet-root {
    width: 176px;
    height: 234px;
    right: 6px;
    bottom: 4px;
  }
  .pet-recall {
    right: 10px;
    bottom: 10px;
    width: 30px;
    height: 30px;
  }
}

@media print {
  .pet-root,
  .pet-recall {
    display: none !important;
  }
}
