/* =====================================================================
   GeekHuang Lab — Server Pet「小黄」page styles
   Uses the site tokens from css/style.css (--bg, --surface, --line,
   --text*, --cyan, --violet, --ok/--warn/--down …). Only the sprite's
   own pixel colours are defined here (scoped to .pet-page).
   ===================================================================== */

.pet-page {
  /* sprite palette (pet-only; site palette untouched) */
  --pet-line:   #3B2A14;
  --pet-body:   #F4C542;
  --pet-hi:     #FFE48A;
  --pet-shade:  #D9A227;
  --pet-belly:  #FFF0B8;
  --pet-beak:   #F29A38;
  --pet-beak-d: #C9681C;
  --pet-eye:    #1A1D26;
  --pet-cheek:  #F59AA8;
  --pet-heart:  #F0648C;
  --pet-cookie: #C98A4B;
  --pet-chip:   #5A3517;
  --pet-size:   224px;
  padding-block: clamp(28px, 5vw, 64px) clamp(64px, 8vw, 120px);
}
[data-theme="dark"] .pet-page { --pet-line: #1E1408; }

.pet-back { display: inline-flex; gap: 8px; color: var(--text-3); margin-bottom: 28px; }
.pet-back:hover { color: var(--text); }

/* ---------- head ---------- */
.pet-eyebrow { display: flex; align-items: center; gap: 12px; color: var(--text-3); }
.pet-eyebrow__rule { flex: 0 1 64px; height: 1px; background: var(--line-2); }
.pet-title {
  margin-top: 14px;
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-weight: 600;
}
.pet-title__en { color: var(--text-3); font-weight: 500; }
.pet-intro { margin-top: 14px; max-width: 60ch; color: var(--text-2); }
.pet-code {
  font-family: var(--font-mono); font-size: 0.86em;
  padding: 1px 6px; border-radius: 4px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  overflow-wrap: anywhere;
}

/* ---------- layout ---------- */
.pet-grid {
  margin-top: clamp(24px, 4vw, 40px);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}
@media (min-width: 900px) {
  .pet-grid { grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr); align-items: start; }
  .pet-page { --pet-size: 288px; }
}

.pet-stage, .pet-panel {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: clamp(16px, 2.4vw, 24px);
}

.pet-stage__top, .pet-panel__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  color: var(--text-3);
}
.pet-stage__title, .pet-panel__title { font: inherit; letter-spacing: inherit; color: var(--text-2); }
.pet-mood { display: inline-flex; align-items: center; gap: 8px; height: 28px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 999px; }

/* ---------- bubble ---------- */
.pet-bubble {
  position: relative;
  margin: 20px auto 0;
  max-width: 460px;
  padding: 12px 16px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  text-align: center;
  min-height: 3.4em;
  display: grid; place-items: center;
  overflow-wrap: anywhere;
}
.pet-bubble::after {
  content: "";
  position: absolute; left: 50%; bottom: -7px;
  width: 12px; height: 12px;
  background: var(--surface-2);
  border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2);
  transform: translateX(-50%) rotate(45deg);
}

/* ---------- habitat ---------- */
.pet-home {
  position: relative;
  display: grid; place-items: center;
  margin-top: 8px;
  padding-top: 8px;
  min-height: calc(var(--pet-size) + 24px);
  overflow: hidden;
}
.pet-floor {
  position: absolute; left: 8%; right: 8%; bottom: 18px;
  border-top: 1px dashed var(--line-2);
}
.pet {
  position: relative; z-index: 1;
  width: var(--pet-size); height: var(--pet-size);
  padding: 0; margin: 0;
  background: none; border: 0; border-radius: 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.pet__svg { width: 100%; height: 100%; overflow: visible; image-rendering: pixelated; }
.pet__svg g { transform-box: fill-box; }

/* pixel colours */
.px-line   { fill: var(--pet-line); }
.px-body   { fill: var(--pet-body); }
.px-hi     { fill: var(--pet-hi); }
.px-shade  { fill: var(--pet-shade); }
.px-belly  { fill: var(--pet-belly); }
.px-slot   { fill: var(--pet-shade); }
.px-beak   { fill: var(--pet-beak); }
.px-beak-d { fill: var(--pet-beak-d); }
.px-mouth  { fill: var(--pet-line); }
.px-tongue { fill: var(--pet-heart); }
.px-eye    { fill: var(--pet-eye); }
.px-glint  { fill: #FFFFFF; }
.px-cheek  { fill: var(--pet-cheek); opacity: 0.85; }
.px-sweat  { fill: var(--cyan); }
.px-band   { fill: #F7F3EA; }
.px-band-d { fill: #D8CFC0; }
.px-q      { fill: var(--cyan); }
.px-steam  { fill: var(--text-3); opacity: 0.6; }
.px-crumb  { fill: var(--pet-cookie); }
.px-heart  { fill: var(--pet-heart); }
.px-cookie { fill: var(--pet-cookie); }
.px-chip   { fill: var(--pet-chip); }
.px-led    { fill: var(--ok); }
.px-led-glint { fill: #FFFFFF; opacity: 0.7; }
.px-bled   { fill: var(--ok); }

/* mood tints */
.pet-stage[data-mood="sick"] { --pet-body: #CFD28A; --pet-hi: #E6E8B4; --pet-shade: #A7AC5E; --pet-belly: #EEF0CC; }
.pet-stage[data-mood="sick"] .px-led, .pet-stage[data-mood="sick"] .px-bled--b { fill: var(--down); }
.pet-stage[data-mood="nervous"] .px-led,
.pet-stage[data-mood="hungry"] .px-led,
.pet-stage[data-mood="panting"] .px-led { fill: var(--warn); }
.pet-stage[data-mood="hungry"] .px-bled--b, .pet-stage[data-mood="panting"] .px-bled--b { fill: var(--warn); }
.pet-stage[data-mood="sleeping"] .px-led { fill: var(--violet); opacity: 0.55; }
.pet-stage[data-mood="confused"] .px-led,
.pet-stage[data-mood="loading"] .px-led { fill: var(--idle); }

/* ---------- animations ---------- */
.pet__body { transform-origin: 50% 100%; }
.pet__eyes { transform-origin: 50% 50%; }

.pet-stage[data-mood="happy"] .pet__body    { animation: pet-bounce 1.6s var(--ease) infinite; }
.pet-stage[data-mood="sleeping"] .pet__body { animation: pet-breathe 3.6s ease-in-out infinite; }
.pet-stage[data-mood="sick"] .pet__body { animation: pet-sway 3.2s ease-in-out infinite; }
.pet-stage[data-mood="nervous"] .pet__body { animation: pet-shiver 0.18s linear infinite; }
.pet-stage[data-mood="hungry"] .pet__body   { transform: scale(1.1, 0.95); animation: pet-stuffed 2.8s ease-in-out infinite; }
.pet-stage[data-mood="panting"] .pet__body { animation: pet-pant 0.45s ease-in-out infinite; }
.pet-stage[data-mood="confused"] .pet__body { animation: pet-tilt 2.4s ease-in-out infinite; }
.pet-stage:is([data-mood="happy"], [data-mood="nervous"], [data-mood="confused"], [data-mood="loading"]) .pet__eyes { animation: pet-blink 4.2s infinite; }
.pet-steam { animation: pet-steam 0.9s ease-in-out infinite; }
.px-bled--a { animation: pet-led 1.2s steps(2) infinite; }
.px-bled--b { animation: pet-led 2.1s steps(2) infinite; }
.pet.is-patted .pet__svg { animation: pet-squish 0.45s var(--ease); }
.pet.is-eating .pet__beak { animation: pet-chomp 0.3s steps(2) infinite; }

@keyframes pet-bounce  { 0%, 100% { transform: translateY(0) scale(1, 1); } 45% { transform: translateY(-1.5px) scale(0.98, 1.03); } 60% { transform: translateY(0) scale(1.03, 0.97); } }
@keyframes pet-breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.03, 0.97); } }
@keyframes pet-sway    { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
@keyframes pet-shiver  { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-0.35px); } 75% { transform: translateX(0.35px); } }
@keyframes pet-stuffed { 0%, 100% { transform: scale(1.1, 0.95); } 50% { transform: scale(1.13, 0.93); } }
@keyframes pet-pant    { 0%, 100% { transform: translateY(0) scale(1, 1); } 50% { transform: translateY(-0.8px) scale(1.02, 0.98); } }
@keyframes pet-tilt    { 0%, 100% { transform: rotate(-7deg); } 50% { transform: rotate(5deg); } }
@keyframes pet-blink   { 0%, 94%, 100% { transform: scaleY(1); } 96% { transform: scaleY(0.1); } }
@keyframes pet-steam   { 0%, 100% { transform: translateY(0); opacity: 0.2; } 50% { transform: translateY(-1px); opacity: 0.8; } }
@keyframes pet-led     { 0% { opacity: 1; } 100% { opacity: 0.25; } }
@keyframes pet-squish  { 0% { transform: scale(1, 1); } 35% { transform: scale(1.08, 0.9); } 70% { transform: scale(0.96, 1.05); } 100% { transform: scale(1, 1); } }
@keyframes pet-chomp   { 0% { transform: translateY(0); } 100% { transform: translateY(0.5px); } }

/* Zzz (only while sleeping) */
.pet-zzz { position: absolute; z-index: 2; top: 6%; left: calc(50% + var(--pet-size) * 0.3); display: none; pointer-events: none; }
.pet-stage[data-mood="sleeping"] .pet-zzz { display: block; }
.pet-zzz span {
  position: absolute; left: 0; top: 0;
  font-family: var(--font-mono); font-weight: 700; color: var(--violet);
  opacity: 0; animation: pet-z 3s ease-in infinite;
}
.pet-zzz span:nth-child(1) { font-size: 22px; }
.pet-zzz span:nth-child(2) { font-size: 17px; animation-delay: 1s; }
.pet-zzz span:nth-child(3) { font-size: 13px; animation-delay: 2s; }
@keyframes pet-z { 0% { transform: translate(0, 24px); opacity: 0; } 20% { opacity: 1; } 100% { transform: translate(22px, -18px); opacity: 0; } }

/* spawned fx: hearts, cookie, crumbs */
.pet-fx { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.pet-fx__item { position: absolute; display: block; transform: translate(-50%, 0); }
.pet-heart { width: 22px; height: 19px; animation: pet-heart 1.3s ease-out forwards; }
.pet-cookie { width: 26px; height: 26px; animation: pet-drop 0.7s cubic-bezier(0.5, 0, 0.9, 0.6) forwards; }
.pet-crumb i { display: block; width: 4px; height: 4px; background: var(--pet-cookie); }
.pet-crumb { animation: pet-crumb 0.7s ease-out forwards; }
.pet-fx__item svg { width: 100%; height: 100%; }
@keyframes pet-heart { 0% { transform: translate(-50%, 10px) scale(0.6); opacity: 0; } 20% { opacity: 1; } 100% { transform: translate(-50%, -60px) scale(1.1); opacity: 0; } }
@keyframes pet-drop  { 0% { transform: translate(-50%, 0); } 100% { transform: translate(-50%, calc(var(--pet-size) * 0.55)); } }
@keyframes pet-crumb { 0% { transform: translate(-50%, 0); opacity: 1; } 100% { transform: translate(-50%, 18px); opacity: 0; } }
.pet-fx__item.is-static { animation: none !important; opacity: 1; }

/* ---------- actions ---------- */
.pet-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 12px; }
.pet-actions__btn { min-width: 132px; cursor: pointer; }
.pet-actions__btn:disabled { opacity: 0.6; cursor: default; }
.pet-count { color: var(--text-3); font-size: 0.7rem; }
.btn--primary .pet-count { color: inherit; }
.pet-note { margin-top: 12px; text-align: center; color: var(--text-3); text-transform: none; }

/* ---------- vitals panel ---------- */
.pet-panel__stamp { color: var(--text-3); }
.pet-stats { margin-top: 16px; border-top: 1px solid var(--line); }
.pet-stat {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 12px;
  padding: 11px 0; border-bottom: 1px dashed var(--line);
}
.pet-stat dt { display: inline-flex; align-items: center; gap: 8px; color: var(--text-3); white-space: nowrap; }
.pet-stat__zh { text-transform: none; letter-spacing: 0.02em; color: var(--text-3); opacity: 0.8; }
.pet-stat dd { font-family: var(--font-mono); font-size: 0.86rem; text-align: right; color: var(--text); overflow-wrap: anywhere; }
.pet-stats.is-stale dd { opacity: 0.55; }

.pet-rules__title { margin-top: 24px; color: var(--text-3); font-weight: 500; }
.pet-rules { margin-top: 10px; display: grid; gap: 6px; }
.pet-rule {
  display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 10px; align-items: baseline;
  padding: 6px 10px; border-radius: var(--radius-sm); border: 1px solid transparent;
  color: var(--text-2); font-size: 13px; line-height: 1.5;
}
.pet-rule__k { color: var(--text-3); font-size: 0.64rem; }
.pet-rule.is-active { border-color: var(--cyan); background: var(--cyan-soft); color: var(--text); }
.pet-rule.is-active .pet-rule__k { color: var(--cyan); }
.pet-rule.is-also { border-color: var(--line-2); border-style: dashed; }
.pet-src { margin-top: 18px; color: var(--text-3); text-transform: none; overflow-wrap: anywhere; }

@media (max-width: 559px) {
  .pet-page { --pet-size: 192px; }
  .pet-actions__btn { flex: 1 1 40%; min-width: 0; }
  .pet-bubble { font-size: 14px; }
  .pet-rule { grid-template-columns: 72px minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .pet-page *, .pet-page *::before, .pet-page *::after { animation: none !important; transition: none !important; }
  .pet-stage[data-mood="sleeping"] .pet-zzz span { opacity: 1; }
  .pet-zzz span:nth-child(2) { transform: translate(12px, -12px); }
  .pet-zzz span:nth-child(3) { transform: translate(22px, -22px); }
}

/* =====================================================================
   v2 — outfits tag, interactions, 亲密度, random events
   (sprite accessory colours are inline fills from sprite.js)
   ===================================================================== */
.pet-page {
  --pet-bubble:  #BDE9FF;
  --pet-spark:   #FFD84A;
  --pet-yarn:    #F0648C;
  --pet-yarn-d:  #B8406A;
  --pet-wood:    #B7793F;
  --pet-bristle: #F4ECDA;
  --pet-bug:     #4FAE5B;
}
.pet-outfit {
  display: inline-flex; align-items: center; height: 28px; padding: 0 10px;
  border: 1px dashed var(--line-2); border-radius: 999px;
  color: var(--text-2); font-size: 0.68rem; text-transform: none; letter-spacing: 0.04em;
}
.pet-outfit[hidden] { display: none; }
.pet-stage__top { justify-content: flex-start; }
.pet-stage__top .pet-stage__title { margin-right: auto; }

/* extra pixel colours */
.px-brush-h { fill: var(--pet-wood); }
.px-brush-b { fill: var(--cyan); }
.px-brush-s { fill: var(--pet-bristle); }
.px-bubble  { fill: var(--pet-bubble); opacity: 0.8; }
.px-bubble-o { fill: var(--cyan); }
.px-bubble-g { fill: #FFFFFF; }
.px-spark   { fill: var(--pet-spark); }
.px-yarn    { fill: var(--pet-yarn); }
.px-yarn-d  { fill: var(--pet-yarn-d); }
.px-yarn-t  { fill: var(--pet-yarn-d); }
.px-note    { fill: var(--cyan); }
.px-bug     { fill: var(--pet-bug); }
.px-bug-e   { fill: #FFFFFF; }
.px-bug-l   { fill: var(--pet-line); }

/* tools row */
.pet-tools { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 12px auto 0; max-width: 560px; }
.pet-tool {
  min-height: 40px; padding: 8px 10px;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 14px;
  cursor: pointer; transition: border-color var(--t-fast), background var(--t-fast);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.pet-tool:hover { border-color: var(--line-3); }
.pet-tool[aria-pressed="true"] { border-color: var(--cyan); background: var(--cyan-soft); }
.pet-tool:focus-visible, .pet-chip:focus-visible, .pet-link:focus-visible, .pet-yarn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* habitat props */
.pet-brush, .pet-yarn, .pet-bug { position: absolute; left: 0; top: 0; z-index: 4; display: block; }
.pet-brush[hidden], .pet-yarn[hidden], .pet-bug[hidden] { display: none; }
.pet-brush { width: 48px; height: 48px; pointer-events: none; filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.18)); }
.pet-brush.is-held { width: 58px; height: 58px; }
.pet-brush svg, .pet-yarn svg, .pet-bug svg { width: 100%; height: 100%; display: block; }
.pet-yarn {
  width: 36px; height: 36px; padding: 0; border: 0; background: none; border-radius: 50%;
  cursor: grab; touch-action: none; -webkit-tap-highlight-color: transparent;
}
.pet-yarn.is-held { cursor: grabbing; }
.pet-stage[data-mode="bath"] .pet-home { touch-action: none; cursor: crosshair; }
.pet-stage[data-mode="bath"] .pet { cursor: crosshair; }
.pet-bug { width: 21px; height: 15px; top: auto; bottom: 20px; left: 4%; pointer-events: none; }
.pet-bug.is-crawling { animation: pet-bug 3.2s steps(24, end) forwards; }
@keyframes pet-bug { 0% { left: 4%; } 50% { left: 48%; transform: translateY(-4px); } 100% { left: 92%; } }

.pet-meter {
  position: absolute; left: 50%; bottom: 0; z-index: 4; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 0.66rem; white-space: nowrap;
}
.pet-meter[hidden] { display: none; }
.pet-meter__bar { width: 96px; height: 6px; border: 1px solid var(--line-2); border-radius: 3px; overflow: hidden; background: var(--surface-2); }
.pet-meter__fill { display: block; width: 0; height: 100%; background: var(--cyan); transition: width 120ms linear; }

/* fx: bubbles, sparkles, +N, notes, dust */
.pet-bubblefx { width: 22px; height: 22px; animation: pet-bubble 1.4s ease-out forwards; }
.pet-spark { width: 20px; height: 20px; animation: pet-spark 1.3s ease-out forwards; }
.pet-plus { color: var(--pet-heart); font-weight: 700; font-size: 0.8rem; animation: pet-heart 1.1s ease-out forwards; }
.pet-note { width: 14px; height: 20px; animation: pet-heart 1.3s ease-out forwards; }
.pet-heart--big { width: 40px; height: 34px; }
.pet-dust i { display: block; width: 4px; height: 4px; background: var(--text-3); }
.pet-dust { animation: pet-dust 0.8s ease-out forwards; }
@keyframes pet-bubble { 0% { transform: translate(-50%, 0) scale(0.4); opacity: 0; } 20% { opacity: 1; } 100% { transform: translate(-50%, -34px) scale(1.15); opacity: 0; } }
@keyframes pet-spark  { 0% { transform: translate(-50%, 0) scale(0.3) rotate(0); opacity: 0; } 30% { opacity: 1; } 100% { transform: translate(-50%, -20px) scale(1.2) rotate(90deg); opacity: 0; } }
@keyframes pet-dust   { 0% { transform: translate(-50%, 0); opacity: 1; } 100% { transform: translate(-50%, 10px) translateX(14px); opacity: 0; } }

/* acts (short animations on the button wrapper so mood animations on .pet__body keep running) */
.pet-stage[data-act="shake"] .pet__svg   { animation: pet-shake 0.12s linear 7; }
.pet-stage[data-act="pounce-l"] .pet__svg { animation: pet-pounce-l 0.65s var(--ease); }
.pet-stage[data-act="pounce-r"] .pet__svg { animation: pet-pounce-r 0.65s var(--ease); }
.pet-stage[data-act="roll"] .pet__svg    { animation: pet-roll 0.8s ease-in-out; }
.pet-stage[data-act="hop"] .pet__svg     { animation: pet-hop 0.6s var(--ease); }
.pet-stage[data-act="dance"] .pet__svg   { animation: pet-dance 0.65s ease-in-out 4; }
.pet-stage[data-act="wave"] .pet__wave   { animation: pet-wave 0.4s ease-in-out 4; transform-origin: 0% 100%; }
.pet-stage[data-act="sneeze"] .pet__svg  { animation: pet-sneeze 0.8s var(--ease); }
.pet-stage[data-act="yawn"] .pet__svg    { animation: pet-yawn 1.7s ease-in-out; }
.pet-stage[data-act="grumpy"] .pet__svg  { animation: pet-shake 0.1s linear 5; }
.pet-stage[data-act="stretch"] .pet__svg { animation: pet-stretch 0.9s var(--ease); }
.pet-stage[data-act="talk"] .pet__beak   { animation: pet-chomp 0.18s steps(2) 5; }
.pet-stage[data-mode="grumpy"] .pet__anger { animation: pet-led 0.6s steps(2) infinite; }
@keyframes pet-shake   { 0%, 100% { transform: translateX(0) rotate(0); } 25% { transform: translateX(-4px) rotate(-3deg); } 75% { transform: translateX(4px) rotate(3deg); } }
@keyframes pet-pounce-l { 0% { transform: translate(0, 0); } 40% { transform: translate(-18%, -14%) rotate(-10deg); } 70% { transform: translate(-12%, 0) scale(1.06, 0.94); } 100% { transform: translate(0, 0); } }
@keyframes pet-pounce-r { 0% { transform: translate(0, 0); } 40% { transform: translate(18%, -14%) rotate(10deg); } 70% { transform: translate(12%, 0) scale(1.06, 0.94); } 100% { transform: translate(0, 0); } }
@keyframes pet-roll    { 0%, 100% { transform: rotate(0); } 35% { transform: rotate(-14deg) translateX(-3%); } 70% { transform: rotate(10deg) translateX(3%); } }
@keyframes pet-hop     { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-12%); } 70% { transform: translateY(0) scale(1.05, 0.95); } }
@keyframes pet-dance   { 0%, 100% { transform: translate(0, 0) rotate(0); } 25% { transform: translate(-6%, -6%) rotate(-8deg); } 50% { transform: translate(0, 0); } 75% { transform: translate(6%, -6%) rotate(8deg); } }
@keyframes pet-wave    { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-24deg); } }
@keyframes pet-sneeze  { 0% { transform: scale(1); } 30% { transform: scale(0.94, 1.06) translateY(-2%); } 45% { transform: scale(1.08, 0.92) translateX(3%); } 100% { transform: scale(1); } }
@keyframes pet-yawn    { 0%, 100% { transform: scale(1); } 50% { transform: scale(0.97, 1.05); } }
@keyframes pet-stretch { 0%, 100% { transform: scale(1); } 45% { transform: scale(0.94, 1.1); } }

/* modes: nap shows Zzz; awake overlays hide the night Zzz */
.pet-stage[data-mode="nap"] .pet-zzz { display: block; }
.pet-stage[data-mode="nap"] .pet__body { animation: pet-breathe 3.6s ease-in-out infinite; }
.pet-stage:is([data-mode="bath"], [data-mode="play"], [data-mode="grumpy"]) .pet-zzz { display: none; }
.pet-stage[data-mode="grumpy"] .pet-mood { border-style: dashed; }

/* ---------- 亲密度 ---------- */
.pet-bond { margin: 20px auto 0; max-width: 560px; padding-top: 16px; border-top: 1px dashed var(--line); }
.pet-bond__head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; color: var(--text-3); }
.pet-bond__title { font: inherit; letter-spacing: inherit; color: var(--text-2); margin-right: auto; }
.pet-bond__lv { color: var(--pet-heart); font-weight: 700; }
.pet-bond__num { color: var(--text-2); }
.pet-bond__bar { margin-top: 8px; height: 10px; border: 1px solid var(--line-2); border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.pet-bond__fill { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--pet-heart), var(--pet-body)); transition: width var(--t-mid) var(--ease); }
.pet-bond__meta { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; color: var(--text-3); text-transform: none; font-size: 0.66rem; }
.pet-link {
  margin-left: auto; padding: 2px 4px; border: 0; background: none; color: var(--text-3);
  font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.pet-link:hover { color: var(--down); }
.pet-unlocks { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.pet-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 10px;
  border: 1px solid var(--line-2); border-radius: 999px; background: none;
  color: var(--text-3); font: inherit; font-size: 13px; cursor: pointer; touch-action: manipulation;
}
.pet-chip.is-on { color: var(--text); border-color: var(--pet-heart); background: color-mix(in srgb, var(--pet-heart) 10%, transparent); }
.pet-chip[aria-disabled="true"] { cursor: not-allowed; opacity: 0.7; }
.pet-chip__lv { font-size: 0.6rem; color: var(--text-3); }
.pet-chip__lock { font-size: 0.7rem; }
.pet-bond__note { margin-top: 8px; color: var(--warn); font-size: 13px; }
.pet-bond__note[hidden] { display: none; }
.pet-bond__src { margin-top: 8px; color: var(--text-3); text-transform: none; font-size: 0.62rem; }

@media (max-width: 559px) {
  .pet-tools { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pet-link { margin-left: 0; }
}

/* ---------- v3: sound toggle (navbar, next to the theme toggle; pixel speaker icon) ---------- */
.pet-sound[hidden] { display: none; }
.pet-sound:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.pet-sound__icon { width: 18px; height: 15px; display: block; fill: currentColor; image-rendering: pixelated; }
.pet-sound[aria-pressed="true"] { color: var(--cyan); }
.pet-sound[aria-pressed="true"] .pet-sound__icon--off,
.pet-sound[aria-pressed="false"] .pet-sound__icon--on { display: none; }
.pet-sound[aria-pressed="false"] { color: var(--text-3); }
.pet-sound[aria-pressed="false"]:hover { color: var(--text); }

/* ---------- v4: 小鱼干 wallet + 小黄换肤商店 ---------- */
.pet-plus--fish { color: var(--cyan); white-space: nowrap; }
.pet-wallet {
  margin-top: 12px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px;
  padding: 10px 12px; border: 1px dashed var(--line-2); border-radius: var(--radius-sm); background: var(--surface-2);
}
.pet-wallet__fish { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; min-width: 0; margin: 0; }
.pet-wallet__label { color: var(--text-2); font-size: 0.72rem; }
.pet-wallet__num { color: var(--text); font-size: 0.95rem; }
.pet-wallet__num b { font-weight: 700; }
.pet-wallet__wear { color: var(--text-3); font-size: 12px; overflow-wrap: anywhere; }
.pet-wallet__shop { min-height: 40px; padding: 0 16px; font-size: 14px; flex: 0 0 auto; }
.pet-wallet__shop[hidden] { display: none; }
.pet-wallet__shop:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

html.pet-shop-lock { overflow: hidden; }
.pet-shop {
  width: min(880px, calc(100vw - 24px)); max-width: none; max-height: calc(100dvh - 24px);
  margin: auto; padding: 0; border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--surface); color: var(--text); box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.pet-shop:not([open]) { display: none; }
.pet-shop::backdrop { background: rgba(7, 11, 20, 0.62); }
[data-theme="light"] .pet-shop::backdrop { background: rgba(11, 16, 32, 0.38); }
.pet-shop.is-fallback { position: fixed; inset: 0; z-index: 90; }     /* browsers without <dialog>.showModal() */
.pet-shop__box { display: flex; flex-direction: column; max-height: calc(100dvh - 26px); }
.pet-shop__head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.pet-shop__title { font-size: 18px; font-weight: 600; margin: 0 auto 0 0; letter-spacing: -0.01em; }
.pet-shop__balance { padding: 4px 10px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--cyan) 45%, var(--line-2)); color: var(--text); font-size: 13px; font-weight: 700; white-space: nowrap; }
.pet-shop__close { flex: 0 0 auto; }
.pet-shop__close svg { width: 14px; height: 14px; fill: currentColor; }
.pet-shop__close:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.pet-shop__body { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 16px; padding: 16px; overflow: auto; overscroll-behavior: contain; min-height: 0; }
.pet-shop__side { position: sticky; top: 0; align-self: start; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.pet-shop__preview {
  width: 100%; aspect-ratio: 1; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: radial-gradient(circle at 50% 60%, color-mix(in srgb, var(--pet-body) 16%, transparent), transparent 70%), var(--surface-2);
}
.pet-shop__svg { width: 86%; height: 86%; display: block; overflow: visible; image-rendering: pixelated; }
.pet-shop__trying { margin: 0; color: var(--text-2); font-size: 12px; }
.pet-shop__outfit { margin: 0; color: var(--violet); font-size: 11px; }
.pet-shop__outfit[hidden], .pet-shop__tryclear[hidden] { display: none; }
.pet-shop__status { margin: 0; min-height: 3em; color: var(--text); font-size: 13px; line-height: 1.5; }
.pet-shop__list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-content: start; }
.pet-shop__foot { margin: 0; padding: 10px 16px 14px; border-top: 1px solid var(--line); color: var(--text-3); font-size: 11px; text-transform: none; line-height: 1.6; }
.pet-shop__note { margin: 0; padding: 0 16px 14px; }

.pet-item {
  display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 10px; align-items: start;
  padding: 10px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface-2);
}
.pet-item[data-state="equipped"] { border-color: var(--pet-heart); background: color-mix(in srgb, var(--pet-heart) 7%, var(--surface-2)); }
.pet-item[data-state="trying"] { border-color: var(--cyan); border-style: dashed; }
.pet-item__pic { width: 64px; height: 64px; display: grid; place-items: center; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); }
.pet-item__svg { width: 56px; height: 56px; display: block; overflow: visible; image-rendering: pixelated; }
.pet-item__main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pet-item__top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pet-item__name { margin: 0; font-size: 15px; font-weight: 600; }
.pet-item__badge { padding: 1px 6px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--text-2); font-size: 11px; line-height: 1.5; }
.pet-item__badge.is-on { color: var(--pet-heart); border-color: color-mix(in srgb, var(--pet-heart) 55%, var(--line-2)); }
.pet-item__badge.is-try { color: var(--cyan); border-color: color-mix(in srgb, var(--cyan) 55%, var(--line-2)); }
.pet-item__meta { display: flex; gap: 10px; color: var(--text-3); font-size: 11px; }
.pet-item__price { color: var(--text); font-weight: 700; }
.pet-item__desc { color: var(--text-2); font-size: 12px; line-height: 1.45; }
.pet-item__acts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.pet-item__btn {
  min-height: 34px; padding: 4px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.pet-item__btn:hover { border-color: var(--line-3); }
.pet-item__btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.pet-item__btn.is-primary { border-color: var(--text); background: var(--text); color: var(--bg); }
.pet-item__btn.is-on { border-color: var(--pet-heart); color: var(--text); }
.pet-item__btn[aria-pressed="true"][data-act="try"] { border-color: var(--cyan); background: var(--cyan-soft); }
.pet-item__btn[aria-disabled="true"] { cursor: not-allowed; opacity: 0.45; border-color: var(--line-2); background: var(--surface); color: var(--text-2); }
.pet-item__short { color: var(--warn); font-size: 11px; white-space: nowrap; }
.pet-item.is-shake { animation: pet-shake 0.12s linear 3; }

@media (max-width: 719px) {
  .pet-shop { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .pet-shop__box { max-height: calc(100dvh - 18px); }
  .pet-shop__head { padding: 10px 12px; }
  /* the try-on preview stays on screen; only the item list scrolls */
  .pet-shop__body { display: flex; flex-direction: column; padding: 0; gap: 0; overflow: hidden; }
  .pet-shop__side { position: static; flex: 0 0 auto; display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; text-align: left; gap: 2px 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .pet-shop__preview { grid-row: span 4; width: 96px; }
  .pet-shop__tryclear { justify-self: start; min-height: 30px; padding: 2px 10px; }
  .pet-shop__status { min-height: 0; font-size: 12px; }
  .pet-shop__list { grid-template-columns: minmax(0, 1fr); overflow: auto; overscroll-behavior: contain; min-height: 0; flex: 1 1 auto; padding: 12px; }
  .pet-shop__foot { padding: 8px 12px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .pet-item.is-shake { animation: none; }
  .pet-item__btn, .pet-wallet__shop { transition: none; }
}

/* =====================================================================
   v5 — 放风模式 (roam)：ANeko 式精灵图小黄
   ===================================================================== */
.pet-tool__new {
  margin-left: 6px; padding: 1px 5px; border-radius: 999px;
  background: var(--pet-heart); color: #FFF;
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em;
}

/* stage: SVG pet fades out, little notice appears */
.pet-stage.is-roaming .pet { opacity: 0; visibility: hidden; transition: opacity 240ms ease; }
.pet-stage.is-roaming .pet-zzz { display: none; }
.pet-roam-note {
  position: absolute; inset: 0; z-index: 2;
  display: grid; place-content: center; justify-items: center; gap: 10px;
  text-align: center;
}
.pet-roam-note[hidden] { display: none; }
.pet-roam-note__text { margin: 0; color: var(--text-2); }

/* the roam pet itself: fixed, transform-only movement, pixelated atlas */
.roam-pet {
  position: fixed; left: 0; top: 0; z-index: 40;
  width: 120px; height: 130px; padding: 0; border: 0;
  background-color: transparent; background-repeat: no-repeat;
  image-rendering: pixelated;
  cursor: pointer; touch-action: none; pointer-events: auto;
  will-change: transform;
  transform-origin: 50% 78.8%;               /* pivot at the feet baseline (164/208) */
  -webkit-tap-highlight-color: transparent;
}
.roam-pet:focus-visible { outline: 2px solid var(--cyan); outline-offset: 4px; }
.roam-pet.is-off { opacity: 0; transition: opacity 260ms ease; pointer-events: none; }
@media (max-width: 640px) { .roam-pet { width: 96px; height: 104px; } }

/* follower bubble (pointer-transparent) */
.roam-bubble {
  position: fixed; left: 0; top: 0; z-index: 40;
  max-width: 210px; padding: 6px 10px;
  border: 1px solid var(--line-2); border-radius: 9px;
  background: var(--surface); color: var(--text);
  font-size: 13px; line-height: 1.5; text-align: center;
  pointer-events: none; opacity: 0; transition: opacity 160ms ease;
}
.roam-bubble.is-on { opacity: 1; }
.roam-bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -6px;
  width: 10px; height: 10px;
  background: var(--surface);
  border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2);
  transform: translateX(-50%) rotate(45deg);
}

/* particles: Zzz / hearts / sparks (fixed spans, CSS-animated) */
.roam-z, .roam-heart-fx, .roam-spark { position: fixed; left: 0; top: 0; z-index: 39; pointer-events: none; }
.roam-z { color: var(--violet); font: 700 16px var(--font-mono); animation: roam-z 2.2s ease-out forwards; }
@keyframes roam-z { 0% { transform: translate(0, 10px); opacity: 0; } 15% { opacity: 0.9; } 100% { transform: translate(22px, -46px); opacity: 0; } }
.roam-heart-fx { width: 18px; animation: roam-heart 1.2s ease-out forwards; }
.roam-heart-fx svg { width: 100%; display: block; }
@keyframes roam-heart { 0% { transform: translate(-50%, 6px) scale(0.6); opacity: 0; } 20% { opacity: 1; } 100% { transform: translate(-50%, -44px) scale(1.1); opacity: 0; } }
.roam-spark { color: var(--pet-spark); font-size: 14px; animation: roam-spark 1s ease-out forwards; }
.roam-spark--sweat { color: var(--cyan); }
@keyframes roam-spark { 0% { transform: translate(-50%, 0) scale(0.5); opacity: 0; } 30% { opacity: 1; } 100% { transform: translate(-50%, -26px) scale(1.2); opacity: 0; } }

/* falling fish-stick mini game */
.roam-fish {
  position: fixed; left: 0; top: 0; z-index: 39; width: 28px; height: 20px;
  cursor: pointer; touch-action: manipulation;
  animation: roam-fish-blink 1.1s steps(2) infinite;
  -webkit-tap-highlight-color: transparent;
}
.roam-fish svg { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
@keyframes roam-fish-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

@media (prefers-reduced-motion: reduce) {
  .roam-z, .roam-heart-fx, .roam-spark { animation-duration: 2.4s; }
  .roam-fish { animation: none; }
  .roam-bubble { transition: none; }
}
