/* ============================================================
   晚上躲怪物13 · 夜间潜行解谜
   移动端优先，所有画面用原生 HTML / CSS / SVG 绘制
   ============================================================ */

:root {
  --orange: #FF8A3D;
  --orange-soft: #FFB25E;
  --orange-deep: #E96A22;
  --amber: #FFD166;
  --cream: #FFF4DC;
  --cream-dim: #E9E2D2;
  --ink: #080C1D;
  --night: #0D1330;
  --night-2: #141C3D;
  --panel: rgba(16, 23, 50, 0.88);
  --muted: #A9B4D6;
  --line: rgba(199, 214, 255, 0.16);
  --danger: #FF5D5D;
  --cell-w: 20%;
  --cell-h: 16.6667%;
  --radius-lg: 26px;
  --radius-md: 16px;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: #080C1D;
  color: var(--cream);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  overflow-x: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[hidden] {
  display: none !important;
}

button {
  font-family: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
}

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

/* ---------- 夜空 ---------- */

.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(120% 85% at 50% -10%, #1D2A5C 0%, #11183A 38%, #080C1D 78%, #060916 100%);
  pointer-events: none;
}

.sky::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(55% 38% at 82% 18%, rgba(255, 210, 130, 0.12), transparent 68%),
    radial-gradient(48% 42% at 15% 82%, rgba(255, 138, 61, 0.08), transparent 70%),
    radial-gradient(70% 55% at 50% 110%, rgba(30, 44, 92, 0.7), transparent 70%);
}

.stars {
  position: absolute;
  inset: 0;
}

.star-dot {
  position: absolute;
  width: var(--s, 2px);
  height: var(--s, 2px);
  border-radius: 50%;
  background: #FFF4D6;
  box-shadow: 0 0 6px rgba(255, 244, 214, 0.7);
  opacity: var(--o, 0.65);
  animation: twinkle var(--d, 3.2s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

.moon {
  position: absolute;
  top: 38px;
  right: max(-28px, calc(50% - 250px));
  width: 128px;
  height: 128px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 32%, #FFF9DB 0%, #FFF0B6 34%, #FFD98A 70%, #F7BC5B 100%);
  box-shadow:
    0 0 44px rgba(255, 217, 138, 0.42),
    0 0 110px rgba(255, 200, 100, 0.24),
    inset -12px -10px 22px rgba(202, 139, 48, 0.28);
  opacity: 0.92;
}

.moon-crater {
  position: absolute;
  border-radius: 50%;
  background: rgba(206, 151, 70, 0.22);
  box-shadow: inset 1px 1px 2px rgba(160, 105, 35, 0.2);
}

.moon-crater.c1 {
  width: 22px;
  height: 22px;
  left: 30%;
  top: 26%;
}

.moon-crater.c2 {
  width: 13px;
  height: 13px;
  left: 57%;
  top: 50%;
}

.moon-crater.c3 {
  width: 9px;
  height: 9px;
  left: 34%;
  top: 62%;
}

.cloud {
  position: absolute;
  height: 42px;
  border-radius: 50%;
  background: rgba(150, 174, 255, 0.07);
  filter: blur(11px);
  animation: cloudDrift 28s ease-in-out infinite alternate;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: inherit;
}

.cloud::before {
  width: 70%;
  height: 150%;
  left: 12%;
  top: -70%;
}

.cloud::after {
  width: 55%;
  height: 120%;
  right: 8%;
  top: -45%;
}

.cloud-a {
  width: 220px;
  left: -70px;
  top: 17%;
}

.cloud-b {
  width: 280px;
  right: -110px;
  top: 31%;
  opacity: 0.7;
  animation-delay: -9s;
}

.cloud-c {
  width: 160px;
  left: 24%;
  top: 6%;
  opacity: 0.5;
  animation-delay: -16s;
}

.sky-haze {
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: -14%;
  height: 38%;
  background: radial-gradient(ellipse at 50% 100%, rgba(255, 138, 61, 0.08), transparent 68%);
}

.fireflies {
  position: absolute;
  inset: 0;
}

.firefly {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #FFC46B;
  box-shadow: 0 0 10px 3px rgba(255, 160, 65, 0.35);
  opacity: 0;
  animation: firefly var(--d, 7s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

/* ---------- 页面骨架 ---------- */

.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 540px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
}

/* ---------- 顶部状态 ---------- */

.hud {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 9px) 14px 7px;
}

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(33, 45, 85, 0.78), rgba(11, 16, 38, 0.82));
  box-shadow:
    0 7px 20px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.09);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.chip .mp-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.chip-night {
  color: #FFF0CC;
}

.chip-night .mp-icon {
  color: var(--orange-soft);
  filter: drop-shadow(0 0 5px rgba(255, 178, 94, 0.55));
}

.chip-state {
  gap: 5px;
  padding: 0 10px;
  color: #B8C5E6;
  font-size: 11px;
  font-weight: 700;
}

.state-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #65E0B0;
  box-shadow: 0 0 7px rgba(101, 224, 176, 0.8);
  animation: statePulse 2s ease-in-out infinite;
}

.chip-state.alert .state-dot {
  background: var(--danger);
  box-shadow: 0 0 9px rgba(255, 93, 93, 0.9);
}

.chip-state.alert {
  color: #FFC4C4;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background:
    linear-gradient(180deg, rgba(33, 45, 85, 0.78), rgba(11, 16, 38, 0.82));
  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.09);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: #DCE4FF;
  transition: transform 0.14s ease, background 0.2s ease, color 0.2s ease;
}

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

.icon-btn:active {
  transform: scale(0.9);
  background: rgba(255, 138, 61, 0.22);
  color: var(--orange-soft);
}

.icon-btn.off {
  color: #7C89AD;
}

/* ---------- 房间舞台 ---------- */

.stage {
  position: relative;
  z-index: 2;
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 4px 14px 3px;
}

.room-frame {
  position: relative;
  width: min(92vw, 404px);
  aspect-ratio: 5 / 6;
  padding: 7px;
  border-radius: 31px;
  background:
    linear-gradient(145deg, #6A4749 0%, #382331 30%, #1B1426 58%, #2C1D2D 82%, #5C3B3F 100%);
  box-shadow:
    0 28px 60px rgba(0, 0, 0, 0.58),
    0 0 0 1px rgba(255, 208, 150, 0.14),
    0 0 74px rgba(255, 138, 61, 0.09),
    inset 0 1px 0 rgba(255, 225, 185, 0.22);
  animation: roomIn 0.7s cubic-bezier(0.18, 0.9, 0.28, 1.08) both;
}

.room-frame::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 28px;
  border: 1px solid rgba(255, 219, 170, 0.12);
  pointer-events: none;
  z-index: 2;
}

.room-frame::after {
  content: "";
  position: absolute;
  left: 9%;
  right: 9%;
  bottom: -11px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  filter: blur(10px);
  z-index: -1;
}

.room {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 24px;
  background: #191329;
  box-shadow:
    inset 0 0 0 1px rgba(255, 222, 175, 0.07),
    inset 0 0 55px rgba(0, 0, 0, 0.55);
  isolation: isolate;
  touch-action: none;
}

/* ---------- 墙 ---------- */

.wall-band {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 16.6667%;
  z-index: 2;
  overflow: hidden;
  background:
    linear-gradient(180deg, #2C2A56 0%, #232146 52%, #181631 100%);
}

.wallpaper {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(255, 209, 102, 0.08), transparent 55%),
    radial-gradient(ellipse at 80% 20%, rgba(120, 150, 255, 0.1), transparent 60%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 2px, transparent 2px 13px),
    repeating-linear-gradient(0deg, transparent 0 17px, rgba(0, 0, 0, 0.07) 17px 18px);
  opacity: 0.95;
}

.wallpaper::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(8, 7, 20, 0.1), transparent 25%, rgba(8, 7, 20, 0.55));
}

.baseboard {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 6px;
  background:
    linear-gradient(180deg, #553746 0%, #2B1C2B 65%, #160F1C 100%);
  box-shadow:
    0 -1px 0 rgba(255, 208, 150, 0.2),
    0 4px 9px rgba(0, 0, 0, 0.55);
  z-index: 3;
}

.wall-glow {
  position: absolute;
  left: 34%;
  right: 34%;
  bottom: -6%;
  height: 70%;
  background: radial-gradient(ellipse at 50% 100%, rgba(255, 138, 61, 0.38), transparent 70%);
  filter: blur(6px);
  opacity: 0.7;
  pointer-events: none;
}

/* 窗户 */

.window {
  position: absolute;
  left: 5.5%;
  top: 9%;
  width: 27%;
  height: 71%;
  z-index: 2;
}

.window-rod {
  position: absolute;
  left: -6%;
  right: -6%;
  top: -5%;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(180deg, #8B6647, #4A302A);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.window-glass {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border: 3px solid #6B4A3C;
  border-radius: 8px 8px 4px 4px;
  background:
    radial-gradient(circle at 68% 26%, rgba(255, 238, 180, 0.18), transparent 24%),
    linear-gradient(180deg, #203C70 0%, #12234A 48%, #09132C 100%);
  box-shadow:
    inset 0 0 16px rgba(160, 195, 255, 0.16),
    0 0 16px rgba(120, 160, 255, 0.14);
}

.win-moon {
  position: absolute;
  right: 13%;
  top: 14%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #FFE7AA;
  box-shadow: 0 0 12px rgba(255, 226, 160, 0.8);
}

.win-star {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #FFF3D6;
  box-shadow: 0 0 4px rgba(255, 243, 214, 0.8);
}

.win-star.s1 {
  left: 20%;
  top: 26%;
}

.win-star.s2 {
  left: 38%;
  top: 55%;
}

.win-star.s3 {
  right: 24%;
  bottom: 22%;
}

.win-muntin {
  position: absolute;
  background: #573C33;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.win-muntin.v {
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
}

.win-muntin.h {
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  margin-top: -1px;
}

.curtain {
  position: absolute;
  top: -6%;
  bottom: 2%;
  width: 19%;
  z-index: 3;
  border-radius: 8px 8px 4px 11px;
  background:
    repeating-linear-gradient(90deg, #9B4F2E 0 6px, #C26A3B 6px 12px, #A85834 12px 18px);
  box-shadow:
    inset 0 1px 0 rgba(255, 208, 160, 0.28),
    0 2px 6px rgba(0, 0, 0, 0.38);
  opacity: 0.92;
}

.curtain-l {
  left: -4%;
  clip-path: polygon(0 0, 100% 0, 78% 100%, 0 100%);
}

.curtain-r {
  right: -4%;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 22% 100%);
}

.window-sill {
  position: absolute;
  left: -12%;
  right: -12%;
  bottom: -8%;
  height: 6px;
  border-radius: 2px;
  background: linear-gradient(180deg, #7A543F, #3F2A29);
  box-shadow: 0 3px 5px rgba(0, 0, 0, 0.42);
}

/* 墙上的画 */

.picture {
  position: absolute;
  right: 7%;
  top: 15%;
  width: 14.5%;
  height: 53%;
  z-index: 2;
}

.pic-frame {
  position: absolute;
  inset: 0;
  padding: 3px;
  border-radius: 3px;
  background: linear-gradient(145deg, #A77A4F, #56372D 58%, #8A5F3E);
  box-shadow:
    0 3px 6px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 229, 180, 0.3);
}

.pic-frame svg {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 1px;
}

.pic-nail {
  position: absolute;
  left: 50%;
  top: -5px;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: #E8C98F;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.6);
}

/* 小串灯 */

.string-lights {
  position: absolute;
  left: -2%;
  top: -3%;
  width: 104%;
  height: 62%;
  z-index: 4;
  pointer-events: none;
  overflow: visible;
}

.bulb {
  filter: drop-shadow(0 0 5px rgba(255, 190, 90, 0.9));
  animation: bulbGlow 3.2s ease-in-out infinite;
}

.bulb.b2 {
  animation-delay: -1.1s;
}

.bulb.b3 {
  animation-delay: -2.2s;
}

.bulb.b4 {
  animation-delay: -0.6s;
}

.bulb.b5 {
  animation-delay: -1.7s;
}

.bulb.b6 {
  animation-delay: -2.6s;
}

/* ---------- 地面 ---------- */

.floor {
  position: absolute;
  top: 16.6667%;
  left: 0;
  width: 100%;
  height: 83.3333%;
  z-index: 1;
  background-color: #2E2338;
  background-image:
    linear-gradient(90deg, rgba(7, 6, 17, 0.6) 0%, transparent 16%, transparent 84%, rgba(7, 6, 17, 0.6) 100%),
    radial-gradient(70% 48% at 19% 16%, rgba(122, 164, 255, 0.17), transparent 68%),
    radial-gradient(62% 48% at 88% 76%, rgba(255, 138, 61, 0.14), transparent 70%),
    repeating-linear-gradient(0deg, rgba(10, 7, 18, 0.42) 0 2px, transparent 2px 19.7%),
    repeating-linear-gradient(91deg, rgba(255, 255, 255, 0.022) 0 1px, transparent 1px 42px),
    linear-gradient(180deg, #3A2B40 0%, #2D2136 54%, #241A2F 100%);
}

.floor::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 48%, transparent 35%, rgba(5, 4, 14, 0.36) 100%),
    linear-gradient(180deg, rgba(8, 6, 16, 0.38) 0%, transparent 10%);
  pointer-events: none;
}

.moonbeam {
  position: absolute;
  top: 16.6667%;
  left: 2%;
  width: 58%;
  height: 84%;
  z-index: 2;
  clip-path: polygon(8% 0%, 38% 0%, 100% 100%, 32% 100%);
  background:
    linear-gradient(180deg, rgba(166, 202, 255, 0.24) 0%, rgba(142, 180, 255, 0.08) 46%, rgba(142, 180, 255, 0) 88%);
  filter: blur(6px);
  opacity: 0.55;
  pointer-events: none;
}

.rug {
  position: absolute;
  left: 12%;
  top: 31%;
  width: 76%;
  height: 50%;
  z-index: 2;
  border-radius: 50% / 44%;
  background:
    radial-gradient(ellipse at 50% 50%, transparent 0 20%, rgba(255, 138, 61, 0.24) 20.5% 21.8%, transparent 22.4% 36%, rgba(255, 209, 102, 0.18) 36.5% 38%, transparent 38.5%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.05) 0 2px, transparent 2px 18px),
    repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.08) 0 2px, transparent 2px 22px),
    linear-gradient(145deg, #2F5668 0%, #203D53 55%, #294C60 100%);
  border: 3px solid rgba(255, 138, 61, 0.33);
  box-shadow:
    inset 0 0 37px rgba(0, 0, 0, 0.42),
    0 9px 18px rgba(0, 0, 0, 0.2);
  opacity: 0.94;
  pointer-events: none;
}

.rug::before,
.rug::after {
  content: "";
  position: absolute;
  left: 7%;
  right: 7%;
  height: 7px;
  background: repeating-linear-gradient(90deg, rgba(255, 205, 140, 0.58) 0 3px, transparent 3px 9px);
  opacity: 0.5;
}

.rug::before {
  top: -7px;
}

.rug::after {
  bottom: -7px;
}

/* ---------- 网格与可点击区域 ---------- */

.grid {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(6, 1fr);
}

.cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 9px;
}

.cell .cell-fx {
  position: absolute;
  inset: 2px;
  border-radius: 9px;
  pointer-events: none;
  transition: background 0.22s ease, box-shadow 0.22s ease, opacity 0.2s ease;
}

.cell.floor-cell .cell-fx {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.018);
}

.cell.walkable {
  cursor: pointer;
}

.cell.walkable .cell-fx::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: rgba(255, 209, 102, 0.28);
  box-shadow: 0 0 8px rgba(255, 209, 102, 0.24);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.cell.adjacent .cell-fx::after {
  opacity: 1;
  transform: scale(1);
  animation: adjacentPulse 2.4s ease-in-out infinite;
}

.cell.danger .cell-fx {
  background:
    repeating-linear-gradient(45deg, rgba(255, 110, 86, 0.16) 0 5px, transparent 5px 10px),
    radial-gradient(circle at 50% 50%, rgba(255, 93, 93, 0.34), rgba(255, 138, 61, 0.13) 72%);
  box-shadow:
    inset 0 0 0 1.5px rgba(255, 120, 92, 0.55),
    inset 0 0 20px rgba(255, 80, 70, 0.24);
  animation: dangerPulse 1.7s ease-in-out infinite;
}

.cell.danger .cell-fx::after {
  opacity: 0;
}

.cell.next-step .cell-fx {
  box-shadow:
    inset 0 0 0 2px rgba(255, 209, 102, 0.42),
    inset 0 0 14px rgba(255, 190, 90, 0.09);
  border-radius: 11px;
}

.cell.deny .cell-fx {
  animation: cellDeny 0.34s ease;
}

.cell.next-step .cell-fx::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: rgba(255, 209, 102, 0.5);
}

.cell.wall-cell {
  pointer-events: none;
}

/* ---------- 门 ---------- */

.door {
  position: absolute;
  left: 40%;
  top: 0;
  width: 20%;
  height: 16.6667%;
  z-index: 7;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}

.door-glow {
  position: absolute;
  left: 50%;
  bottom: -28%;
  width: 190%;
  height: 130%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at 50% 65%, rgba(255, 138, 61, 0.42), rgba(255, 138, 61, 0.1) 45%, transparent 72%);
  filter: blur(7px);
  opacity: 0.7;
  transition: opacity 0.5s ease;
}

.door-inner {
  position: relative;
  width: 82%;
  height: 97%;
  border-radius: 12px 12px 2px 2px;
  background:
    linear-gradient(90deg, #5B3B31 0%, #3A2424 42%, #2A1A22 100%);
  border: 2px solid #7B523D;
  border-bottom: 0;
  box-shadow:
    0 0 0 1px rgba(12, 8, 16, 0.8),
    0 7px 14px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 219, 170, 0.2);
  transition: transform 0.55s cubic-bezier(0.2, 0.8, 0.3, 1), box-shadow 0.5s ease;
  transform-origin: 50% 100%;
}

.door-panel {
  position: absolute;
  inset: 5% 8% 4%;
  border-radius: 9px 9px 1px 1px;
  background:
    linear-gradient(180deg, rgba(255, 190, 120, 0.08), transparent 36%),
    linear-gradient(90deg, #43292A, #2A1920);
  border: 1px solid rgba(255, 214, 160, 0.14);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.45);
}

.door-line {
  position: absolute;
  left: 14%;
  right: 14%;
  height: 1px;
  background: rgba(255, 209, 160, 0.14);
}

.door-line.l1 {
  top: 18%;
}

.door-line.l2 {
  top: 33%;
}

.door-knob {
  position: absolute;
  right: 12%;
  top: 51%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFE8B0, #D19B4A 55%, #8E5A23);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.55), 0 0 5px rgba(255, 209, 102, 0.35);
}

.door-seal {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #2C3C6D, #111932 70%);
  border: 1px solid rgba(255, 209, 102, 0.55);
  box-shadow:
    0 0 0 3px rgba(12, 17, 38, 0.45),
    0 0 12px rgba(255, 190, 90, 0.36);
  color: var(--amber);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.door-seal .mp-icon {
  width: 13px;
  height: 13px;
}

.door-rug {
  position: absolute;
  left: 50%;
  bottom: -32%;
  width: 118%;
  height: 34%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.08) 0 5px, transparent 5px 10px),
    linear-gradient(180deg, #8A4C32, #5A2E25);
  border: 1px solid rgba(255, 209, 102, 0.24);
  box-shadow: 0 3px 7px rgba(0, 0, 0, 0.4);
  color: #FFD9A6;
  font-size: clamp(7px, 1.9vw, 9px);
  font-weight: 800;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
}

.door.unlocked .door-glow {
  opacity: 1;
  animation: doorGlow 2.4s ease-in-out infinite;
}

.door.unlocked .door-inner {
  transform: perspective(240px) rotateY(-7deg);
  box-shadow:
    0 0 0 1.5px rgba(255, 209, 102, 0.6),
    0 0 24px rgba(255, 150, 60, 0.65),
    0 0 54px rgba(255, 138, 61, 0.28),
    inset 0 1px 0 rgba(255, 235, 190, 0.3);
}

.door.unlocked .door-seal {
  opacity: 0;
  transform: scale(0.4) rotate(-30deg);
}

.door.unlocked .door-rug {
  color: #FFF1C8;
  border-color: rgba(255, 209, 102, 0.7);
  box-shadow:
    0 0 14px rgba(255, 170, 70, 0.5),
    0 3px 7px rgba(0, 0, 0, 0.4);
}

.door.deny .door-inner {
  animation: doorDeny 0.34s ease;
}

/* ---------- 家具 ---------- */

.furniture-layer {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}

.furn {
  position: absolute;
  left: calc(var(--fx) * var(--cell-w));
  top: calc(var(--fy) * var(--cell-h));
  width: calc(var(--fw) * var(--cell-w));
  height: calc(var(--fh) * var(--cell-h));
  padding: 2px;
  filter: drop-shadow(0 5px 5px rgba(0, 0, 0, 0.42));
  animation: furnIn 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
  animation-delay: var(--delay, 0s);
}

.furn svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.hide-tag {
  position: absolute;
  left: 5%;
  bottom: 4%;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 15px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(8, 12, 30, 0.76);
  border: 1px solid rgba(255, 209, 102, 0.4);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.36);
  color: #FFE6AC;
  font-size: clamp(7px, 1.9vw, 9px);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.hide-tag .mp-icon {
  width: 9px;
  height: 9px;
  color: var(--amber);
}

.furn.lamp::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 170%;
  height: 170%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 170, 80, 0.22), transparent 65%);
  filter: blur(3px);
  pointer-events: none;
}

/* ---------- 星尘 ---------- */

.items-layer {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}

.item {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cell-w);
  height: var(--cell-h);
  transform: translate(calc(var(--ix) * 100%), calc(var(--iy) * 100%));
  display: grid;
  place-items: center;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.item-halo {
  position: absolute;
  width: 88%;
  height: 88%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 198, 100, 0.36), rgba(255, 138, 61, 0.1) 55%, transparent 72%);
  animation: haloPulse 2.2s ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

.item-star {
  position: relative;
  width: 64%;
  height: 64%;
  filter: drop-shadow(0 0 9px rgba(255, 190, 80, 0.85));
  animation: itemFloat 2.3s ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

.item-star svg {
  display: block;
  width: 100%;
  height: 100%;
}

.item.collected {
  opacity: 0;
  transform: translate(calc(var(--ix) * 100%), calc(var(--iy) * 100%)) scale(1.65);
}

/* ---------- 怪物 ---------- */

.monsters-layer {
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
}

.monster {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cell-w);
  height: var(--cell-h);
  transform: translate(calc(var(--mx) * 100%), calc(var(--my) * 100%));
  transition: transform 0.3s cubic-bezier(0.25, 0.75, 0.35, 1.12);
  will-change: transform;
}

.monster-inner {
  position: absolute;
  left: 50%;
  bottom: -2%;
  width: 126%;
  height: 138%;
  transform: translateX(-50%);
  transition: transform 0.28s ease;
}

.monster.face-left .monster-inner {
  transform: translateX(-50%) scaleX(-1);
}

.monster-sprite {
  width: 100%;
  height: 100%;
  animation: monsterFloat 3.4s ease-in-out infinite;
  filter: drop-shadow(0 7px 7px rgba(0, 0, 0, 0.46)) drop-shadow(0 0 7px rgba(255, 196, 100, 0.14));
}

.monster-sprite svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.monster.alert .monster-sprite {
  animation: monsterAlert 0.36s ease-in-out infinite;
  filter: drop-shadow(0 7px 7px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 16px rgba(255, 70, 70, 0.9));
}

.monster.alert::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 44%;
  width: 84%;
  height: 84%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid rgba(255, 80, 80, 0.5);
  box-shadow: 0 0 20px rgba(255, 60, 60, 0.35), inset 0 0 18px rgba(255, 60, 60, 0.18);
  animation: alertRing 0.55s ease-out infinite;
}

/* 怪物眼睛的高光 */

.monster .mon-eye-glint {
  animation: glint 4s ease-in-out infinite;
}

/* ---------- 玩家小猫 ---------- */

.player {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cell-w);
  height: var(--cell-h);
  z-index: 10;
  transform: translate(calc(var(--px) * 100%), calc(var(--py) * 100%));
  transition: transform 0.18s cubic-bezier(0.22, 0.8, 0.35, 1.16);
  will-change: transform;
}

.player-sprite {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 94%;
  height: 111%;
  transform: translateX(-50%);
  transform-origin: 50% 100%;
  animation: playerIdle 3s ease-in-out infinite;
  filter: drop-shadow(0 6px 5px rgba(0, 0, 0, 0.42));
}

.player-sprite svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.cat-svg {
  transform-origin: 50% 60%;
  transition: transform 0.2s ease;
}

.player.face-left .cat-svg {
  transform: scaleX(-1);
}

.cat-tail {
  transform-origin: 72px 77px;
  animation: tailSway 2.8s ease-in-out infinite;
}

.cat-eyes {
  transform-origin: 50px 45px;
  animation: catBlink 5.6s infinite;
}

.player.hidden .player-sprite {
  opacity: 0.56;
  transform: translateX(-50%) scale(0.84) translateY(3%);
  animation: none;
}

.player.hidden .cat-svg {
  filter: saturate(0.7) brightness(0.8);
}

.hide-ping {
  position: absolute;
  left: 50%;
  top: -15%;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  transform: translateX(-50%) scale(0.55);
  border-radius: 50%;
  background: rgba(8, 13, 32, 0.85);
  border: 1px solid rgba(255, 209, 102, 0.5);
  color: var(--amber);
  opacity: 0;
  transition: opacity 0.22s ease, transform 0.22s ease;
  box-shadow: 0 0 12px rgba(255, 190, 90, 0.3);
}

.hide-ping .mp-icon {
  width: 11px;
  height: 11px;
}

.player.hidden .hide-ping {
  opacity: 1;
  transform: translateX(-50%) scale(1);
  animation: hidePing 1.9s ease-in-out infinite;
}

.player.win {
  opacity: 0;
  transition: transform 0.65s ease, opacity 0.5s ease 0.25s;
}

.player.caught .player-sprite {
  animation: playerCaught 0.4s ease-in-out infinite;
  filter: drop-shadow(0 0 12px rgba(255, 70, 70, 0.8));
}

/* ---------- 特效层 ---------- */

.fx-layer {
  position: absolute;
  inset: 0;
  z-index: 11;
  pointer-events: none;
}

.spark {
  position: absolute;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 10px 2px rgba(255, 190, 80, 0.8);
  animation: sparkFly 0.68s ease-out forwards;
}

.room-vignette {
  position: absolute;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 44%, transparent 48%, rgba(4, 6, 16, 0.38) 78%, rgba(3, 4, 12, 0.66) 100%),
    linear-gradient(180deg, rgba(3, 5, 14, 0.32) 0%, transparent 16%, transparent 82%, rgba(3, 5, 14, 0.4) 100%);
}

.caught-flash {
  position: absolute;
  inset: 0;
  z-index: 13;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 46%, rgba(255, 60, 60, 0.16), rgba(210, 20, 35, 0.7));
  opacity: 0;
}

.room.caught .caught-flash {
  animation: caughtFlash 0.62s ease-out both;
}

.room.caught .room-vignette {
  box-shadow: inset 0 0 80px rgba(255, 30, 40, 0.45);
}

.win-glow {
  position: absolute;
  inset: 0;
  z-index: 13;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 10%, rgba(255, 240, 185, 0.75), rgba(255, 170, 70, 0.3) 28%, transparent 58%);
  opacity: 0;
}

.room.won .win-glow {
  animation: winFlash 1.2s ease-out both;
}

.room.won .room-vignette {
  background:
    radial-gradient(ellipse at 50% 22%, transparent 30%, rgba(60, 30, 10, 0.2) 80%),
    linear-gradient(180deg, rgba(255, 210, 130, 0.1), transparent 50%);
}

/* ---------- 底部操作面板 ---------- */

.deck {
  position: relative;
  z-index: 20;
  margin: 9px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  padding: 9px 11px 11px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background:
    radial-gradient(80% 100% at 50% 0%, rgba(255, 138, 61, 0.08), transparent 56%),
    linear-gradient(180deg, rgba(29, 39, 77, 0.94), rgba(11, 16, 37, 0.98));
  box-shadow:
    0 -12px 34px rgba(0, 0, 0, 0.24),
    0 18px 40px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.09);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.hint-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}

.hint-avatar {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 209, 102, 0.36);
  background:
    radial-gradient(circle at 38% 28%, #405184, #1A2446 72%);
  box-shadow:
    0 0 0 3px rgba(255, 138, 61, 0.08),
    0 3px 8px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.hint-avatar svg {
  display: block;
  width: 29px;
  height: 29px;
}

.hint-bubble {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid rgba(255, 244, 220, 0.09);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 244, 220, 0.075), rgba(255, 244, 220, 0.035));
  color: #D8DFF5;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 500;
}

.hint-bubble::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 12px;
  width: 9px;
  height: 9px;
  background: #242E56;
  border-left: 1px solid rgba(255, 244, 220, 0.09);
  border-bottom: 1px solid rgba(255, 244, 220, 0.09);
  transform: rotate(45deg);
}

.hint-bubble.flash {
  animation: hintFlash 0.35s ease;
}

.pad-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
}

.side-panel {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.quest {
  position: relative;
  padding: 7px 9px 8px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(7, 11, 27, 0.62), rgba(7, 11, 27, 0.4));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
  transition: border-color 0.35s ease, box-shadow 0.35s ease;
}

.quest.done {
  border-color: rgba(255, 209, 102, 0.46);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 0 18px rgba(255, 170, 70, 0.16);
}

.quest-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.quest-label {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.quest-top strong {
  color: var(--cream);
  font-size: 13px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.quest-stars {
  display: flex;
  gap: 3px;
  margin-top: 3px;
}

.quest-stars .mp-icon {
  width: 17px;
  height: 17px;
  color: rgba(255, 255, 255, 0.13);
  transition: color 0.3s ease, filter 0.3s ease, transform 0.3s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.quest-stars .mp-icon.on {
  color: var(--amber);
  filter: drop-shadow(0 0 6px rgba(255, 190, 70, 0.8));
  transform: scale(1.06);
}

.quest-sub {
  margin-top: 3px;
  overflow: hidden;
  color: #8591B3;
  font-size: 9.5px;
  line-height: 1.3;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.wait-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  height: 38px;
  border: 1px solid rgba(255, 138, 61, 0.38);
  border-radius: 13px;
  background:
    linear-gradient(180deg, rgba(255, 138, 61, 0.22), rgba(255, 138, 61, 0.08));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 3px 0 rgba(117, 51, 15, 0.5);
  color: #FFD9B8;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.01em;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.2s ease;
}

.wait-btn .mp-icon {
  width: 15px;
  height: 15px;
  color: var(--orange-soft);
}

.wait-btn:active,
.wait-btn.pressed {
  transform: translateY(3px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 0 rgba(117, 51, 15, 0.5);
  background: linear-gradient(180deg, rgba(255, 138, 61, 0.36), rgba(255, 138, 61, 0.14));
}

/* 方向键 */

.dpad {
  --key: clamp(40px, 11.2vw, 48px);
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(3, var(--key));
  grid-template-rows: repeat(3, var(--key));
  gap: 5px;
}

.key {
  display: grid;
  place-items: center;
  width: var(--key);
  height: var(--key);
  border: 1px solid rgba(199, 214, 255, 0.18);
  border-radius: 14px;
  background:
    linear-gradient(180deg, #2C3A69 0%, #182247 55%, #111832 100%);
  box-shadow:
    0 5px 0 #080D20,
    0 8px 14px rgba(0, 0, 0, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  color: #E9EEFF;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.15s ease, color 0.15s ease;
}

.key .mp-icon {
  width: 23px;
  height: 23px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
}

.key:active,
.key.pressed {
  transform: translateY(4px);
  background:
    linear-gradient(180deg, #FFB25E 0%, #FF8A3D 55%, #E96A22 100%);
  color: #2A1307;
  box-shadow:
    0 1px 0 #8C3E12,
    0 3px 6px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.key-up {
  grid-area: 1 / 2;
}

.key-left {
  grid-area: 2 / 1;
}

.key-right {
  grid-area: 2 / 3;
}

.key-down {
  grid-area: 3 / 2;
}

.dpad-center {
  grid-area: 2 / 2;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: rgba(255, 209, 102, 0.2);
  background: radial-gradient(circle, rgba(255, 209, 102, 0.08), transparent 68%);
  pointer-events: none;
}

.dpad-center svg {
  width: 24px;
  height: 24px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 62px);
  z-index: 45;
  max-width: 84vw;
  padding: 8px 14px;
  border: 1px solid rgba(255, 209, 102, 0.34);
  border-radius: 999px;
  background: rgba(8, 12, 30, 0.93);
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.4),
    0 0 18px rgba(255, 170, 70, 0.1);
  color: var(--cream);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, -8px);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

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

.toast.warn {
  border-color: rgba(255, 120, 92, 0.55);
  color: #FFD8CE;
}

/* ---------- 玩法弹层 ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(3, 5, 14, 0.64);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.24s ease;
}

.sheet-backdrop.show {
  opacity: 1;
}

.sheet {
  position: relative;
  width: min(100%, 500px);
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-bottom: 0;
  border-radius: 27px 27px 0 0;
  background:
    radial-gradient(90% 50% at 50% 0%, rgba(255, 138, 61, 0.1), transparent 60%),
    linear-gradient(180deg, #1C254C, #0D1229 72%);
  box-shadow: 0 -22px 60px rgba(0, 0, 0, 0.55);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.sheet-backdrop.show .sheet {
  transform: translateY(0);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.sheet-close {
  position: absolute;
  right: 15px;
  top: 16px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.045);
  color: #C9D3EF;
}

.sheet-close .mp-icon {
  width: 17px;
  height: 17px;
}

.sheet h2 {
  margin: 0;
  color: #FFF4DC;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.01em;
}

.sheet-sub {
  margin: 5px 0 15px;
  color: var(--muted);
  font-size: 12.5px;
}

.rules {
  display: grid;
  gap: 8px;
  margin: 0 0 17px;
  padding: 0;
  list-style: none;
}

.rules li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.018));
}

.rule-icon {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 209, 102, 0.24);
  border-radius: 11px;
  background: rgba(255, 138, 61, 0.1);
  color: var(--orange-soft);
}

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

.rules b {
  display: block;
  color: #F3EFFB;
  font-size: 13.5px;
  font-weight: 800;
}

.rules p {
  margin: 2px 0 0;
  color: #9FABCB;
  font-size: 11.5px;
  line-height: 1.45;
}

/* ---------- 通用主按钮 ---------- */

.primary-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 50px;
  border: 1px solid rgba(255, 225, 180, 0.42);
  border-radius: 16px;
  background:
    linear-gradient(180deg, #FFAE6A 0%, #FF8A3D 52%, #F07125 100%);
  box-shadow:
    0 6px 0 #A64A14,
    0 13px 24px rgba(255, 122, 47, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  color: #2A1307;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.03em;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.2s ease;
}

.primary-btn:active {
  transform: translateY(5px);
  box-shadow:
    0 1px 0 #A64A14,
    0 3px 8px rgba(255, 122, 47, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* ---------- 结算 ---------- */

.result-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(3, 5, 14, 0.72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.24s ease;
}

.result-backdrop.show {
  opacity: 1;
}

.result-card {
  position: relative;
  width: min(100%, 352px);
  padding: 22px 20px 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 27px;
  background:
    radial-gradient(95% 52% at 50% 0%, rgba(255, 138, 61, 0.18), transparent 66%),
    linear-gradient(180deg, #202A55, #0D1229 72%);
  box-shadow:
    0 28px 70px rgba(0, 0, 0, 0.62),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  text-align: center;
  transform: scale(0.9) translateY(10px);
  transition: transform 0.34s cubic-bezier(0.18, 0.9, 0.28, 1.15);
}

.result-backdrop.show .result-card {
  transform: scale(1) translateY(0);
}

.result-card.fail {
  background:
    radial-gradient(95% 52% at 50% 0%, rgba(255, 70, 70, 0.16), transparent 66%),
    linear-gradient(180deg, #29224A, #100D24 72%);
  border-color: rgba(255, 120, 120, 0.2);
}

.result-art {
  position: relative;
  width: 104px;
  height: 104px;
  margin: 0 auto 4px;
}

.result-art svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.result-kicker {
  margin: 1px 0 4px;
  color: var(--orange-soft);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.result-card h2 {
  margin: 0;
  color: #FFF4DC;
  font-size: 25px;
  font-weight: 900;
  letter-spacing: 0.015em;
  text-shadow: 0 2px 16px rgba(255, 180, 80, 0.16);
}

.result-sub {
  margin: 6px 0 0;
  color: #A9B4D6;
  font-size: 12px;
  line-height: 1.5;
}

.result-stars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 29px;
  margin: 8px 0 15px;
}

.result-stars .mp-icon {
  width: 25px;
  height: 25px;
  color: rgba(255, 255, 255, 0.12);
}

.result-stars .mp-icon.on {
  color: var(--amber);
  filter: drop-shadow(0 0 8px rgba(255, 190, 70, 0.75));
  animation: starPop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.result-stars .mp-icon.on:nth-child(2) {
  animation-delay: 0.08s;
}

.result-stars .mp-icon.on:nth-child(3) {
  animation-delay: 0.16s;
}

.result-card.fail .result-kicker {
  color: #FF9A9A;
}

/* ---------- 动画 ---------- */

@keyframes twinkle {
  0%, 100% { opacity: var(--o, 0.65); transform: scale(1); }
  50% { opacity: 0.16; transform: scale(0.72); }
}

@keyframes cloudDrift {
  from { transform: translate3d(-10px, 0, 0); }
  to { transform: translate3d(18px, 6px, 0); }
}

@keyframes firefly {
  0% { opacity: 0; transform: translate3d(0, 10px, 0) scale(0.7); }
  18% { opacity: 0.9; }
  55% { opacity: 0.45; transform: translate3d(14px, -18px, 0) scale(1); }
  100% { opacity: 0; transform: translate3d(-6px, -42px, 0) scale(0.6); }
}

@keyframes statePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.42; }
}

@keyframes roomIn {
  from { opacity: 0; transform: translateY(15px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes bulbGlow {
  0%, 100% { opacity: 0.7; filter: drop-shadow(0 0 4px rgba(255, 190, 90, 0.6)); }
  50% { opacity: 1; filter: drop-shadow(0 0 9px rgba(255, 205, 120, 1)); }
}

@keyframes dangerPulse {
  0%, 100% { opacity: 0.82; }
  50% { opacity: 1; }
}

@keyframes adjacentPulse {
  0%, 100% { opacity: 0.55; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.12); }
}

@keyframes doorDeny {
  0%, 100% { transform: translateX(0); }
  22% { transform: translateX(-3px) rotate(-1deg); }
  55% { transform: translateX(3px) rotate(1deg); }
  80% { transform: translateX(-1px); }
}

@keyframes cellDeny {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  60% { transform: translateX(3px); }
  82% { transform: translateX(-1px); }
}

@keyframes doorGlow {
  0%, 100% { opacity: 0.7; transform: translateX(-50%) scale(0.94); }
  50% { opacity: 1; transform: translateX(-50%) scale(1.08); }
}

@keyframes furnIn {
  from { opacity: 0; transform: translateY(5px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes haloPulse {
  0%, 100% { opacity: 0.55; transform: scale(0.92); }
  50% { opacity: 0.95; transform: scale(1.08); }
}

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

@keyframes monsterFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-2.5px) scale(1.012); }
}

@keyframes monsterAlert {
  0%, 100% { transform: translateX(0) scale(1.02); }
  25% { transform: translateX(-2px) scale(1.04); }
  75% { transform: translateX(2px) scale(1.04); }
}

@keyframes alertRing {
  0% { opacity: 0.8; transform: translate(-50%, -50%) scale(0.8); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.2); }
}

@keyframes glint {
  0%, 90%, 100% { opacity: 0.9; }
  94% { opacity: 0.35; }
}

@keyframes playerIdle {
  0%, 100% { transform: translateX(-50%) translateY(0) rotate(-0.4deg); }
  50% { transform: translateX(-50%) translateY(-2.4px) rotate(0.5deg); }
}

@keyframes tailSway {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(5deg); }
}

@keyframes catBlink {
  0%, 43%, 49%, 100% { transform: scaleY(1); }
  46% { transform: scaleY(0.08); }
}

@keyframes hidePing {
  0%, 100% { box-shadow: 0 0 12px rgba(255, 190, 90, 0.24); }
  50% { box-shadow: 0 0 18px rgba(255, 190, 90, 0.55); }
}

@keyframes playerCaught {
  0%, 100% { transform: translateX(-50%) rotate(0); }
  25% { transform: translateX(-52%) rotate(-3deg); }
  75% { transform: translateX(-48%) rotate(3deg); }
}

@keyframes sparkFly {
  0% { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.2); }
}

@keyframes caughtFlash {
  0% { opacity: 0; }
  14% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes winFlash {
  0% { opacity: 0; }
  24% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes promptPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 138, 61, 0.35); }
  50% { box-shadow: 0 0 0 7px rgba(255, 138, 61, 0); }
}

@keyframes hintFlash {
  0% { background: rgba(255, 138, 61, 0.18); }
  100% { background: rgba(255, 244, 220, 0.06); }
}

@keyframes starPop {
  from { opacity: 0; transform: scale(0.3) rotate(-18deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes sheetIn {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* ---------- 鼠标设备的状态反馈 ---------- */

@media (hover: hover) and (pointer: fine) {
  .key:hover {
    background: linear-gradient(180deg, #354679 0%, #1E2A54 55%, #151F3E 100%);
    color: #FFF4DC;
  }

  .wait-btn:hover {
    background: linear-gradient(180deg, rgba(255, 138, 61, 0.3), rgba(255, 138, 61, 0.12));
  }

  .icon-btn:hover {
    border-color: rgba(255, 178, 94, 0.42);
    color: #FFD9B8;
  }

  .primary-btn:hover {
    filter: brightness(1.06);
  }

  .sheet-close:hover {
    background: rgba(255, 255, 255, 0.1);
  }

  .cell.walkable:hover .cell-fx::after {
    opacity: 0.75;
    transform: scale(0.9);
  }
}

/* ---------- 响应式 ---------- */

@media (max-width: 380px) {
  .chip-state {
    display: none;
  }

  .hud {
    padding-left: 11px;
    padding-right: 11px;
  }

  .deck {
    margin-left: 9px;
    margin-right: 9px;
    padding-left: 9px;
    padding-right: 9px;
  }

  .hint-bubble {
    font-size: 11.5px;
  }

  .quest-sub {
    font-size: 9px;
  }
}

@media (max-height: 730px) {
  .room-frame {
    width: min(86vw, 372px);
  }

  .deck {
    margin-top: 7px;
    padding-top: 7px;
    padding-bottom: 8px;
  }

  .hint-row {
    min-height: 34px;
  }

  .hint-avatar {
    flex-basis: 30px;
    width: 30px;
    height: 30px;
  }

  .hint-avatar svg {
    width: 26px;
    height: 26px;
  }

  .hint-bubble {
    min-height: 30px;
    padding: 5px 9px;
    font-size: 11.5px;
  }

  .dpad {
    --key: clamp(38px, 10.6vw, 44px);
  }
}

@media (max-height: 650px) {
  .room-frame {
    width: min(78vw, 332px);
  }

  .stage {
    padding-top: 0;
  }

  .deck {
    padding-top: 6px;
    padding-bottom: 7px;
  }

  .hint-row {
    display: none;
  }

  .quest {
    padding: 5px 8px 6px;
  }

  .quest-stars .mp-icon {
    width: 15px;
    height: 15px;
  }

  .wait-btn {
    height: 34px;
    font-size: 11px;
  }

  .dpad {
    --key: clamp(36px, 10.2vw, 42px);
  }

  .hud {
    padding-top: calc(env(safe-area-inset-top, 0px) + 6px);
    padding-bottom: 4px;
  }
}

/* 高屏手机：把房间再放大一点，减少上下空白，画面更满 */
@media (min-width: 360px) and (max-width: 699px) and (min-height: 800px) {
  .room-frame {
    width: min(94vw, 420px);
  }
}

@media (min-width: 700px) {
  .app {
    padding-top: 4px;
  }

  .room-frame {
    width: min(70vh, 404px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
