/* ═══════════════════════════════════════════
   历史人生 · 古典水墨风
   ═══════════════════════════════════════════ */
:root {
  --paper: #f3e8d2;
  --paper-2: #ead9ba;
  --ink: #2b2118;
  --ink-soft: #5c4a36;
  --ink-faint: #8a7557;
  --cinnabar: #9e2b25;
  --cinnabar-dark: #7d1f1a;
  --gold: #b08d3f;
  --line: #c9b28c;
  --ok: #3f6b3a;
  --warn: #9e2b25;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Songti SC", "STSong", "SimSun", "Noto Serif SC", serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 20% 10%, rgba(176,141,63,.10), transparent 60%),
    radial-gradient(ellipse at 85% 90%, rgba(158,43,37,.08), transparent 55%),
    linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 100%);
  background-attachment: fixed;
  line-height: 1.75;
  font-size: 15px;
}

#app { max-width: 1280px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

/* ── 通用 ── */
.btn {
  font-family: inherit; font-size: 14px; color: var(--ink);
  background: rgba(255,252,243,.55); border: 1px solid var(--line);
  border-radius: 4px; padding: 8px 18px; cursor: pointer;
  transition: all .15s ease; letter-spacing: 1px;
}
.btn:hover { border-color: var(--gold); background: rgba(255,252,243,.9); }
.btn-primary { background: var(--cinnabar); border-color: var(--cinnabar); color: #f7ecd8; }
.btn-primary:hover { background: var(--cinnabar-dark); }
.btn-mini { padding: 3px 10px; font-size: 12px; border-radius: 3px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.screen { display: none; flex: 1; }
.screen.active { display: flex; flex-direction: column; }

/* ── 标题屏 ── */
#screen-title { align-items: center; justify-content: center; text-align: center; padding: 40px 20px; }
.title-inner { max-width: 640px; }
.seal {
  width: 64px; height: 64px; margin: 0 auto 18px; border-radius: 8px;
  background: var(--cinnabar); color: #f7ecd8; font-size: 38px; line-height: 64px;
  box-shadow: inset 0 0 0 3px rgba(247,236,216,.55); letter-spacing: 0;
}
.game-title { font-size: 52px; letter-spacing: 14px; margin-left: 14px; font-weight: 700; }
.game-sub { color: var(--ink-soft); letter-spacing: 4px; margin: 10px 0 26px; font-size: 16px; }
.game-desc { color: var(--ink-soft); font-size: 14px; line-height: 2; }
.title-actions { margin-top: 40px; display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.title-actions .btn { font-size: 16px; padding: 12px 30px; }
.title-foot { margin-top: 48px; color: var(--ink-faint); font-size: 13px; }

/* ── 顶栏 ── */
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 10px 18px;
  background: rgba(43,33,24,.88); color: #f3e8d2;
  border-bottom: 3px solid var(--gold); flex-wrap: wrap;
}
.topbar-title { font-size: 17px; letter-spacing: 3px; font-weight: 700; }
.topbar-clock { font-size: 13px; color: #dcc9a2; letter-spacing: 1px; flex: 1; text-align: center; }
.topbar-actions { display: flex; gap: 8px; }
.topbar-actions .btn-mini { background: transparent; color: #f3e8d2; border-color: #6d5c45; }
.topbar-actions .btn-mini:hover { border-color: var(--gold); }

/* ── 创建屏 ── */
.create-body { flex: 1; overflow-y: auto; padding: 26px 20px; max-width: 780px; margin: 0 auto; width: 100%; }
.create-footer {
  padding: 14px 20px; display: flex; justify-content: space-between;
  border-top: 1px solid var(--line); background: rgba(255,252,243,.4);
}
.field { margin-bottom: 22px; }
.field-label { font-size: 13px; color: var(--ink-faint); letter-spacing: 2px; margin-bottom: 8px; display: block; }
.option-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.option-card {
  border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; cursor: pointer;
  background: rgba(255,252,243,.5); transition: all .15s;
}
.option-card:hover { border-color: var(--gold); }
.option-card.sel { border-color: var(--cinnabar); background: rgba(158,43,37,.08); box-shadow: inset 0 0 0 1px var(--cinnabar); }
.option-card .oc-name { font-weight: 700; }
.option-card .oc-desc { font-size: 12px; color: var(--ink-soft); margin-top: 4px; line-height: 1.6; }
.text-input {
  width: 100%; font-family: inherit; font-size: 15px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 6px; background: rgba(255,252,243,.7); color: var(--ink);
}
.text-input:focus { outline: none; border-color: var(--gold); }
.era-card { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.era-card .oc-years { font-size: 12px; color: var(--ink-faint); white-space: nowrap; }
.mode-hint { font-size: 13px; color: var(--ink-soft); margin-top: 10px; padding: 10px 14px; border-left: 3px solid var(--gold); background: rgba(176,141,63,.08); }

/* ── 游戏主布局 ── */
.game-layout { flex: 1; display: grid; grid-template-columns: 1fr 360px; gap: 14px; padding: 14px; min-height: 0; }
.narrative {
  border: 1px solid var(--line); border-radius: 6px; background: rgba(255,252,243,.55);
  padding: 18px 20px; overflow-y: auto; min-height: 320px; max-height: calc(100vh - 120px);
}
.log-entry { margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px dashed var(--line); animation: fadein .3s ease; }
.log-entry:last-child { border-bottom: none; }
.log-date { font-size: 12px; color: var(--ink-faint); letter-spacing: 1px; margin-bottom: 2px; }
.log-title { font-weight: 700; color: var(--cinnabar); margin-bottom: 4px; }
.log-text { font-size: 14px; white-space: pre-wrap; }
.log-text .hl { color: var(--cinnabar); font-weight: 700; }
.log-text .hl-gold { color: var(--gold); font-weight: 700; }
.log-text .hl-green { color: var(--ok); font-weight: 700; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

.side { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; max-height: calc(100vh - 120px); }
.panel { border: 1px solid var(--line); border-radius: 6px; background: rgba(255,252,243,.6); }
.panel-title {
  font-size: 13px; letter-spacing: 3px; padding: 8px 14px; margin: 0;
  background: linear-gradient(90deg, rgba(43,33,24,.9), rgba(43,33,24,.75));
  color: #f3e8d2; border-radius: 6px 6px 0 0; border-bottom: 2px solid var(--gold);
}
.panel-body { padding: 10px 14px; font-size: 13px; }
.kv { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; border-bottom: 1px dotted rgba(201,178,140,.5); }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--ink-soft); }
.kv .v { font-weight: 700; text-align: right; }
.bar { height: 6px; background: rgba(43,33,24,.12); border-radius: 3px; margin: 3px 0 6px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--cinnabar), var(--gold)); }
.bar i.good { background: linear-gradient(90deg, #3f6b3a, #7aa25c); }
.bar i.low { background: linear-gradient(90deg, var(--warn), #d46a5a); }
.world-item { padding: 5px 0; border-bottom: 1px dotted rgba(201,178,140,.5); }
.world-item:last-child { border-bottom: none; }
.world-item .wi-tag { font-size: 11px; color: var(--cinnabar); }
.world-item .wi-text { font-size: 12.5px; color: var(--ink-soft); }
.map-line { padding: 2px 0; font-size: 12.5px; }
.map-line b { color: var(--ink); }

.action-list { display: flex; flex-direction: column; gap: 8px; }
.action-btn {
  text-align: left; font-family: inherit; font-size: 13.5px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 5px; cursor: pointer;
  background: rgba(255,252,243,.7); color: var(--ink); transition: all .15s;
}
.action-btn:hover { border-color: var(--cinnabar); background: rgba(158,43,37,.06); transform: translateX(2px); }
.action-btn .ab-desc { display: block; font-size: 11.5px; color: var(--ink-faint); margin-top: 2px; }
.free-input { display: flex; gap: 8px; margin-top: 4px; }
.free-input input { flex: 1; }

/* ── 事件弹层 ── */
.modal {
  position: fixed; inset: 0; background: rgba(30,22,12,.55);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal.hidden { display: none; }
.modal-card {
  background: linear-gradient(180deg, var(--paper), var(--paper-2));
  border: 1px solid var(--gold); border-radius: 8px; max-width: 620px; width: 100%;
  padding: 24px 28px; box-shadow: 0 12px 40px rgba(0,0,0,.35);
  max-height: 82vh; overflow-y: auto;
}
.event-title { color: var(--cinnabar); letter-spacing: 2px; font-size: 20px; border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 12px; }
.event-text { font-size: 14.5px; line-height: 2; white-space: pre-wrap; margin-bottom: 16px; }
.event-options { display: flex; flex-direction: column; gap: 8px; }
.opt-btn {
  text-align: left; font-family: inherit; font-size: 14px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 5px; cursor: pointer;
  background: rgba(255,252,243,.8); transition: all .15s;
}
.opt-btn:hover { border-color: var(--cinnabar); background: rgba(158,43,37,.08); }
.opt-btn .ob-hint { display: block; font-size: 12px; color: var(--ink-faint); margin-top: 2px; }

/* ── 结局屏 ── */
.dead-body { flex: 1; overflow-y: auto; padding: 30px 20px; max-width: 760px; margin: 0 auto; width: 100%; }
.dead-head { text-align: center; margin-bottom: 26px; }
.dead-head h2 { font-size: 30px; letter-spacing: 8px; margin-left: 8px; color: var(--cinnabar); }
.dead-epitaph { font-size: 14px; color: var(--ink-soft); margin-top: 8px; line-height: 2; }
.dead-section { margin-bottom: 22px; }
.dead-section h3 { font-size: 14px; letter-spacing: 3px; color: var(--gold); border-left: 3px solid var(--gold); padding-left: 10px; margin-bottom: 10px; }
.dead-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px; }
.dead-timeline { font-size: 13px; color: var(--ink-soft); }
.dead-timeline .dt-item { padding: 2px 0; }
.dead-actions { display: flex; gap: 14px; justify-content: center; margin-top: 28px; flex-wrap: wrap; }

/* ── 响应式 ── */
@media (max-width: 900px) {
  .game-layout { grid-template-columns: 1fr; }
  .narrative, .side { max-height: none; }
  .side { order: 2; }
  .game-title { font-size: 38px; letter-spacing: 8px; }
}
