/* =========================================================
   ghxiaochi 的像素头像桌宠
   ---------------------------------------------------------
   只出现在「全部项目」页左下角；右下角保留学校校徽。
   点击轮播台词，点满 6 次出现隐藏彩蛋。
   不做拖拽、滚轮缩放、键盘缩放。
   ========================================================= */

.hnyz-avatar {
  position: fixed;
  left: 16.4px; /* fallback: 旧内核 */
  left: clamp(8px, 1.6vw, 20px);
  bottom: 16.9px; /* fallback: 旧内核 */
  bottom: clamp(10px, 2.2vh, 22px);
  z-index: 35;
  width: 82px; /* fallback: 旧内核 */
  width: clamp(82px, 8vw, 112px);
  pointer-events: none;
  opacity: 0;
  transform: translateY(12px);
  animation: hnyz-avatar-in 0.6s 0.5s ease-out forwards;
}

.hnyz-avatar__button {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: transparent;
  color: inherit;
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.hnyz-avatar__button:active {
  cursor: grabbing;
}

.hnyz-avatar__button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 8px;
}

.hnyz-avatar__button::before {
  content: "";
  position: absolute;
  top: 8%; /* fallback: 旧内核 */
  right: 0; /* fallback: 旧内核 */
  bottom: 12%; /* fallback: 旧内核 */
  left: 0; /* fallback: 旧内核 */
  inset: 8% 0 12%;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 44%, rgba(74, 222, 128, 0.24), rgba(96, 165, 250, 0.1) 54%, transparent 72%);
  filter: blur(8px);
  pointer-events: none;
}

.hnyz-avatar__img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: auto;
  image-rendering: auto;
  filter: drop-shadow(0 12px 16px rgba(15, 118, 110, 0.2));
  animation: hnyz-avatar-float 5.2s ease-in-out infinite;
}

.hnyz-avatar__name {
  position: relative;
  z-index: 2;
  display: block;
  width: max-content;
  max-width: 100%;
  margin: 3px auto 0;
  padding: 2px 8px;
  border: 1px solid rgba(147, 197, 253, 0.75);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.56rem;
  line-height: 1.5;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* 台词气泡：从头顶左侧弹出 */
.hnyz-avatar__speech {
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  z-index: 5;
  width: max-content;
  max-width: 220px;
  margin: 0;
  padding: 9px 13px;
  border: 1px solid rgba(147, 197, 253, 0.85);
  border-radius: 12px 12px 12px 4px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.16);
  color: var(--text-soft);
  font-size: 0.75rem;
  line-height: 1.65;
  text-align: left;
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  transform-origin: 0 100%;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.hnyz-avatar__speech::after {
  content: "";
  position: absolute;
  left: 17px;
  bottom: -7px;
  width: 11px;
  height: 11px;
  border-right: 1px solid rgba(147, 197, 253, 0.85);
  border-bottom: 1px solid rgba(147, 197, 253, 0.85);
  background: rgba(255, 255, 255, 0.98);
  transform: rotate(45deg);
}

.hnyz-avatar.is-speaking .hnyz-avatar__speech {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.hnyz-avatar.is-poked .hnyz-avatar__img {
  animation: hnyz-avatar-poke 0.5s ease;
}

/* 彩蛋出现时，名字标签变绿一点点 */
.hnyz-avatar.is-secret .hnyz-avatar__name {
  border-color: rgba(74, 222, 128, 0.8);
  background: #f0fdf4;
  color: #15803d;
}

@keyframes hnyz-avatar-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes hnyz-avatar-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

/* 点击时的小星星：从头顶散开、向上飘走 */
.hnyz-avatar__spark {
  position: absolute;
  left: 50%;
  bottom: 54%;
  z-index: 6;
  color: var(--blue);
  font-size: var(--size, 12px);
  line-height: 1;
  pointer-events: none;
  opacity: 0;
  animation: hnyz-avatar-spark 1.05s cubic-bezier(0.22, 0.61, 0.36, 1) var(--delay, 0s) forwards;
}

@keyframes hnyz-avatar-spark {
  0% {
    opacity: 0;
    transform: translate(-50%, 0) scale(0.35) rotate(0deg);
  }
  18% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--px, 0px)), var(--py, -70px)) scale(1.15) rotate(40deg);
  }
}

/* 彩蛋状态：整只头像泛一层绿光 */
.hnyz-avatar.is-secret .hnyz-avatar__img {
  filter: drop-shadow(0 0 16px rgba(74, 222, 128, 0.8))
    drop-shadow(0 12px 16px rgba(15, 118, 110, 0.24));
}

@keyframes hnyz-avatar-poke {
  0% {
    transform: scale(1) rotate(0deg);
  }
  20% {
    transform: scale(1.14, 0.86) rotate(-4deg);
  }
  45% {
    transform: scale(0.9, 1.13) rotate(4deg);
  }
  70% {
    transform: scale(1.05, 0.95) rotate(-2deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}

@media (max-width: 720px) {
  .hnyz-avatar {
    left: 8px;
    bottom: 8px;
    width: 76px;
  }

  .hnyz-avatar__speech {
    max-width: 182px;
    font-size: 0.7rem;
  }
}

@media (max-width: 400px) {
  .hnyz-avatar {
    width: 56px;
  }

  .hnyz-avatar__speech {
    max-width: 150px;
  }
}

@media (max-width: 340px) {
  .hnyz-avatar {
    width: 50px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hnyz-avatar {
    opacity: 1;
    transform: none;
    animation: none;
  }

  .hnyz-avatar__img,
  .hnyz-avatar.is-poked .hnyz-avatar__img {
    animation: none;
  }

  .hnyz-avatar__speech {
    transition: none;
  }
}

/* 当「ghxiaochi 的主页」横幅进入视口时，暂时收起固定头像，避免挡住主页文字 */
.hnyz-avatar.is-away {
  visibility: hidden;
  pointer-events: none;
}

/* =========================================================
   首页召唤模式
   ---------------------------------------------------------
   默认不出现（opacity: 0），点右侧按钮后滑入；
   26 秒后自己滑回右侧「项目区」。
   ========================================================= */
.hnyz-avatar--summon {
  left: auto;
  right: 26.6px; /* fallback: 旧内核 */
  right: clamp(18px, 2.6vw, 40px);
  bottom: 153.6px; /* fallback: 旧内核 */
  bottom: clamp(150px, 20vh, 210px);
  animation: none;
  opacity: 0;
  transform: translate(26px, 18px) scale(0.9);
  /* visibility 让隐藏时不参与 Tab 焦点 */
  visibility: hidden;
  transition: opacity 0.4s ease, transform 0.5s cubic-bezier(0.22, 0.61, 0.36, 1),
    visibility 0s linear 0.45s;
  pointer-events: none;
}

.hnyz-avatar--summon .hnyz-avatar__button {
  pointer-events: none;
}

.hnyz-avatar--summon.is-visible {
  opacity: 1;
  transform: none;
  visibility: visible;
  transition: opacity 0.4s ease, transform 0.5s cubic-bezier(0.22, 0.61, 0.36, 1),
    visibility 0s;
}

.hnyz-avatar--summon.is-visible .hnyz-avatar__button {
  pointer-events: auto;
}

.hnyz-avatar--summon.is-leaving {
  opacity: 0;
  transform: translate(96px, 10px) scale(0.86);
}

/* 靠右的桌宠，气泡改成右侧对齐，不然文字会顶出屏幕 */
.hnyz-avatar--summon .hnyz-avatar__speech {
  left: auto;
  right: 0;
  border-radius: 12px 12px 4px 12px;
}

.hnyz-avatar--summon .hnyz-avatar__speech::after {
  left: auto;
  right: 17px;
}

/* 挥手 */
.hnyz-avatar.is-waving .hnyz-avatar__img {
  animation: hnyz-avatar-wave 0.75s ease;
}

@keyframes hnyz-avatar-wave {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(-7deg); }
  42% { transform: rotate(6deg); }
  64% { transform: rotate(-4deg); }
  82% { transform: rotate(2deg); }
}

/* 被连点太多下：左右晃 */
.hnyz-avatar.is-dizzy .hnyz-avatar__img {
  animation: hnyz-avatar-dizzy 0.5s linear 3;
}

@keyframes hnyz-avatar-dizzy {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  20% { transform: translateX(-5px) rotate(-4deg); }
  40% { transform: translateX(5px) rotate(4deg); }
  60% { transform: translateX(-4px) rotate(-2deg); }
  80% { transform: translateX(4px) rotate(2deg); }
}

/* =========================================================
   右侧召唤按钮
   ========================================================= */
.pet-summon {
  position: fixed;
  top: 44%;
  right: 0;
  z-index: 36;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px 10px 9px;
  border: 1px solid var(--border-strong);
  border-right: 0;
  border-radius: 14px 0 0 14px;
  background: var(--panel);
  box-shadow: -8px 10px 26px rgba(30, 64, 175, 0.14);
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 0.6rem;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.pet-summon:hover {
  transform: translateX(-4px);
  border-color: var(--blue);
  box-shadow: -10px 12px 30px rgba(37, 99, 235, 0.22);
}

.pet-summon:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

.pet-summon.is-active {
  border-color: var(--green);
  color: var(--green-bright);
}

.pet-summon.is-active .pet-summon__icon::after {
  content: "";
  position: absolute;
  right: -2px;
  bottom: 0;
  width: 8px;
  height: 8px;
  border: 2px solid var(--panel);
  border-radius: 50%;
  background: var(--green);
}

.pet-summon__icon {
  position: relative;
}

.pet-summon__icon {
  display: block;
  width: 26px;
  height: 38px;
  flex-shrink: 0;
}

.pet-summon__icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 6px rgba(15, 118, 110, 0.22));
}

.pet-summon__label {
  white-space: nowrap;
}

@media (max-width: 900px) {
  .pet-summon {
    top: auto;
    bottom: 104px;
    padding: 8px 9px 8px 7px;
  }

  /* 手机上桌宠缩一号，放在按钮上方，别压住主要按钮 */
  .hnyz-avatar--summon {
    right: 6px;
    bottom: 178px;
    width: 60px;
  }

  .hnyz-avatar--summon .hnyz-avatar__speech {
    max-width: 158px;
    font-size: 0.66rem;
    padding: 7px 10px;
  }

  .pet-summon__label {
    display: none;
  }

  .pet-summon__icon {
    width: 24px;
    height: 35px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hnyz-avatar--summon {
    transition: none;
  }

  .hnyz-avatar.is-waving .hnyz-avatar__img,
  .hnyz-avatar.is-dizzy .hnyz-avatar__img {
    animation: none;
  }
}

/* =========================================================
   100 次彩蛋：暴走 / 弹球 / 字幕爆炸 / 墓碑复活
   ========================================================= */

/* 暴走状态：接管定位，取消所有入场/漂浮/召唤的动画与过渡 */
.hnyz-avatar.is-rampage,
.hnyz-avatar--summon.is-rampage {
  z-index: 210 !important;
  opacity: 1 !important;
  visibility: visible !important;
  transition: none !important;
  animation: none !important;
  transform-origin: 0 0 !important;
  pointer-events: none;
  will-change: transform;
}

.hnyz-avatar.is-rampage .hnyz-avatar__img {
  animation: none !important;
  /* 不放 drop-shadow：1600px 大的元素每帧重算滤镜会卡 */
  filter: none !important;
}

.hnyz-avatar.is-rampage .hnyz-avatar__speech {
  display: none;
}

.hnyz-avatar.is-rampage .hnyz-avatar__button {
  cursor: default;
}

/* 爆炸时人先胀一下再消失 */
.hnyz-avatar.is-dying .hnyz-avatar__img {
  animation: petDie 0.7s ease-in forwards !important;
}

@keyframes petDie {
  0% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
  38% {
    opacity: 1;
    transform: scale(1.45) rotate(-6deg);
  }
  100% {
    opacity: 0;
    transform: scale(0.15) rotate(28deg);
  }
}

.hnyz-avatar.is-gone {
  display: none !important;
}

/* 复活：从小弹回来 */
.hnyz-avatar.is-reviving .hnyz-avatar__img {
  animation: petRevive 0.9s cubic-bezier(0.22, 0.9, 0.3, 1.3) both;
}

@keyframes petRevive {
  0% {
    opacity: 0;
    transform: scale(0.15) rotate(-16deg);
    filter: drop-shadow(0 0 22px rgba(74, 222, 128, 0.9));
  }
  55% {
    opacity: 1;
    transform: scale(1.12) rotate(4deg);
    filter: drop-shadow(0 0 16px rgba(74, 222, 128, 0.65));
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

/* 覆盖层：只用来放冲击波和碎片，不吃鼠标 */
.pet-overlay {
  position: fixed;
  top: 0; /* fallback: 旧内核 */
  right: 0; /* fallback: 旧内核 */
  bottom: 0; /* fallback: 旧内核 */
  left: 0; /* fallback: 旧内核 */
  inset: 0;
  z-index: 205;
  overflow: hidden;
  pointer-events: none;
}

/* 中间的字幕：一个红字的弹窗方框 */
.pet-rampage-line {
  --zoom: 1;
  --shake: 1;
  position: fixed;
  left: 50%;
  top: 40%;
  z-index: 212;
  width: max-content;
  max-width: 640px; /* fallback: 旧内核 */
  max-width: min(86vw, 640px);
  margin: 0;
  padding: 26px 34px 24px;
  border: 4px solid #14141a;
  border-radius: 8px;
  background: #fffdf5;
  box-shadow:
    10px 10px 0 rgba(20, 20, 26, 0.28),
    inset 0 0 0 3px #ffffff,
    inset 0 0 0 5px rgba(225, 29, 46, 0.18);
  color: #e11d2e;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Heiti SC", sans-serif;
  font-size: 38.9px; /* fallback: 旧内核 */
  font-size: clamp(1.35rem, 3.8vw, 2.5rem);
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.04em;
  line-height: 1.25;
  text-align: center;
  text-shadow:
    2px 2px 0 #ffd37f,
    4px 4px 0 rgba(20, 20, 26, 0.16);
  opacity: 0;
  transform: translate(-50%, -50%) rotate(-2deg) scale(calc(var(--zoom) * 0.82));
  transition: opacity 0.28s ease, transform 0.18s cubic-bezier(0.22, 0.9, 0.3, 1.4);
  pointer-events: none;
  will-change: transform, opacity;
  user-select: none;
}

/* 方框顶部的小标签，像老式弹窗的标题栏 */
.pet-rampage-line::before {
  content: "!! WARNING !!";
  position: absolute;
  top: -16px;
  left: 18px;
  padding: 3px 10px;
  border: 3px solid #14141a;
  background: #e11d2e;
  color: #fff8e7;
  font-family: var(--mono);
  font-size: 0.58rem;
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.22em;
  line-height: 1.4;
  text-shadow: none;
}

/* 右下角的小尾巴，像对话框 */
.pet-rampage-line::after {
  content: "";
  position: absolute;
  right: 34px;
  bottom: -18px;
  width: 22px;
  height: 22px;
  border-right: 4px solid #14141a;
  border-bottom: 4px solid #14141a;
  background: #fffdf5;
  transform: skewX(18deg) rotate(45deg);
}

.pet-rampage-line.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) rotate(-2deg) scale(var(--zoom));
  pointer-events: auto;
  cursor: zoom-in;
  touch-action: none;
}

.pet-rampage-line.is-boom {
  pointer-events: none;
}

/* 逐字抖动：每个字一个很小的错位，密度刚好是“老式显示器在抖” */
.pet-rampage-chars {
  display: inline;
}

/* 每隔两三秒整行抖一下，像信号不好 */
.pet-rampage-line.is-visible .pet-rampage-chars {
  animation: petLineGlitch 2.7s steps(1, end) infinite;
}

@keyframes petLineGlitch {
  0%, 92%, 100% { translate: 0 0; }
  93% { translate: -2px 1px; }
  95% { translate: 2px -1px; }
  97% { translate: -1px -1px; }
}

.pet-rampage-char {
  display: inline-block;
  animation: petCharShake 0.16s steps(2, end) infinite;
  animation-delay: calc(var(--i, 0) * -0.019s);
  will-change: transform;
}

@keyframes petCharShake {
  0% { transform: translate(0, 0) rotate(0deg); }
  25% {
    transform: translate(calc(-1px * var(--shake, 1)), calc(0.6px * var(--shake, 1)))
      rotate(calc(-0.7deg * var(--shake, 1)));
  }
  50% {
    transform: translate(calc(0.7px * var(--shake, 1)), calc(-0.8px * var(--shake, 1)))
      rotate(calc(0.5deg * var(--shake, 1)));
  }
  75% {
    transform: translate(calc(0.5px * var(--shake, 1)), calc(0.7px * var(--shake, 1)))
      rotate(calc(-0.4deg * var(--shake, 1)));
  }
  100% { transform: translate(0, 0) rotate(0deg); }
}

/* 缩放时的外框脉冲 */
.pet-rampage-line.is-bumped {
  animation: petLineBump 0.3s ease;
}

@keyframes petLineBump {
  0%, 100% {
    box-shadow:
      10px 10px 0 rgba(20, 20, 26, 0.28),
      inset 0 0 0 3px #ffffff,
      inset 0 0 0 5px rgba(225, 29, 46, 0.18);
  }
  50% {
    box-shadow:
      0 0 0 12px rgba(225, 29, 46, 0.22),
      10px 10px 0 rgba(20, 20, 26, 0.28),
      inset 0 0 0 3px #ffffff,
      inset 0 0 0 5px rgba(225, 29, 46, 0.3);
  }
}

/* 弹窗边缘的小粒子 */
.pet-line-spark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--sz, 6px);
  height: var(--sz, 6px);
  border-radius: 50%;
  background: var(--c, #e11d2e);
  box-shadow: 0 0 7px var(--c, #e11d2e);
  opacity: 0;
  pointer-events: none;
  animation: petLineSpark var(--d, 0.7s) cubic-bezier(0.15, 0.7, 0.25, 1) forwards;
}

.pet-line-spark:nth-child(3n) {
  border-radius: 2px;
}

@keyframes petLineSpark {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.4) rotate(0deg);
  }
  12% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(calc(var(--rot, 0deg) * 0.2));
  }
  70% {
    opacity: 0.92;
    transform: translate(calc(-50% + var(--dx, 0px) * 0.72), calc(-50% + var(--dy, 0px) * 0.72))
      scale(0.88) rotate(calc(var(--rot, 0deg) * 0.7));
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px)))
      scale(0.25) rotate(var(--rot, 0deg));
  }
}

/* 角落提示：告诉用户可以缩放 */
.pet-rampage-zoomhint {
  position: absolute;
  left: 14px;
  bottom: 7px;
  color: #b4232f;
  font-family: var(--mono);
  font-size: 9px;
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.12em;
  opacity: 0.55;
  text-shadow: none;
  pointer-events: none;
}

.pet-rampage-line.is-boom {
  animation: petLineBoom 0.75s cubic-bezier(0.3, 0, 0.6, 1) forwards;
}

/* 只用 transform / opacity，不用 filter: blur（大字号模糊会卡） */
@keyframes petLineBoom {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(-2deg) scale(1);
  }
  55% {
    opacity: 1;
    transform: translate(-50%, -52%) rotate(4deg) scale(1.5);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -54%) rotate(9deg) scale(3.2);
  }
}

/* 白闪 */
.pet-flash {
  position: fixed;
  top: 0; /* fallback: 旧内核 */
  right: 0; /* fallback: 旧内核 */
  bottom: 0; /* fallback: 旧内核 */
  left: 0; /* fallback: 旧内核 */
  inset: 0;
  z-index: 230;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
  animation: petFlash 0.5s ease-out forwards;
}

@keyframes petFlash {
  0% { opacity: 0.85; }
  100% { opacity: 0; }
}

/* 冲击波 */
.pet-shock {
  position: fixed;
  left: 50%;
  top: 46%;
  width: 60px;
  height: 60px;
  margin: -30px 0 0 -30px;
  border: 4px solid rgba(37, 99, 235, 0.65);
  border-radius: 50%;
  animation: petShock 0.85s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}

@keyframes petShock {
  0% {
    opacity: 0.9;
    transform: scale(0.3);
  }
  100% {
    opacity: 0;
    transform: scale(14);
  }
}

/* 碎片 */
.pet-shard {
  position: fixed;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  background: var(--c, #2563eb);
  pointer-events: none;
  animation: petShard 0.9s cubic-bezier(0.2, 0.6, 0.4, 1) forwards;
}

@keyframes petShard {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx, 0), var(--dy, 0)) scale(0.3) rotate(var(--rot, 180deg));
  }
}

/* ---------- 墓碑 ---------- */
.pet-tomb-veil {
  position: fixed;
  top: 0; /* fallback: 旧内核 */
  right: 0; /* fallback: 旧内核 */
  bottom: 0; /* fallback: 旧内核 */
  left: 0; /* fallback: 旧内核 */
  inset: 0;
  z-index: 214;
  background:
    radial-gradient(circle at 50% 54%, rgba(15, 23, 42, 0.42), rgba(15, 23, 42, 0.22) 58%, rgba(15, 23, 42, 0.08));
  opacity: 0;
  transition: opacity 0.45s ease;
  pointer-events: none;
}

.pet-tomb-veil.is-visible {
  opacity: 1;
}

.pet-tomb {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 215;
  display: grid;
  justify-items: center;
  transform: translate(-50%, calc(-50% + 24px)) scale(0.9);
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.5s cubic-bezier(0.22, 0.9, 0.3, 1.25);
}

.pet-tomb[hidden] {
  display: none;
}

.pet-tomb.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.pet-tomb.is-leaving {
  opacity: 0;
  transform: translate(-50%, calc(-50% + 18px)) scale(0.92);
}

.pet-tomb__btn {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.pet-tomb__btn:focus-visible {
  outline: 2px dashed rgba(255, 211, 127, 0.8);
  outline-offset: 10px;
  border-radius: 26px;
}

.pet-tomb__stone {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 3px;
  width: 184.3px; /* fallback: 旧内核 */
  width: clamp(168px, 18vw, 212px);
  aspect-ratio: 0.7;
  padding: 12px 14px 16px;
  border: 3px solid #2a323e;
  border-radius: 999px 999px 8px 8px;
  background:
    linear-gradient(180deg, #8d99ad 0%, #6f7b8f 30%, #4f5a6c 66%, #353d4c 100%);
  box-shadow:
    inset 0 -7px 0 rgba(16, 22, 32, 0.28),
    inset 0 7px 0 rgba(255, 255, 255, 0.16),
    0 26px 44px rgba(15, 23, 42, 0.45);
  color: #f4f8ff;
  text-align: center;
  text-shadow: 0 1px 0 rgba(12, 18, 28, 0.55);
  transition: transform 0.25s ease, filter 0.25s ease;
}

.pet-tomb__btn:hover .pet-tomb__stone {
  transform: translateY(-3px);
  filter: brightness(1.06);
}

/* 墓碑上刻着桌宠的样子 */
.pet-tomb__portrait {
  position: relative;
  display: block;
  overflow: hidden;
  width: 108px;
  height: 128px;
  margin: 2px auto 6px;
  border-radius: 7px;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(255, 255, 255, 0.16), transparent 70%),
    linear-gradient(180deg, #6c778b, #485264);
  box-shadow:
    inset 0 0 0 2px rgba(24, 30, 40, 0.5),
    inset 0 8px 14px rgba(12, 16, 24, 0.45);
}

.pet-tomb__portrait img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 2%;
  image-rendering: pixelated;
  filter: grayscale(1) brightness(0.66) contrast(1.08);
  opacity: 0.95;
}

/* 敲一下多一条裂纹 */
.pet-tomb__stone::after {
  content: "";
  position: absolute;
  top: 0; /* fallback: 旧内核 */
  right: 0; /* fallback: 旧内核 */
  bottom: 0; /* fallback: 旧内核 */
  left: 0; /* fallback: 旧内核 */
  inset: 0;
  border-radius: inherit;
  background-image:
    linear-gradient(112deg, transparent 46.6%, rgba(24, 28, 36, 0.55) 47.8%, transparent 49.4%),
    linear-gradient(64deg, transparent 47%, rgba(24, 28, 36, 0.4) 48.2%, transparent 50%);
  background-size: 58px 104px, 84px 150px;
  opacity: calc(var(--cracks, 0) * 0.17);
  mix-blend-mode: multiply;
  pointer-events: none;
}

.pet-tomb__stone[data-clicks="1"] { --cracks: 1; }
.pet-tomb__stone[data-clicks="2"] { --cracks: 2; }
.pet-tomb__stone[data-clicks="3"] { --cracks: 3; }
.pet-tomb__stone[data-clicks="4"] { --cracks: 4; }
.pet-tomb__stone[data-clicks="5"] { --cracks: 5; }

/* 5 个提示点：敲一下亮一个 */
.pet-tomb__pips {
  display: flex;
  gap: 6px;
  margin-top: 7px;
}

.pet-tomb__pips i {
  width: 7px;
  height: 7px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  background: transparent;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.pet-tomb__pips i.is-on {
  border-color: #ffd37f;
  background: #ffd37f;
  box-shadow: 0 0 7px rgba(255, 211, 127, 0.9);
}

/* 敲墓碑时抖一下 */
.pet-tomb.is-hit .pet-tomb__stone {
  animation: petTombHit 0.22s linear;
}

@keyframes petTombHit {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  30% { transform: translate(-3px, 1px) rotate(-1.2deg); }
  65% { transform: translate(3px, -1px) rotate(1.2deg); }
}

.pet-tomb__stone::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -13px;
  width: 132%;
  height: 26px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(34, 197, 94, 0.35), transparent 68%);
  pointer-events: none;
}

.pet-tomb__name {
  font-weight: 800;
  font-size: 15.4px; /* fallback: 旧内核 */
  font-size: clamp(0.92rem, 1.5vw, 1.08rem);
  letter-spacing: 0.06em;
}

.pet-tomb__date {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  opacity: 0.8;
}

.pet-tomb__word {
  margin-top: 1px;
  font-size: 0.58rem;
  line-height: 1.45;
  opacity: 0.78;
}

.pet-tomb__hint {
  padding: 3px 10px;
  border: 1px dashed rgba(37, 99, 235, 0.55);
  border-radius: 999px;
  background: var(--panel);
  color: var(--blue);
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  animation: petTombHint 2.4s ease-in-out infinite;
}

@keyframes petTombHint {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

[data-theme="dark"] .pet-tomb__stone {
  background: linear-gradient(180deg, #78849a 0%, #5d687c 34%, #414a5b 72%, #2b323f 100%);
  color: #eef4ff;
}

@media (max-width: 720px) {
  .pet-rampage-line {
    font-size: 30.4px; /* fallback: 旧内核 */
    font-size: clamp(1.25rem, 7vw, 1.9rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pet-tomb,
  .pet-rampage-line {
    transition: none;
  }

  .pet-rampage-line.is-boom {
    animation-duration: 0.4s;
  }

  .pet-shard,
  .pet-shock,
  .pet-flash {
    display: none;
  }

  .hnyz-avatar.is-reviving .hnyz-avatar__img {
    animation: none;
  }
}

.pet-tomb__mark {
  margin-bottom: 3px;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.3em;
  opacity: 0.8;
}


/* =========================================================
   暴走时降负载
   ---------------------------------------------------------
   头像放大到 1600px 到处飞的时候，页面上任何“每帧重算”的
   东西都会抢 GPU：头部 backdrop-filter、背景图标浮动、
   跑马灯、舞台条纹。这里统一暂停，弹完自动恢复。
   ========================================================= */
body.is-pet-boom .site-header {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  background: var(--panel);
}

body.is-pet-boom .bg-icon,
body.is-pet-boom .bg-orbs__orb,
body.is-pet-boom .hnyz-ticker__track,
body.is-pet-boom .char-stage__stripes,
body.is-pet-boom .char-splash__burst,
body.is-pet-boom .char-splash__bob,
body.is-pet-boom .char-splash__decor {
  animation-play-state: paused !important;
}

body.is-pet-boom .hnyz-avatar {
  /* 独立合成层，避免和页面一起重排 */
  contain: layout style;
}

/* 减少动态：弹窗只保留缩放能力，不再抖、不再喷粒子 */
@media (prefers-reduced-motion: reduce) {
  .pet-rampage-char,
  .pet-rampage-line.is-visible .pet-rampage-chars,
  .pet-rampage-line.is-bumped {
    animation: none;
  }

  .pet-line-spark {
    display: none;
  }
}
