:root {
  --bg-dark: rgba(18, 22, 18, 0.78);
  --bg-panel: rgba(24, 31, 24, 0.92);
  --border-olive: rgba(168, 190, 152, 0.34);
  --accent-green: #5ea867;
  --accent-gold: #e9c46a;
  --accent-luo: #d97757;
  --accent-lei: #5fa8d3;
  --accent-zhang: #e9c46a;
  --accent-dong: #81b29a;
  --text-main: #f5f2eb;
  --text-muted: #b9c4b4;
}

* {
  box-sizing: border-box;
  user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #141814;
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

/* ==================== 第一人称游戏 HUD ==================== */
.hud-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.hud-box {
  background: rgba(16, 21, 16, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

/* 左上：地点与时间 */
.hud-location {
  position: absolute;
  top: 18px;
  left: 20px;
  padding: 10px 14px;
  min-width: 185px;
}

.hud-location .title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: #f6f4ee;
}

.hud-location .meta {
  margin-top: 3px;
  font-size: 12px;
  color: #cbd5c5;
  display: flex;
  gap: 10px;
}

/* 右上：王国订单追踪 */
.hud-quest {
  position: absolute;
  top: 18px;
  right: 20px;
  padding: 10px 14px;
  min-width: 224px;
}

.hud-quest .quest-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-gold);
  margin-bottom: 5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hud-quest .quest-row {
  font-size: 12.5px;
  color: #edf1ea;
  line-height: 1.55;
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.hud-quest .quest-bar {
  margin-top: 6px;
  height: 5px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 3px;
  overflow: hidden;
}

.hud-quest .quest-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #74b76e, #e9c46a);
  transition: width 0.5s ease;
}

/* 中心准星 */
.crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  opacity: 0.85;
}

.crosshair::before,
.crosshair::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.9);
}

.crosshair::before {
  left: 8px;
  top: 1px;
  width: 2px;
  height: 16px;
}

.crosshair::after {
  top: 8px;
  left: 1px;
  width: 16px;
  height: 2px;
}

/* 事件 / 交易 / 关系 / 意向 轻量弹窗（右上订单下方） */
.toast-stack {
  position: absolute;
  top: 132px;
  right: 20px;
  width: 318px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.game-toast {
  background: rgba(22, 32, 23, 0.92);
  border: 1px solid rgba(132, 184, 128, 0.52);
  border-left: 4px solid #78ba70;
  border-radius: 7px;
  padding: 11px 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  animation: toastIn 0.35s cubic-bezier(0.2, 0.85, 0.25, 1);
}

.game-toast.gold {
  border-left-color: #e9c46a;
  border-color: rgba(233, 196, 106, 0.58);
}

.game-toast.blue {
  border-left-color: #6bb2d9;
  border-color: rgba(107, 178, 217, 0.5);
}

.game-toast .toast-tag {
  font-size: 11px;
  color: #a9c4a3;
  letter-spacing: 0.6px;
  margin-bottom: 3px;
}

.game-toast .toast-title {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 5px;
}

.game-toast .toast-body {
  font-size: 12.5px;
  line-height: 1.5;
  color: #dde5da;
}

.toast-deltas {
  margin-top: 6px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.toast-delta {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  padding: 4px 6px;
  text-align: center;
  font-size: 12px;
}

.toast-delta .plus { color: #7ae582; font-weight: 700; }
.toast-delta .minus { color: #f28482; font-weight: 700; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(22px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ==================== 3D 人物头顶浮动标签与气泡 ==================== */
.overhead-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 12;
  overflow: hidden;
}

.npc-label {
  position: absolute;
  transform: translate(-50%, -100%);
  text-align: center;
  transition: opacity 0.2s ease;
  will-change: transform, left, top;
}

.npc-bubble {
  max-width: 280px;
  margin: 0 auto 6px;
  padding: 6px 10px;
  background: rgba(16, 20, 17, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  font-size: 12.5px;
  line-height: 1.45;
  color: #fff;
  text-align: left;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
}

.npc-nameplate {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  background: rgba(15, 19, 16, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.npc-nameplate .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.npc-nameplate .role-sub {
  font-weight: 400;
  font-size: 11px;
  color: #c2ccc0;
}

.npc-detail-card {
  margin: 4px auto 0;
  padding: 6px 9px;
  background: rgba(19, 25, 20, 0.86);
  border: 1px solid rgba(185, 205, 175, 0.28);
  border-radius: 5px;
  font-size: 11px;
  line-height: 1.45;
  color: #d8e1d5;
  text-align: left;
  min-width: 146px;
}

.npc-detail-card .muted { color: #9db09a; }

/* ==================== 底部字幕 + 血量 + 快捷物品栏 ==================== */
.bottom-hud {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.subtitle-bar {
  min-height: 44px;
  max-width: min(740px, 84vw);
  padding: 9px 18px;
  background: rgba(14, 18, 15, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.45;
  color: #fff;
  text-align: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

.subtitle-bar.visible {
  opacity: 1;
}

.subtitle-speaker {
  font-weight: 700;
  margin-right: 8px;
}

.vitals-row {
  width: 396px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2px;
  font-size: 14px;
  text-shadow: 0 1px 2px #000;
}

.hearts {
  letter-spacing: 1px;
  color: #e34a4a;
}

.hint-mini {
  font-size: 11.5px;
  color: rgba(240, 244, 236, 0.78);
  background: rgba(14, 18, 15, 0.56);
  padding: 2px 8px;
  border-radius: 4px;
}

.hotbar {
  display: grid;
  grid-template-columns: repeat(9, 42px);
  gap: 2px;
  padding: 3px;
  background: rgba(20, 22, 20, 0.82);
  border: 2px solid #484d48;
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.hotbar-slot {
  width: 42px;
  height: 42px;
  background: rgba(54, 58, 54, 0.72);
  border: 2px solid #2b2e2b;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.hotbar-slot.active {
  border-color: #f4f1e6;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.65);
  background: rgba(88, 94, 86, 0.85);
}

.hotbar-slot img {
  width: 26px;
  height: 26px;
  image-rendering: pixelated;
}

.hotbar-slot .slot-label {
  position: absolute;
  bottom: 1px;
  right: 3px;
  font-size: 9px;
  color: #d6dcd2;
  text-shadow: 0 1px 1px #000;
}

/* 左下角合规角标（文档第 9 页） */
.concept-watermark {
  position: fixed;
  left: 16px;
  bottom: 12px;
  z-index: 11;
  font-size: 11px;
  color: rgba(235, 240, 232, 0.68);
  background: rgba(14, 18, 15, 0.5);
  padding: 3px 8px;
  border-radius: 4px;
  pointer-events: none;
}

/* ==================== 第 4 幕公共聊天频道 (T 键) ==================== */
.chat-panel {
  position: fixed;
  left: 20px;
  bottom: 92px;
  width: min(460px, 44vw);
  background: rgba(16, 22, 17, 0.86);
  border: 1px solid rgba(154, 184, 148, 0.36);
  border-radius: 8px;
  padding: 10px 12px;
  z-index: 20;
  pointer-events: auto;
  display: none;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
}

.chat-panel.open {
  display: flex;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #9dc298;
  font-weight: 600;
}

.chat-log {
  max-height: 195px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  line-height: 1.48;
}

.chat-line {
  color: #f3f5f1;
}

.chat-line .tag {
  font-weight: 700;
  margin-right: 4px;
}

.chat-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chat-preset-btn {
  background: rgba(112, 156, 108, 0.22);
  border: 1px solid rgba(138, 186, 134, 0.4);
  color: #e6f2e4;
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 11.5px;
  cursor: pointer;
}

.chat-preset-btn:hover {
  background: rgba(112, 156, 108, 0.4);
}

.chat-input-row {
  display: flex;
  gap: 6px;
}

.chat-input-row input {
  flex: 1;
  background: rgba(8, 12, 9, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 5px;
  color: #fff;
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
  user-select: text;
}

.chat-input-row button {
  background: #4e8050;
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 0 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

/* ==================== 小镇实时状态面板 (O 键) ==================== */
.town-modal {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 9, 0.42);
  pointer-events: auto;
}

.town-modal.open {
  display: flex;
}

.town-card {
  width: min(820px, 90vw);
  max-height: 84vh;
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border-olive);
  border-radius: 12px;
  padding: 18px 22px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
}

.town-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding-bottom: 10px;
  margin-bottom: 14px;
}

.town-card-header h2 {
  margin: 0;
  font-size: 17px;
  color: var(--accent-gold);
}

.close-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  padding: 5px 11px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.panel-section {
  margin-bottom: 16px;
}

.panel-section h3 {
  margin: 0 0 8px;
  font-size: 13.5px;
  color: #b7d3b0;
  letter-spacing: 0.4px;
}

.warehouse-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.stock-tile {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}

.stock-tile .num {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
}

.stock-tile .lbl {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.npc-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.npc-panel-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left: 3px solid #888;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.5;
}

.npc-panel-card .head {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  margin-bottom: 4px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.data-table th, .data-table td {
  padding: 7px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  text-align: left;
}

.data-table th {
  background: rgba(74, 112, 72, 0.35);
  color: #e4f0e0;
}

.budget-warn {
  margin-top: 8px;
  font-size: 12.5px;
  color: #f4a261;
  font-weight: 600;
}

/* ==================== 结局黑卡（文档第 8 页） ==================== */
.ending-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(14, 21, 15, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.8s ease, background 1.8s ease;
}

.ending-overlay.visible {
  opacity: 1;
  background: rgba(14, 21, 15, 0.84);
  pointer-events: auto;
}

.ending-box {
  text-align: center;
  padding: 36px 48px;
  border: 1px solid rgba(164, 198, 154, 0.32);
  border-radius: 12px;
  background: rgba(20, 31, 21, 0.92);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.ending-box .brand {
  font-size: 12px;
  letter-spacing: 3px;
  color: #a2be9c;
  margin-bottom: 14px;
}

.ending-box h1 {
  margin: 0 0 14px;
  font-size: 30px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 1px;
}

.ending-box .pillars {
  font-size: 14px;
  color: #d6e3d2;
  letter-spacing: 1.5px;
  margin-bottom: 18px;
}

.ending-box .coming {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-gold);
  margin-bottom: 10px;
}

.ending-box .foot {
  font-size: 12px;
  color: #95a792;
}

/* ==================== 可一键隐藏的导播录屏控制条 (H 键) ==================== */
.director-bar {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(15, 20, 16, 0.92);
  border: 1px solid rgba(148, 186, 140, 0.4);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.director-bar.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -18px);
}

.d-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #f3f6f1;
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.d-btn:hover { background: rgba(255, 255, 255, 0.16); }
.d-btn.primary { background: #3f7a44; border-color: #6ab570; font-weight: 600; }
.d-btn.active { background: #60853b; border-color: #b4db87; }
.d-btn.rec { background: #9b2c2c; border-color: #f06e6e; font-weight: 700; }

.d-sep {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.16);
  margin: 0 2px;
}

.d-select {
  background: rgba(10, 14, 10, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #edf2eb;
  border-radius: 6px;
  padding: 4px 7px;
  font-size: 12px;
}

/* 设置弹窗（可选接本地 Qwen3-TTS 或实时 LLM） */
.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: auto;
}

.settings-modal.open { display: flex; }

.settings-card {
  width: min(500px, 92vw);
  background: var(--bg-panel);
  border: 1px solid var(--border-olive);
  border-radius: 12px;
  padding: 18px 20px;
}

.settings-card label {
  display: block;
  font-size: 12px;
  color: #c2d1be;
  margin: 10px 0 4px;
}

.settings-card input, .settings-card select {
  width: 100%;
  padding: 7px 10px;
  background: rgba(8, 12, 9, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  color: #fff;
  font-size: 12.5px;
  user-select: text;
}

/* 顶部轻微提示：按 H 唤出导播条 */
.director-peek {
  position: fixed;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 39;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 8px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.director-peek.visible {
  opacity: 1;
}
