/* 晚上躲怪物4 · 移动端竖屏游戏样式 */
:root {
  --orange: #FF8A3D;
  --orange-2: #FFB066;
  --orange-3: #FFD08A;
  --orange-deep: #F06F22;
  --gold: #FFD166;
  --red: #FF5F5F;
  --teal: #4FD1C5;
  --ink: #F7F1E6;
  --muted: #9AA8C4;
  --line: rgba(255, 255, 255, 0.09);
  --panel: #121B30;
  --safe-top: max(9px, env(safe-area-inset-top));
  --safe-bottom: max(9px, env(safe-area-inset-bottom));
  --ease: cubic-bezier(0.2, 0.9, 0.3, 1);
}

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

html, body {
  height: 100%;
  margin: 0;
  background: #04070E;
  color: var(--ink);
  overflow: hidden;
  overscroll-behavior: none;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font-family: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

button:focus-visible { outline: 2px solid rgba(255, 176, 102, 0.8); outline-offset: 2px; }

.app {
  position: relative;
  height: 100vh;
  height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  overflow: hidden;
  isolation: isolate;
  background: radial-gradient(120% 70% at 50% 0%, #16213C 0%, #0A1120 48%, #05080F 100%);
}

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; }
.hidden { display: none !important; }

.round-btn {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: rgba(10, 17, 32, 0.62);
  border: 1px solid var(--line);
  color: #E9EEFB;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 0.12s var(--ease), background 0.2s;
}
.round-btn .mp-icon { width: 21px; height: 21px; opacity: 0.9; }
.round-btn:active { transform: scale(0.92); background: rgba(255, 138, 61, 0.18); }

.snd-off { display: none; }
.muted .snd-on { display: none; }
.muted .snd-off { display: inline-block; }

/* ============================= 开始页 ============================= */
.start {
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  background:
    radial-gradient(95% 55% at 78% 0%, rgba(45, 74, 130, 0.55), transparent 70%),
    linear-gradient(180deg, #0D1830 0%, #091020 45%, #050812 100%);
}
.start::-webkit-scrollbar { display: none; }

.start-scene {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: min(58%, 530px);
  min-height: 330px;
  pointer-events: none;
  overflow: hidden;
}
.scene-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.scene-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(5, 9, 18, 0) 0%, rgba(5, 9, 18, 0.03) 45%, rgba(7, 12, 23, 0.72) 82%, #070C17 100%);
}

.start-topbar {
  position: relative;
  z-index: 5;
  display: flex;
  justify-content: flex-end;
  padding: var(--safe-top) 16px 0;
}

.brand {
  position: relative;
  z-index: 4;
  flex: 0 0 auto;
  text-align: center;
  padding: 0 20px;
  margin-top: clamp(34px, 11vh, 104px);
}
.brand-kicker {
  margin: 0;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.34em;
  color: #F2A16E;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}
.brand-title {
  margin: 7px 0 5px;
  font-size: clamp(36px, 10.6vw, 52px);
  line-height: 1.02;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: #FFF6E8;
  text-shadow:
    0 2px 0 #6D2B0C,
    0 4px 0 rgba(0, 0, 0, 0.3),
    0 16px 34px rgba(0, 0, 0, 0.72);
}
.brand-num {
  color: var(--orange);
  -webkit-text-stroke: 1px rgba(255, 210, 160, 0.22);
  text-shadow: 0 0 28px rgba(255, 138, 61, 0.65);
}
.brand-tag {
  margin: 0;
  font-size: 12.5px;
  letter-spacing: 0.08em;
  color: #A9B7D3;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

.start-panel {
  position: relative;
  z-index: 6;
  flex: 0 0 auto;
  margin-top: auto;
  padding: 18px 20px calc(15px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(17, 27, 48, 0.94), rgba(8, 13, 25, 0.99));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 28px 28px 0 0;
  box-shadow: 0 -24px 60px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* 生成图：宽幅电影感故事条（只取原图中间的画面，避开图内自带 UI） */
.story-art {
  position: relative;
  margin: 12px 0 0;
  padding-top: 30.3%;
  overflow: hidden;
  border-radius: 15px;
  border: 1px solid rgba(255, 190, 140, 0.18);
  background: #080d18;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
.story-art img {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  width: 190%;
  height: auto;
  max-width: none;
  transform: translate(-14.35%, -60.6%);
  filter: saturate(1.04) brightness(1.03);
}
.story-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(7, 12, 23, 0.16) 0%, transparent 38%, rgba(7, 12, 23, 0.82) 100%),
    linear-gradient(90deg, rgba(7, 12, 23, 0.55), transparent 45%);
  pointer-events: none;
}
.story-art-cap {
  position: absolute;
  z-index: 2;
  left: 11px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #FFE3C7;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9);
}
.story-art-cap .mp-icon {
  width: 14px;
  height: 14px;
  color: #FFB06E;
  filter: drop-shadow(0 0 5px rgba(255, 138, 61, 0.65));
}

.panel-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.panel-kicker {
  margin: 0 0 3px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: var(--orange-2);
}
.panel-story {
  margin: 0;
  max-width: 260px;
  font-size: 11.5px;
  line-height: 1.5;
  color: #B8C4DC;
}
.progress-pill {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(255, 138, 61, 0.1);
  border: 1px solid rgba(255, 138, 61, 0.26);
}
.progress-pill b { font-size: 13px; color: #FFC48F; line-height: 1.1; }
.progress-pill span { margin-top: 1px; font-size: 8px; letter-spacing: 0.12em; color: #B98B6B; }

.night-dots { display: flex; gap: 6px; margin: 13px 0 14px; }
.night-dots span {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid transparent;
  transition: background 0.3s;
}
.night-dots span.done {
  background: linear-gradient(90deg, #FF9A52, #FFCF8A);
  box-shadow: 0 0 10px rgba(255, 138, 61, 0.3);
}
.night-dots span.current { background: rgba(255, 138, 61, 0.3); border-color: rgba(255, 160, 90, 0.6); }

.rules { display: flex; flex-direction: column; gap: 7px; margin-bottom: 15px; }
.rule {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.055);
}
.rule-ico {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.rule-ico svg { width: 21px; height: 21px; display: block; }
.rule-ico .mp-icon { width: 20px; height: 20px; }
.rule-ico.gold { background: rgba(255, 193, 94, 0.12); color: #FFC15E; }
.rule-ico.red { background: rgba(255, 95, 95, 0.12); color: #FF8A8A; }
.rule-ico.teal { background: rgba(79, 209, 197, 0.12); color: #6FE0D6; }
.rule-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rule-copy b { font-size: 12.5px; font-weight: 700; color: #F2ECDF; }
.rule-copy small { font-size: 10.5px; line-height: 1.35; color: #8F9DB8; }

.btn {
  border: 0;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  font-weight: 700;
  color: var(--ink);
  transition: transform 0.12s var(--ease), filter 0.2s, box-shadow 0.2s, background 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn .mp-icon { width: 20px; height: 20px; }
.btn-primary {
  background: linear-gradient(180deg, #FFAB63 0%, #FF8A3D 45%, #F06F22 100%);
  color: #341606;
  box-shadow:
    0 10px 24px rgba(240, 111, 34, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 -2px 0 rgba(140, 50, 0, 0.22);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.2);
}
.btn-primary:active {
  filter: brightness(1.05);
  box-shadow: 0 5px 12px rgba(240, 111, 34, 0.3), inset 0 2px 6px rgba(120, 40, 0, 0.2);
}
.btn-xl { width: 100%; height: 54px; font-size: 16px; letter-spacing: 0.02em; border-radius: 16px; }
.btn-xl .mp-icon { width: 24px; height: 24px; }
.btn-ghost {
  flex: 1;
  height: 42px;
  min-height: 42px;
  font-size: 12.5px;
  color: #C8D4EA;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}
.btn-ghost .mp-icon { width: 17px; height: 17px; color: #FFB27A; }
.btn-ghost:active { background: rgba(255, 138, 61, 0.12); border-color: rgba(255, 138, 61, 0.35); }
.btn-line {
  width: 100%;
  height: 46px;
  min-height: 46px;
  font-size: 13px;
  color: #DBE4F5;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.start-foot {
  margin: 9px 0 0;
  text-align: center;
  font-size: 10px;
  line-height: 1.4;
  color: #71809B;
  letter-spacing: 0.02em;
}

/* ============================= 游戏页 ============================= */
.game {
  gap: 7px;
  padding: var(--safe-top) 14px calc(7px + env(safe-area-inset-bottom));
  background:
    radial-gradient(110% 60% at 50% 0%, #17233F 0%, #0A1120 46%, #05080F 100%);
}

.hud { display: flex; align-items: center; gap: 9px; }
.hud-title { flex: 1; min-width: 0; text-align: center; }
.hud-title span {
  display: block;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.26em;
  color: #F0A06A;
}
.hud-title b {
  display: block;
  margin-top: 1px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 34px;
  padding: 0 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
}
.hearts { display: flex; align-items: center; gap: 3px; }
.heart { width: 17px; height: 17px; display: inline-block; color: #FF6F7C; }
.heart svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 0 4px rgba(255, 80, 100, 0.35)) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5)); }
.heart.lost { opacity: 0.22; filter: grayscale(1); }
.stat-sep { width: 1px; height: 14px; background: rgba(255, 255, 255, 0.1); }
.shard-stat { display: flex; align-items: center; gap: 3px; font-size: 11px; color: #FFD08A; }
.shard-stat svg { width: 14px; height: 14px; filter: drop-shadow(0 0 6px rgba(255, 180, 90, 0.6)); }
.shard-stat b { font-size: 13px; color: #FFE1B0; }
.shard-stat span { font-size: 9px; color: #9C8A72; }
.step-stat { display: flex; align-items: center; gap: 4px; margin-left: auto; font-size: 10px; color: #9FB0CC; }
.step-stat .mp-icon { width: 15px; height: 15px; color: #7186A8; }
.step-stat b { font-size: 12px; color: #D6DEF0; }

.objective {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 16px;
  margin: 0;
  padding: 0 4px;
  font-size: 10.5px;
  color: #AEbBD3;
}
.objective .mp-icon { width: 13px; height: 13px; color: #FF9F5B; }
.objective.all { color: #FFD08A; }

.board-area {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1px 0;
}

/* 棋盘：夜里木地板 + 木框 */
.board {
  position: relative;
  flex: 0 0 auto;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.13);
  box-shadow:
    0 16px 34px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(0, 0, 0, 0.25);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  background-color: var(--floor-a, #3A2A24);
  background-image:
    radial-gradient(120% 80% at 50% 25%, rgba(255, 160, 90, 0.09), transparent 62%),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.24) 0 1px, transparent 1px 10%),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.15) 0 1px, transparent 1px 25%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(0, 0, 0, 0.16));
}

.board.theme-bedroom { --floor-a: #3A2A24; --wall-a: #29324D; --wall-b: #131B2E; }
.board.theme-living { --floor-a: #302A3B; --wall-a: #2A3350; --wall-b: #141B30; }
.board.theme-kitchen { --floor-a: #2E3431; --wall-a: #243846; --wall-b: #101C2A; }
.board.theme-study { --floor-a: #35293A; --wall-a: #302941; --wall-b: #161327; }
.board.theme-attic { --floor-a: #3A2D22; --wall-a: #2B2C42; --wall-b: #141728; }

.tiles {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(10, 1fr);
}
.tile { position: relative; min-width: 0; min-height: 0; }
.tile.floor { background: transparent; }
.tile.floor::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 42% 32%, rgba(255, 255, 255, 0.028), transparent 68%);
  opacity: var(--v, 0.6);
}
.tile.wall {
  background: linear-gradient(180deg, var(--wall-a, #29324D), var(--wall-b, #131B2E));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.11),
    inset 0 -2px 0 rgba(0, 0, 0, 0.38),
    inset 0 0 0 1px rgba(0, 0, 0, 0.2);
}
.tile.wall::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.45;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 100% 50%, 50% 100%;
}
.tile.top-edge.wall { box-shadow: inset 0 4px 0 rgba(255, 255, 255, 0.07), inset 0 -2px 0 rgba(0, 0, 0, 0.4); }
.tile.bottom-edge.wall { box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.05), inset 0 -5px 0 rgba(0, 0, 0, 0.45); }
.tile.doorway { background: linear-gradient(180deg, #0A1020, #101a2e); }

.layer { position: absolute; inset: 0; pointer-events: none; }
.decor-layer { z-index: 2; }
.furn-layer { z-index: 3; }
.vision-layer { z-index: 4; }
.item-layer { z-index: 5; }
.actor-layer { z-index: 6; }
.dot-layer { z-index: 5; }
.hint-layer { z-index: 7; }
.fx-layer { z-index: 8; }

/* 地毯 */
.rug {
  position: absolute;
  border-radius: 10px;
  opacity: 0.95;
  background:
    repeating-linear-gradient(45deg, rgba(255, 178, 110, 0.12) 0 6px, transparent 6px 12px),
    linear-gradient(135deg, #63362C, #47251F);
  box-shadow:
    inset 0 0 0 2px rgba(255, 190, 120, 0.18),
    0 2px 6px rgba(0, 0, 0, 0.3);
}
.rug::after {
  content: "";
  position: absolute;
  inset: 9%;
  border: 1px dashed rgba(255, 205, 150, 0.26);
  border-radius: 6px;
}

/* 窗与门 */
.window { position: absolute; z-index: 2; filter: drop-shadow(0 0 10px rgba(120, 170, 255, 0.28)); }
.window svg { width: 100%; height: 100%; display: block; }
.door { position: absolute; z-index: 3; filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.5)); }
.door svg { width: 100%; height: 100%; display: block; }
.door-lock {
  position: absolute;
  left: 50%;
  top: 54%;
  transform: translate(-50%, -50%);
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #FFD08A;
  background: rgba(8, 13, 24, 0.9);
  border: 1px solid rgba(255, 180, 90, 0.5);
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
  transition: opacity 0.3s, transform 0.3s;
}
.door-lock .mp-icon { width: 14px; height: 14px; }
.door.unlocked { filter: drop-shadow(0 0 13px rgba(255, 138, 61, 0.8)); }
.door.unlocked .door-lock { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
.door.won { animation: doorOpen 0.8s var(--ease); }

/* 家具 */
.furn {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  filter: drop-shadow(0 5px 5px rgba(0, 0, 0, 0.4));
}
.furn svg { width: 100%; height: 100%; display: block; overflow: visible; }
.furn.is-hide { filter: drop-shadow(0 5px 6px rgba(0, 0, 0, 0.45)); }
.hide-tag {
  position: absolute;
  right: 3%;
  top: 2%;
  width: max(15px, calc(var(--cell, 40px) * 0.34));
  height: max(15px, calc(var(--cell, 40px) * 0.34));
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: max(7px, calc(var(--cell, 40px) * 0.145));
  font-weight: 800;
  line-height: 1;
  color: #062421;
  background: rgba(98, 224, 210, 0.88);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.45);
}

/* 怪物视线 */
.vision {
  position: absolute;
  border-radius: 4px;
  background: radial-gradient(
    circle at 50% 50%,
    rgba(255, 92, 92, 0.42),
    rgba(255, 70, 70, 0.17) 55%,
    rgba(255, 70, 70, 0.045) 78%
  );
  box-shadow: inset 0 0 0 1px rgba(255, 130, 110, 0.16);
  animation: visionBreath 2.2s ease-in-out infinite;
}

/* 月光碎片 */
.shard {
  position: absolute;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  animation: shardFloat 2.6s ease-in-out infinite;
}
.shard svg {
  width: 74%;
  height: 74%;
  display: block;
  filter: drop-shadow(0 0 8px rgba(255, 190, 90, 0.9));
}
.shard::after {
  content: "";
  position: absolute;
  inset: 24%;
  border-radius: 50%;
  background: rgba(255, 170, 80, 0.18);
  filter: blur(6px);
}
.shard.picked { animation: shardPick 0.34s ease-out forwards; }

/* 角色 */
.actor {
  position: absolute;
  left: 0;
  top: 0;
  width: 12.5%;
  height: 10%;
  will-change: transform;
  pointer-events: none;
}
.actor.no-anim { transition: none !important; }
.actor svg { width: 100%; height: 100%; display: block; overflow: visible; }
.player { z-index: 26; transition: transform 0.16s cubic-bezier(0.25, 0.9, 0.3, 1); }
.monster { z-index: 24; transition: transform 0.2s cubic-bezier(0.25, 0.9, 0.3, 1); }

.player::before {
  content: "";
  position: absolute;
  inset: -46%;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 164, 82, 0.3), rgba(255, 138, 61, 0.06) 58%, transparent 70%);
  pointer-events: none;
}
.player .kid {
  transform-origin: 50% 72%;
  animation: kidBreathe 2.8s ease-in-out infinite;
}
.player.walking .kid { animation: kidHop 0.18s ease-out; }
.player.is-hidden { opacity: 0.58; filter: saturate(0.72); }
.player.is-hidden::before {
  background: radial-gradient(circle, rgba(79, 209, 197, 0.3), transparent 66%);
}
.hide-chip {
  position: absolute;
  left: 50%;
  top: -4%;
  transform: translateX(-50%) translateY(4px);
  padding: 1px 5px;
  border-radius: 8px;
  font-size: max(7px, calc(var(--cell, 40px) * 0.145));
  font-weight: 800;
  color: #062421;
  background: #6FE0D6;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
}
.player.is-hidden .hide-chip { opacity: 1; transform: translateX(-50%) translateY(0); }

.monster .m-body {
  transform-box: fill-box;
  transform-origin: center;
  animation: monsterBob 2.4s ease-in-out infinite;
}
.monster .eye { animation: eyeGlow 3.2s ease-in-out infinite; }
.monster[data-dir="left"] .m-body { transform: scaleX(-1); }
.monster .facing {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 7%;
  height: 7%;
  border-radius: 50%;
  background: #FFD08A;
  box-shadow: 0 0 7px #FFB066;
  opacity: 0.72;
  transform: translate(-50%, -50%) translateY(-250%);
}
.monster[data-dir="up"] .facing { transform: translate(-50%, -50%) translateY(-250%); }
.monster[data-dir="down"] .facing { transform: translate(-50%, -50%) translateY(180%); }
.monster[data-dir="left"] .facing { transform: translate(-50%, -50%) translateX(-180%); }
.monster[data-dir="right"] .facing { transform: translate(-50%, -50%) translateX(180%); }
.monster[data-dir="left"] .facing,
.monster[data-dir="right"] .facing { opacity: 0.55; }

/* 可走提示点 */
.step-dot { position: absolute; z-index: 5; display: grid; place-items: center; }
.step-dot::after {
  content: "";
  width: 16%;
  height: 16%;
  min-width: 3px;
  min-height: 3px;
  border-radius: 50%;
  background: rgba(255, 200, 140, 0.46);
  box-shadow: 0 0 8px rgba(255, 160, 80, 0.4);
  animation: dotPulse 2.5s ease-in-out infinite;
}
.step-dot.danger::after {
  width: 20%;
  height: 20%;
  background: rgba(255, 95, 95, 0.9);
  box-shadow: 0 0 9px rgba(255, 70, 70, 0.8);
}

/* 提示 */
.hint-ring {
  position: absolute;
  z-index: 7;
  border-radius: 10px;
  border: 2px solid rgba(255, 214, 130, 0.95);
  box-shadow: 0 0 0 3px rgba(255, 138, 61, 0.14), 0 0 20px rgba(255, 170, 80, 0.55);
  animation: hintPulse 1s ease-in-out infinite;
}
.hint-ring span {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  transform: translateX(-50%);
  padding: 2px 6px;
  border-radius: 6px;
  background: #FFD08A;
  color: #2B1406;
  font-size: 9px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* 特效 */
.spark {
  position: absolute;
  z-index: 8;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #FFE0A0;
  box-shadow: 0 0 8px #FFB066;
  animation: sparkOut 0.65s ease-out forwards;
}
.footstep {
  position: absolute;
  z-index: 8;
  border-radius: 50%;
  border: 1px solid rgba(255, 200, 140, 0.55);
  animation: footOut 0.55s ease-out forwards;
}

.vignette {
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  background: radial-gradient(120% 85% at 50% 44%, transparent 38%, rgba(2, 5, 10, 0.35) 72%, rgba(2, 5, 10, 0.72) 100%);
}
.moonbeam {
  position: absolute;
  z-index: 8;
  top: 0;
  left: 10%;
  width: 52%;
  height: 62%;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(130, 180, 255, 0.12), rgba(130, 180, 255, 0.02) 70%, transparent);
  transform: skewX(-14deg);
  filter: blur(3px);
  mix-blend-mode: screen;
}
.motes { position: absolute; inset: 0; z-index: 8; pointer-events: none; overflow: hidden; }
.mote {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255, 214, 160, 0.5);
  box-shadow: 0 0 6px rgba(255, 190, 120, 0.45);
  animation: moteDrift linear infinite;
}

.game-foot { display: flex; flex-direction: column; gap: 6px; }
.tip {
  min-height: 13px;
  margin: 0;
  padding: 0 6px;
  text-align: center;
  font-size: 10px;
  line-height: 1.35;
  color: #8B9BB8;
}
.actions { display: flex; gap: 9px; }
.actions .btn { flex: 1; }

/* ============================= 弹层 ============================= */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(3, 7, 14, 0.72);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.overlay-card {
  width: 100%;
  max-width: 350px;
  padding: 24px 20px 18px;
  text-align: center;
  border-radius: 24px;
  background: linear-gradient(180deg, #1A2540, #0D1526);
  border: 1px solid rgba(255, 255, 255, 0.11);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transform: translateY(14px) scale(0.96);
  transition: transform 0.25s var(--ease);
}
.overlay.show .overlay-card { transform: none; }
.ov-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  color: #FFCF8A;
  background: radial-gradient(circle at 50% 30%, rgba(255, 178, 100, 0.35), rgba(255, 138, 61, 0.08));
  border: 1px solid rgba(255, 160, 90, 0.35);
  box-shadow: 0 0 30px rgba(255, 138, 61, 0.18);
}
.ov-icon svg { width: 34px; height: 34px; display: block; }
.ov-icon .mp-icon { width: 30px; height: 30px; }
.ov-icon.danger {
  color: #FF9A9A;
  background: rgba(255, 70, 70, 0.1);
  border-color: rgba(255, 100, 100, 0.35);
  box-shadow: 0 0 30px rgba(255, 70, 70, 0.12);
}
.ov-kicker {
  margin: 0 0 4px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.24em;
  color: #FFAB6E;
  text-transform: uppercase;
}
.overlay-card h2 {
  margin: 0 0 6px;
  font-size: 25px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: #FFF6E8;
}
.ov-text {
  max-width: 270px;
  margin: 0 auto 16px;
  font-size: 12px;
  line-height: 1.55;
  color: #9DABC4;
}
.ov-stats { display: flex; justify-content: center; gap: 8px; margin: 14px 0 18px; }
.ov-stats div {
  flex: 1;
  padding: 9px 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.ov-stats b { display: block; font-size: 18px; line-height: 1.1; color: #FFD08A; }
.ov-stats span { display: block; margin-top: 3px; font-size: 9px; color: #8593AD; }
.ov-actions { display: flex; flex-direction: column; gap: 8px; }
.ov-actions .btn { width: 100%; flex: none; }

/* 提示条与受击闪屏 */
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 70;
  max-width: 84%;
  padding: 9px 14px;
  border-radius: 12px;
  background: rgba(12, 19, 34, 0.95);
  border: 1px solid rgba(255, 138, 61, 0.3);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  color: #FFD9B0;
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.flash {
  position: absolute;
  inset: 0;
  z-index: 65;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255, 60, 60, 0.42), rgba(255, 30, 30, 0.08) 55%, transparent 75%);
}
.flash.on { animation: flashHit 0.5s ease-out; }

.board.shake { animation: boardShake 0.34s ease-out; }

/* ============================= 动画 ============================= */
@keyframes shardFloat {
  0%, 100% { transform: translateY(-6%); }
  50% { transform: translateY(6%); }
}
@keyframes shardPick {
  0% { transform: scale(1); opacity: 1; }
  35% { transform: scale(1.35); opacity: 1; }
  100% { transform: scale(0.2) translateY(-40%); opacity: 0; }
}
@keyframes kidBreathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.025, 0.985); }
}
@keyframes kidHop {
  0% { transform: translateY(0) scale(1); }
  45% { transform: translateY(-7%) scale(1.04, 0.96); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes monsterBob {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-4%) rotate(1deg); }
}
@keyframes eyeGlow {
  0%, 100% { opacity: 0.86; }
  50% { opacity: 1; }
}
@keyframes visionBreath {
  0%, 100% { filter: brightness(0.9); }
  50% { filter: brightness(1.18); }
}
@keyframes dotPulse {
  0%, 100% { opacity: 0.35; transform: scale(0.9); }
  50% { opacity: 0.8; transform: scale(1.15); }
}
@keyframes hintPulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.045); opacity: 1; }
}
@keyframes sparkOut {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--tx, 0), var(--ty, -18px)) scale(0.2); opacity: 0; }
}
@keyframes footOut {
  0% { transform: scale(0.4); opacity: 0.8; }
  100% { transform: scale(1.5); opacity: 0; }
}
@keyframes flashHit {
  0% { opacity: 0; }
  20% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes boardShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px) rotate(-0.4deg); }
  40% { transform: translateX(4px) rotate(0.3deg); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}
@keyframes doorOpen {
  0% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(255, 138, 61, 0)); }
  45% { transform: scale(1.08); filter: drop-shadow(0 0 22px rgba(255, 170, 90, 0.95)); }
  100% { transform: scale(1); filter: drop-shadow(0 0 12px rgba(255, 138, 61, 0.8)); }
}
@keyframes moteDrift {
  0% { transform: translate3d(0, 8%, 0); opacity: 0; }
  15% { opacity: 0.66; }
  85% { opacity: 0.5; }
  100% { transform: translate3d(14px, -90px, 0); opacity: 0; }
}
@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.08); }
}
@keyframes batA {
  0%, 100% { transform: translate(118px, 96px) rotate(-6deg) scale(0.9); }
  50% { transform: translate(154px, 72px) rotate(7deg) scale(1.05); }
}
@keyframes batB {
  0%, 100% { transform: translate(268px, 150px) rotate(5deg) scale(0.7); }
  50% { transform: translate(236px, 128px) rotate(-8deg) scale(0.85); }
}
.scene-monster .scene-eye {
  transform-box: fill-box;
  transform-origin: center;
  animation: blink 5.5s infinite;
}
.scene-monster .scene-eye + .scene-eye { animation-delay: 0.15s; }
.bat { transform-box: fill-box; transform-origin: center; }
.bat-a { animation: batA 9s ease-in-out infinite; }
.bat-b { animation: batB 11s ease-in-out infinite; }

/* ============================= 小屏适配 ============================= */
@media (max-height: 700px) {
  .brand { margin-top: 26px; }
  .brand-title { font-size: 34px; margin-top: 5px; }
  .brand-tag { font-size: 11.5px; }
  .start-scene { height: 47%; min-height: 270px; }
  .start-panel { padding-top: 14px; }
  .panel-story { font-size: 10.5px; }
  .night-dots { margin: 9px 0 10px; }
  .rule { padding: 6px 9px; }
  .rule-ico { width: 33px; height: 33px; border-radius: 10px; }
  .rule-copy small { font-size: 9.5px; }
  .rules { gap: 5px; margin-bottom: 11px; }
  .btn-xl { height: 48px; font-size: 15px; }
  .start-foot { font-size: 9px; }
  .game { gap: 5px; }
  .stats { height: 31px; }
  .tip { font-size: 9px; }
}

@media (max-width: 350px) {
  .start-panel { padding-left: 14px; padding-right: 14px; }
  .panel-story { max-width: 220px; }
  .rule-copy small { font-size: 9px; }
  .brand-title { font-size: 32px; }
}

@media (min-width: 560px) {
  .app { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 30px 80px rgba(0, 0, 0, 0.8); }
  body { background: radial-gradient(120% 90% at 50% 0%, #101a30, #03060c 70%); }
}

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