/* ---------- 舞台分层 ---------- */
.stage { position: absolute; inset: 0; overflow: hidden; background: #04070c; }
.stage-bg {
  position: absolute;
  inset: 0;
  background: #0a0f18 center / cover no-repeat;
  opacity: 0;
  transition: opacity 0.7s ease;
}
.stage-bg.show { opacity: 1; }
.stage-bg.missing { background: linear-gradient(160deg, #121a26, #070b12); }

.stage-chars { position: absolute; inset: 0; z-index: 1; transition: opacity 0.4s; }
.stage-chars.under-cg { opacity: 0; }
.sprite {
  position: absolute;
  left: var(--x, 50%);
  bottom: 4%;
  height: 93%;
  aspect-ratio: 853 / 1280;
  transform: translateX(-50%);
  opacity: 0;
  transition: left 0.4s var(--ease), opacity 0.4s, filter 0.35s, transform 0.4s var(--ease);
  filter: brightness(0.6) saturate(0.85);
}
.stage-chars[data-n="3"] .sprite { height: 88%; }
.sprite.show { opacity: 1; }
.sprite.speaking { filter: brightness(1) saturate(1); }
.sprite.enter { animation: sprite-in 0.45s var(--ease); }
@keyframes sprite-in { from { opacity: 0; transform: translateX(-50%) translateY(16px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.sprite-img { width: 100%; height: 100%; background: bottom center / contain no-repeat; }

.stage-cg { position: absolute; inset: 0; z-index: 2; background: #000 center / cover no-repeat; opacity: 0; transition: opacity 0.7s ease; }
.stage-cg.show { opacity: 1; }
.stage-fx { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.stage-scan { position: absolute; inset: 0; z-index: 4; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.09) 0 1px, transparent 1px 3px); opacity: 0.55; }
.stage-scan::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 120px;
  top: -120px;
  background: linear-gradient(180deg, transparent, rgba(95, 211, 208, 0.06), transparent);
  animation: scan 7s linear infinite;
}
@keyframes scan { to { top: 100%; } }

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 18px 30px 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.hud > * { pointer-events: auto; }
.hud.ui-hidden, .hud.ui-hidden > * { opacity: 0; pointer-events: none; }
.hud-chapter { display: flex; align-items: baseline; gap: 10px; padding: 6px 14px 6px 12px; background: linear-gradient(90deg, rgba(7, 11, 18, 0.75), rgba(7, 11, 18, 0)); border-left: 2px solid var(--amber); }
.hud-chapter-no { font-size: 16px; font-weight: 700; letter-spacing: 3px; color: var(--amber); }
.hud-chapter-title { font-size: 15px; letter-spacing: 2px; color: rgba(220, 232, 236, 0.85); }
.hud-right { display: flex; align-items: center; gap: 8px; }
.hud-clues { display: flex; align-items: center; gap: 6px; padding: 0 12px; height: 34px; border: 1px solid rgba(232, 178, 76, 0.45); border-radius: 17px; color: var(--amber); background: rgba(7, 11, 18, 0.6); backdrop-filter: blur(6px); font-family: var(--mono); font-size: 14px; }
.hud-count { min-width: 14px; text-align: center; }
.hud-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  border-radius: 17px;
  border: 1px solid var(--line-soft);
  background: rgba(7, 11, 18, 0.6);
  backdrop-filter: blur(6px);
  color: rgba(220, 232, 236, 0.85);
  font-size: 13px;
  letter-spacing: 1px;
  transition: all 0.2s;
}
.hud-btn:hover, .hud-btn:focus-visible { border-color: var(--cyan); color: var(--cyan); outline: none; background: rgba(95, 211, 208, 0.1); }
.hud-btn.on { background: var(--cyan); border-color: var(--cyan); color: #061014; font-weight: 700; }

/* ---------- 对话框 ---------- */
.dialogue {
  position: absolute;
  left: 36px;
  right: 36px;
  bottom: 26px;
  z-index: 6;
  min-height: 158px;
  padding: 20px 56px 22px 34px;
  background: linear-gradient(180deg, rgba(10, 16, 26, 0.86) 0%, rgba(7, 11, 18, 0.94) 100%);
  border: 1px solid var(--line);
  border-radius: 6px;
  backdrop-filter: blur(10px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.3s, transform 0.35s var(--ease);
}
.dialogue.show { opacity: 1; transform: translateY(0); }
.dialogue.ui-hidden { opacity: 0 !important; pointer-events: none; }
.dialogue::before { content: ""; position: absolute; left: -1px; top: 18px; bottom: 18px; width: 3px; background: var(--cyan); box-shadow: 0 0 12px rgba(95, 211, 208, 0.6); }
.dialogue::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 14px;
  width: 10px;
  height: 10px;
  border-top: 1px solid rgba(95, 211, 208, 0.5);
  border-right: 1px solid rgba(95, 211, 208, 0.5);
}
.dlg-head { display: flex; align-items: baseline; gap: 14px; min-height: 30px; margin-bottom: 6px; }
.dlg-name { font-size: var(--name-size, 22px); font-weight: 800; letter-spacing: 3px; color: var(--cyan); text-shadow: 0 0 14px rgba(95, 211, 208, 0.35); }
.dlg-role { font-size: 12px; letter-spacing: 3px; color: var(--dim); }
.dlg-role::before { content: "/ "; }
.dlg-text { font-size: var(--dlg-size, 25px); line-height: 1.72; letter-spacing: 0.5px; color: var(--text); min-height: calc(var(--dlg-size, 25px) * 1.72); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); }
.think { color: #a9bcc5; }
.dlg-arrow { position: absolute; right: 22px; bottom: 16px; color: var(--cyan); opacity: 0; transition: opacity 0.2s; }
.dlg-arrow.show { opacity: 1; animation: arrow 1.1s ease-in-out infinite; }
.dialogue.waiting .dlg-arrow { display: none; }
@keyframes arrow { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(4px); } }

.dialogue.narration .dlg-head { display: none; }
.dialogue.narration .dlg-text { color: #c9d6dc; }
.dialogue.narration::before { background: var(--dim); box-shadow: none; }
.dialogue.player .dlg-name { color: var(--text); text-shadow: none; }
.dialogue.glitch::before { background: var(--red); box-shadow: 0 0 14px var(--red); }
.dialogue.glitch .dlg-text { animation: glitch-text 2.2s steps(1) infinite; }
@keyframes glitch-text {
  0%, 92%, 100% { text-shadow: none; transform: none; }
  93% { text-shadow: 2px 0 rgba(224, 90, 106, 0.8), -2px 0 rgba(95, 211, 208, 0.8); transform: translateX(1px); }
  95% { text-shadow: -2px 0 rgba(224, 90, 106, 0.8), 2px 0 rgba(95, 211, 208, 0.8); transform: translateX(-1px); }
  97% { text-shadow: none; transform: none; }
}

/* ---------- 选项 ---------- */
.choices-layer { position: absolute; inset: 0; z-index: 7; display: none; background: linear-gradient(180deg, rgba(3, 5, 10, 0.15), rgba(3, 5, 10, 0.55)); }
.choices-layer.show { display: block; }
.choices { position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); width: 760px; display: flex; flex-direction: column; gap: 12px; }
.choice {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 15px 22px 15px 16px;
  background: rgba(10, 16, 26, 0.92);
  border: 1px solid var(--line);
  border-left: 3px solid var(--cyan);
  border-radius: 4px;
  color: var(--text);
  font-size: var(--choice-size, 20px);
  letter-spacing: 1px;
  text-align: left;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.3s, transform 0.35s var(--ease), background 0.2s, border-color 0.2s;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.choice.in { opacity: 1; transform: translateY(0); }
.choice:hover, .choice:focus-visible { outline: none; background: linear-gradient(rgba(95, 211, 208, 0.18), rgba(95, 211, 208, 0.18)), rgba(10, 16, 26, 0.96); border-color: var(--cyan); transform: translateX(8px); }
.choice-key { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border: 1px solid var(--cyan); border-radius: 50%; font-family: var(--mono); font-size: 13px; color: var(--cyan); flex: none; }
.choice-text { line-height: 1.5; }

/* ---------- 指证 ---------- */
.deduce-layer { position: absolute; inset: 0; z-index: 8; display: none; }
.deduce-layer.show { display: block; }
.deduce-backdrop { position: absolute; inset: 0; background: rgba(3, 5, 10, 0.8); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; animation: screen-in 0.3s; }
.deduce-panel { width: 1200px; max-height: 680px; display: flex; flex-direction: column; padding: 22px 28px 24px; background: var(--panel); border: 1px solid rgba(224, 90, 106, 0.4); box-shadow: 0 0 0 1px rgba(224, 90, 106, 0.12), 0 30px 80px rgba(0, 0, 0, 0.6); }
.deduce-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.deduce-speaker { font-size: 13px; letter-spacing: 4px; font-weight: 700; }
.deduce-q { margin-top: 4px; font-size: 26px; font-weight: 700; letter-spacing: 1px; line-height: 1.4; }
.deduce-hint { margin-top: 8px; font-size: 14px; color: var(--dim); letter-spacing: 1px; }
.deduce-hint.warn { color: var(--amber); }
.deduce-strikes { display: flex; gap: 8px; padding-top: 8px; }
.strike { width: 46px; height: 4px; background: rgba(224, 90, 106, 0.25); transition: background 0.3s, box-shadow 0.3s; }
.strike.hit { background: var(--red); box-shadow: 0 0 10px var(--red); }
.deduce-grid { margin-top: 18px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; flex: 1; min-height: 0; overflow-y: auto; padding-right: 6px; align-content: start; scrollbar-width: thin; scrollbar-color: rgba(95, 211, 208, 0.4) transparent; }
.deduce-card { display: flex; flex-direction: column; gap: 4px; padding: 11px 13px; background: #0e1621; border: 1px solid var(--line-soft); text-align: left; color: var(--text); transition: all 0.2s; min-height: 92px; }
.deduce-card:hover, .deduce-card:focus-visible { outline: none; border-color: var(--cyan); background: rgba(95, 211, 208, 0.1); transform: translateY(-2px); }
.deduce-card.correct { border-color: var(--amber); background: rgba(232, 178, 76, 0.18); box-shadow: 0 0 20px rgba(232, 178, 76, 0.3); }
.deduce-card.wrong { border-color: var(--red); background: rgba(224, 90, 106, 0.2); animation: wrong-shake 0.4s; }
@keyframes wrong-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.clue-cat { font-family: var(--mono); font-size: 11px; letter-spacing: 2px; color: var(--cyan); display: flex; align-items: center; gap: 6px; }
.clue-name { font-size: 16px; font-weight: 700; letter-spacing: 1px; }
.clue-desc { font-size: 12px; color: var(--dim); line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- 章节卡 ---------- */
.chapter-card {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #0c141f 0%, #04070c 70%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s;
}
.chapter-card.show { opacity: 1; }
.chapter-line { width: 0; height: 1px; background: var(--cyan); margin-bottom: 22px; }
.chapter-card.show .chapter-line { animation: line-grow 0.8s 0.2s var(--ease) forwards; }
@keyframes line-grow { to { width: 120px; } }
.chapter-no { font-family: var(--mono); font-size: 16px; letter-spacing: 8px; color: var(--amber); }
.chapter-title { margin-top: 10px; font-size: 54px; font-weight: 800; letter-spacing: 14px; text-indent: 14px; color: #f3f7f8; text-shadow: 0 0 40px rgba(95, 211, 208, 0.25); }
.chapter-card.show .chapter-no, .chapter-card.show .chapter-title { animation: title-text 0.8s var(--ease) both; }
.chapter-card.show .chapter-title { animation-delay: 0.15s; }
@keyframes title-text { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- 游戏内菜单 ---------- */
.menu-layer { position: absolute; inset: 0; z-index: 10; display: none; background: rgba(3, 5, 10, 0.55); }
.menu-layer.show { display: block; }
.menu-box {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 400px;
  padding: 44px 40px 30px;
  background: linear-gradient(270deg, rgba(7, 11, 18, 0.98) 0%, rgba(7, 11, 18, 0.92) 70%, rgba(7, 11, 18, 0.75) 100%);
  border-left: 1px solid var(--line);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  animation: menu-in 0.3s var(--ease);
}
@keyframes menu-in { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.menu-brand-cn { font-size: 30px; font-weight: 800; letter-spacing: 8px; }
.menu-brand-en { margin-top: 4px; font-family: var(--mono); font-size: 12px; letter-spacing: 5px; color: var(--cyan); }
.menu-list { margin-top: 40px; display: flex; flex-direction: column; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  background: transparent;
  border: 0;
  border-left: 2px solid transparent;
  color: rgba(220, 232, 236, 0.85);
  font-size: 18px;
  letter-spacing: 3px;
  text-align: left;
  transition: all 0.2s;
}
.menu-item svg { color: var(--dim); transition: color 0.2s; }
.menu-item:hover, .menu-item:focus-visible { outline: none; background: rgba(95, 211, 208, 0.1); border-left-color: var(--cyan); color: #fff; padding-left: 22px; }
.menu-item:hover svg, .menu-item:focus-visible svg { color: var(--cyan); }
.menu-item.danger { color: #f2a3ad; }
.menu-item.danger svg { color: var(--red); }
.menu-foot { margin-top: auto; font-size: 12px; letter-spacing: 2px; color: var(--dim); }
