:root {
  --ink: #2f2119;
  --paper: #fff3cf;
  --paper-deep: #f4d58c;
  --wood: #8d4f24;
  --wood-deep: #522912;
  --gold: #f3bd43;
  --jade: #44b879;
  --jade-deep: #176a55;
  --coral: #d85e4b;
  --plum: #723654;
  --cream: #fff9df;
  --shadow: rgba(37, 22, 15, 0.25);
  --cat-icon-tabby: url("assets/art/v3/cats/tabby-sit.png?v=6");
  --cat-icon-sleepy: url("assets/art/v3/cats/sleepy-sit.png?v=6");
  --cat-icon-monk: url("assets/art/v3/cats/monk-sit.png?v=6");
  --cat-icon-vendor: url("assets/art/v3/cats/vendor-sit.png?v=6");
  --icon-bracelet: url("assets/art/v3/bracelets/monkey-head-default-0.png");
  --icon-token: url("assets/art/v3/ui/token.png");
  --icon-incense: url("assets/art/v3/ui/incense.png");
  --icon-jade: url("assets/art/v3/ui/jade.png");
  --ui-arrow: url("assets/art/v3/ui/arrow.png");
  --ui-sparkle: url("assets/art/v3/ui/sparkle.png");
  --ui-lock: url("assets/art/v3/ui/lock.png");
  --ui-panel-corner: url("assets/art/v3/ui/panel-corner.png");
  --bracelet-bodhi-root: url("assets/art/v3/bracelets/bodhi-root-pure-0.png");
  --bracelet-monkey-head: url("assets/art/v3/bracelets/monkey-head-default-0.png");
  --bracelet-xingyue: url("assets/art/v3/bracelets/xingyue-default-0.png");
  --bracelet-vajra: url("assets/art/v3/bracelets/vajra-default-0.png");
  --decor-cat-tree: url("assets/art/v3/decor/cat-tree.png");
  --decor-cat-bed: url("assets/art/v3/decor/cat-bed.png");
  --decor-scratch-post: url("assets/art/v3/decor/scratch-post.png");
  --decor-window-perch: url("assets/art/v3/decor/window-perch.png");
  --decor-toy-basket: url("assets/art/v3/decor/toy-basket.png");
  --decor-display-shelf: url("assets/art/v3/decor/display-shelf.png");
  --bead-station: url("assets/art/v3/station/bead-station.png");
  font-family: "Trebuchet MS", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(68, 184, 121, 0.14) 0 25%, transparent 25% 50%, rgba(216, 94, 75, 0.12) 50% 75%, transparent 75%),
    linear-gradient(180deg, #fff8dd 0%, #eecb80 42%, #77b990 100%);
  background-size: 18px 18px, 100% 100%;
  image-rendering: pixelated;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
}

.game-shell {
  width: min(1440px, 100%);
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  margin: 0 auto;
  padding: clamp(8px, 1.2vw, 14px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(8px, 1.3vh, 12px);
  overflow: hidden;
}

.pixel-panel {
  position: relative;
  border: 4px solid var(--wood-deep);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 249, 223, 0.88), rgba(244, 213, 140, 0.9)),
    repeating-linear-gradient(0deg, rgba(82, 41, 18, 0.1) 0 2px, transparent 2px 9px);
  box-shadow: 0 10px 0 rgba(82, 41, 18, 0.18), 0 18px 34px var(--shadow);
}

.pixel-panel::before,
.pixel-panel::after {
  content: "";
  position: absolute;
  pointer-events: none;
  background-repeat: no-repeat;
  image-rendering: pixelated;
}

.pixel-panel::before {
  width: 78px;
  height: 78px;
  right: 8px;
  top: -12px;
  background-image: var(--ui-panel-corner);
  background-size: contain;
  background-position: center;
  opacity: 0.7;
}

.pixel-panel::after {
  width: calc(100% - 28px);
  height: 8px;
  left: 14px;
  bottom: 8px;
  border-radius: 4px;
  background: repeating-linear-gradient(90deg, rgba(82, 41, 18, 0.18) 0 12px, rgba(68, 184, 121, 0.16) 12px 20px);
}

.topbar {
  min-height: 0;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: minmax(210px, 0.82fr) minmax(340px, 1.58fr);
  gap: 12px;
  align-items: center;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-title-stack {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.game-logo {
  display: block;
  width: min(430px, 100%);
  max-height: clamp(62px, 7.8vh, 92px);
  object-fit: contain;
  object-position: left center;
  image-rendering: pixelated;
  filter: drop-shadow(0 4px 0 rgba(82, 41, 18, 0.18));
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.brand-lockup p {
  margin: -3px 0 0 154px;
  color: #6a4a2c;
  font-size: 0.82rem;
}

.audio-button,
.guide-button {
  min-width: 78px;
  min-height: 38px;
  padding: 5px 8px;
}

.audio-button {
  margin-left: auto;
}

.audio-button.off {
  opacity: 0.72;
  filter: grayscale(0.35);
}

.audio-button .ui-icon,
.guide-button .ui-icon {
  width: 18px;
  height: 18px;
}

.ui-emblem {
  flex: 0 0 auto;
  background-image: var(--ui-panel-corner);
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center;
  image-rendering: pixelated;
}

.ui-tab {
  width: 72px;
  height: 48px;
  filter: drop-shadow(0 5px 0 rgba(82, 41, 18, 0.22));
}

.resource-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.resource-card {
  min-height: 58px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  padding: 8px;
  border: 3px solid #714019;
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 249, 223, 0.9), rgba(255, 220, 122, 0.72)),
    repeating-linear-gradient(90deg, rgba(141, 79, 36, 0.12) 0 4px, transparent 4px 12px);
  box-shadow: inset 0 -4px 0 rgba(82, 41, 18, 0.18);
  min-width: 0;
}

.resource-card strong {
  display: block;
  font-size: clamp(1rem, 2vw, 1.45rem);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.resource-card small,
.mini-stat span,
.progress-label span,
.progress-label strong {
  color: #684421;
  font-weight: 800;
  letter-spacing: 0;
}

.sprite {
  display: inline-block;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  filter: drop-shadow(0 6px 0 rgba(82, 41, 18, 0.18));
}

.sprite.tabby { background-image: var(--cat-icon-tabby); }
.sprite.sleepy { background-image: var(--cat-icon-sleepy); }
.sprite.monk { background-image: var(--cat-icon-monk); }
.sprite.vendor { background-image: var(--cat-icon-vendor); }
.sprite.bracelet { background-image: var(--icon-bracelet); }
.sprite.jade { background-image: var(--icon-jade); }
.sprite.incense { background-image: var(--icon-incense); }
.sprite.token { background-image: var(--icon-token); }

.cat-action-sprite {
  display: inline-block;
  image-rendering: pixelated;
  user-select: none;
  -webkit-user-drag: none;
}

.cat-action-sprite.tabby.action-sit { --cat-image: url("assets/art/v3/cats/tabby-sit.png?v=6"); }
.cat-action-sprite.tabby.action-jump { --cat-image: url("assets/art/v3/cats/tabby-jump.png?v=6"); }
.cat-action-sprite.tabby.action-lie { --cat-image: url("assets/art/v3/cats/tabby-lie.png?v=6"); }
.cat-action-sprite.sleepy.action-sit { --cat-image: url("assets/art/v3/cats/sleepy-sit.png?v=6"); }
.cat-action-sprite.sleepy.action-jump { --cat-image: url("assets/art/v3/cats/sleepy-jump.png?v=6"); }
.cat-action-sprite.sleepy.action-lie { --cat-image: url("assets/art/v3/cats/sleepy-lie.png?v=6"); }
.cat-action-sprite.monk.action-sit { --cat-image: url("assets/art/v3/cats/monk-sit.png?v=6"); }
.cat-action-sprite.monk.action-jump { --cat-image: url("assets/art/v3/cats/monk-jump.png?v=6"); }
.cat-action-sprite.monk.action-lie { --cat-image: url("assets/art/v3/cats/monk-lie.png?v=6"); }
.cat-action-sprite.vendor.action-sit { --cat-image: url("assets/art/v3/cats/vendor-sit.png?v=6"); }
.cat-action-sprite.vendor.action-jump { --cat-image: url("assets/art/v3/cats/vendor-jump.png?v=6"); }
.cat-action-sprite.vendor.action-lie { --cat-image: url("assets/art/v3/cats/vendor-lie.png?v=6"); }

.cat-art {
  position: absolute;
  inset: 0;
  display: block;
  pointer-events: none;
  background-image: var(--cat-image);
  background-repeat: no-repeat;
  background-position: center bottom;
  background-size: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 6px 0 rgba(82, 41, 18, 0.18));
  transform: scaleX(var(--cat-face, 1));
  transform-origin: bottom center;
}

.bracelet-sprite {
  display: inline-block;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  background-image: var(--bracelet-image, var(--bracelet-bodhi-root));
  image-rendering: pixelated;
  filter: drop-shadow(0 6px 0 rgba(82, 41, 18, 0.18));
}

.bracelet-sprite.bodhi-root { --bracelet-image: var(--bracelet-bodhi-root); }
.bracelet-sprite.monkey-head { --bracelet-image: var(--bracelet-monkey-head); }
.bracelet-sprite.xingyue { --bracelet-image: var(--bracelet-xingyue); }
.bracelet-sprite.vajra { --bracelet-image: var(--bracelet-vajra); }

.decor-sprite {
  display: inline-block;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 6px 0 rgba(82, 41, 18, 0.18));
}

.decor-sprite.cat-tree { background-image: var(--decor-cat-tree); }
.decor-sprite.cat-bed { background-image: var(--decor-cat-bed); }
.decor-sprite.scratch-post { background-image: var(--decor-scratch-post); }
.decor-sprite.window-perch { background-image: var(--decor-window-perch); }
.decor-sprite.toy-basket { background-image: var(--decor-toy-basket); }
.decor-sprite.display-shelf { background-image: var(--decor-display-shelf); }

.resource-card .sprite {
  width: 40px;
  height: 40px;
}

.play-layout {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 410px);
  gap: clamp(8px, 1vw, 12px);
}

.stage {
  min-height: 0;
  height: 100%;
  overflow: hidden;
  display: grid;
  grid-template-rows: minmax(280px, 1.72fr) minmax(132px, 0.72fr) auto;
  gap: clamp(10px, 1.7dvh, 18px);
  padding: 10px;
  isolation: isolate;
  background:
    linear-gradient(180deg, rgba(255, 249, 223, 0.9), rgba(206, 147, 85, 0.84)),
    repeating-linear-gradient(90deg, rgba(82, 41, 18, 0.08) 0 10px, transparent 10px 22px);
}

.room-scene {
  position: relative;
  min-height: clamp(260px, 43dvh, 430px);
  overflow: hidden;
  border: 3px solid #6d3517;
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 246, 202, 0.96) 0 54%, rgba(184, 116, 64, 0.96) 54%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.18) 0 80px, rgba(255, 255, 255, 0.02) 80px 160px);
  box-shadow: inset 0 -7px 0 rgba(82, 41, 18, 0.16);
}

.stage-sky {
  position: absolute;
  inset: 0 0 44%;
  z-index: 0;
  background:
    linear-gradient(180deg, rgba(255, 249, 223, 0.92), rgba(130, 199, 148, 0.32)),
    linear-gradient(90deg, transparent 0 45%, rgba(216, 94, 75, 0.2) 45% 55%, transparent 55%);
}

.stage-rail {
  position: absolute;
  left: -10px;
  right: -10px;
  top: 54%;
  height: 28px;
  z-index: 1;
  border-block: 4px solid #542a14;
  background: repeating-linear-gradient(90deg, #8d4f24 0 18px, #a8683b 18px 26px);
}

.decor-layer {
  position: absolute;
  inset: 8px 14px 8px;
  z-index: 2;
  pointer-events: auto;
}

.decor-layer.dragging-decor-layer {
  z-index: 5;
}

.stage-decor {
  position: absolute;
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  transition: opacity 260ms ease, transform 260ms ease, filter 260ms ease;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  pointer-events: none;
}

.stage-decor.show {
  opacity: 0.92;
  transform: translateY(0) scale(1);
  cursor: grab;
  pointer-events: auto;
}

.stage-decor.dragging-decor {
  z-index: 6;
  opacity: 1;
  cursor: grabbing;
  outline: 3px solid rgba(255, 243, 207, 0.66);
  outline-offset: 2px;
  transition: opacity 120ms ease, transform 120ms ease, filter 120ms ease;
}

.stage-decor:not(.show) {
  visibility: hidden;
}

.stage-decor[data-decor="cat-tree"] {
  left: 2%;
  bottom: 0;
  width: clamp(112px, 18vw, 218px);
  height: clamp(126px, 20vw, 244px);
}

.stage-decor[data-decor="cat-bed"] {
  right: 24%;
  bottom: 2%;
  width: clamp(110px, 16vw, 202px);
  height: clamp(82px, 12vw, 152px);
}

.stage-decor[data-decor="scratch-post"] {
  right: 12%;
  bottom: 8%;
  width: clamp(78px, 10vw, 132px);
  height: clamp(112px, 15vw, 184px);
}

.stage-decor[data-decor="window-perch"] {
  left: 14%;
  top: 0;
  width: clamp(150px, 21vw, 274px);
  height: clamp(118px, 16vw, 214px);
}

.stage-decor.show[data-decor="window-perch"] {
  opacity: 0.82;
}

.stage-decor[data-decor="toy-basket"] {
  left: 32%;
  bottom: 0;
  width: clamp(104px, 14vw, 178px);
  height: clamp(92px, 12vw, 156px);
}

.stage-decor[data-decor="display-shelf"] {
  right: 4%;
  top: 0;
  width: clamp(112px, 15vw, 190px);
  height: clamp(130px, 18vw, 228px);
}

.cat-layer {
  position: absolute;
  inset: 0 18px 7px 18px;
  z-index: 4;
  pointer-events: none;
}

.stage-cat {
  position: absolute;
  left: var(--cat-left, 2%);
  bottom: var(--cat-bottom, 0%);
  z-index: var(--cat-z, 4);
  width: clamp(54px, 7.8vw, 108px);
  aspect-ratio: 1;
  height: auto;
  opacity: 0;
  transform-origin: bottom center;
  transition: opacity 240ms ease, transform 240ms ease, left 420ms linear, bottom 180ms ease;
  rotate: 0deg;
  transform: translateY(14px);
  pointer-events: none;
  touch-action: none;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
}

.stage-cat.show {
  opacity: 1;
  transform: translateY(0);
  cursor: grab;
  pointer-events: auto;
}

.stage-cat.dragging-cat {
  z-index: 30;
  cursor: grabbing;
  transition: opacity 120ms ease, transform 120ms ease;
  outline: 3px solid rgba(255, 243, 207, 0.78);
  outline-offset: 2px;
}

.stage-cat.show:hover {
  outline: 3px solid rgba(255, 243, 207, 0.58);
  outline-offset: 2px;
}

.stage-cat.show:focus-visible {
  outline: 3px solid rgba(64, 132, 87, 0.85);
  outline-offset: 3px;
}

.stage-cat.activity-jump.show {
  animation: catHop 900ms ease-in-out infinite;
  animation-delay: var(--cat-delay, 0ms);
}

.stage-cat.activity-walk.show {
  animation: catStep 760ms ease-in-out infinite;
  animation-delay: var(--cat-delay, 0ms);
}

.stage-cat.activity-run.show {
  animation: catStep 420ms ease-in-out infinite;
  animation-delay: var(--cat-delay, 0ms);
}

.stage-cat.activity-play.show {
  animation: catPlay 1.4s ease-in-out infinite;
  animation-delay: var(--cat-delay, 0ms);
}

.cat-group-chip {
  position: absolute;
  left: 50%;
  bottom: -4px;
  z-index: 2;
  min-width: 46px;
  padding: 3px 7px;
  border: 2px solid #562b12;
  border-radius: 999px;
  background: #fff1a8;
  color: #4b2613;
  font-size: 0.72rem;
  font-weight: 900;
  text-align: center;
  transform: translateX(-50%);
  white-space: nowrap;
  box-shadow: 0 3px 0 rgba(82, 41, 18, 0.18);
}

.cat-group-panel {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 18;
  width: min(270px, calc(100% - 28px));
  display: grid;
  gap: 5px;
  padding: 12px;
  font-size: 0.9rem;
  font-weight: 900;
}

.cat-group-panel[hidden] {
  display: none;
}

.cat-group-panel strong {
  color: #3d2216;
  font-size: 1.05rem;
}

.cat-group-panel span {
  color: #684421;
}

.cat-group-close {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 30px;
  min-width: 30px;
  min-height: 28px;
  padding: 0;
  line-height: 1;
}

.stage-cat.newcomer-cat {
  animation: catJoin 920ms ease-out both;
}

.stage-cat.happy-cat {
  animation: catHappy 560ms ease-out both;
}

.altar {
  position: relative;
  width: min(58vw, 48dvh, 520px);
  aspect-ratio: 1.8;
  display: block;
  margin: 0;
  padding: 0;
  cursor: pointer;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  z-index: 5;
  transition: transform 130ms ease;
  touch-action: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.altar:active,
.altar.pulse {
  transform: translateY(4px) scale(0.985);
}

.altar.polishing {
  cursor: grabbing;
}

.altar-bracelet {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 47%;
  width: 33%;
  height: 58%;
  translate: -50% -50%;
  rotate: var(--bracelet-rotation, 0deg);
  transform-origin: center;
  transition: rotate 70ms linear, filter 120ms ease;
  will-change: rotate;
  pointer-events: none;
}

.altar.polishing .altar-bracelet {
  filter: drop-shadow(0 0 12px rgba(255, 240, 164, 0.95)) brightness(1.08);
}

.station-art {
  position: absolute;
  inset: 0;
  z-index: 1;
  background-image: var(--bead-station);
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 8px 0 rgba(82, 41, 18, 0.2));
}

.altar-core {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 2%;
  min-width: 34%;
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  gap: 1px;
  padding: 5px 9px;
  border: 3px solid #542a14;
  border-radius: 6px;
  background: rgba(255, 249, 223, 0.94);
  box-shadow: 0 4px 0 rgba(82, 41, 18, 0.18);
}

.altar-core b {
  font-size: clamp(0.8rem, 1.3vw, 1.05rem);
}

.altar-core small {
  color: #176a55;
  font-weight: 900;
}

.altar-core em {
  max-width: min(220px, 42vw);
  color: #8a4b24;
  font-size: clamp(0.58rem, 0.92vw, 0.72rem);
  font-style: normal;
  font-weight: 900;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ritual-bar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  width: min(360px, 100%);
  z-index: 3;
}

.station-zone {
  min-height: clamp(132px, 20dvh, 210px);
  margin-top: clamp(14px, 2.8dvh, 34px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  justify-items: center;
  align-items: end;
  gap: 5px;
  padding-inline: 8px;
}

.station-zone .primary-action,
.station-zone .soft-action {
  min-height: 34px;
  padding: 5px 10px;
  border-width: 3px;
}

.station-zone .ui-icon {
  width: 18px;
  height: 18px;
}

.primary-action,
.soft-action,
.shop-button,
.tab-button,
.ghost-button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 10px;
  border: 3px solid #5b2b11;
  border-radius: 6px;
  background:
    linear-gradient(180deg, #fff0a4 0%, #f3bd43 58%, #b96b20 100%);
  box-shadow: inset 0 -5px 0 rgba(82, 41, 18, 0.24), 0 5px 0 rgba(82, 41, 18, 0.18);
  font-weight: 900;
  cursor: pointer;
  transition: transform 100ms ease, filter 100ms ease, opacity 100ms ease;
}

.soft-action,
.shop-button.secondary,
.ghost-button {
  background:
    linear-gradient(180deg, #fff9df 0%, #79cd92 58%, #278562 100%);
}

.primary-action:hover,
.soft-action:hover,
.shop-button:hover,
.tab-button:hover,
.ghost-button:hover {
  filter: brightness(1.05);
}

.primary-action:active,
.soft-action:active,
.shop-button:active,
.tab-button:active,
.ghost-button:active {
  transform: translateY(3px);
  box-shadow: inset 0 -3px 0 rgba(82, 41, 18, 0.24), 0 2px 0 rgba(82, 41, 18, 0.18);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  filter: grayscale(0.45);
}

.has-upgrade::after {
  content: "!";
  position: absolute;
  right: -7px;
  top: -8px;
  z-index: 8;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 2px solid #542a14;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff3cf, #f3bd43 58%, #d85e4b);
  color: #542a14;
  font-size: 0.86rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 3px 0 rgba(82, 41, 18, 0.2);
  pointer-events: none;
}

.tab-button.has-upgrade,
.shop-button.has-upgrade,
.primary-action.has-upgrade,
.soft-action.has-upgrade {
  position: relative;
}

button:disabled.has-upgrade::after {
  display: none;
}

.shop-card.has-upgrade .shop-button.has-upgrade::after,
.bead-card.has-upgrade .shop-button.has-upgrade::after,
.decor-card.has-upgrade .shop-button.has-upgrade::after,
.wish-card.has-upgrade .shop-button.has-upgrade::after,
.paw-talent-card.has-upgrade .shop-button.has-upgrade::after {
  display: none;
}

.ui-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  image-rendering: pixelated;
}

.ui-icon.arrow { background-image: var(--ui-arrow); }
.ui-icon.sparkle { background-image: var(--ui-sparkle); }
.ui-icon.lock { background-image: var(--ui-lock); }

.progress-wrap {
  margin-top: 10px;
  z-index: 3;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.progress-frame {
  height: 24px;
  padding: 4px;
  border: 3px solid #542a14;
  border-radius: 6px;
  background: #452412;
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.18);
}

.progress-frame > div {
  width: 0%;
  height: 100%;
  border-radius: 3px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.22) 0 8px, transparent 8px 16px),
    linear-gradient(90deg, var(--jade), #f3bd43, var(--coral));
  transition: width 180ms ease;
}

.next-goal {
  margin-top: 6px;
  color: #4f321b;
  font-size: 0.86rem;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-panel {
  min-height: 0;
  height: 100%;
  overflow: hidden;
  padding: 10px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.tabbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.tab-button {
  min-height: 38px;
  padding-inline: 8px;
  background: linear-gradient(180deg, #ffe4a0 0%, #c6812d 100%);
}

.tab-button.active {
  color: #fff9df;
  background: linear-gradient(180deg, #56c987 0%, #176a55 100%);
}

.panel-view {
  min-height: 0;
  display: none;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 3px;
  scrollbar-gutter: stable;
}

.panel-view.active {
  display: block;
}

.shop-list,
.wish-list,
.bead-board,
.decor-list {
  display: grid;
  gap: 10px;
}

.ai-forge {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px;
  border: 3px solid #643316;
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(221, 247, 219, 0.96), rgba(255, 231, 166, 0.88)),
    repeating-linear-gradient(90deg, rgba(216, 94, 75, 0.12) 0 5px, transparent 5px 15px);
  box-shadow: inset 0 -5px 0 rgba(82, 41, 18, 0.14);
}

.ai-forge input[type="text"],
.ai-forge select,
.ai-forge textarea {
  width: 100%;
  border: 2px solid #643316;
  border-radius: 5px;
  padding: 7px 8px;
  color: var(--ink);
  background: rgba(255, 249, 223, 0.95);
  font: inherit;
  font-weight: 800;
}

.ai-forge input:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.ai-forge textarea {
  resize: vertical;
  min-height: 54px;
}

.ai-forge textarea[readonly] {
  cursor: text;
  background:
    linear-gradient(180deg, rgba(255, 249, 223, 0.98), rgba(241, 255, 230, 0.9));
}

.sprite-prompt-button {
  width: 100%;
}

.sprite-prompt-text {
  max-height: 132px;
  font-size: 0.78rem;
  line-height: 1.35;
  white-space: pre-wrap;
}

.sprite-service-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}

.sprite-service-row .ghost-button {
  width: auto;
  min-width: 64px;
  min-height: 34px;
}

.ai-forge small {
  color: #684421;
  font-weight: 800;
  line-height: 1.35;
}

.file-pick {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 2px dashed #643316;
  border-radius: 6px;
  padding: 7px 8px;
  background: rgba(255, 249, 223, 0.58);
  cursor: pointer;
  font-weight: 900;
}

.file-pick input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.shop-card,
.wish-card,
.bead-card,
.decor-card {
  position: relative;
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 10px;
  padding: 8px;
  border: 3px solid #643316;
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 249, 223, 0.92), rgba(244, 213, 140, 0.84)),
    repeating-linear-gradient(90deg, rgba(68, 184, 121, 0.12) 0 5px, transparent 5px 15px);
  box-shadow: inset 0 -5px 0 rgba(82, 41, 18, 0.14);
}

.shop-card .sprite,
.bead-card .sprite,
.bead-card .bracelet-sprite,
.decor-card .decor-sprite {
  width: 62px;
  height: 66px;
  align-self: center;
}

.card-copy {
  min-width: 0;
}

.card-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 900;
}

.card-title span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-meta {
  margin: 4px 0 7px;
  display: grid;
  gap: 4px;
  color: #684421;
  font-size: 0.9rem;
  font-weight: 800;
}

.shop-button {
  width: 100%;
  min-height: 36px;
  padding-block: 7px;
}

.bead-card.locked {
  opacity: 0.68;
}

.decor-card.locked {
  opacity: 0.68;
}

.bead-card.active-bead {
  outline: 4px solid rgba(68, 184, 121, 0.48);
}

.bead-progress {
  height: 12px;
  margin: 3px 0 7px;
  border: 2px solid #542a14;
  border-radius: 4px;
  background: #5a331d;
  overflow: hidden;
}

.bead-progress span {
  display: block;
  width: 0%;
  height: 100%;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.22) 0 5px, transparent 5px 10px),
    linear-gradient(90deg, #f6e6b0, #d3944d, #7c3f24);
  transition: width 180ms ease;
}

.bead-actions {
  display: grid;
  grid-template-columns: 0.82fr 1.18fr;
  gap: 7px;
}

.bead-actions .shop-button {
  min-height: 34px;
  padding-block: 6px;
}

.wish-card {
  grid-template-columns: minmax(0, 1fr);
}

.paw-panel,
.paw-talent-card {
  position: relative;
  padding: 9px;
  border: 3px solid #643316;
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 249, 223, 0.95), rgba(121, 205, 146, 0.34)),
    repeating-linear-gradient(90deg, rgba(243, 189, 67, 0.12) 0 5px, transparent 5px 15px);
  box-shadow: inset 0 -5px 0 rgba(82, 41, 18, 0.14);
}

.paw-panel {
  display: grid;
  gap: 8px;
}

.paw-talent-grid {
  display: grid;
  gap: 8px;
}

.paw-talent-card {
  display: grid;
  gap: 6px;
}

.paw-talent-card .shop-button {
  min-height: 32px;
  padding-block: 5px;
}

.wish-card.claimed {
  background:
    linear-gradient(180deg, rgba(218, 247, 201, 0.95), rgba(121, 205, 146, 0.72));
}

.wish-progress {
  height: 16px;
  border: 2px solid #542a14;
  border-radius: 4px;
  background: #f1c46d;
  overflow: hidden;
}

.wish-progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--jade), var(--gold));
}

.bottom-dock {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) repeat(3, auto);
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
}

.mini-stat {
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: 6px 8px;
  border: 3px solid rgba(82, 41, 18, 0.82);
  border-radius: 6px;
  background: rgba(255, 249, 223, 0.68);
}

.mini-stat strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ghost-button {
  min-width: 82px;
}

.bottom-dock .ghost-button {
  min-width: 68px;
}

.float-pop {
  position: fixed;
  z-index: 20;
  color: #fff9df;
  text-shadow: 2px 2px 0 #542a14;
  font-weight: 900;
  pointer-events: none;
  animation: floatPop 760ms ease-out forwards;
}

.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 30;
  display: grid;
  gap: 8px;
  width: min(340px, calc(100vw - 32px));
}

.toast {
  padding: 10px 12px;
  border: 3px solid #542a14;
  border-radius: 6px;
  background: #fff3cf;
  box-shadow: 0 6px 0 rgba(82, 41, 18, 0.18);
  font-weight: 900;
}

.save-export-layer[hidden] {
  display: none;
}

.save-export-layer {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(35, 22, 15, 0.46);
}

.save-export-card {
  width: min(620px, 100%);
  max-height: min(78vh, 680px);
  display: grid;
  gap: 10px;
  padding: 14px;
}

.save-export-card h2 {
  margin: 0;
  color: #3d2216;
  font-size: 1.2rem;
}

.save-export-card textarea {
  width: 100%;
  min-height: 260px;
  max-height: 46vh;
  resize: vertical;
  border: 3px solid #643316;
  border-radius: 6px;
  padding: 9px;
  color: #3d2216;
  background: rgba(255, 249, 223, 0.96);
  font: 700 0.78rem/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.save-export-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.guide-layer[hidden] {
  display: none;
}

.guide-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}

.guide-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(35, 22, 15, 0.44);
  pointer-events: none;
}

.guide-spotlight {
  position: fixed;
  z-index: 115;
  display: none;
  border: 5px solid rgba(255, 243, 207, 0.98);
  border-radius: 12px;
  box-shadow:
    0 0 0 6px rgba(68, 184, 121, 0.58),
    0 0 0 9999px rgba(35, 22, 15, 0.22),
    0 0 24px rgba(255, 240, 164, 0.95),
    inset 0 0 18px rgba(255, 249, 223, 0.52);
  pointer-events: none;
  animation: guidePulse 1100ms ease-in-out infinite;
}

.guide-spotlight.show {
  display: block;
}

.guide-card {
  position: absolute;
  right: clamp(12px, 3vw, 34px);
  bottom: clamp(12px, 3vh, 28px);
  z-index: 120;
  width: min(430px, calc(100vw - 24px));
  max-height: min(72vh, 520px);
  display: grid;
  gap: 10px;
  padding: 16px;
  overflow-y: auto;
  pointer-events: auto;
}

.guide-card::before {
  opacity: 0.32;
}

.guide-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.guide-head small {
  color: #176a55;
  font-weight: 900;
}

.guide-close {
  width: 36px;
  min-width: 36px;
  min-height: 34px;
  padding: 0;
  font-size: 1.3rem;
  line-height: 1;
}

.guide-card h2 {
  margin: 0;
  color: #3d2216;
  font-size: clamp(1.25rem, 2vw, 1.6rem);
}

.guide-card p {
  margin: 0;
  color: #4d321e;
  font-size: 1rem;
  line-height: 1.55;
  font-weight: 800;
}

.guide-hint {
  padding: 9px 10px;
  border: 2px solid rgba(82, 41, 18, 0.7);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 249, 223, 0.88), rgba(121, 205, 146, 0.34));
  color: #176a55;
  font-size: 0.92rem;
  font-weight: 900;
}

.guide-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}

.guide-dots span {
  width: 12px;
  height: 12px;
  border: 2px solid #542a14;
  border-radius: 999px;
  background: #fff3cf;
}

.guide-dots span.active {
  background: var(--jade);
}

.guide-actions {
  display: grid;
  grid-template-columns: auto 1fr 1.2fr;
  gap: 8px;
}

.guide-actions .ghost-button,
.guide-actions .soft-action,
.guide-actions .primary-action {
  min-height: 38px;
  padding: 6px 9px;
}

.guide-focus {
  position: relative;
  z-index: 90 !important;
}

@keyframes turn {
  to {
    transform: rotate(360deg);
  }
}

@keyframes catHop {
  0%, 100% {
    translate: 0 0;
  }
  50% {
    translate: 0 -9px;
  }
}

@keyframes catStep {
  0%, 100% {
    translate: 0 0;
  }
  50% {
    translate: 0 -2px;
  }
}

@keyframes catPlay {
  0%, 100% {
    translate: 0 0;
    rotate: 0deg;
  }
  45% {
    translate: 0 -7px;
    rotate: -3deg;
  }
  70% {
    rotate: 3deg;
  }
}

@keyframes catJoin {
  0% {
    opacity: 0;
    translate: -46px 0;
  }
  70% {
    opacity: 1;
    translate: 7px -3px;
  }
  100% {
    opacity: 1;
    translate: 0 0;
  }
}

@keyframes catHappy {
  0%, 100% {
    translate: 0 0;
  }
  38% {
    translate: 0 -11px;
  }
  65% {
    translate: 0 -4px;
  }
}

@keyframes guidePulse {
  0%, 100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.08);
  }
}

@media (max-width: 640px) {
  .audio-button,
  .guide-button {
    min-width: 42px;
  }

  .audio-button span:last-child,
  .guide-button span:last-child {
    display: none;
  }

  .guide-card {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
  }

  .guide-actions {
    grid-template-columns: 1fr 1fr;
  }

  .guide-actions .primary-action {
    grid-column: 1 / -1;
  }
}

@keyframes floatPop {
  0% {
    opacity: 0;
    transform: translate(-50%, 10px) scale(0.8);
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -54px) scale(1.08);
  }
}

@media (max-width: 980px) {
  .game-shell {
    padding: 8px;
    gap: 8px;
  }

  .topbar {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 8px;
  }

  .play-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 0.62fr) minmax(0, 0.38fr);
    gap: 8px;
  }

  .resource-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stage {
    min-height: 0;
    grid-template-rows: minmax(260px, 1.7fr) minmax(126px, 0.68fr) auto;
    padding: 10px;
    gap: 10px;
  }

  .room-scene {
    min-height: clamp(260px, 42dvh, 410px);
  }

  .side-panel {
    min-height: 0;
  }

  .altar {
    width: min(78vw, 28dvh, 410px);
    margin-bottom: 10px;
  }

  .altar-bracelet {
    top: 42%;
    width: 38%;
    height: 66%;
  }

  .altar-core {
    bottom: -10px;
  }

  .station-zone {
    min-height: clamp(126px, 19dvh, 190px);
    margin-top: clamp(12px, 2.4dvh, 28px);
    gap: 10px;
  }

  .cat-layer {
    inset: 0 10px 6px;
  }

  .decor-layer {
    inset: 6px 10px 6px;
  }

  .stage-decor[data-decor="window-perch"] {
    left: 8%;
  }

  .stage-decor[data-decor="display-shelf"] {
    right: 8%;
  }

  .stage-cat {
    width: clamp(50px, 9.5vw, 94px);
  }
}

@media (max-width: 620px) {
  body {
    font-size: 14px;
  }

  .game-shell {
    padding: 6px;
    gap: 6px;
  }

  .topbar {
    padding: 6px;
  }

  .brand-lockup {
    align-items: center;
  }

  .game-logo {
    width: min(360px, 100%);
    max-height: 64px;
  }

  .brand-lockup p {
    display: none;
  }

  .resource-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
  }

  .bottom-dock {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 6px;
  }

  .bottom-dock .ghost-button {
    min-width: 0;
  }

  .resource-card {
    grid-template-columns: 28px minmax(0, 1fr);
    min-height: 44px;
    padding: 5px;
    border-width: 2px;
  }

  .resource-card .sprite {
    width: 28px;
    height: 28px;
  }

  .resource-card strong {
    font-size: 0.9rem;
  }

  .resource-card small,
  .mini-stat span {
    font-size: 0.72rem;
  }

  .stage {
    min-height: 0;
    grid-template-rows: minmax(260px, 1.72fr) minmax(132px, 0.68fr) auto;
    padding: 8px;
    gap: 9px;
  }

  .room-scene {
    min-height: clamp(260px, 43dvh, 400px);
  }

  .altar {
    width: min(96vw, 32dvh, 360px);
    max-width: calc(100vw - 24px);
    margin-bottom: 24px;
  }

  .altar-bracelet {
    top: 38%;
    width: 46%;
    height: 76%;
  }

  .station-zone {
    min-height: clamp(132px, 23dvh, 226px);
    margin-top: clamp(10px, 2dvh, 22px);
    padding-inline: 2px;
    gap: 8px;
  }

  .station-zone .primary-action,
  .station-zone .soft-action {
    min-height: 30px;
    padding: 4px 7px;
  }

  .altar-core {
    bottom: -22px;
    min-width: min(176px, 58vw);
    padding: 4px 7px;
    border-width: 2px;
  }

  .altar-core b {
    font-size: 0.72rem;
  }

  .altar-core small {
    font-size: 0.64rem;
  }

  .altar-core em {
    max-width: min(164px, 54vw);
    font-size: 0.56rem;
    white-space: normal;
    text-align: center;
    line-height: 1.05;
  }

  .cat-layer {
    inset: 0 5px 5px;
  }

  .decor-layer {
    inset: 4px 5px 4px;
  }

  .stage-decor[data-decor="cat-tree"] {
    width: clamp(78px, 26vw, 124px);
    height: clamp(90px, 30vw, 144px);
  }

  .stage-decor[data-decor="window-perch"] {
    left: 4%;
    width: clamp(104px, 34vw, 166px);
    height: clamp(78px, 25vw, 128px);
  }

  .stage-decor[data-decor="display-shelf"],
  .stage-decor[data-decor="scratch-post"] {
    display: none;
  }

  .stage-cat {
    width: clamp(44px, 15.5vw, 76px);
  }

  .primary-action,
  .soft-action,
  .shop-button,
  .tab-button,
  .ghost-button {
    min-height: 34px;
    padding: 6px 8px;
  }

  .shop-card,
  .bead-card,
  .decor-card {
    grid-template-columns: 54px minmax(0, 1fr);
  }

  .bead-actions {
    grid-template-columns: 1fr;
  }

  .shop-card .sprite,
  .bead-card .sprite,
  .bead-card .bracelet-sprite,
  .decor-card .decor-sprite {
    width: 52px;
    height: 54px;
  }
}

@media (max-width: 760px) and (orientation: portrait) {
  html,
  body {
    overflow: auto;
  }

  .game-shell {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
    grid-template-rows: auto auto auto;
  }

  .play-layout {
    grid-template-rows: auto auto;
  }

  .stage {
    min-height: 64dvh;
  }

  .room-scene {
    min-height: 40dvh;
  }

  .altar {
    width: min(96vw, 36dvh, 390px);
    margin-bottom: 22px;
  }

  .altar-bracelet {
    top: 37%;
    width: 48%;
    height: 78%;
  }

  .station-zone {
    min-height: clamp(154px, 25dvh, 246px);
    margin-top: clamp(10px, 2dvh, 22px);
  }

  .side-panel {
    min-height: 42dvh;
  }

  .panel-view {
    max-height: 38dvh;
  }

  .bottom-dock {
    position: sticky;
    bottom: 0;
    z-index: 25;
  }
}
