/**
 * 《公司战争》终端 UI 主题层
 * 乳胶宇宙地下产业终端：哑光橡胶质感 + 拘束氛围，信息效率优先
 */
:root {
  /* —— 色彩：深墨蓝灰 · 哑光乳胶 —— */
  --bg-page: #0c1016;
  --bg-card: #141a22;
  --bg-elev: #1a222c;
  --border-subtle: #1c2633;
  --border-line: #2a3a4c;

  --text-primary: #d8dee6;
  --text-body: #8b96a5;
  --text-muted: #5c6775;

  /* 主色：深墨蓝（#1E3A5F 系），降饱和 */
  --accent-main: #1e3a5f;
  --accent-main-hi: #2a4f7a;
  --accent-main-soft: #3d5f8a;

  /* 生物溶剂墨绿 / 工业警示暗橘 */
  --color-ok: #1a5c45;
  --color-ok-hi: #247a5c;
  --color-warn: #b85a28;
  --color-warn-hi: #c96a36;
  --color-hot: #a8484c;
  --accent-locked: #6b4558;

  /* CRT 冷绿日志 */
  --log-ok: #3d7a62;
  --log-warn: #a88a5a;
  --log-hot: #a86064;

  --radius-card: 6px;
  --radius-btn: 4px;
  --radius-tag: 4px;
  --radius-bar: 5px;
  --radius-pill: 999px;

  --pad-card-y: 16px;
  --pad-card-x: 20px;
  --gap-module: 12px;
  --gap-group: 10px;
  --row-h: 28px;
  --ease-ui: 0.2s ease;

  /* 乳胶接缝：细描边 + 内柔边 */
  --shadow-card:
    inset 0 1px 0 rgba(180, 200, 220, 0.04),
    inset 0 0 0 1px rgba(30, 58, 95, 0.18);
  --glow-main: 0 0 0 1px rgba(30, 58, 95, 0.35);
  --glow-ok: 0 0 0 1px rgba(26, 92, 69, 0.4);
  --glow-soft: 0 0 0 1px rgba(30, 58, 95, 0.28);

  --font-ui: "Noto Sans SC", sans-serif;
  --font-mono: "Share Tech Mono", monospace;

  /* —— 兼容旧变量名 —— */
  --bg-deep: var(--bg-page);
  --bg-panel: var(--bg-card);
  --bg-elevated: var(--bg-elev);
  --border: var(--border-line);
  --border-glow: color-mix(in srgb, var(--accent-main-hi) 40%, var(--border-line));
  --text: var(--text-body);
  --text-dim: var(--text-muted);
  --text-bright: var(--text-primary);
  --accent: var(--accent-main-soft);
  --accent-ok: var(--color-ok-hi);
  --accent-warn: var(--color-warn);
  --accent-hot: var(--color-hot);
}

html,
body {
  height: 100%;
  background: var(--bg-page);
  color: var(--text-body);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
}

body {
  background-color: var(--bg-page);
  background-image:
    /* 极淡网格（再压淡） */
    linear-gradient(rgba(255, 255, 255, 0.012) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.01) 1px, transparent 1px),
    radial-gradient(ellipse 65% 40% at 12% 0%, rgba(30, 58, 95, 0.12), transparent 55%),
    radial-gradient(ellipse 45% 30% at 95% 100%, rgba(26, 92, 69, 0.05), transparent 50%);
  background-size: 44px 44px, 44px 44px, auto, auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* P2：极淡乳胶哑光细纹理（≤5%） */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.12 0 0 0 0 0.18 0 0 0 0 0.28 0 0 0 0.5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 160px 160px;
  mix-blend-mode: soft-light;
}

#title-gate,
#game {
  position: relative;
  z-index: 1;
}

#title-gate {
  width: 100%;
}

/* 自定义滚动条 */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-line) transparent;
}
*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
*::-webkit-scrollbar-thumb {
  background: var(--border-line);
  border-radius: 4px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}

#game {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 260px;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "header header header"
    "left scene side";
  width: min(100vw - 16px, calc((100vh - 16px) * 16 / 9));
  height: min(100vh - 16px, calc((100vw - 16px) * 9 / 16));
  max-width: 1600px;
  aspect-ratio: 16 / 9;
  margin: 8px auto;
  padding: 10px;
  gap: 10px;
  box-sizing: border-box;
  overflow: hidden;
}

#top-bar {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  border-left: 3px solid var(--accent-main-hi);
  box-shadow: var(--shadow-card);
  min-height: 0;
}

.left-panel {
  grid-area: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: hidden;
}

.left-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.left-sys {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px !important;
}

.left-sys .btn {
  width: 100%;
  text-align: center;
  padding: 7px 10px;
  font-size: 0.82rem;
}

/* P0：重置存档与「返回封面」拉开安全距离 */
.left-sys #btn-reset {
  margin-top: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.portrait-wrap {
  padding: 12px !important;
  text-align: center;
}

.portrait-frame {
  width: 160px;
  height: 160px;
  margin: 0 auto;
  border-radius: var(--radius-card);
  border: 3px solid #243446;
  background: #0a0e14;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  box-shadow:
    inset 0 0 0 1px rgba(30, 58, 95, 0.35),
    inset 0 2px 8px rgba(0, 0, 0, 0.55),
    inset 0 -1px 0 rgba(180, 200, 220, 0.06),
    0 0 0 1px rgba(20, 30, 42, 0.8);
  transition: border-color var(--ease-ui), box-shadow var(--ease-ui);
}

.portrait-frame:hover {
  border-color: var(--accent-main-hi);
  box-shadow:
    inset 0 0 0 1px rgba(42, 79, 122, 0.45),
    inset 0 2px 10px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(30, 58, 95, 0.5);
}

.portrait-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.portrait-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  background:
    linear-gradient(135deg, rgba(30, 58, 95, 0.15), transparent 50%),
    #0a0e14;
}

.portrait-actions {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 8px;
}

.portrait-actions .btn {
  font-size: 0.72rem;
  padding: 4px 8px;
}

.portrait-crop-stage {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.portrait-crop-canvas {
  width: 240px;
  height: 240px;
  max-width: 100%;
  border: 1px solid var(--border-line);
  border-radius: var(--radius-card);
  background: #0c0f14;
  cursor: grab;
  touch-action: none;
}

.portrait-crop-canvas:active {
  cursor: grabbing;
}

.portrait-crop-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

#char-panel {
  padding: 12px 14px !important;
}

#char-panel .stat-row,
#gear-panel .stat-row {
  min-height: var(--row-h);
  font-size: 0.82rem;
}

.brand {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  letter-spacing: 0.14em;
  color: var(--accent-main-soft);
  white-space: nowrap;
  font-weight: 600;
}

.top-info {
  flex: 1;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.top-stats {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-primary);
  white-space: nowrap;
}

#scene {
  grid-area: scene;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: transparent;
  border: none;
  padding: 0;
  min-height: 0;
  max-height: none;
  overflow: hidden;
}

.narrative {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  color: var(--text-body);
  padding: var(--pad-card-y) var(--pad-card-x);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.choices {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  flex: 0 0 auto;
  position: relative;
  z-index: 2;
  margin-top: 0;
  padding: var(--pad-card-y) var(--pad-card-x);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.choices.choices-explore {
  display: block;
  padding: 12px 14px;
}

/* 格子模式：左十字方向 + 右操作 */
.explore-controls {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px 16px;
  align-items: start;
  width: 100%;
}

.dir-pad {
  display: grid;
  grid-template-columns: 52px 52px 52px;
  grid-template-rows: 40px 40px 40px;
  gap: 4px;
  flex: 0 0 auto;
}

.dir-pad .dir-btn {
  padding: 0;
  min-width: 0;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.06em;
}

.dir-pad .dir-n { grid-column: 2; grid-row: 1; }
.dir-pad .dir-w { grid-column: 1; grid-row: 2; }
.dir-pad .dir-e { grid-column: 3; grid-row: 2; }
.dir-pad .dir-s { grid-column: 2; grid-row: 3; }

.dir-pad .dir-hub {
  grid-column: 2;
  grid-row: 2;
  border-radius: var(--radius-btn);
  border: 1px dashed var(--border-subtle);
  background: rgba(0, 0, 0, 0.25);
}

.explore-actions {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  min-width: 0;
}

.explore-actions .btn {
  font-size: 0.84rem;
  padding: 8px 12px;
}

.choice-sep {
  flex-basis: 100%;
  height: 0;
  margin: var(--gap-group) 0 2px;
  border-top: 1px solid var(--border-subtle);
  opacity: 0.9;
}

@media (max-width: 700px) {
  .explore-controls {
    grid-template-columns: 1fr;
  }
  .dir-pad {
    justify-self: center;
  }
}

/* —— 标题锚点 —— */
.narrative h1,
.narrative h2,
.panel h3,
.home-block > h2 {
  position: relative;
  font-weight: 600;
  color: var(--text-primary);
  padding-left: 11px;
  margin-bottom: 12px;
}

.narrative h1::before,
.narrative h2::before,
.panel h3::before,
.home-block > h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.15em;
  bottom: 0.15em;
  width: 3px;
  border-radius: 2px;
  background: var(--accent-main-hi);
}

.narrative h1 {
  font-size: 1.42rem;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 14px;
}

.narrative h2,
.home-block > h2 {
  font-size: 1.12rem;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.narrative > p {
  margin-bottom: 10px;
  color: var(--text-body);
}

/* 普通描述：略浅底，与对话行拉开色阶 */
.narrative > p:not(.hero-line):not(.assist-line):not(.alert):not(.success):not(.locked-status):not(.flavor) {
  padding: 2px 0;
  background: transparent;
}

.narrative .flavor {
  color: var(--text-muted);
  font-style: italic;
  border-left: 2px solid var(--border-line);
  padding-left: 12px;
  margin: 12px 0;
}

.narrative .alert {
  color: #c9a080;
  background: rgba(184, 90, 40, 0.1);
  padding: 10px 12px;
  border: 1px solid rgba(184, 90, 40, 0.28);
  border-radius: var(--radius-card);
  margin: 10px 0;
}

.narrative .success {
  color: #7aaf96;
  background: rgba(26, 92, 69, 0.12);
  padding: 10px 12px;
  border: 1px solid rgba(26, 92, 69, 0.32);
  border-radius: var(--radius-card);
  margin: 10px 0;
}

.narrative .locked-status {
  color: #e0a0c0;
  background: rgba(139, 74, 107, 0.15);
  padding: 10px 12px;
  border: 1px solid rgba(139, 74, 107, 0.4);
  border-radius: var(--radius-card);
  margin: 10px 0;
}

/* —— 安全屋分区卡片 —— */
.home-block {
  margin: 14px 0;
  padding: 14px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.home-block.home-story {
  background: color-mix(in srgb, var(--bg-elev) 80%, #0a0e14);
}

.home-overview {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin: 10px 0 4px;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--text-primary);
}

.home-overview .ov-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 72px;
}

.home-overview .ov-label {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-family: var(--font-ui);
}

.home-overview .ov-value {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

.home-overview .ov-value.money {
  color: #c4a86a;
}

/* —— 按钮系统 —— */
.btn {
  font-family: var(--font-ui);
  font-size: 0.88rem;
  padding: 9px 14px;
  background: transparent;
  color: var(--text-body);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition:
    background var(--ease-ui),
    border-color var(--ease-ui),
    color var(--ease-ui),
    box-shadow var(--ease-ui),
    filter var(--ease-ui),
    transform var(--ease-ui);
}

.btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--bg-elev) 88%, #fff 3%);
  border-color: var(--accent-main-hi);
  color: var(--text-primary);
  box-shadow: var(--glow-soft);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn.primary {
  border-color: var(--accent-main-hi);
  color: #8fa8c4;
}

.btn.primary:hover:not(:disabled) {
  background: rgba(30, 58, 95, 0.35);
  color: #d0dce8;
  box-shadow: var(--glow-main);
}

.btn.ok {
  background: var(--color-ok);
  border-color: #164a38;
  color: #d4e8df;
  font-weight: 600;
}

.btn.ok:hover:not(:disabled) {
  filter: brightness(1.1);
  box-shadow: var(--glow-ok);
  color: #eef6f2;
  background: var(--color-ok-hi);
}

.btn.danger {
  background: var(--color-warn);
  border-color: #8a421c;
  color: #f2e6dc;
  font-weight: 700;
}

.btn.danger:hover:not(:disabled) {
  filter: brightness(1.08);
  color: #fff8f2;
  background: var(--color-warn-hi);
  box-shadow: 0 0 0 1px rgba(184, 90, 40, 0.35);
}

.btn.warn {
  border-color: var(--color-warn);
  color: #c9956e;
}

.btn.warn:hover:not(:disabled) {
  background: rgba(184, 90, 40, 0.12);
  color: #e0b48a;
}

/* P1：场景入口 — 细描边+圆角，次要但仍可发现 */
.btn.scene {
  border: 1px solid var(--border-line);
  background: transparent;
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: var(--radius-btn);
}

.btn.scene:hover:not(:disabled) {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
  border-color: color-mix(in srgb, var(--border-line) 70%, var(--accent-main));
  box-shadow: var(--glow-soft);
}

/* —— 侧栏 —— */
.side-panel {
  grid-area: side;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: none;
  min-height: 0;
  overflow-y: auto;
}

#assistant-panel {
  border-left: 3px solid var(--accent-main-hi);
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: var(--pad-card-y) 16px;
  box-shadow: var(--shadow-card);
}

.panel h3 {
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: none;
  color: var(--text-primary);
  margin-bottom: 12px;
  font-family: var(--font-ui);
  font-weight: 600;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.panel-section {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.panel-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.panel-section-title {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-family: var(--font-mono);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: var(--row-h);
  margin-bottom: 0;
  padding: 0 2px;
  font-size: 0.88rem;
  gap: 10px;
  line-height: 1.2;
}

.stat-row .label {
  color: var(--text-muted);
  flex: 0 1 auto;
  min-width: 0;
}

.stat-row .value {
  font-family: var(--font-mono);
  color: var(--text-primary);
  text-align: right;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-highlight .value {
  font-size: 1.05rem;
  font-weight: 600;
  color: #c4a86a;
}

/* P1：进度条加粗 + 数值内嵌靠右 */
.bar-cap {
  display: flex;
  align-items: center;
  min-height: 20px;
  margin-top: 2px;
}

.bar-cap .label {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.bar {
  position: relative;
  height: 16px;
  background: #0a0e14;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-bar);
  margin: 2px 0 10px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.45);
}

.bar-fill {
  display: block;
  height: 100%;
  min-width: 0;
  border-radius: calc(var(--radius-bar) - 1px);
  /* 哑光乳胶填充：无高光渐变、无外发光 */
  background: #2a4568;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: width 0.3s ease;
}

.bar.hp .bar-fill {
  background: #6b4838;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.bar.xp .bar-fill {
  background: #1e4a3a;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.bar-val-in {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.85);
  pointer-events: none;
  z-index: 1;
  line-height: 1;
}

/* 兼容旧结构 .bar > span */
.bar > span:not(.bar-val-in):not(.bar-fill) {
  display: block;
  height: 100%;
  border-radius: calc(var(--radius-bar) - 1px);
  background: #2a4568;
  transition: width 0.3s ease;
}

.bar.hp > span:not(.bar-val-in):not(.bar-fill) {
  background: #6b4838;
}

.bar.xp > span:not(.bar-val-in):not(.bar-fill) {
  background: #1e4a3a;
}

.bar-row {
  display: none;
}

.inv-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  min-height: var(--row-h);
  padding: 0 6px;
  margin: 0 -4px;
  border-radius: var(--radius-btn);
  border-bottom: 1px solid transparent;
  color: var(--text-body);
  gap: 10px;
  transition: background var(--ease-ui), box-shadow var(--ease-ui);
}

.inv-item > span:first-child {
  color: var(--text-muted);
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inv-item .qty {
  font-family: var(--font-mono);
  color: var(--text-primary);
  text-align: right;
  flex: 0 0 auto;
}

.inv-item:hover {
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(30, 58, 95, 0.22);
}

/* —— 对话标签 —— */
.hero-line,
.assist-line {
  margin: 12px 0;
  padding: 10px 12px 12px;
  border-left: none;
  border-radius: var(--radius-card);
  background: rgba(12, 16, 22, 0.72);
  border: 1px solid rgba(30, 58, 95, 0.35);
  line-height: 1.65;
  color: var(--text-body);
}

.assist-line {
  background: rgba(10, 12, 16, 0.55);
  border-color: rgba(92, 103, 117, 0.28);
}

.hero-tag,
.assist-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  margin-right: 8px;
  margin-bottom: 2px;
  padding: 2px 8px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--accent-main-hi);
  color: #d8e4f0;
  vertical-align: 1px;
  font-weight: 500;
}

.assist-tag {
  background: var(--bg-elev);
  color: var(--text-body);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-tag);
}

.env-block {
  color: var(--text-body);
  margin: 10px 0;
  padding: 10px 12px;
  background: rgba(15, 18, 24, 0.45);
  border-radius: var(--radius-card);
  border: 1px solid var(--border-subtle);
}

.assistant-brief {
  background: var(--bg-elev);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 12px 14px;
  margin: 12px 0;
}

/* —— 任务列表 —— */
.mission-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 4px;
}

.mission-card {
  padding: 12px 14px 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  cursor: pointer;
  transition:
    background var(--ease-ui),
    border-color var(--ease-ui),
    box-shadow var(--ease-ui);
  position: relative;
  box-shadow: var(--shadow-card);
}

.mission-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 2px;
  border-radius: 2px;
  background: transparent;
  transition: background 0.2s ease;
}

.mission-card:hover,
.mission-card.selected {
  background: color-mix(in srgb, var(--bg-elev) 90%, #fff 2%);
  border-color: color-mix(in srgb, var(--accent-main-hi) 50%, var(--border-subtle));
  box-shadow: var(--glow-soft);
}

.mission-card:hover::before,
.mission-card.selected::before {
  background: var(--accent-main-hi);
}

.mission-card .diff {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  margin-right: 8px;
  padding: 2px 8px;
  border-radius: var(--radius-tag);
  color: #fff;
  vertical-align: middle;
}

.mission-card strong {
  color: var(--text-primary);
  font-weight: 600;
}

.mission-card .mission-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.45;
}

.diff-white {
  background: #6b7280;
  color: #fff !important;
}
.diff-green {
  background: #059669;
  color: #fff !important;
}
.diff-blue {
  background: #1e3a5f;
  color: #d0dce8 !important;
}
.diff-silver {
  background: #64748b;
  color: #fff !important;
}
.diff-gold {
  background: #d97706;
  color: #fff !important;
}
.diff-red {
  background: #dc2626;
  color: #fff !important;
}

/* —— 系统提示：固定贴在操作按钮正上方 —— */
#log-bar {
  flex: 0 0 auto;
  margin-top: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 8px 12px;
  max-height: 88px;
  overflow-y: auto;
  box-shadow: var(--shadow-card);
}

.system-log {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #4a6358;
  line-height: 1.45;
}

.system-log .line {
  margin: 2px 0;
}

.system-log .line.hot {
  color: var(--log-hot);
}
.system-log .line.ok {
  color: var(--log-ok);
}
.system-log .line.warn {
  color: var(--log-warn);
}

.map-view {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: 12px;
  overflow: auto;
  color: var(--text-muted);
  line-height: 1.4;
  flex: 0 1 auto;
  max-height: min(42vh, 360px);
  min-height: 0;
  box-shadow: var(--shadow-card);
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-line);
  border-radius: var(--radius-card);
  max-width: 480px;
  width: 100%;
  padding: 24px;
  box-shadow: var(--glow-main);
}

.fatigue-ok {
  color: var(--text-muted);
}
.fatigue-warn {
  color: #a88a5a;
}
.fatigue-hot {
  color: var(--accent-hot);
}

.keller-suit {
  margin-top: 8px;
  padding: 8px 10px;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--text-muted);
  border-left: 2px solid var(--accent-main-hi);
  background: rgba(0, 0, 0, 0.22);
  border-radius: 0 var(--radius-card) var(--radius-card) 0;
}

.keller-suit strong {
  color: var(--text-primary);
}

/* —— 公司战争关系图 —— */
.faction-war-map {
  margin: 12px 0 8px;
  padding: 16px 12px;
  background: rgba(10, 14, 20, 0.55);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.fwm-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 100%;
}

.fwm-mid {
  gap: 0;
  flex-wrap: nowrap;
  max-width: 100%;
}

.fwm-node {
  min-width: 72px;
  max-width: 110px;
  padding: 8px 10px;
  text-align: center;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border-line);
  background: var(--bg-elev);
  box-shadow: inset 0 1px 0 rgba(180, 200, 220, 0.04);
  line-height: 1.25;
}

.fwm-node .fwm-name {
  display: block;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.88rem;
  letter-spacing: 0.04em;
}

.fwm-node .fwm-val {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-body);
  margin-top: 2px;
}

.fwm-node .fwm-att {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  margin-top: 2px;
}

.fwm-player {
  min-width: 88px;
  border-color: var(--accent-main-hi);
  background: color-mix(in srgb, var(--bg-elev) 70%, var(--accent-main) 30%);
  box-shadow: var(--glow-soft);
}

.fwm-player .fwm-name {
  color: #c8d8e8;
}

.fwm-lin {
  border-style: dashed;
}

.fwm-vline {
  width: 2px;
  height: 18px;
  background: color-mix(in srgb, var(--border-line) 80%, var(--accent-main-hi));
  opacity: 0.75;
}

.fwm-vline-soft {
  opacity: 0.45;
  height: 14px;
  border-left: 1px dashed var(--border-line);
  width: 0;
  background: transparent;
}

.fwm-hline {
  width: 28px;
  height: 2px;
  flex: 0 0 28px;
  background: color-mix(in srgb, var(--border-line) 80%, var(--accent-main-hi));
  opacity: 0.75;
}

.fwm-node.att-trust {
  border-color: #2a6b52;
  background: rgba(26, 92, 69, 0.22);
}
.fwm-node.att-trust .fwm-att { color: #7aaf96; }

.fwm-node.att-coop {
  border-color: #3d5f8a;
  background: rgba(30, 58, 95, 0.28);
}
.fwm-node.att-coop .fwm-att { color: #8fa8c4; }

.fwm-node.att-neutral {
  border-color: var(--border-line);
}

.fwm-node.att-hostile {
  border-color: #8a5a32;
  background: rgba(184, 90, 40, 0.14);
}
.fwm-node.att-hostile .fwm-att { color: #c9956e; }

.fwm-node.att-war {
  border-color: #8a4044;
  background: rgba(168, 72, 76, 0.18);
}
.fwm-node.att-war .fwm-att { color: #c8888c; }

.fwm-legend {
  margin: 10px 0 2px;
  font-size: 0.82rem;
  text-align: center;
}

.fwm-hint {
  margin: 0 0 4px;
  font-size: 0.72rem;
  text-align: center;
  opacity: 0.85;
}

.fwm-detail-title {
  font-size: 0.95rem;
  margin: 14px 0 8px;
  color: var(--text-primary);
  padding-left: 11px;
  position: relative;
}

.fwm-detail-title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.15em;
  bottom: 0.15em;
  width: 3px;
  border-radius: 2px;
  background: var(--accent-main-hi);
}

.habit-row.faction-detail.att-trust .habit-pct { color: #7aaf96; }
.habit-row.faction-detail.att-coop .habit-pct { color: #8fa8c4; }
.habit-row.faction-detail.att-hostile .habit-pct { color: #c9956e; }
.habit-row.faction-detail.att-war .habit-pct { color: #c8888c; }

@media (max-width: 520px) {
  .fwm-node {
    min-width: 58px;
    padding: 6px 6px;
  }
  .fwm-hline {
    width: 12px;
    flex-basis: 12px;
  }
  .fwm-node .fwm-name {
    font-size: 0.78rem;
  }
}

/* —— 终局报告 / 密室战争档案 —— */
.end-report {
  margin: 0;
  padding: 4px 0 8px;
}

.end-report-head {
  text-align: center;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.end-report-kicker {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  color: var(--accent-main-soft);
  margin-bottom: 8px;
}

.end-report-head h2 {
  margin-bottom: 6px;
  border-bottom: none;
  padding-bottom: 0;
}

.end-report-meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
}

.end-report-epitaph {
  margin: 14px auto 18px;
  padding: 12px 16px;
  max-width: 36em;
  border: none;
  border-left: 3px solid var(--accent-main-hi);
  background: rgba(12, 16, 22, 0.65);
  border-radius: 0 var(--radius-card) var(--radius-card) 0;
  color: var(--text-primary);
  font-size: 1.02rem;
  line-height: 1.65;
  font-style: normal;
}

.end-report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  margin: 8px 0 16px;
}

.end-kv {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-btn);
  box-shadow: var(--shadow-card);
  min-width: 0;
}

.end-kv .k {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.end-kv .v {
  font-size: 0.9rem;
  color: var(--text-primary);
  word-break: break-word;
}

.end-kv-wide {
  grid-column: 1 / -1;
}

.end-kv-final {
  border-color: var(--accent-main-hi);
  background: color-mix(in srgb, var(--bg-elev) 75%, var(--accent-main) 25%);
}

.end-kv-final .v {
  font-weight: 600;
  color: #c8d8e8;
}

.end-report-map {
  margin: 0 0 12px;
}

.end-report-map .fwm-legend,
.end-report-map .fwm-hint {
  display: none;
}

.end-report-foot {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.end-report.is-preview .end-report-kicker {
  opacity: 0.7;
}

@media (max-width: 520px) {
  .end-report-grid {
    grid-template-columns: 1fr;
  }
}

/* —— 悬浮说明窗 —— */
.has-tip {
  cursor: help;
  border-bottom: 1px dotted rgba(156, 163, 175, 0.35);
}

.has-tip:hover,
.has-tip:focus-visible {
  color: var(--text-primary);
  border-bottom-color: var(--accent-main);
  outline: none;
}

.tip-chip {
  display: inline-block;
  margin: 1px 2px;
  padding: 1px 5px;
  border-radius: var(--radius-tag);
  background: rgba(30, 58, 95, 0.22);
  border: 1px solid rgba(42, 79, 122, 0.35);
  border-bottom-style: solid;
  font-size: 0.72rem;
  line-height: 1.35;
  white-space: nowrap;
}

/* —— 题材微图标（线性浅灰） —— */
.ico {
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  margin-right: 0.28em;
  vertical-align: -0.08em;
  background: currentColor;
  opacity: 0.55;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}

.ico-suit {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 2.5h6l1 3.5v7.5H4V6z'/%3E%3Cpath d='M5 6h6M6.5 2.5V1.5h3v1'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 2.5h6l1 3.5v7.5H4V6z'/%3E%3Cpath d='M5 6h6M6.5 2.5V1.5h3v1'/%3E%3C/svg%3E");
}

.ico-vial {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 1.5h4M7 1.5v4.2L4.5 13.5h7L9 5.7V1.5'/%3E%3Cpath d='M5.2 10h5.6'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 1.5h4M7 1.5v4.2L4.5 13.5h7L9 5.7V1.5'/%3E%3Cpath d='M5.2 10h5.6'/%3E%3C/svg%3E");
}

.ico-keycard {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='1.5' y='4' width='13' height='8' rx='1.2'/%3E%3Cpath d='M4 8h4M10.5 7.2h1.5v1.6H10.5z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='1.5' y='4' width='13' height='8' rx='1.2'/%3E%3Cpath d='M4 8h4M10.5 7.2h1.5v1.6H10.5z'/%3E%3C/svg%3E");
}

.ico-lock {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3.5' y='7' width='9' height='7' rx='1'/%3E%3Cpath d='M5.5 7V5a2.5 2.5 0 0 1 5 0v2'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3.5' y='7' width='9' height='7' rx='1'/%3E%3Cpath d='M5.5 7V5a2.5 2.5 0 0 1 5 0v2'/%3E%3C/svg%3E");
}

.skill-chip-wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.float-tip {
  position: fixed;
  z-index: 10000;
  max-width: min(320px, calc(100vw - 24px));
  padding: 10px 12px;
  background: #12161e;
  border: 1px solid var(--border-line);
  border-radius: var(--radius-card);
  box-shadow: var(--glow-soft), 0 8px 24px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-body);
}

.float-tip.hidden {
  display: none;
}

.float-tip-title {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-subtle);
}

.float-tip-body {
  white-space: pre-wrap;
  color: var(--text-body);
}

.keller-suit-tip {
  display: block;
  border-bottom: none;
}

.keller-suit-tip .keller-suit {
  margin-top: 0;
}

.inv-item.has-tip {
  border-bottom: 1px solid transparent;
}

.inv-item.has-tip:hover {
  border-bottom-color: transparent;
}

/* MOD 管理器 */
.mod-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 16px;
}
.mod-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.mod-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--seam, #3a4a5c) 80%, transparent);
  background: color-mix(in srgb, var(--panel, #121820) 92%, #000);
}
.mod-row.on {
  border-color: color-mix(in srgb, var(--ok, #4a7a5c) 55%, var(--seam, #3a4a5c));
}
.mod-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.mod-meta {
  font-size: 0.75rem;
  opacity: 0.7;
}
.mod-desc {
  font-size: 0.85rem;
  opacity: 0.9;
}

.mod-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: 4px;
}
.mod-compat-ok { font-size: 0.75rem; color: var(--color-ok-hi); }
.mod-compat-bad { font-size: 0.75rem; color: var(--color-hot); }
.mod-row-bad {
  border-color: color-mix(in srgb, var(--color-hot) 45%, var(--border-line));
}
.mod-report {
  margin: 10px 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--border-line);
  background: color-mix(in srgb, var(--bg-elev) 90%, #000);
  font-size: 0.85rem;
}
.mod-report.ok { border-color: color-mix(in srgb, var(--color-ok-hi) 50%, var(--border-line)); }
.mod-report.bad { border-color: color-mix(in srgb, var(--color-hot) 50%, var(--border-line)); }
.mod-err { color: var(--color-hot); margin-top: 4px; }
.mod-warn { color: var(--color-warn); margin-top: 4px; }
.mod-detail p { margin: 6px 0; }

.mod-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.mission-card.mod-mission {
  border-color: color-mix(in srgb, var(--accent-main-hi) 55%, var(--border-line));
}

.mod-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 5px;
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  vertical-align: middle;
  color: var(--text-primary);
  border: 1px solid color-mix(in srgb, var(--accent-main-hi) 60%, transparent);
  background: color-mix(in srgb, var(--accent-main) 35%, transparent);
}

.mission-tags {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.inv-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.inv-icon {
  width: 18px;
  height: 18px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid color-mix(in srgb, var(--border-line) 70%, transparent);
  background: color-mix(in srgb, var(--bg-elev) 90%, #000);
}

.shop-name {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.shop-icon {
  width: 28px;
  height: 28px;
  margin-top: 2px;
}

body.mod-has-page-bg {
  background-repeat: no-repeat;
  background-position: center;
}

@media (max-width: 900px) {
  #game {
    width: 100vw;
    height: auto;
    min-height: 100vh;
    aspect-ratio: auto;
    max-width: none;
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "left"
      "scene"
      "side";
    overflow: auto;
  }
  .left-panel {
    max-height: none;
  }
  .left-sys {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .left-sys .btn {
    width: auto;
    flex: 1 1 40%;
  }
  .top-stats {
    display: none;
  }
}

/* 密室档案 Codex */
.codex-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.codex-row {
  padding: 10px 12px;
  border: 1px solid var(--border-line);
  background: color-mix(in srgb, var(--bg-elev) 88%, #000);
  cursor: default;
}
.codex-row.open { cursor: pointer; border-color: color-mix(in srgb, var(--accent-main-hi) 50%, var(--border-line)); }
.codex-row.open:hover { border-color: var(--accent-main-hi); }
.codex-row.locked { opacity: 0.72; }
.codex-row.hidden-arc { opacity: 0.55; font-style: italic; }
.codex-code {
  display: inline-block;
  margin-right: 8px;
  font-size: 0.75rem;
  color: var(--accent-main-soft);
  font-family: var(--font-mono);
}
.codex-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }
.codex-teaser { font-size: 0.85rem; color: var(--text-body); margin-top: 4px; }
.codex-body p { margin: 0 0 10px; line-height: 1.7; }
.world-brief p { margin-bottom: 10px; }
