/* 萌宠营救大挑战 · 箭头突围 */
:root {
  --orange: #FF8A3D;
  --orange-deep: #D9611D;
  --orange-light: #FFB067;
  --cream: #FFF6E3;
  --cream-2: #FFFDF6;
  --brown: #6B4A2F;
  --brown-soft: #8E6B4B;
  --green: #79C74A;
  --green-deep: #3F7F2E;
  --blue: #49B8F2;
  --red: #F05B4F;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  overflow: hidden;
  overscroll-behavior: none;
  background: radial-gradient(circle at 50% 18%, #6FBF4D 0%, #478B33 55%, #2F6423 100%);
  color: var(--brown);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font-family: inherit;
  color: inherit;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 3px solid #FFF3B0;
  outline-offset: 2px;
}

.game {
  position: relative;
  width: 100%;
  max-width: 540px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  isolation: isolate;
  background: linear-gradient(180deg, #A7E5D4 0%, #C9EFC4 24%, #8DCF5C 44%, #65AF39 100%);
  box-shadow: 0 0 70px rgba(20, 48, 12, 0.42);
}

.pet-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.scenery {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  transition: filter 0.35s ease, opacity 0.35s ease;
}

body.plain .scenery {
  filter: saturate(0.82) brightness(1.03);
}

body.plain .deco-flowers,
body.plain .deco-butterflies,
body.plain .deco-tufts {
  opacity: 0.22;
}

/* ---------------------------------------------------------- 顶部游戏状态 */
.hud {
  position: relative;
  z-index: 6;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 6px;
  padding: max(9px, var(--safe-top)) 12px 0;
}

.hud-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  min-width: 0;
}

.round-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 13px;
  border: 2.5px solid #6B4A2F;
  background: linear-gradient(180deg, #FFFCF2, #FFE9C8);
  box-shadow: 0 3px 0 rgba(94, 58, 24, 0.3), inset 0 2px 0 #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.round-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(94, 58, 24, 0.3), inset 0 2px 0 #fff;
}

.round-btn .mp-icon {
  width: 20px;
  height: 20px;
  color: var(--brown);
}

.plain-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 0 6px;
  border: 2px solid var(--brown);
  border-radius: 999px;
  background: linear-gradient(180deg, #FFFCF2, #FFEED3);
  box-shadow: 0 3px 0 rgba(94, 58, 24, 0.22), inset 0 1.5px 0 #fff;
  cursor: pointer;
  transition: transform 0.08s ease;
}

.plain-toggle:active { transform: translateY(1px) scale(0.98); }

.plain-paw {
  width: 15px;
  height: 15px;
  color: var(--orange);
  flex: 0 0 auto;
}

.plain-label {
  font-size: 11px;
  line-height: 1;
  font-weight: 800;
  color: #624227;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.switch {
  position: relative;
  width: 26px;
  height: 14px;
  border-radius: 999px;
  background: #D9C9B0;
  box-shadow: inset 0 1px 2px rgba(90, 58, 28, 0.22);
  flex: 0 0 auto;
  transition: background 0.22s ease;
}

.knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #FFFDF8;
  box-shadow: 0 1px 2px rgba(80, 50, 20, 0.32);
  transition: transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

body.plain .switch { background: var(--orange); }
body.plain .knob { transform: translateX(12px); }

.level-plaque {
  position: relative;
  justify-self: center;
  margin-top: 3px;
  display: flex;
  align-items: baseline;
  gap: 2px;
  padding: 5px 14px;
  border: 2.5px solid #7A4A25;
  border-radius: 12px;
  background: linear-gradient(180deg, #FFB76B 0%, #FF8A3D 62%, #F47522 100%);
  box-shadow: 0 4px 0 #C45B1B, 0 7px 12px rgba(80, 45, 15, 0.18), inset 0 2px 0 rgba(255, 255, 255, 0.35);
  color: #FFFDF6;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.5px;
  text-shadow: 0 1.5px 0 rgba(122, 62, 20, 0.5);
  white-space: nowrap;
  transform-origin: center;
}

.level-plaque b {
  font-size: 19px;
  line-height: 1;
  margin: 0 1px;
  letter-spacing: 0;
}

.level-plaque::before,
.level-plaque::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #FFDCA8;
  box-shadow: 0 1px 0 #9F4B15;
  transform: translateY(-50%);
}
.level-plaque::before { left: 4px; }
.level-plaque::after { right: 4px; }

.level-plaque.pop {
  animation: plaquePop 0.42s cubic-bezier(0.2, 0.9, 0.3, 1.35);
}

.progress-pill {
  justify-self: end;
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 7px 3px 3px;
  border: 2.5px solid #7A4A25;
  border-radius: 14px;
  background: linear-gradient(180deg, #FFFCF2, #FFEFD6);
  box-shadow: 0 4px 0 rgba(94, 58, 24, 0.2), inset 0 1.5px 0 #fff;
  min-width: 0;
}

.ring {
  position: relative;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: conic-gradient(var(--orange) calc(var(--p, 0) * 1%), #E8DAC3 0);
  display: grid;
  place-items: center;
  transition: background 0.3s ease;
}

.ring::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: linear-gradient(180deg, #FFFDF8, #FFF2DC);
  box-shadow: inset 0 1px 2px rgba(122, 74, 37, 0.1);
}

.ring .mp-icon {
  position: relative;
  z-index: 1;
  width: 14px;
  height: 14px;
  color: #E07A2E;
}

.ring.done {
  background: conic-gradient(#79C74A 100%, #79C74A 0);
}

.progress-meta {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1;
  min-width: 0;
}

.progress-meta b {
  font-size: 13.5px;
  font-weight: 900;
  color: #563820;
  letter-spacing: -0.2px;
  white-space: nowrap;
}

.progress-meta small {
  margin-top: 3px;
  font-size: 8.5px;
  font-weight: 700;
  color: #A18365;
  white-space: nowrap;
  letter-spacing: 0.1px;
}

/* ---------------------------------------------------------- 提示条 */
.hintbar {
  position: relative;
  z-index: 4;
  flex: 0 0 auto;
  margin: 7px auto 0;
  display: flex;
  align-items: center;
  gap: 5px;
  height: 27px;
  max-width: calc(100% - 32px);
  padding: 0 12px;
  border: 2px solid rgba(107, 74, 47, 0.48);
  border-radius: 999px;
  background: rgba(255, 251, 239, 0.94);
  box-shadow: 0 2px 0 rgba(80, 50, 20, 0.12);
  color: #6B4A2F;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  transition: opacity 0.32s ease, transform 0.32s ease;
}

.hintbar .mp-icon {
  width: 15px;
  height: 15px;
  color: var(--orange);
  flex: 0 0 auto;
}

.hintbar.gone {
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
}

/* ---------------------------------------------------------- 游戏区 */
.stage {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px 10px 0;
  overflow: visible;
}

.field {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cols, 7), 1fr);
  grid-template-rows: repeat(var(--rows, 10), 1fr);
  transform-origin: center;
  overflow: visible;
}

.field::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: -12px -8px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.17) 0%, rgba(255, 255, 255, 0.05) 52%, rgba(255, 255, 255, 0) 72%);
  pointer-events: none;
}

.slot {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 2;
  overflow: visible;
}

.animal {
  position: absolute;
  inset: 1px;
  z-index: 2;
  overflow: visible;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.48s cubic-bezier(0.2, 0.72, 0.28, 1), opacity 0.4s ease-in 0.05s;
  will-change: transform, opacity;
}

.animal::before {
  content: "";
  position: absolute;
  left: 17%;
  right: 17%;
  bottom: 3%;
  height: 15%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(37, 74, 20, 0.3) 0%, rgba(37, 74, 20, 0) 72%);
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.animal::after {
  content: "";
  position: absolute;
  inset: 4%;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.rotor {
  position: absolute;
  inset: 0;
  transition: transform 0.38s cubic-bezier(0.2, 0.9, 0.25, 1.18);
  will-change: transform;
}

.bob {
  position: absolute;
  inset: 0;
  animation: idleBob 2.6s ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

body.dense-level .bob { animation: none; }

.pet-svg {
  position: absolute;
  left: calc(50% + var(--jx, 0px));
  top: calc(50% + var(--jy, 0px));
  width: calc(130% * var(--s, 1));
  height: calc(130% * var(--s, 1));
  overflow: visible;
  transform: translate(-50%, -50%) rotate(var(--tilt, 0deg));
  filter: drop-shadow(0 2px 1px rgba(45, 78, 25, 0.28));
  transition: transform 0.12s ease-out, filter 0.22s ease;
  pointer-events: none;
}

.animal:active .pet-svg {
  transform: translate(-50%, -50%) rotate(var(--tilt, 0deg)) scale(0.9);
}

.animal:focus-visible .pet-svg {
  filter: drop-shadow(0 0 0 2px #FFF9DC) drop-shadow(0 0 8px #FFF3A0) drop-shadow(0 2px 1px rgba(45, 78, 25, 0.28));
}

.field.selecting .animal::after {
  opacity: 1;
  animation: selectGlow 1.25s ease-in-out infinite;
}

.field.selecting.mode-grab .animal::after {
  border-color: #FFE0C2;
  box-shadow: 0 0 0 3px rgba(255, 138, 61, 0.28);
}

.field.selecting.mode-flip .animal::after {
  border-color: #CDF1FF;
  box-shadow: 0 0 0 3px rgba(73, 184, 242, 0.28);
}

.field.selecting .animal {
  cursor: pointer;
}

.animal.leaving {
  transform: translate(var(--tx, 0), var(--ty, 0)) scale(0.72);
  opacity: 0;
  pointer-events: none;
}

.animal.leaving::before { opacity: 0; }

.animal.grabbed {
  animation: grabbedAway 0.42s cubic-bezier(0.3, 0.6, 0.5, 1) forwards;
  pointer-events: none;
}

.animal.flip-pop .pet-svg {
  animation: flipPop 0.36s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.animal.shuffle-flip .pet-svg {
  animation: shufflePop 0.42s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.animal.free-glow .pet-svg {
  filter: drop-shadow(0 0 5px #FFF8B8) drop-shadow(0 0 10px #B9F274) drop-shadow(0 2px 1px rgba(45, 78, 25, 0.24));
  animation: freeGlow 0.8s ease-in-out infinite;
}

.animal.hint-free .pet-svg {
  filter: drop-shadow(0 0 5px #FFF8B8) drop-shadow(0 0 13px #FFE56F) drop-shadow(0 2px 1px rgba(45, 78, 25, 0.28));
  animation: freeGlow 0.9s ease-in-out infinite;
}

.animal.tutorial .pet-svg {
  filter: drop-shadow(0 0 5px #FFF8B8) drop-shadow(0 0 12px #FFE56F) drop-shadow(0 2px 1px rgba(45, 78, 25, 0.3));
}

.tut-hand {
  position: absolute;
  z-index: 5;
  right: -18%;
  top: -28%;
  width: 29px;
  height: 29px;
  border: 2px solid #7A4218;
  border-radius: 50%;
  background: linear-gradient(180deg, #FFC067, #FF8A3D);
  box-shadow: 0 3px 0 rgba(120, 60, 15, 0.3), inset 0 1.5px 0 rgba(255, 255, 255, 0.5);
  display: grid;
  place-items: center;
  color: #FFFDF6;
  pointer-events: none;
  animation: tapHand 1.1s ease-in-out infinite;
}

.tut-hand .mp-icon {
  width: 18px;
  height: 18px;
}

.field.shuffling {
  animation: fieldShake 0.48s ease-in-out;
}

/* ---------------------------------------------------------- 底部道具 */
.dock {
  position: relative;
  z-index: 7;
  flex: 0 0 auto;
  padding: 2px 12px max(10px, var(--safe-bottom));
}

.dock-tools {
  display: flex;
  align-items: stretch;
  gap: 5px;
  padding: 9px 7px 8px;
  border: 3px solid var(--brown);
  border-radius: 22px;
  background: linear-gradient(180deg, #FFFCF3 0%, #FFF2D8 58%, #FFE7C0 100%);
  box-shadow: 0 5px 0 rgba(92, 55, 22, 0.32), 0 10px 22px rgba(38, 74, 20, 0.16), inset 0 2px 0 #fff;
}

.tool {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: none;
  cursor: pointer;
  transition: transform 0.09s ease;
  -webkit-tap-highlight-color: transparent;
}

.tool:active { transform: translateY(3px); }

.tool-icon {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  border: 2.5px solid rgba(56, 30, 12, 0.58);
  display: grid;
  place-items: center;
  color: #FFFDF6;
  box-shadow: 0 4px 0 rgba(60, 30, 10, 0.38), inset 0 2px 0 rgba(255, 255, 255, 0.45);
  transition: transform 0.09s ease, box-shadow 0.09s ease;
}

.tool-icon .mp-icon {
  width: 27px;
  height: 27px;
  filter: drop-shadow(0 1.5px 0 rgba(0, 0, 0, 0.18));
}

.tool-grab .tool-icon {
  background: linear-gradient(180deg, #FFB564 0%, #FF8A3D 58%, #F27222 100%);
  border-color: #8A4A1C;
}

.tool-flip .tool-icon {
  background: linear-gradient(180deg, #7ED4FF 0%, #49B8F2 58%, #2C9AD4 100%);
  border-color: #1D6E9A;
}

.tool-shuffle .tool-icon {
  background: linear-gradient(180deg, #9FE075 0%, #6BC34A 58%, #4EA631 100%);
  border-color: #2F7520;
}

.tool:active .tool-icon {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(60, 30, 10, 0.38), inset 0 2px 0 rgba(255, 255, 255, 0.45);
}

.tool.active .tool-icon {
  animation: toolPulse 0.9s ease-in-out infinite;
  box-shadow: 0 0 0 3px #FFF6D0, 0 0 0 6px rgba(255, 246, 208, 0.3), 0 4px 0 rgba(60, 30, 10, 0.38), inset 0 2px 0 rgba(255, 255, 255, 0.45);
}

.tool.active .tool-label { color: #E8722B; }

.tool.needs-help .tool-icon {
  animation: needHelp 0.75s ease-in-out infinite;
}

.tool-badge {
  position: absolute;
  z-index: 4;
  top: -6px;
  right: calc(50% - 37px);
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 2px solid #FFF9EA;
  border-radius: 999px;
  background: linear-gradient(180deg, #FF7B6E, #E94B3C);
  box-shadow: 0 2px 0 rgba(120, 30, 20, 0.32);
  color: #FFFDF8;
  font-size: 10.5px;
  font-weight: 900;
  line-height: 1;
  display: grid;
  place-items: center;
}

.tool-badge.is-ad {
  background: linear-gradient(180deg, #FFB35E, #F47A22);
  font-size: 9px;
  letter-spacing: -0.3px;
  animation: badgePulse 1.4s ease-in-out infinite;
}

.tool-label {
  margin-top: 2px;
  font-size: 13.5px;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: #5E3D23;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
  line-height: 1.1;
}

.tool-sub {
  font-size: 9px;
  font-weight: 700;
  color: #A08367;
  white-space: nowrap;
  line-height: 1.15;
}

.tool.no-uses .tool-sub { color: #E8722B; }

/* ---------------------------------------------------------- 顶部选择提示 */
.hint-cancel {
  display: none;
  align-items: center;
  justify-content: center;
  height: 20px;
  margin-left: 2px;
  padding: 0 9px;
  border: 0;
  border-radius: 999px;
  background: #FFF6E3;
  color: #5E3D23;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.hintbar.mode {
  background: rgba(59, 39, 24, 0.94);
  border-color: rgba(59, 39, 24, 0.94);
  color: #FFF6E3;
  box-shadow: 0 4px 14px rgba(30, 20, 10, 0.24);
}

.hintbar.mode .mp-icon { color: #FFD45C; }
.hintbar.mode .hint-cancel { display: inline-flex; }

/* ---------------------------------------------------------- 提示与关卡横幅 */
.toast {
  position: absolute;
  z-index: 15;
  left: 50%;
  bottom: calc(182px + var(--safe-bottom));
  max-width: calc(100% - 40px);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(59, 39, 24, 0.94);
  box-shadow: 0 6px 18px rgba(30, 20, 10, 0.28);
  color: #FFF8E9;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.level-flash {
  position: absolute;
  z-index: 12;
  left: 50%;
  top: 39%;
  padding: 10px 24px;
  border: 2.5px solid #FFDCA8;
  border-radius: 18px;
  background: rgba(58, 37, 22, 0.94);
  box-shadow: 0 8px 24px rgba(30, 20, 10, 0.3);
  color: #FFF6E3;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 2px;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.8);
  pointer-events: none;
}

.level-flash.show {
  animation: levelFlash 1.1s ease-out forwards;
}

/* ---------------------------------------------------------- 覆盖层 */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(31, 52, 22, 0.52);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.26s ease;
}

.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.win-card,
.pause-card,
.ad-card {
  position: relative;
  z-index: 2;
  width: min(100%, 330px);
  padding: 18px 18px 16px;
  border: 3.5px solid #6B4A2F;
  border-radius: 26px;
  background: linear-gradient(180deg, #FFFDF5 0%, #FFF5E1 62%, #FFEBCB 100%);
  box-shadow: 0 10px 0 rgba(60, 35, 15, 0.24), 0 22px 44px rgba(20, 40, 10, 0.3), inset 0 2px 0 #fff;
  text-align: center;
  overflow: hidden;
  transform: translateY(14px) scale(0.96);
  transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.overlay.show .win-card,
.overlay.show .pause-card,
.overlay.show .ad-card {
  transform: translateY(0) scale(1);
}

.win-card h2,
.pause-card h2,
.ad-card h2 {
  position: relative;
  z-index: 1;
  margin: 2px 0 6px;
  color: #5B3A20;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 1px;
  text-shadow: 0 2px 0 #FFE3B5;
  line-height: 1.1;
}

.win-rays {
  position: absolute;
  z-index: 0;
  top: -74px;
  left: 50%;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, rgba(255, 196, 92, 0.32) 0deg 11deg, rgba(255, 196, 92, 0) 11deg 24deg);
  transform: translateX(-50%);
  animation: spinSlow 22s linear infinite;
  pointer-events: none;
}

.win-pets {
  position: relative;
  z-index: 1;
  height: 76px;
  margin: 0 0 1px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.win-pets svg {
  width: 62px;
  height: 62px;
  filter: drop-shadow(0 3px 1px rgba(90, 60, 25, 0.24));
  animation: petBounce 1.8s ease-in-out infinite;
}

.win-pets svg:nth-child(2) {
  width: 78px;
  height: 78px;
  z-index: 2;
  margin: 0 -9px;
  animation-delay: 0.14s;
}

.win-pets svg:nth-child(3) { animation-delay: 0.28s; }
.win-pets svg:nth-child(4) { animation-delay: 0.42s; }

.win-kicker {
  position: relative;
  z-index: 1;
  margin: 3px 0 1px;
  color: #E07A2E;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 3px;
}

.win-sub {
  position: relative;
  z-index: 1;
  margin: 0 0 12px;
  color: #8E6B4B;
  font-size: 11.5px;
  font-weight: 700;
}

.win-stats {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 0 0 14px;
}

.win-stats > div {
  flex: 1 1 0;
  min-width: 0;
  padding: 7px 3px 6px;
  border: 2px solid #E1CEAF;
  border-radius: 12px;
  background: rgba(255, 252, 242, 0.9);
  box-shadow: inset 0 1px 0 #fff;
}

.win-stats b {
  display: block;
  color: #5B3A20;
  font-size: 16px;
  font-weight: 900;
  line-height: 1.1;
  white-space: nowrap;
}

.win-stats span {
  display: block;
  margin-top: 2px;
  color: #A18365;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
}

.btn-primary {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 46px;
  border: 2.5px solid #7A4218;
  border-radius: 15px;
  background: linear-gradient(180deg, #FFB367 0%, #FF8A3D 55%, #F47422 100%);
  box-shadow: 0 4px 0 #C4591B, inset 0 2px 0 rgba(255, 255, 255, 0.4);
  color: #FFFDF6;
  font-size: 15.5px;
  font-weight: 900;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  text-shadow: 0 1px 0 rgba(120, 55, 10, 0.5);
  transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.2s ease;
}

.btn-primary:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #C4591B, inset 0 2px 0 rgba(255, 255, 255, 0.4);
}

.btn-primary:disabled {
  opacity: 0.55;
  filter: grayscale(0.16);
  cursor: default;
}

.btn-primary .mp-icon {
  width: 20px;
  height: 20px;
}

.btn-ghost {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 35px;
  margin-top: 8px;
  padding: 0 8px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: #8E6B4B;
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-ghost:active { background: rgba(122, 74, 37, 0.08); }
.btn-ghost .mp-icon { width: 16px; height: 16px; }

.pause-card { width: min(100%, 300px); }

.pause-pet {
  width: 84px;
  height: 84px;
  margin: -4px auto 0;
  filter: drop-shadow(0 4px 2px rgba(90, 60, 25, 0.2));
}

.pause-pet svg { width: 100%; height: 100%; animation: petBounce 2.2s ease-in-out infinite; }

.pause-card > p {
  margin: 0 0 14px;
  color: #8E6B4B;
  font-size: 12px;
  font-weight: 700;
}

.pause-row {
  display: flex;
  gap: 7px;
  margin-top: 8px;
}

.pause-row .btn-ghost {
  flex: 1 1 0;
  margin-top: 0;
  min-height: 38px;
  border: 2px solid #D9C5A8;
  border-radius: 12px;
  background: #FFF8E8;
  box-shadow: inset 0 1px 0 #fff;
}

/* 广告演示 */
.ad-card { width: min(100%, 320px); }

.ad-demo {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: #EFE3CF;
  color: #8B6C4A;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.5px;
}

.ad-art {
  position: relative;
  width: 88px;
  height: 88px;
  margin: 11px auto 7px;
  border: 2.5px solid #7A4218;
  border-radius: 24px;
  background: radial-gradient(circle at 34% 28%, #FFE08A 0%, #FFAD5C 55%, #FF8A3D 100%);
  box-shadow: 0 5px 0 #C4591B, inset 0 2px 0 rgba(255, 255, 255, 0.45);
  display: grid;
  place-items: center;
}

.ad-art .mp-icon {
  width: 46px;
  height: 46px;
  color: #FFFDF6;
  filter: drop-shadow(0 2px 0 rgba(120, 55, 10, 0.35));
}

.ad-spark {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #FFF7C2;
  animation: sparkle 1.5s ease-in-out infinite;
}

.ad-spark.s1 { top: 11px; right: 13px; }
.ad-spark.s2 { bottom: 17px; left: 12px; animation-delay: 0.4s; width: 4px; height: 4px; }
.ad-spark.s3 { top: 24px; left: 16px; animation-delay: 0.8s; width: 5px; height: 5px; }

.ad-card > p {
  margin: 0 0 9px;
  color: #8E6B4B;
  font-size: 11.5px;
  font-weight: 700;
}

.ad-progress {
  height: 8px;
  margin: 0 0 12px;
  border-radius: 999px;
  background: #EADDC8;
  box-shadow: inset 0 1px 2px rgba(100, 65, 35, 0.16);
  overflow: hidden;
}

.ad-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #FFD45C, #FF8A3D);
  transition: width 0.1s linear;
}

/* ---------------------------------------------------------- 特效层 */
.fx-layer {
  position: absolute;
  inset: 0;
  z-index: 14;
  overflow: hidden;
  pointer-events: none;
}

.puff {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: puffOut 0.62s ease-out forwards;
}

.plus-one {
  position: absolute;
  transform: translate(-50%, -50%);
  color: #FFF8C4;
  font-size: 16px;
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(83, 110, 24, 0.45);
  animation: plusUp 0.8s ease-out forwards;
}

.bump-mark {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #F05B4F;
  box-shadow: 0 3px 0 rgba(120, 30, 20, 0.3);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  animation: bumpMark 0.6s ease-out forwards;
}

.confetti-wrap {
  position: absolute;
  z-index: 1;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti {
  position: absolute;
  top: -20px;
  border-radius: 2px;
  animation: confettiFall 2.6s linear forwards;
}

/* ---------------------------------------------------------- 关键帧 */
@keyframes idleBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

@keyframes plaquePop {
  0% { transform: scale(1); }
  42% { transform: scale(1.12) rotate(-1.5deg); }
  100% { transform: scale(1); }
}

@keyframes selectGlow {
  0%, 100% { opacity: 0.55; transform: scale(0.97); }
  50% { opacity: 1; transform: scale(1.02); }
}

@keyframes toolPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}

@keyframes needHelp {
  0%, 100% { transform: translateY(0); filter: brightness(1); }
  50% { transform: translateY(-3px); filter: brightness(1.12); }
}

@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

@keyframes flipPop {
  0% { transform: translate(-50%, -50%) rotate(var(--tilt, 0deg)) scale(1); }
  48% { transform: translate(-50%, -50%) rotate(var(--tilt, 0deg)) scale(1.12); }
  100% { transform: translate(-50%, -50%) rotate(var(--tilt, 0deg)) scale(1); }
}

@keyframes shufflePop {
  0% { transform: translate(-50%, -50%) rotate(var(--tilt, 0deg)) scale(1) rotate(0deg); }
  50% { transform: translate(-50%, -50%) rotate(var(--tilt, 0deg)) scale(1.1) rotate(8deg); }
  100% { transform: translate(-50%, -50%) rotate(var(--tilt, 0deg)) scale(1) rotate(0deg); }
}

@keyframes freeGlow {
  0%, 100% { transform: translate(-50%, -50%) rotate(var(--tilt, 0deg)) scale(1); }
  50% { transform: translate(-50%, -50%) rotate(var(--tilt, 0deg)) scale(1.05); }
}

@keyframes grabbedAway {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  38% { transform: translate(0, -9px) scale(1.07); opacity: 1; }
  100% { transform: translate(0, 16px) scale(0.18); opacity: 0; }
}

@keyframes tapHand {
  0%, 100% { transform: translate(0, 0) rotate(-8deg); }
  50% { transform: translate(-2px, -7px) rotate(-18deg); }
}

@keyframes fieldShake {
  0%, 100% { transform: translateX(0) rotate(0); }
  18% { transform: translateX(-4px) rotate(-0.7deg); }
  38% { transform: translateX(5px) rotate(0.7deg); }
  58% { transform: translateX(-3px) rotate(-0.45deg); }
  78% { transform: translateX(2px) rotate(0.3deg); }
}

@keyframes levelFlash {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.72); }
  16% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
  30% { transform: translate(-50%, -50%) scale(1); }
  72% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(0.96); }
}

@keyframes puffOut {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0.6); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx, 12px)), calc(-50% + var(--dy, -12px))) scale(0); }
}

@keyframes plusUp {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(0.7); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  100% { opacity: 0; transform: translate(-50%, -170%) scale(1); }
}

@keyframes bumpMark {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(0.5); }
  25% { opacity: 1; transform: translate(-50%, -60%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -120%) scale(1); }
}

@keyframes confettiFall {
  0% { opacity: 1; transform: translateY(0) rotate(0); }
  100% { opacity: 0.85; transform: translateY(820px) rotate(var(--spin, 360deg)); }
}

@keyframes spinSlow {
  from { transform: translateX(-50%) rotate(0deg); }
  to { transform: translateX(-50%) rotate(360deg); }
}

@keyframes petBounce {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-5px) rotate(1.5deg); }
}

@keyframes sparkle {
  0%, 100% { opacity: 0.35; transform: scale(0.7); }
  50% { opacity: 1; transform: scale(1.25); }
}

/* ---------------------------------------------------------- 屏幕适配 */
@media (min-width: 480px) {
  .dock { padding-left: 18px; padding-right: 18px; }
  .dock-tools { padding: 11px 10px 10px; border-radius: 24px; }
  .tool-icon { width: 62px; height: 62px; border-radius: 18px; }
  .tool-icon .mp-icon { width: 32px; height: 32px; }
  .tool-label { font-size: 15px; }
  .tool-sub { font-size: 10px; }
  .tool-badge { right: calc(50% - 42px); min-width: 22px; height: 22px; font-size: 11.5px; }
  .hintbar { height: 30px; font-size: 12.5px; }
  .toast { bottom: calc(206px + var(--safe-bottom)); font-size: 13px; }
}

@media (max-height: 700px) {
  .hud { padding-top: max(6px, var(--safe-top)); }
  .round-btn { width: 36px; height: 36px; border-radius: 11px; }
  .plain-toggle { height: 27px; }
  .plain-label { font-size: 10px; }
  .switch { width: 23px; height: 13px; }
  .knob { width: 9px; height: 9px; }
  body.plain .knob { transform: translateX(10px); }
  .hintbar { height: 24px; margin-top: 5px; font-size: 10.5px; }
  .tool-icon { width: 46px; height: 46px; border-radius: 14px; }
  .tool-icon .mp-icon { width: 24px; height: 24px; }
  .tool-label { font-size: 12px; }
  .tool-sub { font-size: 8.5px; }
  .tool-badge { right: calc(50% - 33px); }
  .dock-tools { padding: 7px 6px 6px; border-radius: 19px; }
  .level-plaque { font-size: 12px; padding: 4px 12px; }
  .level-plaque b { font-size: 17px; }
  .toast { bottom: calc(166px + var(--safe-bottom)); }
}

@media (max-width: 360px) {
  .hud { padding-left: 9px; padding-right: 9px; gap: 3px; }
  .plain-label { font-size: 10px; }
  .plain-toggle { padding: 0 5px; gap: 3px; }
  .progress-pill { padding-right: 5px; gap: 3px; }
  .progress-meta b { font-size: 12px; }
  .progress-meta small { font-size: 8px; }
  .level-plaque { padding-left: 11px; padding-right: 11px; }
  .tool-label { font-size: 12.5px; }
  .win-card h2, .pause-card h2, .ad-card h2 { font-size: 23px; }
  .win-pets svg { width: 56px; height: 56px; }
  .win-pets svg:nth-child(2) { width: 70px; height: 70px; }
}

@media (prefers-reduced-motion: reduce) {
  .bob,
  .win-rays,
  .win-pets svg,
  .pause-pet svg,
  .tut-hand,
  .ad-spark,
  .tool-badge.is-ad,
  .tool.active .tool-icon,
  .tool.needs-help .tool-icon,
  .field.shuffling {
    animation: none !important;
  }
  .animal,
  .rotor {
    transition-duration: 0.01ms;
  }
}

.tool-badge.ad {
  background: #2B2118;
  color: #FFE08A;
  font-size: 10px;
  letter-spacing: 0.4px;
}
.tool.needs-ad .tool-sub {
  color: #C45B1B;
}
.ad-progress {
  height: 8px;
  margin: 12px 0;
  border-radius: 999px;
  background: #F3E2CC;
  overflow: hidden;
}
.ad-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: #FF8A3D;
  transition: width .12s linear;
}
