/* ===== 基础变量与重置 ===== */
:root {
  --bg-dark: #0d0e10;
  --bg-panel: #16181c;
  --bg-panel-2: #1c1f24;
  --ink: #e8dcc4;
  --ink-dim: #9a8f7a;
  --red: #C53030;
  --red-soft: #8a2a2a;
  --gold: #C9A96E;
  --gold-soft: #8a7647;
  --border: rgba(201, 169, 110, 0.25);
  --glass: rgba(28, 31, 36, 0.65);
}

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

html, body {
  height: 100%;
  font-family: "PingFang SC", "Microsoft YaHei", "Songti SC", "STSong", serif;
  color: var(--ink);
  background: var(--bg-dark);
  overflow: hidden;
}

body {
  position: relative;
  min-height: 100vh;
}

/* ===== 宣纸纹理背景 ===== */
.paper-texture {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(201,169,110,0.04) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(197,48,48,0.03) 0%, transparent 45%),
    linear-gradient(180deg, #0d0e10 0%, #111317 100%);
}

.paper-texture::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.08;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255,255,255,0.02) 2px, rgba(255,255,255,0.02) 3px),
    repeating-linear-gradient(90deg, transparent, transparent 3px, rgba(0,0,0,0.03) 3px, rgba(0,0,0,0.03) 4px);
}

.ink-splash {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 600px 400px at 15% 90%, rgba(0,0,0,0.5) 0%, transparent 60%),
    radial-gradient(ellipse 500px 300px at 90% 10%, rgba(197,48,48,0.06) 0%, transparent 60%);
}

/* ===== 磨砂玻璃面板 ===== */
.glass-panel {
  background: var(--glass);
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.04);
}

/* ===== Modal 通用 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5,6,8,0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 20px;
}

.modal-overlay.hidden {
  display: none;
}

/* ===== 启动设置弹窗 ===== */
.setup-scroll {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 8px;
  padding: 0;
}

.scroll-header {
  position: relative;
  text-align: center;
  padding: 28px 24px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(197,48,48,0.08) 0%, transparent 100%);
}

.scroll-header h1 {
  font-size: 22px;
  letter-spacing: 4px;
  color: var(--gold);
  margin-top: 8px;
  font-weight: 600;
}

.scroll-header .subtitle {
  margin-top: 6px;
  color: var(--ink-dim);
  font-size: 13px;
  letter-spacing: 1px;
}

.seal {
  display: inline-block;
  width: 44px;
  height: 44px;
  line-height: 44px;
  border: 2px solid var(--red);
  color: var(--red);
  font-size: 22px;
  border-radius: 4px;
  background: rgba(197,48,48,0.1);
  transform: rotate(-3deg);
}

.setup-body {
  padding: 22px 24px 24px;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field-label {
  display: block;
  font-size: 13px;
  color: var(--gold);
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.field input {
  width: 100%;
  padding: 10px 12px;
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border);
  color: var(--ink);
  font-size: 14px;
  border-radius: 4px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

.field input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(201,169,110,0.15);
}

.field select {
  width: 100%;
  padding: 10px 12px;
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border);
  color: var(--ink);
  font-size: 14px;
  border-radius: 4px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
  cursor: pointer;
}

.field select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(201,169,110,0.15);
}

.field select option {
  background: var(--bg-panel);
  color: var(--ink);
}

/* 测试连接 */
.test-api-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 14px;
}

.test-api-row .ghost-btn {
  width: auto;
  margin: 0;
  flex-shrink: 0;
}

.test-api-status {
  font-size: 11.5px;
  color: var(--ink-dim);
  line-height: 1.5;
  word-break: break-all;
}

.test-api-status.test-ok {
  color: #7dd87d;
}

.field-hint {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--ink-dim);
}

/* ===== 性价比引导卡 ===== */
.cost-guide {
  margin: 18px 0;
  padding: 14px 16px;
  border: 1px solid var(--gold-soft);
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(201,169,110,0.08), rgba(197,48,48,0.04));
}

.cost-guide-title {
  font-size: 14px;
  color: var(--gold);
  margin-bottom: 8px;
  font-weight: 600;
}

.cost-list {
  list-style: none;
  font-size: 12px;
  color: var(--ink-dim);
  line-height: 1.8;
}

.cost-list li::before {
  content: "·";
  color: var(--red);
  margin-right: 6px;
  font-weight: bold;
}

.cost-list b {
  color: var(--ink);
}

.cost-tip {
  margin-top: 10px;
  padding: 8px 10px;
  font-size: 11.5px;
  color: var(--gold);
  background: rgba(201,169,110,0.06);
  border-left: 3px solid var(--gold);
  border-radius: 2px;
}

/* ===== 模型警告 ===== */
.model-warning {
  margin: 12px 0;
  padding: 10px 12px;
  font-size: 12px;
  color: #ffd76b;
  background: rgba(255,215,107,0.08);
  border: 1px solid rgba(255,215,107,0.4);
  border-radius: 4px;
}

.model-warning.hidden {
  display: none;
}

/* 需代理服务商的警示样式（区别于普通提示） */
.model-warning.hint-warn {
  color: #ff8f7a;
  background: rgba(255,107,87,0.1);
  border-color: rgba(255,107,87,0.5);
}

/* ===== 按钮 ===== */
.primary-btn {
  width: 100%;
  padding: 12px;
  margin-top: 8px;
  background: linear-gradient(180deg, var(--red) 0%, var(--red-soft) 100%);
  color: #fff;
  font-size: 15px;
  letter-spacing: 3px;
  border: 1px solid var(--red);
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(197,48,48,0.3);
}

.primary-btn:hover:not(:disabled) {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

.primary-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ghost-btn {
  width: 100%;
  margin-top: 10px;
  padding: 8px;
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold-soft);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: all 0.2s;
}

.ghost-btn:hover:not(:disabled) {
  background: rgba(201,169,110,0.1);
}

/* ===== §18.4 本地存档目录 ===== */
.save-dir-field {
  border-top: 1px dashed rgba(201,169,110,0.25);
  padding-top: 14px;
  margin-top: 6px;
}
.save-dir-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.save-dir-row .small-btn {
  flex: 1;
  width: auto;
  margin-top: 0;
  padding: 8px 10px;
  font-size: 12px;
  letter-spacing: 1px;
}
.save-dir-status {
  margin: 6px 0;
  font-size: 12px;
  line-height: 1.5;
}
.save-dir-status .dir-ok { color: #6fbf6f; }
.save-dir-status .dir-warn { color: #e0a84e; }
.save-dir-status .dir-default { color: var(--ink-dim); }

/* ===== 主界面三栏 ===== */
.game-root {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 260px 1fr 300px;
  gap: 14px;
  height: 100vh;
  padding: 14px;
}

.game-root.hidden {
  display: none;
}

.column {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
}

.column-title {
  font-size: 15px;
  color: var(--gold);
  letter-spacing: 2px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
  text-align: center;
}

.title-seal {
  display: inline-block;
  width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  border: 1px solid var(--red);
  color: var(--red);
  font-size: 12px;
  margin-right: 6px;
  border-radius: 2px;
  vertical-align: middle;
}

/* ===== 左栏 ===== */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}

.tab {
  flex: 1;
  padding: 6px 4px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  color: var(--ink-dim);
  font-size: 11px;
  cursor: pointer;
  border-radius: 3px;
  font-family: inherit;
  transition: all 0.2s;
}

.tab.active {
  background: rgba(197,48,48,0.2);
  border-color: var(--red);
  color: var(--ink);
}

.tab:hover:not(.active) {
  color: var(--ink);
}

.npc-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.npc-empty {
  padding: 20px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-dim);
  line-height: 1.8;
  border: 1px dashed var(--border);
  border-radius: 4px;
  font-style: italic;
}

.npc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.npc-item:hover {
  border-color: var(--gold);
  background: rgba(201,169,110,0.06);
}

.npc-item.dead {
  opacity: 0.4;
  filter: grayscale(0.7);
}

.npc-portrait-thumb {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--gold-soft);
  background: linear-gradient(135deg, #3a2a1a, #1a1a1a);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  font-size: 14px;
  font-weight: bold;
  flex-shrink: 0;
}

.npc-item-info {
  flex: 1;
  min-width: 0;
}

.npc-item-name {
  font-size: 13px;
  color: var(--ink);
}

.npc-item-title {
  font-size: 11px;
  color: var(--ink-dim);
  margin-top: 2px;
}

.right-column {
  /* 顶部留白，避开右上角「菜单/语言/帮助」工具栏（上移右列标题） */
  padding-top: 46px;
}

/* ===== 中栏 ===== */
.center-column {
  gap: 10px;
}

.year-bar-wrap {
  flex-shrink: 0;
}

.year-label {
  font-size: 14px;
  color: var(--gold);
  text-align: center;
  letter-spacing: 2px;
}

.year-label span {
  color: var(--red);
  font-size: 18px;
  font-weight: bold;
}

.year-bar {
  height: 6px;
  background: rgba(0,0,0,0.4);
  border-radius: 3px;
  margin: 6px 0;
  overflow: hidden;
}

.year-progress {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold-soft), var(--gold));
  border-radius: 3px;
  transition: width 0.6s ease;
}

.year-anchor {
  font-size: 10.5px;
  color: var(--ink-dim);
  text-align: center;
  letter-spacing: 0.5px;
}

.scroll-panel {
  flex: 1;
  position: relative;
  padding: 20px 24px;
  overflow-y: auto;
  border-radius: 6px;
  min-height: 0;
}

.scroll-deco {
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-soft), transparent);
  margin: 4px 0 12px;
}

.scroll-deco.bottom {
  margin: 12px 0 4px;
}

.story-text {
  font-size: 15px;
  line-height: 2;
  color: var(--ink);
  letter-spacing: 1px;
  text-indent: 2em;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 80px;
}

.typing-cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  background: var(--red);
  vertical-align: middle;
  margin-left: 2px;
  animation: blink 0.8s infinite;
}

.typing-cursor.hidden {
  display: none;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* ===== 上一回合回顾 ===== */
.last-turn {
  flex-shrink: 0;
  padding: 10px 12px;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  border-radius: 4px;
}

.last-turn-head {
  font-size: 12px;
  color: var(--gold);
  letter-spacing: 2px;
  margin-bottom: 6px;
}

.last-turn-row {
  display: flex;
  gap: 8px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-dim);
}

.last-turn-row + .last-turn-row {
  margin-top: 2px;
}

.lt-label {
  flex-shrink: 0;
  color: var(--red);
  letter-spacing: 1px;
}

.lt-action {
  color: var(--ink);
}

/* ===== 决策区 ===== */
.decision-panel {
  flex-shrink: 0;
  padding: 12px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.decision-title {
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.option-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.option-btn {
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  background: rgba(201,169,110,0.05);
  border: 1px solid var(--gold-soft);
  color: var(--ink);
  font-size: 13px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  line-height: 1.5;
}

.option-btn:hover:not(:disabled) {
  background: rgba(197,48,48,0.15);
  border-color: var(--red);
}

.option-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.custom-action {
  display: flex;
  gap: 6px;
}

.custom-action input {
  flex: 1;
  padding: 9px 12px;
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border);
  color: var(--ink);
  font-size: 13px;
  border-radius: 4px;
  outline: none;
  font-family: inherit;
}

.custom-action input:focus {
  border-color: var(--gold);
}

.custom-action .primary-btn {
  width: auto;
  padding: 9px 18px;
  margin-top: 0;
  letter-spacing: 1px;
  font-size: 13px;
}

/* ===== 右栏 ===== */
.stat-block {
  margin-bottom: 14px;
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.stat-name {
  width: 48px;
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 1px;
}

.stat-bar {
  flex: 1;
  height: 12px;
  background: rgba(0,0,0,0.4);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.stat-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold-soft), var(--gold));
  border-radius: 6px;
  transition: width 0.6s ease;
}

.stat-fill.warn {
  background: linear-gradient(90deg, var(--red-soft), var(--red));
}

.stat-val {
  width: 32px;
  text-align: right;
  font-size: 13px;
  color: var(--ink);
}

.cache-monitor {
  padding: 10px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 12px;
}

.cache-title {
  font-size: 12px;
  color: var(--gold);
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.cache-val {
  font-size: 11px;
  color: var(--ink-dim);
  margin-bottom: 4px;
  line-height: 1.5;
}

.history-log {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  font-size: 11.5px;
  color: var(--ink-dim);
  line-height: 1.6;
  padding-right: 4px;
}

.history-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 6px;
}

.history-toolbar .history-count {
  flex: 1;
  font-size: 11px;
  color: var(--ink-dim);
}

.history-toolbar .export-btn {
  width: auto;
  margin: 0;
  padding: 3px 10px;
  font-size: 11px;
}

.history-more-btn {
  width: 100%;
  margin-top: 6px;
  padding: 6px;
  background: rgba(201,169,110,0.08);
  border: 1px dashed var(--gold-soft);
  color: var(--ink-dim);
  font-size: 11.5px;
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}

.history-more-btn:hover {
  background: rgba(201,169,110,0.16);
  color: var(--ink);
}

.history-item {
  padding: 6px 8px;
  margin-bottom: 4px;
  background: rgba(0,0,0,0.2);
  border-left: 2px solid var(--gold-soft);
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.15s;
}

.history-item:hover {
  background: rgba(201,169,110,0.12);
  border-left-color: var(--gold);
}

.history-year {
  color: var(--red);
  margin-right: 4px;
}

/* ===== 往事留痕详情弹窗 ===== */
.history-detail {
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  padding: 24px;
  border-radius: 8px;
  overflow-y: auto;
  position: relative;
}

.history-detail-year {
  font-size: 15px;
  color: var(--gold);
  letter-spacing: 2px;
  margin-bottom: 12px;
  padding-right: 24px;
}

.history-detail-text {
  font-size: 13.5px;
  color: var(--ink);
  line-height: 1.9;
  white-space: pre-wrap;
}

/* ===== 暂歇菜单 ===== */
.pause-menu {
  width: 100%;
  max-width: 360px;
  padding: 26px;
  border-radius: 8px;
  text-align: center;
}

.pause-menu h2 {
  color: var(--gold);
  font-size: 20px;
  letter-spacing: 6px;
  margin-bottom: 8px;
}

.pause-subtitle {
  font-size: 12px;
  color: var(--ink-dim);
  margin-bottom: 18px;
}

.pause-menu .ghost-btn {
  margin-top: 10px;
}

/* ===== 页脚 ===== */
.footer-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--ink-dim);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.footer-btn:hover {
  color: var(--gold);
}

/* ===== 关于 / 隐私政策弹窗 ===== */
.legal-panel {
  width: 100%;
  max-width: 640px;
  height: 80vh;
  padding: 20px 24px 24px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  position: relative;
}

.legal-panel h2 {
  color: var(--gold);
  font-size: 17px;
  letter-spacing: 3px;
  margin-bottom: 12px;
  padding-right: 30px;
  flex-shrink: 0;
}

.legal-frame {
  flex: 1;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
}
.save-choice {
  width: 100%;
  max-width: 480px;
  padding: 0;
  border-radius: 8px;
  overflow: hidden;
}

.save-list {
  max-height: 260px;
  overflow-y: auto;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.save-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.save-item:hover {
  background: rgba(201,169,110,0.1);
  border-color: var(--gold-soft);
}

.save-item.save-over {
  opacity: 0.6;
  cursor: default;
}

.save-item-head {
  font-size: 12.5px;
  color: var(--gold);
  letter-spacing: 0.5px;
}

.save-over-tag {
  color: var(--red);
  font-size: 11px;
  margin-left: 4px;
}

.save-item-meta {
  font-size: 11px;
  color: var(--ink-dim);
  margin-top: 3px;
}

.save-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.save-act {
  padding: 4px 10px;
  font-size: 11.5px;
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
  background: rgba(201,169,110,0.12);
  border: 1px solid var(--gold-soft);
  color: var(--ink);
}

.save-act:hover {
  background: rgba(201,169,110,0.25);
}

.save-delete {
  background: rgba(197,48,48,0.15);
  border-color: var(--red-soft);
  color: #ffb3a7;
}

.save-delete:hover,
.save-delete-confirm {
  background: rgba(197,48,48,0.35);
}

.save-empty {
  padding: 18px;
  text-align: center;
  color: var(--ink-dim);
  font-size: 12.5px;
}

.save-choice-body {
  padding: 20px 24px 24px;
}

.save-choice-summary {
  font-size: 12.5px;
  color: var(--ink-dim);
  line-height: 1.7;
  padding: 10px 12px;
  margin-bottom: 14px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold-soft);
  border-radius: 4px;
}

.save-choice-hint {
  margin-top: 12px;
  font-size: 11.5px;
  color: var(--ink-dim);
  line-height: 1.6;
}

/* ===== 人物 Modal ===== */
.npc-scroll {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 24px;
  border-radius: 8px;
  text-align: center;
}

.close-btn {
  position: absolute;
  top: 10px;
  right: 14px;
  width: 30px;
  height: 30px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink-dim);
  font-size: 18px;
  cursor: pointer;
  border-radius: 4px;
  line-height: 1;
}

.close-btn:hover {
  color: var(--red);
  border-color: var(--red);
}

.npc-portrait-frame {
  width: 100px;
  height: 100px;
  margin: 0 auto 14px;
  border-radius: 50%;
  border: 3px solid var(--gold);
  padding: 4px;
  background: var(--bg-dark);
}

.npc-portrait {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(135deg, #3a2a1a, #1a1a1a);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  font-size: 32px;
  font-weight: bold;
}

.npc-scroll h2 {
  font-size: 22px;
  color: var(--gold);
  letter-spacing: 3px;
  margin-bottom: 4px;
}

.npc-title-text {
  font-size: 13px;
  color: var(--red);
  margin-bottom: 16px;
  letter-spacing: 1px;
}

.npc-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-dim);
  text-align: left;
}

.npc-meta span {
  color: var(--ink);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  padding: 14px 24px;
  background: rgba(197,48,48,0.95);
  color: #fff;
  font-size: 14px;
  border-radius: 4px;
  border: 1px solid var(--red);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  letter-spacing: 1px;
  max-width: 90vw;
  text-align: center;
}

.toast.hidden {
  display: none;
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.2);
}

::-webkit-scrollbar-thumb {
  background: var(--gold-soft);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gold);
}

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
  .game-root {
    grid-template-columns: 220px 1fr 260px;
  }
}

@media (max-width: 820px) {
  .game-root {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
  }
  html, body { overflow: auto; }
  .npc-list { max-height: 240px; }
  .scroll-panel { min-height: 240px; max-height: 400px; }
  .history-list { max-height: 200px; }
  .top-toolbar { top: 8px; right: 8px; }
  .tutorial-card { max-width: 92vw; }
}

/* ===== V2.5.0 新增：顶部工具栏 ===== */
.top-toolbar {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 200; /* 高于 modal-overlay(100)，保证启动弹窗阶段语言切换也可用 */
  display: flex;
  gap: 6px;
}

.tool-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(28, 31, 36, 0.85);
  border: 1px solid var(--gold-soft);
  color: var(--gold);
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  font-family: inherit;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.2s;
  letter-spacing: 0;
}

.tool-btn:hover {
  background: rgba(197, 48, 48, 0.4);
  border-color: var(--red);
  color: #fff;
}

/* ===== 语言切换下拉（§22 8 语言） ===== */
.lang-switch-wrap {
  position: relative;
}
.lang-menu {
  position: absolute;
  top: 42px;
  right: 0;
  z-index: 300;
  min-width: 150px;
  background: rgba(24, 20, 13, 0.97);
  border: 1px solid var(--gold-soft);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.lang-menu.hidden { display: none; }
.lang-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
}
.lang-opt:hover { background: rgba(201, 169, 110, 0.15); color: #fff; }
.lang-opt.active { background: rgba(201, 169, 110, 0.22); color: var(--gold); }
.lang-opt-code {
  font-size: 11px;
  color: var(--gold);
  opacity: 0.7;
  letter-spacing: 0.5px;
}

/* ===== 阶段氛围光（5 阶段不同色调，body 加 class="phase-xxx"） ===== */
body.phase-exile::after,
body.phase-military::after,
body.phase-lord::after,
body.phase-throne::after,
body.phase-empire::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0.5;
  transition: background 1.5s ease;
}

body.phase-exile::after {
  background:
    radial-gradient(ellipse 80% 50% at 50% 100%, rgba(120, 90, 50, 0.15) 0%, transparent 60%),
    radial-gradient(circle at 30% 20%, rgba(140, 100, 60, 0.08) 0%, transparent 50%);
}
body.phase-military::after {
  background:
    radial-gradient(ellipse 80% 50% at 50% 100%, rgba(197, 48, 48, 0.18) 0%, transparent 60%),
    radial-gradient(circle at 70% 20%, rgba(220, 80, 60, 0.10) 0%, transparent 50%);
}
body.phase-lord::after {
  background:
    radial-gradient(ellipse 80% 50% at 50% 100%, rgba(180, 130, 70, 0.18) 0%, transparent 60%),
    radial-gradient(circle at 50% 80%, rgba(201, 169, 110, 0.10) 0%, transparent 50%);
}
body.phase-throne::after {
  background:
    radial-gradient(ellipse 80% 50% at 50% 100%, rgba(201, 169, 110, 0.22) 0%, transparent 60%),
    radial-gradient(circle at 50% 30%, rgba(255, 215, 0, 0.10) 0%, transparent 50%);
}
body.phase-empire::after {
  background:
    radial-gradient(ellipse 80% 50% at 50% 100%, rgba(255, 215, 0, 0.20) 0%, transparent 60%),
    radial-gradient(circle at 50% 50%, rgba(255, 180, 80, 0.12) 0%, transparent 60%);
}

/* 阶段标签色调 */
.phase-tag {
  display: inline-block;
  padding: 2px 10px;
  border: 1px solid var(--red);
  border-radius: 3px;
  background: rgba(197, 48, 48, 0.15);
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 2px;
}

body.phase-exile .phase-tag { border-color: var(--gold-soft); background: rgba(138, 118, 71, 0.15); }
body.phase-military .phase-tag { border-color: var(--red); background: rgba(197, 48, 48, 0.2); }
body.phase-lord .phase-tag { border-color: var(--gold); background: rgba(201, 169, 110, 0.2); }
body.phase-throne .phase-tag { border-color: #ffd76b; background: rgba(255, 215, 107, 0.2); color: #ffd76b; }
body.phase-empire .phase-tag { border-color: #ffcc33; background: rgba(255, 204, 51, 0.25); color: #ffcc33; }

/* ===== 资源变化特效（§13.7 飘字 / 数字滚动 / 高亮闪烁） ===== */
.stat-row {
  position: relative;
  transition: background 0.3s;
}

.stat-row.highlight-gain {
  animation: highlightGain 0.8s ease-out;
}
.stat-row.highlight-loss {
  animation: highlightLoss 0.8s ease-out;
}

@keyframes highlightGain {
  0%   { background: rgba(34, 197, 94, 0); box-shadow: 0 0 0 0 rgba(201, 169, 110, 0); }
  20%  { background: rgba(34, 197, 94, 0.25); box-shadow: 0 0 12px 2px rgba(201, 169, 110, 0.6); }
  60%  { background: rgba(34, 197, 94, 0.15); box-shadow: 0 0 8px 1px rgba(201, 169, 110, 0.4); }
  100% { background: rgba(34, 197, 94, 0); box-shadow: 0 0 0 0 rgba(201, 169, 110, 0); }
}

@keyframes highlightLoss {
  0%   { background: rgba(239, 68, 68, 0); transform: translateX(0); }
  20%  { background: rgba(239, 68, 68, 0.3); transform: translateX(-2px); }
  40%  { background: rgba(239, 68, 68, 0.2); transform: translateX(2px); }
  60%  { background: rgba(239, 68, 68, 0.15); transform: translateX(-1px); }
  80%  { background: rgba(239, 68, 68, 0.08); transform: translateX(1px); }
  100% { background: rgba(239, 68, 68, 0); transform: translateX(0); }
}

.float-text {
  position: absolute;
  right: 36px;
  top: 50%;
  font-size: 14px;
  font-weight: bold;
  pointer-events: none;
  animation: floatUp 0.6s ease-out forwards;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  z-index: 5;
}
.float-text.positive { color: #22c55e; }
.float-text.negative { color: #ef4444; }

@keyframes floatUp {
  0%   { opacity: 0; transform: translateY(0); }
  20%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-30px); }
}

/* ===== 战斗印章（§13.7 全屏特效） ===== */
.battle-effect-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0) 70%);
  animation: battleOverlay 0.3s ease-out;
}

.battle-stamp {
  font-size: 96px;
  font-weight: 900;
  letter-spacing: 12px;
  border: 8px solid;
  padding: 30px 60px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.8);
}

.battle-stamp.victory {
  color: #ffd76b;
  border-color: #ffd76b;
  box-shadow: 0 0 80px rgba(255, 215, 107, 0.6), inset 0 0 30px rgba(255, 215, 107, 0.2);
  animation: stampIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), victoryShine 1.5s ease-out;
}

.battle-stamp.defeat {
  color: #ef4444;
  border-color: #ef4444;
  box-shadow: 0 0 60px rgba(239, 68, 68, 0.6), inset 0 0 30px rgba(239, 68, 68, 0.2);
  animation: stampIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), defeatShake 0.4s ease-in-out 0.2;
}

@keyframes battleOverlay {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes stampIn {
  0%   { opacity: 0; transform: scale(2.5) rotate(-15deg); }
  60%  { opacity: 1; transform: scale(0.95) rotate(-3deg); }
  100% { opacity: 1; transform: scale(1) rotate(-3deg); }
}

@keyframes victoryShine {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.4) drop-shadow(0 0 30px #ffd76b); }
}

@keyframes defeatShake {
  0%, 100% { transform: scale(1) rotate(-3deg) translateX(0); }
  25%      { transform: scale(1) rotate(-3deg) translateX(-8px); }
  75%      { transform: scale(1) rotate(-3deg) translateX(8px); }
}

/* ===== 策略选项气泡（§9.5） ===== */
.option-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  min-height: 52px;
  color: var(--gold);
  font-size: 14px;
  letter-spacing: 1px;
  border: 1px dashed rgba(201, 169, 110, 0.5);
  border-radius: 8px;
  background: rgba(201, 169, 110, 0.06);
  animation: loadingPulse 1.4s ease-in-out infinite;
}

.option-loading::before {
  content: '';
  width: 12px;
  height: 12px;
  border: 2px solid rgba(201, 169, 110, 0.35);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes loadingPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.option-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

.option-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(197, 48, 48, 0.3);
  border: 1px solid var(--red);
  color: var(--gold);
  font-size: 13px;
  font-weight: bold;
  flex-shrink: 0;
}

.option-btn:nth-child(1) .option-label { background: rgba(201, 169, 110, 0.3); border-color: var(--gold); }
.option-btn:nth-child(2) .option-label { background: rgba(197, 100, 48, 0.3); border-color: #c56430; }
.option-btn:nth-child(3) .option-label { background: rgba(197, 48, 48, 0.4); border-color: var(--red); }

.option-text {
  flex: 1;
  line-height: 1.5;
}

.option-bubble {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  width: max-content;
  max-width: 360px;
  padding: 8px 12px;
  background: rgba(15, 17, 20, 0.96);
  border: 1px solid var(--gold-soft);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
  font-size: 11.5px;
  color: var(--ink);
  line-height: 1.7;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 20;
}

.option-bubble.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.option-bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--gold-soft);
}

.bubble-row {
  margin: 2px 0;
}

.bubble-row b {
  color: var(--gold);
  margin-right: 4px;
}

/* ===== 重新生成按钮 ===== */
.reroll-btn {
  width: 100%;
  margin-bottom: 8px;
  padding: 8px;
  background: transparent;
  color: var(--ink-dim);
  border: 1px dashed var(--gold-soft);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: all 0.2s;
  letter-spacing: 1px;
}

.reroll-btn:hover:not(:disabled) {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(201, 169, 110, 0.05);
}

.reroll-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===== 新手引导遮罩 + 高亮（§17） ===== */
.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.tutorial-overlay.hidden { display: none; }

.tutorial-card {
  position: relative;
  max-width: 460px;
  width: 100%;
  padding: 24px 28px;
  border-radius: 8px;
  text-align: center;
  /* 实底暖色背景：保证文字清晰可读 */
  background: linear-gradient(180deg, #32250f, #241a0c);
  border: 1px solid var(--gold-soft);
  box-shadow: 0 10px 40px rgba(0,0,0,0.65), inset 0 1px 0 rgba(255,255,255,0.06);
  animation: tutorialCardIn 0.3s ease-out;
}

@keyframes tutorialCardIn {
  0%   { opacity: 0; transform: translateY(10px) scale(0.95); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.tutorial-text {
  font-size: 16px;
  font-weight: 500;
  color: #f4ead6;
  line-height: 1.85;
  margin-bottom: 18px;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

.tutorial-btns {
  display: flex;
  gap: 8px;
}

.tutorial-btns .ghost-btn,
.tutorial-btns .primary-btn {
  flex: 1;
  margin-top: 0;
}

.tutorial-highlight {
  position: relative;
  z-index: 510;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45), 0 0 0 2px var(--gold), 0 0 26px 6px var(--gold);
  border-radius: 6px;
  animation: tutorialPulse 1.4s ease-in-out infinite;
}

@keyframes tutorialPulse {
  0%, 100% { box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45), 0 0 0 2px var(--gold), 0 0 26px 6px var(--gold); }
  50%      { box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45), 0 0 0 2px var(--gold), 0 0 34px 10px var(--gold); }
}

/* ===== 性格四轴（NPC Modal） ===== */
.npc-personality {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 14px 0 8px;
}

.pers-tag {
  display: inline-block;
  padding: 4px 10px;
  font-size: 11.5px;
  color: var(--gold);
  background: rgba(201, 169, 110, 0.08);
  border: 1px solid var(--gold-soft);
  border-radius: 12px;
  letter-spacing: 0.5px;
}

/* ===== 结拜义字标记 ===== */
.sworn-mark {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10px;
  color: #ffd76b;
  background: rgba(255, 215, 107, 0.15);
  border: 1px solid #ffd76b;
  border-radius: 8px;
  vertical-align: middle;
}

.sworn-btn {
  margin-top: 16px;
}

/* ===== 帮助弹窗 ===== */
.help-scroll {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 26px 28px;
  border-radius: 8px;
}

.help-scroll h2 {
  font-size: 20px;
  color: var(--gold);
  letter-spacing: 4px;
  text-align: center;
  margin-bottom: 18px;
}

.help-content {
  font-size: 13px;
  color: var(--ink);
  line-height: 2;
  white-space: pre-wrap;
  font-family: inherit;
  letter-spacing: 0.5px;
}

/* ===== 战斗布阵面板 ===== */
.battle-scroll {
  position: relative;
  width: 100%;
  max-width: 560px;
  padding: 24px 26px 20px;
  border-radius: 8px;
}

.battle-scroll h2 {
  font-size: 20px;
  color: var(--gold);
  letter-spacing: 4px;
  text-align: center;
  margin-bottom: 8px;
}

.battle-hint {
  font-size: 12px;
  color: var(--ink-dim);
  text-align: center;
  margin-bottom: 16px;
  letter-spacing: 1px;
}

.formation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.formation-card {
  padding: 12px 8px;
  background: rgba(201, 169, 110, 0.05);
  border: 1px solid var(--gold-soft);
  color: var(--ink);
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
  letter-spacing: 1px;
  text-align: center;
}

.formation-card:hover {
  background: rgba(197, 48, 48, 0.15);
  border-color: var(--red);
  color: #fff;
}

.formation-card.selected {
  background: rgba(197, 48, 48, 0.3);
  border-color: var(--red);
  color: #fff;
  box-shadow: 0 0 12px rgba(197, 48, 48, 0.4);
}

/* ===== 结算弹窗 ===== */
.settle-scroll {
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 28px 26px;
  border-radius: 8px;
  text-align: center;
}

.settle-text {
  font-size: 14px;
  color: var(--ink);
  line-height: 2;
  margin-bottom: 18px;
  white-space: pre-wrap;
  letter-spacing: 0.5px;
}

/* ===== 死亡抉择弹窗 ===== */
.death-scroll {
  width: 100%;
  max-width: 480px;
  padding: 26px 24px;
  border-radius: 8px;
  text-align: center;
}

.death-scroll h2 {
  font-size: 22px;
  color: var(--red);
  letter-spacing: 6px;
  margin-bottom: 16px;
}

.death-inherit-list {
  margin: 14px 0;
  max-height: 200px;
  overflow-y: auto;
  font-size: 12.5px;
  color: var(--ink-dim);
}

.death-inherit-list .death-reason {
  font-size: 14px;
  color: var(--ink);
  line-height: 1.9;
  margin-bottom: 12px;
}

.death-inherit-list .death-stat {
  font-size: 12px;
  color: var(--gold);
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.death-inherit-list .death-epitaph {
  font-size: 12.5px;
  color: var(--ink-dim);
  line-height: 1.7;
  padding: 10px;
  background: rgba(201,169,110,0.08);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.death-inherit-list .inherit-item {
  padding: 8px;
  margin-bottom: 6px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.death-inherit-list .inherit-item:hover {
  border-color: var(--gold);
  background: rgba(201, 169, 110, 0.08);
}

.death-inherit-list .inherit-item.selected {
  border-color: var(--red);
  background: rgba(197, 48, 48, 0.2);
}

/* ===== 页脚 ===== */
.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 6px 12px;
  font-size: 11px;
  color: var(--ink-dim);
  background: rgba(13, 14, 16, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  letter-spacing: 1px;
}

.site-footer a {
  color: var(--gold-soft);
  text-decoration: none;
  transition: color 0.2s;
}

.site-footer a:hover {
  color: var(--gold);
}

/* ===== NPC Modal 缺失字段（生年/现年等） ===== */
.npc-meta > div {
  padding: 4px 0;
}

.npc-meta span {
  color: var(--ink);
  font-weight: 600;
}

/* ===== AdSense 占位（启用时显示） ===== */
.adsbygoogle {
  display: block;
  margin: 8px auto;
  min-height: 60px;
}

/* ===== 历史/性格演化日志（右栏往事留痕扩展） ===== */
.history-list .history-item .history-action {
  color: var(--ink);
  font-size: 11px;
}

/* ===== 启动设置弹窗标题修正 ===== */
.setup-scroll h1 {
  letter-spacing: 6px;
}

/* ===== 选项按钮 disabled 时透明 ===== */
.option-btn:disabled .option-label {
  opacity: 0.4;
}

/* ===== 触摸区域 ≥44px（§八 体验设计） ===== */
.tab,
.tool-btn,
.close-btn,
.formation-card {
  min-height: 36px;
}

.option-btn,
.reroll-btn,
.tutorial-btns button {
  min-height: 44px;
}
