/* =========================================================
   春秋人生・古风样式（消息流版）
   ========================================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --paper:       #efe2c2;
  --paper-deep:  #d9c598;
  --paper-light: #f5ecd1;
  --ink:         #2a1f12;
  --ink-2:       #5a4326;
  --vermilion:   #a82e2e;
  --vermilion-d: #7a1f1f;
  --gold:        #b88a3a;
  --gold-d:      #856232;
  --bamboo:      #6e8c52;
  --moss:        #4d6b3a;
  --line:        #856e51;
  --line-light:  #cba87a;
  --shadow:      rgba(80,50,20,0.25);
}

html, body {
  height: 100%;
  background:
    repeating-linear-gradient(0deg, transparent 0px, transparent 26px, rgba(133,110,81,0.05) 26px, rgba(133,110,81,0.05) 27px),
    radial-gradient(ellipse at top, #f0e0bc 0%, #d6bf8a 100%);
  color: var(--ink);
  font-family: 'STKaiti','Kaiti SC','楷体','KaiTi','Songti SC','SimSun', serif;
  font-size: 16px;
  line-height: 1.7;
}

/* ===== 顶部全局栏（只放语言切换；游戏中隐藏） ===== */
.topbar {
  position: fixed;
  top: 8px;
  right: 12px;
  z-index: 100;
  display: flex;
  gap: 8px;
}
.topbar-l { display: none; }
body.in-game .topbar { display: none; }
.lang-btn {
  background: var(--vermilion);
  color: var(--paper-light);
  border: 1px solid var(--gold);
  padding: 4px 12px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  border-radius: 2px;
  letter-spacing: 2px;
  box-shadow: 0 2px 6px var(--shadow);
}
.lang-btn:hover { background: var(--vermilion-d); }

/* ===== 开局界面 ===== */
.scroll {
  max-width: 920px;
  margin: 32px auto;
  padding: 36px 56px;
  background: var(--paper);
  border: 2px solid var(--gold-d);
  border-radius: 4px;
  box-shadow:
    inset 0 0 30px rgba(120,80,40,0.18),
    0 4px 16px var(--shadow);
  position: relative;
}
.scroll::before, .scroll::after {
  content: ''; position: absolute; left: 0; right: 0; height: 16px;
  background: linear-gradient(180deg, #7a4a28 0%, #5a3018 100%);
  border-top: 1px solid var(--gold);
  border-bottom: 1px solid var(--gold);
}
.scroll::before { top: -16px; }
.scroll::after { bottom: -16px; }

.title-block { text-align: center; margin-bottom: 28px; }
.game-title {
  font-size: 56px;
  letter-spacing: 16px;
  color: var(--vermilion-d);
  font-weight: 900;
  text-shadow: 2px 2px 0 var(--paper-deep);
  margin-bottom: 8px;
}
.subtitle { color: var(--ink-2); font-size: 14px; letter-spacing: 2px; }

.ai-status {
  display: inline-block;
  margin-top: 14px;
  padding: 4px 14px;
  font-size: 13px;
  border-radius: 14px;
  letter-spacing: 1px;
}
.ai-status.ai-on  { background: #d8e8c8; color: var(--moss); border: 1px solid var(--moss); }
.ai-status.ai-off { background: #f0d8d0; color: var(--vermilion-d); border: 1px solid var(--vermilion); }
.ai-status.ai-pending { background: #ece4cc; color: var(--ink-2); border: 1px solid var(--gold); font-style: italic; }
.ai-row { margin-top: 10px; }
.ai-btn {
  background: var(--gold);
  color: var(--paper-light);
  border: 1px solid var(--gold-d);
  padding: 6px 18px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  letter-spacing: 2px;
  border-radius: 2px;
}
.ai-btn:hover { background: var(--gold-d); }

.mode-select h2, .scroll h2 {
  text-align: center;
  font-size: 22px;
  color: var(--ink-2);
  margin-bottom: 20px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line-light);
  letter-spacing: 4px;
}
.mode-grid, .klass-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.mode-card, .klass-card, .hist-card {
  display: block;
  width: 100%;
  background: var(--paper-light);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 16px 18px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  color: inherit;
}
.mode-card:hover, .klass-card:hover, .hist-card:hover {
  border-color: var(--vermilion);
  background: #fbf3dc;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px var(--shadow);
}
.mode-name, .klass-name {
  font-size: 20px;
  color: var(--vermilion-d);
  font-weight: bold;
  margin-bottom: 6px;
  letter-spacing: 3px;
}
.mode-desc, .klass-desc, .hist-bg {
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.6;
}
.hist-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 6px;
}
.hist-name { font-size: 17px; color: var(--vermilion-d); font-weight: bold; margin-bottom: 4px; }
.hist-meta { font-size: 13px; color: var(--ink-2); font-weight: normal; margin-left: 10px; }
.hist-empty { color: var(--ink-2); font-style: italic; padding: 20px; text-align: center; }

/* ===== 年代选择 ===== */
.era-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.era-card {
  background: var(--paper-light);
  border: 1px solid var(--line);
  padding: 16px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  color: inherit;
  border-radius: 2px;
}
.era-card:hover {
  border-color: var(--vermilion);
  background: #fbf3dc;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px var(--shadow);
}
.era-icon {
  font-size: 38px;
  text-align: center;
  color: var(--vermilion-d);
  margin-bottom: 4px;
  font-weight: bold;
  letter-spacing: 4px;
}
.era-name {
  font-size: 18px;
  color: var(--vermilion-d);
  text-align: center;
  font-weight: bold;
  letter-spacing: 6px;
  margin-bottom: 4px;
}
.era-period {
  font-size: 12px;
  color: var(--ink-2);
  text-align: center;
  letter-spacing: 1px;
  margin-bottom: 8px;
  font-style: italic;
}
.era-desc {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.6;
  border-top: 1px dashed var(--line-light);
  padding-top: 6px;
  margin-bottom: 6px;
}
.era-sig {
  font-size: 12px;
  color: var(--gold-d);
  letter-spacing: 1px;
}

.back {
  margin-top: 20px;
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--line);
  padding: 6px 18px;
  font-family: inherit;
  cursor: pointer;
}
.back:hover { color: var(--vermilion); border-color: var(--vermilion); }

/* ===== AI 配置 ===== */
.ai-cfg { padding: 0 0 16px; }
.ai-warn {
  background: #f5e8c2;
  border-left: 3px solid var(--gold);
  padding: 10px 14px;
  margin-bottom: 18px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-2);
}
.form-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
.form-row label { color: var(--ink-2); font-weight: bold; letter-spacing: 2px; }
.form-row input, .form-row select {
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: var(--paper-light);
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  width: 100%;
}
.form-row small {
  grid-column: 2;
  font-size: 12px;
  color: var(--ink-2);
  margin-top: 4px;
}
.form-row small a { color: var(--vermilion-d); }
.ai-actions { margin-top: 18px; display: flex; gap: 10px; }
.ai-test-result {
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--paper-light);
  border: 1px dashed var(--line);
  font-size: 13px;
  color: var(--ink-2);
  white-space: pre-wrap;
  min-height: 24px;
}

/* ===== 游戏主布局 ===== */
.game-layout {
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.top-strip {
  background: linear-gradient(180deg, #5a3622 0%, #4a2a18 100%);
  color: var(--paper-light);
  padding: 8px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 2px solid var(--gold);
  flex-shrink: 0;
}
.ts-title { font-size: 18px; letter-spacing: 3px; color: var(--gold); font-weight: bold; }
.ts-meta { flex: 1; font-size: 13px; color: var(--paper); opacity: 0.85; letter-spacing: 1px; }
.ts-actions { display: flex; gap: 4px; }
.ts-btn,
.ts-lang-btn {
  background: rgba(255,255,255,0.08);
  color: var(--paper-light);
  border: 1px solid var(--gold);
  padding: 4px 12px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  letter-spacing: 1px;
  border-radius: 2px;
}
.ts-btn:hover,
.ts-lang-btn:hover { background: var(--vermilion); border-color: var(--vermilion); }
/* 文/白 视觉上做为独立永久按钮，跟其他菜单按钮区分 */
.ts-lang-btn {
  background: rgba(184,138,58,0.22);
  font-weight: bold;
  letter-spacing: 2px;
  white-space: nowrap;
}

.game-body {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr) 320px;
  gap: 0;
  overflow: hidden;
}
.profile-pane {
  background: var(--paper);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  transition: max-width 0.25s, padding 0.25s;
}
.profile-pane.open { max-width: 320px; padding: 14px 18px; width: 320px; }
.profile-pane.closed { max-width: 0; padding: 0; width: 0; border-right: none; }
.side-pane {
  background: var(--paper);
  border-left: 1px solid var(--line);
  padding: 14px 16px;
  overflow-y: auto;
}

/* ===== 消息流 ===== */
.stream-pane {
  background:
    repeating-linear-gradient(0deg, transparent 0px, transparent 32px, rgba(133,110,81,0.04) 32px, rgba(133,110,81,0.04) 33px),
    var(--paper-light);
  overflow-y: auto;
  padding: 24px 36px;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
}
.stream-pane:hover { background-color: #f7eed3; }
.stream-list { flex: 1; }

.stream-node {
  margin-bottom: 14px;
  padding: 10px 14px 10px 16px;
  border-left: 3px solid transparent;
  animation: fadeIn 0.4s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.sn-yr {
  display: inline-block;
  font-size: 12px;
  color: var(--vermilion-d);
  font-weight: bold;
  margin-right: 8px;
  letter-spacing: 1px;
}
.sn-src {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 8px;
  margin-right: 6px;
  letter-spacing: 1px;
}
.sn-src.sn-claude { background: #e8d6e8; color: #6b3866; }
.sn-src.sn-deepseek { background: #d8e8f0; color: #345670; }
.sn-src.sn-trigger { background: #f0e0c0; color: #7a5824; }
.sn-src.sn-local  { background: #e2dcc8; color: #6e6440; }

.ts-chain {
  background: rgba(184,138,58,0.3);
  padding: 1px 8px;
  border-radius: 8px;
  color: var(--gold);
  font-style: italic;
}
.sn-text {
  font-size: 17px;
  line-height: 1.85;
  color: var(--ink);
  text-indent: 2em;
}

.sn-flavor {
  border-left-color: var(--bamboo);
  opacity: 0.85;
}
.sn-flavor .sn-text { font-style: italic; color: var(--ink-2); font-size: 15px; }

.sn-narrate { border-left-color: var(--line); }

.sn-world {
  border-left-color: var(--gold);
  background: rgba(184,138,58,0.08);
  padding: 10px 14px;
}
.sn-world .sn-text { font-weight: 500; }

.sn-choice { border-left-color: var(--vermilion); background: rgba(168,46,46,0.06); }
.sn-pending {
  margin-top: 8px;
  font-size: 14px;
  color: var(--vermilion-d);
  letter-spacing: 2px;
  font-style: italic;
  text-align: right;
}
.sn-choice-made {
  margin-top: 6px;
  font-size: 14px;
  color: var(--vermilion-d);
  padding-left: 1em;
}
.sn-outcome {
  margin-top: 4px;
  font-size: 14px;
  color: var(--ink-2);
  padding-left: 1em;
  font-style: italic;
}
.stream-node.consumed { opacity: 0.85; }

/* 推进提示 */
.advance-hint {
  text-align: center;
  margin: 24px 0 12px;
  color: var(--ink-2);
  font-size: 13px;
  letter-spacing: 4px;
  opacity: 0.6;
  font-style: italic;
  user-select: none;
}
@keyframes pulse { 0%,100%{opacity:0.3;} 50%{opacity:1;} }

/* 流尾加载提示（醒目，紧跟最后一条事件） */
.stream-loading {
  margin: 16px 0 12px;
  padding: 14px 22px;
  background: linear-gradient(90deg, rgba(168,46,46,0.08) 0%, rgba(184,138,58,0.12) 100%);
  border-left: 4px solid var(--vermilion);
  border-radius: 2px;
  display: flex;
  align-items: center;
  gap: 14px;
  animation: slide-in 0.3s ease-out;
}
@keyframes slide-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.loading-dots {
  display: inline-flex;
  gap: 4px;
}
.loading-dots span {
  width: 8px; height: 8px;
  background: var(--vermilion);
  border-radius: 50%;
  animation: dot-bounce 1.2s infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-bounce {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}
.loading-text {
  color: var(--vermilion-d);
  font-size: 16px;
  letter-spacing: 4px;
  font-style: italic;
}

/* 选择栏（粘在流底部） */
/* ===== 抉择面板（持久化 portal —— 出现顶起 stream，完毕/加载收起，带过渡） ===== */
#choice-portal.choice-bar {
  /* 折叠态：脱离文档流 + 高度 0 + 不交互 */
  position: fixed;
  left: 0;
  right: 320px;          /* 让出右侧 side-pane */
  bottom: 0;
  z-index: 50;
  margin: 0;
  background: linear-gradient(180deg, var(--paper) 0%, var(--paper-deep) 100%);
  border-top: 0 solid var(--vermilion);
  padding: 0 36px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  cursor: default;
  pointer-events: none;
  transition: max-height 0.32s cubic-bezier(.2,.7,.2,1),
              padding 0.32s cubic-bezier(.2,.7,.2,1),
              opacity 0.2s ease,
              border-top-width 0.2s ease,
              box-shadow 0.2s ease;
}
#choice-portal.choice-bar.active {
  /* 展开态：自然高度（max-height 上限）+ 顶边强调线 + 阴影 */
  max-height: 70vh;
  opacity: 1;
  padding: 16px 36px 20px;
  border-top: 2px solid var(--vermilion);
  box-shadow: 0 -8px 18px rgba(120,80,40,0.25);
  pointer-events: auto;
  overflow-y: auto;
}
@media (max-width: 1100px) {
  #choice-portal.choice-bar { right: 0; }
}
/* portal 展开时给 stream-pane 留底部缓冲，最后一条消息不被遮
   实际数值由 JS 动态匹配 portal 高度（syncStreamBottomPad），此处仅给个最小兜底 */
.stream-pane { transition: padding-bottom 0.28s ease; }
body.choice-active .stream-pane { padding-bottom: 220px; }
.choice-q {
  font-size: 16px;
  color: var(--vermilion-d);
  margin-bottom: 12px;
  letter-spacing: 1px;
  text-indent: 2em;
}
.choice-options { display: flex; flex-direction: column; gap: 8px; }
.choice-opt {
  background: var(--paper-light);
  border: 1px solid var(--line);
  padding: 10px 16px;
  text-align: left;
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
  color: var(--ink);
  transition: all 0.12s;
  border-radius: 2px;
}
.choice-opt:hover {
  background: #fbf3dc;
  border-color: var(--vermilion);
  color: var(--vermilion-d);
  padding-left: 24px;
}
.choice-custom {
  background: rgba(184,138,58,0.10);
  font-style: italic;
  color: var(--gold-d);
  border: 1px dashed var(--gold);
  letter-spacing: 2px;
}
.choice-custom:hover {
  background: rgba(184,138,58,0.20);
  border-color: var(--gold-d);
  color: var(--vermilion-d);
}
.choice-custom-form {
  background: var(--paper);
  border: 1px solid var(--gold-d);
  padding: 12px 14px;
  border-radius: 2px;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.choice-custom-form textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  padding: 8px 10px;
  background: var(--paper-light);
  border: 1px solid var(--line);
  resize: vertical;
  color: var(--ink);
  line-height: 1.7;
}
.choice-custom-form textarea:focus {
  outline: none;
  border-color: var(--vermilion);
}
.choice-custom-actions {
  display: flex;
  gap: 8px;
}
.choice-custom-submit {
  background: var(--vermilion);
  color: var(--paper-light);
  border-color: var(--vermilion-d);
}
.choice-custom-submit:hover {
  background: var(--vermilion-d);
  color: var(--paper-light);
  padding-left: 16px;
}

/* ===== 档案面板 ===== */
.profile-head { border-bottom: 1px solid var(--line-light); padding-bottom: 8px; margin-bottom: 10px; }
.ch-name { font-size: 22px; font-weight: bold; color: var(--vermilion-d); letter-spacing: 4px; }
.ch-meta { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.ch-bg { font-size: 14px; color: var(--ink); line-height: 1.7; padding: 8px 0; border-bottom: 1px dashed var(--line-light); margin-bottom: 10px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.tag {
  display: inline-block;
  background: var(--paper-deep);
  border: 1px solid var(--line);
  color: var(--ink-2);
  padding: 1px 8px;
  font-size: 12px;
  border-radius: 2px;
}
.tag-tal {
  background: #f5dec0;
  border-color: var(--gold);
  color: var(--vermilion-d);
}
.tag-school {
  background: #d8e8c8;
  border-color: var(--moss);
  color: var(--moss);
}
.tag-item {
  background: #e2d4f0;
  border-color: #6e5a8c;
  color: #4a3866;
  cursor: help;
}
.tag-illness {
  background: #d8c2c2;
  border-color: #8c4a4a;
  color: #6e2a2a;
  font-weight: bold;
}

/* 小传 */
.bio-section {
  background: #f5e8c8;
  border-left: 4px solid var(--vermilion-d);
  padding: 18px 22px !important;
}
.obit-bio {
  font-size: 16px;
  line-height: 1.95;
  text-indent: 2em;
  white-space: pre-wrap;
  color: var(--ink);
}
.obit-bio.loading {
  text-align: center;
  color: var(--vermilion-d);
  font-style: italic;
  text-indent: 0;
}
.sn-narrate.illness {
  border-left-color: #8c4a4a;
  background: rgba(140,74,74,0.06);
}
.stats-fold { margin-top: 12px; }
.stats-fold .fold-summary,
.stats-fold summary {
  cursor: pointer;
  color: var(--ink-2);
  font-size: 13px;
  letter-spacing: 2px;
  padding: 4px 0;
  border: none;
  border-bottom: 1px dashed var(--line-light);
  margin-bottom: 6px;
  background: none;
  font-family: inherit;
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stats-fold .fold-summary:hover { color: var(--vermilion); }
.stats-fold .fold-caret { color: var(--gold-d); font-size: 11px; }
.stat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 13px;
}
.stat-k { width: 22px; color: var(--vermilion-d); }
.stat-bar {
  flex: 1;
  height: 8px;
  background: var(--paper-deep);
  border: 1px solid var(--line);
  border-radius: 1px;
  overflow: hidden;
}
.stat-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--gold) 0%, var(--vermilion) 100%);
}
.stat-v { width: 24px; text-align: right; color: var(--ink-2); }

/* ===== 副面板 ===== */
.log-panel h3, .map-panel h3, .rel-panel h3 {
  font-size: 16px;
  color: var(--vermilion-d);
  letter-spacing: 4px;
  border-bottom: 1px dashed var(--line-light);
  padding-bottom: 6px;
  margin-bottom: 10px;
}
.log-list { display: flex; flex-direction: column; gap: 4px; }
.log-entry {
  font-size: 13px;
  line-height: 1.6;
  padding: 4px 0;
  border-bottom: 1px dotted #e8d4a8;
}
.log-entry.log-world {
  background: #f5e2c2;
  padding: 6px 8px;
  border-left: 3px solid var(--gold);
}
.log-yr {
  display: inline-block;
  width: 60px;
  color: var(--vermilion-d);
  font-weight: bold;
  font-size: 12px;
}
.log-empty { color: var(--ink-2); font-style: italic; padding: 8px 0; font-size: 13px; }

.map-svg {
  width: 100%;
  background: #f5e8c8;
  border: 1px solid var(--line);
  margin-bottom: 12px;
}
.map-list { display: flex; flex-direction: column; gap: 2px; }
.state-row {
  display: grid;
  grid-template-columns: 60px 50px 36px 36px;
  gap: 4px;
  font-size: 11px;
  padding: 3px 4px;
  border-bottom: 1px dotted #e0c98e;
}
.state-row.state-dead { text-decoration: line-through; color: #999; }
.state-nm { color: var(--vermilion-d); font-weight: bold; }
.state-cap { color: var(--ink-2); }
.state-pw { color: var(--bamboo); }
.state-ar { color: var(--vermilion); }

.rel-section { margin-bottom: 14px; }
.rel-section h4 {
  font-size: 13px;
  color: var(--ink-2);
  letter-spacing: 3px;
  margin-bottom: 6px;
  font-weight: normal;
}
.rel-list { display: flex; flex-direction: column; gap: 3px; }
.rel-row {
  display: grid;
  grid-template-columns: 1fr 1fr 36px;
  gap: 4px;
  font-size: 12px;
  padding: 3px 4px;
  background: var(--paper-light);
  border: 1px solid #e0c98e;
}
.rel-nm { color: var(--ink); font-weight: bold; }
.rel-rl { color: var(--ink-2); font-size: 11px; }
.rel-aff { color: var(--vermilion); text-align: right; }
.rel-empty { color: var(--ink-2); font-style: italic; padding: 6px 0; font-size: 12px; }

/* ===== 按钮 ===== */
.big-btn, .big-btn-2 {
  padding: 10px 20px;
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
  border-radius: 2px;
  letter-spacing: 2px;
  border: 1px solid;
}
.big-btn {
  background: var(--vermilion);
  color: var(--paper-light);
  border-color: var(--vermilion-d);
}
.big-btn:hover { background: var(--vermilion-d); }
.big-btn-2 {
  background: var(--paper-deep);
  border-color: var(--line);
  color: var(--ink);
}
.big-btn-2:hover { background: #e6d3a4; }

/* ===== 死亡总结 ===== */
.obit {
  max-width: 800px;
  margin: 30px auto;
  padding: 36px 48px;
  background: var(--paper);
  border: 3px double var(--gold-d);
  text-align: center;
}
.obit-title {
  font-size: 42px;
  color: var(--vermilion-d);
  letter-spacing: 12px;
  margin-bottom: 8px;
}
.obit-meta { color: var(--ink-2); font-size: 16px; letter-spacing: 3px; margin-bottom: 4px; }
.obit-period { color: var(--ink-2); font-style: italic; margin-bottom: 24px; border-bottom: 1px solid var(--line-light); padding-bottom: 12px; }
.obit-bg {
  text-align: left;
  text-indent: 2em;
  background: var(--paper-light);
  padding: 12px 18px;
  border-left: 3px solid var(--vermilion);
  margin-bottom: 24px;
}
.obit-section { text-align: left; margin-bottom: 20px; }
.obit-section h3 {
  color: var(--vermilion-d);
  letter-spacing: 4px;
  border-bottom: 1px dashed var(--line-light);
  padding-bottom: 6px;
  margin-bottom: 10px;
}
.obit-row { font-size: 14px; line-height: 1.8; padding: 4px 0; }
.obit-choice {
  display: inline-block;
  background: rgba(168,46,46,0.15);
  color: var(--vermilion-d);
  padding: 1px 8px;
  border-radius: 2px;
  font-size: 13px;
  margin-right: 4px;
}
.obit-illness {
  display: inline-block;
  background: #d8c2c2;
  color: #6e2a2a;
  padding: 1px 8px;
  border-radius: 2px;
  font-size: 13px;
  margin-right: 4px;
}
.obit-stats {
  text-align: center;
  font-size: 18px;
  color: var(--vermilion-d);
  letter-spacing: 4px;
  padding: 16px 0;
  border-top: 1px dashed var(--line-light);
}
.obit-actions { margin-top: 20px; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--paper-deep); }
::-webkit-scrollbar-thumb { background: var(--gold-d); border-radius: 3px; }

/* =============================================================
   移动端适配（≤900px）：中间瀑布流 + 底部 portal + 顶栏可展开菜单
   ============================================================= */

/* 桌面默认：菜单按钮与 pane 关闭按钮隐藏 */
.ts-menu-btn, .pane-close, .mobile-mask { display: none; }

@media (max-width: 900px) {
  /* ---------- 顶栏（flex-wrap，始终悬浮顶端） ---------- */
  .top-strip {
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 6px 8px;
    align-items: center;
    /* sticky 兜底：即便外层 overflow:visible 时仍贴顶 */
    position: sticky;
    top: 0;
    z-index: 50;
  }
  .ts-title { font-size: 16px; letter-spacing: 2px; order: 1; }
  /* meta 占独立第二行，允许内容自动 wrap 成两行——避免单行截断 */
  .ts-meta {
    flex: 1 0 100%;
    order: 3;
    font-size: 12px;
    letter-spacing: 0.5px;
    white-space: normal;
    word-break: break-word;
    line-height: 1.55;
    opacity: 0.9;
  }
  .ts-meta .ts-chain { display: inline-block; }
  /* 文/白 按钮（移动端依然显在顶栏右侧，不被菜单收起） */
  .ts-lang-btn {
    order: 2;
    margin-left: auto;
    padding: 6px 10px;
    font-size: 12px;
    height: 36px;
    line-height: 1;
    flex: 0 0 auto;
  }
  /* 菜单按钮（移动端可见，紧跟在文/白 右侧） */
  .ts-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--vermilion);
    color: var(--paper-light);
    border: 1px solid var(--gold);
    font-size: 18px;
    cursor: pointer;
    border-radius: 2px;
    order: 2.5;
    padding: 0;
    margin-left: 4px;
    flex: 0 0 auto;
  }
  .ts-menu-btn:hover { background: var(--vermilion-d); }
  /* 操作按钮组：默认收起，菜单展开时落下来 */
  .ts-actions {
    flex: 1 0 100%;
    order: 4;
    display: none;
    flex-direction: column;
    gap: 4px;
    background: rgba(0,0,0,0.15);
    border-top: 1px solid var(--gold);
    padding: 8px 4px;
    margin: 6px -12px -8px;
  }
  .ts-actions.menu-open { display: flex; }
  .ts-actions .ts-btn {
    text-align: left;
    padding: 10px 16px;
    font-size: 15px;
    width: 100%;
    background: rgba(255,255,255,0.08);
  }

  /* ---------- 主体布局：单列；保持 100vh contained 滚动，stream-pane 内部滚 ---------- */
  .game-body { grid-template-columns: 1fr; position: relative; overflow: hidden; min-height: 0; }

  /* stream 占满整宽 */
  .stream-pane {
    padding: 16px 18px;
    background-attachment: fixed;
  }
  .sn-text { font-size: 16px; line-height: 1.75; }
  .stream-node { padding: 8px 10px 8px 12px; margin-bottom: 12px; }

  /* ---------- 档案 / 侧栏 改为右侧抽屉 overlay ---------- */
  .profile-pane, .side-pane {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 88vw;
    max-width: 360px;
    z-index: 240;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(.2,.7,.2,1);
    background: var(--paper);
    border: none;
    border-left: 1px solid var(--line);
    box-shadow: -8px 0 18px rgba(80,50,20,0.25);
    overflow-y: auto;
    padding: 44px 18px 60px;
  }
  .profile-pane.open,
  .side-pane.open {
    transform: translateX(0);
    /* 移动端 .profile-pane.open 不再要 max-width:0 桌面态 */
    max-width: 360px;
    width: 88vw;
    padding: 44px 18px 60px;
  }
  .profile-pane.closed { transform: translateX(100%); width: 88vw; max-width: 360px; padding: 44px 18px 60px; }
  /* 侧栏默认隐藏（不挂 .open 时） */
  .side-pane { display: block; }

  /* 关闭按钮 */
  .pane-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 10px;
    right: 12px;
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--line);
    color: var(--ink-2);
    font-size: 18px;
    cursor: pointer;
    border-radius: 2px;
    z-index: 10;
  }
  .pane-close:hover { color: var(--vermilion); border-color: var(--vermilion); }

  /* 半透遮罩：点空白关抽屉 */
  .mobile-mask {
    display: block;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.35);
    z-index: 230;
    animation: maskFade 0.2s ease;
  }
  @keyframes maskFade { from { opacity: 0; } to { opacity: 1; } }

  /* ---------- 抉择 portal：移动端底部 ---------- */
  #choice-portal.choice-bar {
    right: 0;          /* 全宽 */
    padding: 0 14px;
  }
  #choice-portal.choice-bar.active {
    max-height: 60vh;  /* 留足 stream 可见区 */
    padding: 12px 14px 14px;
  }
  body.choice-active .stream-pane { padding-bottom: 200px; }

  /* ---------- AI 配置/原型选择/年代选择：留出顶部 ---------- */
  .scroll {
    margin: 18px 8px;
    padding: 22px 18px;
    max-width: 100%;
  }
  .archetype-grid { grid-template-columns: 1fr; }
  .klass-grid, .mode-grid, .era-grid { grid-template-columns: 1fr; }
}

/* 平板兼容：≤1100 但 >900 时仍保留旧的 1 列布局，但不抽屉化 */
@media (max-width: 1100px) and (min-width: 901px) {
  .game-body { grid-template-columns: 1fr; }
  .profile-pane.open { max-width: none; width: 100%; }
  .side-pane { display: none; }
}

/* ===== 出身原型选择 ===== */
.archetype-hint {
  text-align: center;
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 20px;
  font-style: italic;
}
.archetype-group {
  margin-bottom: 22px;
}
.archetype-klass {
  font-size: 17px;
  color: var(--vermilion-d);
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
  margin: 14px 0 10px;
  letter-spacing: 4px;
}
.archetype-klass-sub {
  font-size: 12px;
  color: var(--ink-2);
  font-weight: normal;
  letter-spacing: 1px;
  margin-left: 8px;
}
.archetype-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.archetype-card {
  background: var(--paper-light);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  color: inherit;
}
.archetype-card:hover {
  border-color: var(--vermilion);
  background: #fbf3dc;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px var(--shadow);
}
.archetype-name {
  font-size: 16px;
  color: var(--vermilion-d);
  font-weight: bold;
  margin-bottom: 4px;
  letter-spacing: 2px;
}
.archetype-meta {
  font-size: 12px;
  color: var(--gold);
  margin-bottom: 5px;
}
.archetype-desc {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.5;
}

/* ===== 等待命运中 loading ===== */
.destiny-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  text-align: center;
}
.destiny-seal {
  width: 96px;
  height: 96px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.seal-spin {
  width: 84px;
  height: 84px;
  background: var(--vermilion);
  color: var(--paper-light);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  font-family: serif;
  font-weight: bold;
  letter-spacing: 0;
  box-shadow: 0 4px 16px rgba(168,46,46,0.35);
  animation: sealRotate 4s linear infinite;
}
@keyframes sealRotate {
  0%   { transform: rotate(0deg)  scale(1);   }
  50%  { transform: rotate(180deg) scale(1.05); }
  100% { transform: rotate(360deg) scale(1);   }
}
.destiny-title {
  font-size: 22px;
  color: var(--vermilion-d);
  letter-spacing: 6px;
  margin-bottom: 18px;
}
.destiny-skeleton {
  background: var(--paper-light);
  border: 1px solid var(--line);
  padding: 18px 26px;
  border-radius: 2px;
  min-width: 280px;
  margin-bottom: 18px;
}
.ds-row {
  display: flex;
  font-size: 14px;
  padding: 4px 0;
  color: var(--ink);
}
.ds-k {
  width: 70px;
  color: var(--ink-2);
  font-size: 12px;
  letter-spacing: 2px;
}
.destiny-dots {
  display: inline-flex;
  gap: 6px;
  margin-bottom: 12px;
}
.destiny-dots span {
  width: 8px;
  height: 8px;
  background: var(--vermilion);
  border-radius: 50%;
  animation: dotPulse 1.2s infinite ease-in-out;
}
.destiny-dots span:nth-child(2) { animation-delay: 0.2s; }
.destiny-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); }
  40%           { opacity: 1;    transform: scale(1.1); }
}
.destiny-tip {
  color: var(--ink-2);
  font-size: 13px;
  font-style: italic;
}

/* ===== 角色 tags（身份/履历类，区别于性格/天赋） ===== */
.tags-row { margin-bottom: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.tag-id {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 2px;
  letter-spacing: 1px;
  border: 1px solid currentColor;
}
.tag-shadow { color: #6a1f1f; background: #f0d4d4; }
.tag-war    { color: #5a3010; background: #ead7b8; }
.tag-noble  { color: #5a3a82; background: #e3d6f0; }
.tag-myst   { color: #2c5260; background: #cfe2eb; }
.tag-misc   { color: var(--ink-2); background: var(--paper-light); }

/* ===== 当次点击新增的消息：竖条标绿（覆盖类型色） ===== */
.stream-node.fresh {
  border-left-color: #4a8f3f;
}
.stream-node.fresh.sn-world {
  /* world 类有底色，配合绿条调整一下色调 */
  background: rgba(74,143,63,0.07);
}
.stream-node.fresh.sn-choice {
  background: rgba(74,143,63,0.06);
}

/* AI 配置：云模式不可用警告 */

.ai-warn-strong {

  background: #f8d7da;

  color: #6e1f25;

  border: 1px solid #c44;

  padding: 10px 14px;

  border-radius: 4px;

  margin: 10px 0;

  font-size: 14px;

}

/* 云模式：固定配置展示 */

.cloud-fixed {

  background: var(--paper-light);

  border: 1px solid var(--line);

  padding: 10px 14px;

  border-radius: 2px;

  font-size: 14px;

  line-height: 1.8;

}

.cloud-fixed .dim { color: var(--ink-2); font-weight: normal; }

.cloud-fixed .small { font-size: 12px; }



/* 云模式：用量条 */

.usage-bar-wrap {

  margin: 12px 0;

  padding: 12px 14px;

  background: var(--paper-light);

  border: 1px solid var(--line-light);

  border-radius: 2px;

}

.usage-bar-label { font-size: 13px; margin-bottom: 6px; color: var(--ink); }

.usage-bar-label strong { color: var(--vermilion-d); }

.usage-remain { color: var(--moss); font-size: 12px; margin-left: 4px; }

.usage-capped { color: var(--vermilion-d); font-size: 12px; font-weight: bold; margin-left: 4px; }

.usage-bar { height: 8px; background: var(--paper-deep); border-radius: 4px; overflow: hidden; }

.usage-bar-fill {

  height: 100%;

  background: linear-gradient(90deg, #6a9c4a 0%, #6a9c4a 100%);

  transition: width 0.4s ease;

}

.usage-bar-fill.mid { background: linear-gradient(90deg, #b88a3a 0%, #b88a3a 100%); }

.usage-bar-fill.high { background: linear-gradient(90deg, #a82e2e 0%, #a82e2e 100%); }

.usage-bar-hint { font-size: 11px; color: var(--ink-2); margin-top: 6px; font-style: italic; }

/* SOS 团状态面板（haruhi 模式专属） */

.sos-panel {

  background: linear-gradient(135deg, #fff5d8 0%, #ffe9b8 100%);

  border: 1px solid var(--gold);

  border-radius: 4px;

  padding: 10px 12px;

  margin: 10px 0;

  box-shadow: 0 2px 4px rgba(120,80,40,0.15);

}

.sos-head {

  display: flex;

  justify-content: space-between;

  font-size: 13px;

  margin-bottom: 6px;

}

.sos-phase { font-weight: bold; color: var(--vermilion-d); letter-spacing: 1px; }

.sos-counts { color: var(--gold-d); font-size: 12px; }

.sos-bar {

  height: 6px;

  background: var(--paper-deep);

  border-radius: 3px;

  overflow: hidden;

  margin-bottom: 8px;

}

.sos-bar-fill {

  height: 100%;

  background: linear-gradient(90deg, #b88a3a 0%, #a82e2e 100%);

  transition: width 0.4s ease;

}

.sos-members {

  display: flex;

  flex-direction: column;

  gap: 3px;

}

.sos-member {

  display: flex;

  justify-content: space-between;

  font-size: 12px;

  padding: 3px 8px;

  border-radius: 2px;

  background: rgba(255,255,255,0.4);

}

.sos-name { font-weight: bold; }

.sos-stat { color: var(--ink-2); font-size: 11px; }

.sos-self { background: rgba(168,46,46,0.18); }

.sos-self .sos-name { color: var(--vermilion-d); }

.sos-joined { background: rgba(74,143,63,0.18); }

.sos-joined .sos-name { color: #4a8f3f; }

.sos-recognized { background: rgba(184,138,58,0.18); }

.sos-recognized .sos-name { color: var(--gold-d); }

.sos-unknown { opacity: 0.6; }

.sos-unknown .sos-name { color: var(--ink-2); font-style: italic; }

/* SOS 团状态面板：扩展行 */

.sos-line {

  display: flex;

  justify-content: space-between;

  font-size: 12px;

  margin-top: 4px;

  padding: 2px 4px;

  border-top: 1px dashed rgba(184,138,58,0.3);

}

.sos-k { color: var(--ink-2); letter-spacing: 1px; }

.sos-v { color: var(--ink); }

.sos-tension { font-weight: bold; }

.sos-tension.low  { color: var(--moss); }

.sos-tension.mid  { color: var(--gold-d); }

.sos-tension.high { color: var(--vermilion-d); }
