:root {
  --bg: #050505;
  --fg: #d8d2c8;
  --accent: #8a1f1f;
  --accent2: #b23a3a;
  --gold: #c9a76a;
  --panel-bg: rgba(12, 10, 10, 0.92);
  --border: rgba(160, 60, 60, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Serif SC", serif;
  user-select: none;
  cursor: default;
}

canvas { display: block; touch-action: none; }

/* ---------- 全屏覆盖层 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background:
    radial-gradient(ellipse at center, rgba(40, 8, 8, 0.9), rgba(0, 0, 0, 0.98) 75%);
  text-align: center;
  padding: 24px;
}

/* ---------- 专属加载界面 ---------- */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 400px;
}
.loading-title {
  font-size: 48px;
  letter-spacing: 0.4em;
  color: var(--accent2);
  text-shadow: 0 0 20px rgba(178, 58, 58, 0.85);
  margin-bottom: 25px;
  text-align: center;
  padding-left: 0.4em;
  animation: flicker 3s infinite;
}
.loading-bar-container {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.8);
}
#loading-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  box-shadow: 0 0 8px var(--accent2);
  transition: width 0.1s linear;
}
#loading-status {
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 0.1em;
  opacity: 0.85;
  margin-bottom: 20px;
  animation: pulse-light 1.5s infinite ease-in-out;
}
.loading-warn {
  font-size: 12px;
  color: #666;
  letter-spacing: 0.05em;
  line-height: 1.6;
}
@keyframes pulse-light {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.title {
  font-size: 56px;
  letter-spacing: 0.5em;
  color: var(--accent2);
  text-shadow: 0 0 18px rgba(178, 58, 58, 0.8);
  animation: flicker 4s infinite;
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  90% { opacity: 1; }
  92% { opacity: 0.3; }
  94% { opacity: 1; }
  96% { opacity: 0.6; }
  98% { opacity: 1; }
}

.subtitle {
  letter-spacing: 0.35em;
  color: var(--gold);
  font-size: 14px;
  opacity: 0.8;
}

.hint {
  font-size: 12px;
  color: #888;
  letter-spacing: 0.06em;
  max-width: 520px;
  line-height: 1.8;
}

/* ---------- 按钮 ---------- */
.btn {
  background: linear-gradient(180deg, #2a1414, #160a0a);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 12px 34px;
  font-size: 16px;
  letter-spacing: 0.2em;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.btn:hover { border-color: var(--accent2); color: #fff; text-shadow: 0 0 8px rgba(255,120,120,0.6); }
.btn.small { padding: 6px 14px; font-size: 13px; letter-spacing: 0.1em; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#hud .btn { pointer-events: auto; }

.crosshair {
  position: absolute;
  left: 50%; top: 50%;
  width: 6px; height: 6px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 4px rgba(0,0,0,0.8);
}

.hud-top-left {
  position: absolute; top: 18px; left: 20px;
  display: flex; flex-direction: column; gap: 10px;
}
.hud-top-right {
  position: absolute; top: 18px; right: 20px;
  display: flex; gap: 8px;
}

#sanity-wrap { width: 180px; }
#sanity-label { font-size: 12px; color: #bbb; letter-spacing: 0.1em; }
.bar {
  margin-top: 4px;
  height: 8px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
}
#sanity-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #4a7a4a, #7ab47a);
  transition: width 0.3s, background 0.3s;
}
#objective {
  font-size: 13px;
  color: #c9a76a;
  letter-spacing: 0.06em;
  text-shadow: 0 0 6px rgba(0,0,0,0.9);
}

/* ---------- 提示 toast ---------- */
#toast {
  position: absolute;
  bottom: 90px; left: 50%;
  transform: translateX(-50%);
  background: var(--panel-bg);
  border: 1px solid var(--border);
  padding: 10px 22px;
  font-size: 14px;
  letter-spacing: 0.05em;
  color: #e8e0d0;
  animation: toast-in 0.25s ease;
}

/* ---------- 面板 ---------- */
.panel {
  position: fixed;
  z-index: 60;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  min-width: 360px;
  max-width: 540px;
  max-height: 80vh;
  overflow: auto;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  box-shadow: 0 0 40px rgba(0,0,0,0.8);
  padding: 22px;
  text-align: center;
}
.panel h2 {
  letter-spacing: 0.3em;
  color: var(--gold);
  font-size: 18px;
  margin-bottom: 16px;
}
.panel-hint { font-size: 12px; color: #777; margin-top: 12px; line-height: 1.6; }

#inventory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  min-height: 60px;
}
.item {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 10px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--fg);
}
.item:hover, .item.selected { border-color: var(--accent2); background: rgba(178,58,58,0.15); }
.item .icon { font-size: 26px; }
.item .name { font-size: 11px; margin-top: 4px; }
#item-detail { margin-top: 12px; font-size: 13px; color: #ccc; min-height: 40px; line-height: 1.6; }

#notes-content { text-align: left; font-size: 14px; line-height: 1.9; color: #cfc8bb; }

/* ---------- 密码锁 ---------- */
#lock-digits { display: flex; gap: 12px; justify-content: center; margin-bottom: 18px; }
.lock-digit {
  width: 46px; height: 56px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: var(--gold);
}
#lock-numpad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  max-width: 240px; margin: 0 auto;
}
.numpad-key {
  padding: 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  cursor: pointer;
  font-size: 18px;
}
.numpad-key:hover { background: rgba(178,58,58,0.2); }
.numpad-key.clear { grid-column: span 2; color: #c66; }

/* ---------- 特效层 ---------- */
#fx-vignette {
  position: fixed; inset: 0; z-index: 5; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.85) 100%);
}
#fx-flicker {
  position: fixed; inset: 0; z-index: 6; pointer-events: none;
  background: rgba(0,0,0,0.9); opacity: 0;
}
#fx-noise {
  position: fixed; inset: 0; z-index: 7; pointer-events: none;
  opacity: 0.5;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.12'/></svg>");
}

.hidden { display: none !important; }

/* ---------- 移动端虚拟按键样式 ---------- */
#mobile-controls {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}
#joystick-container {
  position: absolute;
  bottom: calc(30px + env(safe-area-inset-bottom));
  left: calc(30px + env(safe-area-inset-left));
  width: 120px;
  height: 120px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  touch-action: none;
}
#joystick-base {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  justify-content: center;
}
#joystick-handle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent2);
  box-shadow: 0 0 10px rgba(178, 58, 58, 0.6);
  transition: transform 0.05s ease;
}
#action-buttons {
  position: absolute;
  bottom: calc(40px + env(safe-area-inset-bottom));
  right: calc(30px + env(safe-area-inset-right));
  display: flex;
  gap: 16px;
  pointer-events: auto;
}
.touch-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--fg);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: none;
  text-shadow: 0 0 4px rgba(0,0,0,0.5);
}
.touch-btn:active {
  background: var(--accent);
  border-color: var(--accent2);
  transform: scale(0.92);
}

/* 现实世界温馨小窗 / 防沉迷关怀 */
#humanity-care-popup {
  position: fixed;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: rgba(18, 14, 14, 0.95);
  border: 1px solid var(--gold);
  border-radius: 4px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--fg);
  box-shadow: 0 4px 15px rgba(0,0,0,0.8);
  animation: care-slide-in 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
#humanity-care-popup .heart-icon {
  color: var(--accent2);
  animation: heartbeat 1.2s infinite;
}
@keyframes care-slide-in {
  from { top: -60px; opacity: 0; }
  to { top: 15px; opacity: 1; }
}
@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* 手机端响应式细节优化 */
@media (max-width: 768px) {
  .title {
    font-size: 36px;
    letter-spacing: 0.3em;
  }
  .panel {
    width: 90%;
    min-width: unset;
    max-height: 85vh;
    padding: 16px;
  }
  #inventory-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  #lock-digits {
    gap: 8px;
  }
  .lock-digit {
    width: 38px;
    height: 48px;
    font-size: 20px;
  }
  .numpad-key {
    padding: 10px;
    font-size: 16px;
  }
  .hud-top-left {
    top: 10px; left: 10px;
    gap: 6px;
  }
  .hud-top-right {
    top: 10px; right: 10px;
    gap: 4px;
  }
  #sanity-wrap {
    width: 120px;
  }
  #objective {
    font-size: 11px;
    max-width: 200px;
    line-height: 1.3;
  }
  .btn {
    padding: 8px 20px;
    font-size: 14px;
  }
  #toast, #subtitle {
    bottom: 120px;
    font-size: 13px;
    width: 90%;
    padding: 8px 16px;
  }
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

#ending-text { white-space: pre-line; }

/* ---------- 剧情字幕条 ---------- */
#subtitle {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 720px;
  width: 86%;
  text-align: center;
  color: rgba(230, 230, 230, 0.95);
  font-size: 15px;
  letter-spacing: 0.08em;
  line-height: 1.7;
  text-shadow: 0 0 6px #000, 0 0 14px rgba(120, 20, 20, 0.6);
  background: linear-gradient(transparent, rgba(0,0,0,0.55), transparent);
  padding: 10px 16px;
  border-radius: 6px;
  z-index: 300;
  pointer-events: none;
  animation: subtitle-in 0.3s ease;
}
#subtitle.hidden { display: none; }
@keyframes subtitle-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---------- 跳杀层 ---------- */
#jumpscare {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: radial-gradient(circle at center, rgba(40,0,0,0.4), rgba(0,0,0,0.95));
  pointer-events: none;
  animation: jumpscare-flash 0.32s steps(4) both;
}
#jumpscare.hidden { display: none; }
@keyframes jumpscare-flash {
  0% { opacity: 0; }
  25% { opacity: 1; background: rgba(120,10,10,0.9); }
  50% { opacity: 0.2; }
  75% { opacity: 1; background: #000; }
  100% { opacity: 0; }
}

/* 恐怖脸：巨大的扭曲表情 + 抖动 + 高对比 */
#scare-face {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
  font-size: min(40vw, 420px);
  z-index: 1000;
  pointer-events: none;
  filter: grayscale(0.4) contrast(1.8) brightness(1.3) drop-shadow(0 0 40px rgba(180,20,20,0.9));
  animation: face-shake 0.32s steps(3) infinite;
  mix-blend-mode: screen;
}
#scare-face.hidden { display: none; }
@keyframes face-shake {
  0% { transform: translate(-50%, -50%) translate(-14px, -8px) rotate(-8deg) scale(1.06); }
  33% { transform: translate(-50%, -50%) translate(12px, 6px) rotate(6deg) scale(1.1); }
  66% { transform: translate(-50%, -50%) translate(-8px, 14px) rotate(-4deg) scale(0.98); }
  100% { transform: translate(-50%, -50%) translate(10px, -10px) rotate(9deg) scale(1.12); }
}

/* ---------- 低理智 / 狩猎 / 血色 全身状态 ---------- */
body.low-sanity #fx-noise {
  animation: static-noise 0.06s infinite;
  background-image: radial-gradient(rgba(255,255,255,0.35) 1px, transparent 1.5px);
  background-size: 3px 3px;
}
body.hunted #fx-vignette {
  background: radial-gradient(ellipse at 30% 50%, transparent 30%, rgba(90,0,0,0.75) 100%) !important;
  animation: pulse-glow 0.5s infinite;
}
body.bloodscreen::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 700;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 20%, rgba(140,0,0,0.25), rgba(90,0,0,0.7));
  border: 24px solid rgba(120,10,10,0.35);
  box-shadow: inset 0 0 120px rgba(150,0,0,0.6);
  animation: heartbeat-blood 1.1s ease-in-out infinite;
}
@keyframes heartbeat-blood {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  45% { opacity: 1; transform: scale(1.015); }
  55% { opacity: 0.6; }
}

/* ---------- 数字 HUD ---------- */
#digit-hud {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-right: 8px;
}
.digit-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid #555;
  color: #777;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: rgba(0,0,0,0.6);
  transition: all 0.3s;
}
.digit-dot.got {
  color: #ffd98a;
  border-color: var(--gold);
  background: rgba(201,167,106,0.15);
  box-shadow: 0 0 10px rgba(201,167,106,0.5);
  text-shadow: 0 0 6px rgba(201,167,106,0.9);
}

/* ---------- 成就列表 ---------- */
#achv-list {
  max-height: 46vh;
  overflow-y: auto;
}
.achv-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  color: #888;
}
.achv-row.got {
  color: #ddd;
}
.achv-row.got .achv-icon {
  color: var(--gold);
  text-shadow: 0 0 6px rgba(201,167,106,0.7);
}
.achv-icon {
  width: 22px;
  text-align: center;
  flex: none;
}
.achv-name {
  min-width: 96px;
  color: inherit;
  font-weight: bold;
  letter-spacing: 0.05em;
}
.achv-desc {
  font-size: 12px;
  color: #777;
}

@media (max-width: 640px) {
  .title { font-size: 36px; }
  #inventory-grid { grid-template-columns: repeat(3, 1fr); }
  .panel { padding: 16px; min-width: 300px; }
}

/* ---------- 扩展动画效果 ---------- */
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 8px rgba(138, 31, 31, 0.3); }
  50% { box-shadow: 0 0 20px rgba(138, 31, 31, 0.6); }
}

@keyframes glitch {
  0% { transform: translate(0); }
  20% { transform: translate(-2px, 2px); }
  40% { transform: translate(-2px, -2px); }
  60% { transform: translate(2px, 2px); }
  80% { transform: translate(2px, -2px); }
  100% { transform: translate(0); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes blood-drip {
  0% { transform: translateY(-100%); opacity: 0; }
  50% { opacity: 1; }
  100% { transform: translateY(100vh); opacity: 0; }
}

@keyframes static-noise {
  0% { background-position: 0 0; }
  100% { background-position: 100% 100%; }
}

/* ---------- 扩展UI组件 ---------- */
.glitch-text {
  animation: glitch 0.3s infinite;
  position: relative;
}

.glitch-text::before,
.glitch-text::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.8;
}

.glitch-text::before {
  color: #ff0000;
  animation: glitch 0.2s infinite;
  z-index: -1;
}

.glitch-text::after {
  color: #00ffff;
  animation: glitch 0.3s infinite reverse;
  z-index: -2;
}

.blood-text {
  color: #8a1f1f;
  text-shadow: 0 0 10px rgba(138, 31, 31, 0.8), 2px 2px 4px rgba(0, 0, 0, 0.8);
  font-weight: bold;
}

.pulse-warning {
  animation: pulse-glow 1.5s infinite;
  border-color: #8a1f1f;
}

/* ---------- 扩展面板样式 ---------- */
.panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent2), transparent);
  animation: static-noise 2s linear infinite;
  background-size: 200% 200%;
}

.panel-content-scroll {
  max-height: 40vh;
  overflow-y: auto;
  padding-right: 8px;
  text-align: left;
}

.panel-content-scroll::-webkit-scrollbar {
  width: 6px;
}

.panel-content-scroll::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
}

.panel-content-scroll::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 3px;
}

/* ---------- 扩展物品栏样式 ---------- */
.item {
  position: relative;
  overflow: hidden;
}

.item::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: radial-gradient(circle, rgba(138, 31, 31, 0.4), transparent);
  transform: translate(-50%, -50%);
  transition: all 0.3s;
  border-radius: 50%;
}

.item:hover::after {
  width: 120%;
  height: 120%;
}

.item.quest-item {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(201, 167, 106, 0.3);
}

.item.quest-item .icon {
  filter: drop-shadow(0 0 5px rgba(201, 167, 106, 0.6));
}

/* ---------- 扩展HUD组件 ---------- */
.minimap {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 120px;
  height: 120px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--border);
  border-radius: 50%;
  overflow: hidden;
}

.minimap-player {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
}

.compass {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 2px;
  background: rgba(138, 31, 31, 0.5);
}

/* ---------- 扩展密码锁样式 ---------- */
.lock-digit.correct {
  color: #4a7a4a;
  text-shadow: 0 0 10px rgba(74, 122, 74, 0.6);
}

.lock-digit.wrong {
  color: #8a1f1f;
  animation: shake 0.3s;
}

.numpad-key:active {
  transform: scale(0.95);
  background: rgba(138, 31, 31, 0.3);
}

/* ---------- 扩展特效层 ---------- */
#fx-vignette.damaged {
  background: radial-gradient(ellipse at center, transparent 40%, rgba(138, 31, 31, 0.6) 100%);
}

#fx-vignette.insane {
  background: radial-gradient(ellipse at center, transparent 30%, rgba(138, 31, 31, 0.8) 100%);
  animation: pulse-glow 2s infinite;
}

.blood-overlay {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  background: radial-gradient(ellipse at 80% 20%, rgba(138, 31, 31, 0.3), transparent 40%);
  opacity: 0;
  transition: opacity 0.5s;
}

/* ---------- 对话框扩展 ---------- */
.dialog-system {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 600px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  padding: 16px;
  z-index: 100;
  display: none;
}

.dialog-system.active {
  display: block;
  animation: toast-in 0.3s ease;
}

.dialog-portrait {
  width: 60px;
  height: 60px;
  background: rgba(138, 31, 31, 0.3);
  border-radius: 50%;
  margin-right: 16px;
  float: left;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.dialog-content {
  overflow: hidden;
}

.dialog-name {
  color: var(--gold);
  font-weight: bold;
  margin-bottom: 8px;
  letter-spacing: 0.1em;
}

.dialog-text {
  color: var(--fg);
  line-height: 1.6;
  font-size: 14px;
}

.dialog-choices {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dialog-choice {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  color: var(--fg);
}

.dialog-choice:hover {
  background: rgba(178, 58, 58, 0.2);
  border-color: var(--accent2);
}

/* ---------- 任务系统样式 ---------- */
.quest-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 400px;
  max-width: 600px;
  max-height: 70vh;
  overflow: auto;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  box-shadow: 0 0 40px rgba(0,0,0,0.8);
  padding: 24px;
  text-align: left;
  z-index: 60;
}

.quest-item {
  padding: 12px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid var(--accent);
}

.quest-item.completed {
  border-left-color: #4a7a4a;
  opacity: 0.7;
}

.quest-item.completed .quest-title {
  text-decoration: line-through;
  color: #888;
}

.quest-title {
  color: var(--gold);
  font-weight: bold;
  margin-bottom: 4px;
  letter-spacing: 0.05em;
}

.quest-description {
  color: #aaa;
  font-size: 13px;
  line-height: 1.5;
}

/* ---------- 成就系统样式 ---------- */
.achievement-popup {
  position: fixed;
  top: 20px;
  right: -400px;
  width: 350px;
  background: linear-gradient(135deg, rgba(20, 15, 15, 0.95), rgba(10, 8, 8, 0.98));
  border: 2px solid var(--accent2);
  border-radius: 8px;
  padding: 16px;
  z-index: 200;
  transition: right 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 5px 20px rgba(138, 31, 31, 0.4);
}

.achievement-popup.show {
  right: 20px;
}

.achievement-icon {
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 2px 10px rgba(138, 31, 31, 0.5);
}

.achievement-info h4 {
  color: var(--gold);
  margin-bottom: 4px;
  letter-spacing: 0.1em;
}

.achievement-info p {
  color: #ccc;
  font-size: 12px;
  line-height: 1.4;
}

/* ---------- 加载动画 ---------- */
.loading-bar {
  width: 300px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 20px;
}

.loading-progress {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  width: 0%;
  transition: width 0.3s;
  box-shadow: 0 0 10px rgba(138, 31, 31, 0.6);
}

.loading-text {
  margin-top: 12px;
  font-size: 12px;
  color: #888;
  letter-spacing: 0.1em;
}

/* ---------- 设置面板样式 ---------- */
.settings-panel {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  text-align: left;
}

.setting-item {
  background: rgba(255, 255, 255, 0.03);
  padding: 12px;
  border-radius: 4px;
}

.setting-label {
  display: block;
  margin-bottom: 8px;
  color: #ccc;
  font-size: 12px;
  letter-spacing: 0.05em;
}

.setting-slider {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  appearance: none;
  outline: none;
}

.setting-slider::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent2);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(138, 31, 31, 0.5);
}

.setting-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.setting-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(255, 255, 255, 0.1);
  transition: 0.3s;
  border-radius: 24px;
}

.toggle-slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #888;
  transition: 0.3s;
  border-radius: 50%;
}

/* ---------- 警告与校准屏幕 ---------- */
#warning-screen {
  z-index: 200;
  background: radial-gradient(ellipse at center, rgba(10, 5, 5, 0.98), rgba(0, 0, 0, 1) 80%);
  animation: warning-flicker 5s infinite;
}

@keyframes warning-flicker {
  0%, 100% { opacity: 1; }
  92% { opacity: 1; }
  93% { opacity: 0.7; }
  94% { opacity: 1; }
  96% { opacity: 0.85; }
  97% { opacity: 1; }
}

.warning-content {
  max-width: 600px;
  width: 90%;
  background: rgba(20, 10, 10, 0.9);
  border: 1px solid var(--accent);
  padding: 30px;
  box-shadow: 0 0 30px rgba(138, 31, 31, 0.4);
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
}

.warning-icon {
  font-size: 48px;
  color: var(--accent2);
  animation: pulse-glow 2s infinite;
  filter: drop-shadow(0 0 10px rgba(178, 58, 58, 0.8));
}

.warning-text {
  text-align: left;
  font-size: 14px;
  line-height: 1.8;
  color: #d8d2c8;
}

.warning-text p {
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 12px;
}

.warning-text p:last-child {
  margin-bottom: 0;
  border-bottom: none;
  padding-bottom: 0;
}

.warning-text strong {
  color: var(--accent2);
  display: block;
  margin-bottom: 4px;
}

.calibration-section {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.calibration-section h3, .gameplay-tips h3 {
  color: var(--gold);
  font-size: 16px;
  margin-bottom: 12px;
  letter-spacing: 0.15em;
  text-align: center;
}

.calibration-section p {
  text-align: center;
  font-size: 13px;
  color: #aaa;
  margin-bottom: 15px;
}

.volume-control {
  display: flex;
  align-items: center;
  gap: 15px;
  justify-content: center;
}

.volume-control span {
  font-size: 20px;
}

.gameplay-tips {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.gameplay-tips ul {
  list-style: none;
  padding: 0;
  text-align: left;
}

.gameplay-tips li {
  position: relative;
  padding-left: 20px;
  margin-bottom: 10px;
  font-size: 13px;
  color: #ccc;
  line-height: 1.5;
}

.gameplay-tips li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--accent2);
  font-weight: bold;
}

.gameplay-tips li strong {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 12px;
}

/* ---------- 视觉特效增强 ---------- */

/* 色差/屏幕扭曲效果（理智过低时激活） */
#fx-chromatic {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.6) 100%);
}
#fx-chromatic.active {
  opacity: 1;
  animation: chromatic-aberration 0.15s infinite;
}
@keyframes chromatic-aberration {
  0% { filter: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='c'%3E%3CfeColorMatrix type='matrix' values='1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0'/%3E%3C/filter%3E%3C/svg%3E#c"); }
  50% { filter: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='c'%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0'/%3E%3C/filter%3E%3C/svg%3E#c"); }
  100% { filter: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='c'%3E%3CfeColorMatrix type='matrix' values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0'/%3E%3C/filter%3E%3C/svg%3E#c"); }
}

/* 增强型血腥叠层（带滴落动画） */
#bloodscreen {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s;
  background:
    radial-gradient(ellipse 60% 80% at 30% 20%, rgba(80,0,0,0.5) 0%, transparent 70%),
    radial-gradient(ellipse 40% 60% at 70% 80%, rgba(100,0,0,0.4) 0%, transparent 60%);
}
#bloodscreen.active {
  opacity: 1;
  animation: blood-drip 3s ease-in-out infinite;
}
@keyframes blood-drip {
  0%, 100% { background-position: 0% 0%, 0% 0%; }
  25% { background-position: 5% 3%, 0% 0%; }
  50% { background-position: 0% 0%, 5% 3%; }
  75% { background-position: 3% 2%, 0% 0%; }
}

/* 动态闪烁增强 */
#fx-flicker {
  position: fixed;
  inset: 0;
  z-index: 35;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at center, rgba(50,50,50,0.3) 0%, transparent 70%);
}
#fx-flicker.active {
  opacity: 1;
  animation: flicker-intense 0.08s infinite;
}
@keyframes flicker-intense {
  0% { opacity: 0; }
  50% { opacity: 0.15; background: radial-gradient(ellipse at center, rgba(80,80,80,0.4) 0%, transparent 60%); }
  100% { opacity: 0; }
}

/* 跳跃惊吓屏幕震动 */
.jumpscare-flash {
  animation: jumpflash 0.15s ease-out;
}
@keyframes jumpflash {
  0% { background: rgba(255,255,255,0.9); }
  100% { background: rgba(255,255,255,0); }
}

/* 屏幕震动动画 */
.screen-shake {
  animation: screen-shake 0.3s ease-out;
}
@keyframes screen-shake {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-3px, 2px); }
  20% { transform: translate(3px, -1px); }
  30% { transform: translate(-2px, 3px); }
  40% { transform: translate(2px, -2px); }
  50% { transform: translate(-1px, 1px); }
  60% { transform: translate(3px, 2px); }
  70% { transform: translate(-3px, -1px); }
  80% { transform: translate(1px, 2px); }
  90% { transform: translate(-2px, -2px); }
}

/* 低理智视觉扭曲 */
#low-sanity {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1s;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.8) 100%);
}
#low-sanity.active {
  opacity: 1;
  animation: sanity-warp 2s ease-in-out infinite;
}

/* 现实崩坏：画面撕裂重影 */
body.reality-break canvas,
body.reality-break .overlay {
  animation: reality-shatter 0.18s steps(2) infinite;
}
@keyframes reality-shatter {
  0% { transform: translate(0, 0) skewX(0deg) scale(1); filter: none; }
  25% { transform: translate(4px, -3px) skewX(4deg) scale(1.01); filter: hue-rotate(90deg) saturate(2); }
  50% { transform: translate(-4px, 2px) skewX(-5deg) scale(0.99); filter: invert(0.2) contrast(1.4); }
  75% { transform: translate(3px, 3px) skewX(3deg) scale(1.02); filter: hue-rotate(-60deg) blur(1px); }
  100% { transform: translate(0, 0) skewX(0deg) scale(1); filter: none; }
}
@keyframes sanity-warp {
  0%, 100% { transform: scale(1); filter: none; }
  25% { transform: scale(1.02); filter: hue-rotate(5deg) saturate(1.2); }
  50% { transform: scale(0.98); filter: hue-rotate(-5deg) saturate(0.8); }
  75% { transform: scale(1.01); filter: hue-rotate(3deg) saturate(1.1); }
}

/* 游戏内动态提示 */
#hint-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid rgba(178, 58, 58, 0.3);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  color: #e8ddd0;
  text-align: center;
  max-width: 500px;
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}
#hint-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
#hint-toast.hidden {
  display: block !important;
}

/* ---------- 响应式优化 ---------- */

input:checked + .toggle-slider {
  background: var(--accent);
}

input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: #fff;
}

/* ---------- 响应式优化 ---------- */
@media (max-width: 480px) {
  .overlay { padding: 16px; gap: 12px; }
  .title { font-size: 28px; letter-spacing: 0.3em; }
  .btn { padding: 10px 24px; font-size: 14px; }
  #hud-top-left { top: 12px; left: 12px; }
  #hud-top-right { top: 12px; right: 12px; }
  .panel { min-width: 280px; padding: 16px; }
  .minimap { width: 80px; height: 80px; bottom: 12px; right: 12px; }
  .achievement-popup { width: 300px; right: -350px; }
  .achievement-popup.show { right: 10px; }
  .quest-panel { min-width: 300px; max-height: 60vh; }
  #inventory-grid { grid-template-columns: repeat(3, 1fr); }
  .item .icon { font-size: 20px; }
  .item .name { font-size: 10px; }
}