:root {
  --bg: #12161c;
  --bg-panel: #1a2029;
  --bg-soft: #222a35;
  --text: #e8e2d6;
  --muted: #9aa5b1;
  --accent: #d4a24c;
  --accent-dim: #a67b2e;
  --teal: #6d8a92;
  --danger: #c4746a;
  --ok: #7fa67a;
  --border: #2c3644;
  --focus: #f0c36a;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC",
    system-ui, sans-serif;
  --body-size: 18px;
  --line: 1.75;
  --max: 1100px;
  --radius: 12px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 20% -10%, #1c2733 0%, var(--bg) 55%);
  color: var(--text);
  font-size: var(--body-size);
  line-height: var(--line);
}
body.font-large { --body-size: 20px; }

a { color: var(--accent); }
button, .btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 10px;
  min-height: 44px;
  padding: 0.55rem 1rem;
}
button:focus-visible, .btn:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
button.primary {
  background: linear-gradient(180deg, #c9953d, var(--accent-dim));
  border-color: #8d6424;
  color: #1a1206;
  font-weight: 600;
}
button:disabled, .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
button.danger { border-color: #7a3f39; color: #f0c8c3; }

.app {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}
.header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.header h1 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: 0.04em;
  font-weight: 650;
}
.header .sub {
  color: var(--teal);
  margin: 0.15rem 0 0;
  font-size: 0.95rem;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { order: -1; }
}

.panel {
  background: color-mix(in srgb, var(--bg-panel) 92%, black);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.art {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: #0d1218;
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}
.art img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #0d1218;
}
.art .placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.35rem;
  color: var(--muted);
  background: repeating-linear-gradient(
    -12deg,
    #141b24,
    #141b24 12px,
    #171f2a 12px,
    #171f2a 24px
  );
  font-size: 0.95rem;
}
.art .placeholder strong { color: var(--text); font-weight: 600; }

.node-title {
  margin: 0 0 0.4rem;
  font-size: 1.25rem;
}
.node-text {
  margin: 0 0 1.1rem;
  color: var(--text);
  white-space: pre-wrap;
}
.disclaimer {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 1rem;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.choice {
  text-align: left;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 0.7rem 0.9rem;
  border-color: #3a4656;
  background: #1c2430;
}
.choice.primary-action {
  border-color: #8d6424;
  box-shadow: inset 0 0 0 1px rgba(212, 162, 76, 0.25);
}
.choice .meta {
  color: var(--muted);
  font-size: 0.88rem;
}
.choice .reason {
  color: #c9a36a;
  font-size: 0.88rem;
}
.choices.locked { opacity: 0.7; pointer-events: none; }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem 0.75rem;
  margin: 0.4rem 0 0.8rem;
}
.stat {
  background: var(--bg-soft);
  border-radius: 8px;
  padding: 0.4rem 0.55rem;
  font-size: 0.92rem;
}
.stat span { color: var(--muted); display: block; font-size: 0.78rem; }
.side-block { margin-top: 0.85rem; }
.side-block h3 {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
  color: var(--teal);
  font-weight: 600;
}
.list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.92rem;
}
.list li {
  padding: 0.25rem 0;
  border-bottom: 1px solid #273140;
}
.muted { color: var(--muted); }
.banner {
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.9rem;
  border: 1px solid var(--border);
  background: #243041;
}
.banner.warn { border-color: #7a5a28; background: #2a2318; color: #f0d9a8; }
.banner.err { border-color: #7a3f39; background: #2a1b1a; color: #f0c8c3; }
.banner.ok { border-color: #3f5f3c; background: #1b261b; color: #d5e8d2; }

.screen-title { margin-top: 0; }
.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1rem;
}
details.mobile-more { display: none; margin-top: 0.75rem; }
@media (max-width: 820px) {
  .desktop-only-side { display: none; }
  details.mobile-more { display: block; }
  details.mobile-more summary {
    min-height: 44px;
    display: flex;
    align-items: center;
    cursor: pointer;
    color: var(--accent);
  }
}
.history-item { margin-bottom: 0.65rem; }
.history-item .t { color: var(--accent); font-size: 0.9rem; }
.hidden { display: none !important; }
.footer-note {
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}
textarea.import-box {
  width: 100%;
  min-height: 120px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  background: #0f141b;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
}

.mobile-stats { display: none; }
.stat span { font-size: 0.875rem; }
.choice:disabled { opacity: 1; background: #171d25; border-color: #303a47; color: #aeb7c2; }
@media (max-width: 820px) {
  .mobile-stats { display: grid; margin: 0 0 1rem; }
}

.mobile-more .stat-grid { display: none; }

/* 首章阅读与档案 */
:root { --max: 1240px; --bg: #0c1418; --bg-panel: #132126; --bg-soft: #1b2c32; --border: #30434a; --accent: #dfb56f; }
body { background: radial-gradient(ellipse at 0 0, #193039, transparent 65%), #0c1418; }
.header { padding: .4rem 0 1rem; border-bottom: 1px solid var(--border); }
.header h1 { font-size: 1.65rem; letter-spacing: .14em; }
.layout { grid-template-columns: minmax(0, 1fr) 290px; }
.boot-panel { max-width: 900px; margin: 2rem auto; padding: 1.5rem; }
.boot-panel .screen-title { font-size: clamp(2rem, 6vw, 3.2rem); letter-spacing: .18em; margin-bottom: .4rem; }
.boot-panel .art { max-height: 400px; }
.eyebrow { color: var(--accent); letter-spacing: .14em; font-size: .8rem; margin: 1rem 0 .4rem; }
.mission-strip { color: #c1d7d6; font-size: .85rem; padding: .7rem .8rem; border-left: 3px solid var(--accent); background: #1c2c31; margin: .4rem 0 1.2rem; }
.node-title { font-size: 1.45rem; margin-bottom: .8rem; }
.node-text { line-height: 1.9; }
.node-title:focus { outline: none; }
.choice { padding: 1rem; background: #17272d; transition: background .15s, border-color .15s; }
.choice.primary-action:hover { background: #253a40; border-color: #eac687; }
.choice.primary-action { border-color: #716047; box-shadow: none; }
.sidebar { padding: 1rem; }
.chapter-dossier { font-size: .95rem; }
.chapter-dossier h2 { font-size: 1.15rem; margin-top: 1.6rem; }
.chapter-dossier h3 { color: #a8c7c7; font-size: .95rem; margin: 1.2rem 0 .5rem; }
.party-cards { display: grid; gap: .65rem; }
.party-card { display: flex; gap: .8rem; align-items: center; border: 1px solid var(--border); background: #17272c; padding: .6rem; border-radius: 8px; }
.party-card img { width: 64px; height: 80px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.party-card p { margin: .15rem 0; font-size: .8rem; }
.party-card strong { color: #f0e9db; }
.trust-value { color: var(--accent); }
.clue-item { border-bottom: 1px solid var(--border); padding: .55rem 0; }
.clue-item summary { cursor: pointer; min-height: 36px; color: var(--accent); }
.clue-item p { color: #c3d0d2; }
.dossier-dialog { color: var(--text); background: #122126; border: 1px solid #53686c; border-radius: 14px; width: min(660px, calc(100vw - 24px)); max-height: 88vh; padding: 1.3rem; }
.dossier-dialog::backdrop { background: #02080dcc; }
.dossier-dialog > button { position: sticky; top: 0; z-index: 1; background: #2c4045; }
.dossier-dialog .party-cards { grid-template-columns: 1fr; }
.ending-review { border-left: 3px solid var(--teal); padding: .2rem 1rem; margin: 1.2rem 0; font-size: .9rem; }
@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .app { padding: .8rem .65rem 2rem; }
  .header { gap: .6rem; }
  .toolbar { gap: .35rem; }
  .toolbar button { font-size: .85rem; padding: .45rem .65rem; }
  .panel { padding: .85rem; }
  .boot-panel { margin: 1rem 0; }
  .mobile-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .3rem; }
  .mobile-stats .stat { padding: .4rem .3rem; }
  .mobile-stats .stat span { font-size: .73rem; }
  .mobile-stats .stat strong { font-size: .8rem; }
}
@media (prefers-reduced-motion: reduce) { .choice { transition: none; } }
.hub-hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 1.6rem; padding: 1.3rem; margin-bottom: 1.4rem; align-items: center; }
.hub-hero > img { width: 100%; border-radius: 8px; }
.hub-intro h2 { font-size: clamp(1.6rem,3vw,2.4rem); margin: .5rem 0; }
.credit-balance { color: var(--accent); font-size: 1.5rem; }
.hub-layout { display: grid; grid-template-columns: minmax(0,1fr) 310px; gap: 1.3rem; align-items: start; }
.upgrade-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.upgrade-card { background: #192b31; border: 1px solid var(--border); border-radius: 10px; padding: 1rem; display: flex; flex-direction: column; }
.upgrade-card h3 { margin: 0; }
.upgrade-card p { font-size: .9rem; }
.upgrade-card button { margin-top: auto; }
.next-expedition { margin-top: 1.5rem; padding-top: 1.3rem; border-top: 1px solid var(--border); }
.next-expedition .btn, .next-expedition button { margin: .3rem; display: inline-block; text-decoration: none; }
@media(max-width:820px){.hub-hero,.hub-layout {grid-template-columns:minmax(0,1fr);} .hub-hero {gap:1rem;} .upgrade-grid{grid-template-columns:minmax(0,1fr);} .upgrade-card button {width:100%;} }
.inventory-gallery {display:grid;grid-template-columns:1fr 1fr;gap:.8rem;}
.item-card {background:#1b2c32;border:1px solid var(--border);padding:.65rem;border-radius:8px;}
.item-card img {width:100%;aspect-ratio:1;object-fit:contain;border-radius:6px;}
.item-card strong {display:block;margin:.4rem 0;}
.item-card p {font-size:.85rem;}
@media(max-width:440px){.inventory-gallery{grid-template-columns:1fr;}}

/* 续玩、行动反馈与本地保存状态 */
.save-status { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; color: #aec8bd; font-size: .82rem; margin: -.3rem 0 .8rem; }
.save-status:empty { display: none; }
.save-status.unsaved { color: #f0d9a8; }
.save-status button { font-size: .85rem; padding: .35rem .7rem; border-color: #9a7945; }
.resume-summary { margin: 1.2rem 0; padding: .8rem 1rem; background: #1b2c32; border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; }
.resume-summary p { margin: .35rem 0; font-size: .9rem; }
.action-feedback { margin: 0 0 1.1rem; padding: .5rem .8rem; background: #1b2c32; border-radius: 8px; font-size: .82rem; color: #b7c8ca; }
.action-feedback summary { cursor: pointer; min-height: 32px; color: #dfc18d; padding: .2rem 0; }
.action-feedback p { margin: .2rem 0 .35rem; }
.import-file { padding: .75rem 0; }
.import-file label { display: block; font-size: .9rem; }
.import-file input { display: block; width: 100%; max-width: 100%; margin: .5rem 0; color: var(--text); font: inherit; font-size: .85rem; }
.import-file input::file-selector-button { font: inherit; min-height: 44px; background: var(--bg-soft); color: var(--text); border: 1px solid var(--border); border-radius: 8px; margin-right: .5rem; padding: .4rem .7rem; cursor: pointer; }
.import-file p { font-size: .85rem; overflow-wrap: anywhere; }
textarea:focus-visible, input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.ability-status { margin: 1rem 0; }
.ability-status > h3 { margin: 0 0 .6rem; color: #a8c7c7; font-size: 1rem; }
.ability-row { border-bottom: 1px solid var(--border); padding: .4rem 0; }
.ability-row summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .2rem .6rem; min-height: 44px; cursor: pointer; font-size: .88rem; }
.ability-row summary::after { content: '查看用途'; color: var(--muted); font-size: .75rem; }
.ability-row[open] summary::after { content: '收起用途'; }
.ability-remaining { color: var(--accent); }
.ability-row p, .ability-note { font-size: .82rem; }
.expedition-summary { margin: 1rem 0; padding: .8rem 1rem; background: #1b2c32; border-radius: 8px; }
.expedition-summary h3 { margin: .2rem 0; font-size: 1rem; }
.expedition-summary p { font-size: .9rem; margin: .45rem 0; }
.pending-upgrades { color: #dfc18d; border-left: 2px solid var(--accent); padding-left: .65rem; }
.return-record { margin-top: 1.5rem; padding-top: .7rem; border-top: 1px solid var(--border); }
.return-record p { font-size: .85rem; }
.expedition-summary > summary { min-height: 44px; display: list-item; cursor: pointer; color: var(--accent); font-size: .95rem; padding: .35rem 0; }
.next-expedition:first-child { margin-top: 0; padding-top: 0; border-top: 0; margin-bottom: 1.5rem; padding-bottom: 1.2rem; border-bottom: 1px solid var(--border); }
.objective-list { display: flex; flex-wrap: wrap; gap: .35rem .7rem; list-style: none; padding: 0; margin: .65rem 0 .1rem; }
.objective-list li { color: #9bacb2; font-size: .78rem; border: 1px solid #405057; border-radius: 5px; padding: .2rem .45rem; }
.objective-list .objective-done { color: #c5dac2; border-color: #596c58; background: #24352e; }
.chapter-dossier > .objective-panel { margin-bottom: .9rem; }
.terminal-risk { font-size: .85rem; color: #ffd2b6; border-left: 3px solid #d88b6f; padding-left: .5rem; }
body.reading-text .art { display: none; }
body.reading-text .boot-panel { max-width: 760px; }
.dossier-actions { position: sticky; top: 0; display: flex; flex-wrap: wrap; gap: .5rem; z-index: 1; padding: .3rem 0 .8rem; background: #122126; border-bottom: 1px solid var(--border); }
.dossier-actions button { font-size: .9rem; }
.history-panel h2 { font-size: 1.2rem; }
.history-panel > p { font-size: .85rem; }
.history-search { width: 100%; min-height: 44px; color: var(--text); background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px; font: inherit; padding: .5rem .7rem; }
.history-entry { padding: .7rem 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.history-entry h3 { margin: 0 0 .3rem; font-size: .95rem; color: var(--accent); }
.history-entry p { margin: .25rem 0; font-size: .85rem; }
.history-location { color: #b1c9c9; }
.history-panel > button { margin-top: .9rem; }
.import-preview { margin: 1rem 0; padding: .75rem 1rem; border-left: 3px solid var(--teal); background: #1b2c32; border-radius: 0 8px 8px 0; overflow-wrap: anywhere; }
.import-preview h3 { margin: 0 0 .4rem; font-size: 1rem; }
.import-preview p { margin: .35rem 0; font-size: .85rem; }
.import-error { color: #ffd2b6; font-size: .9rem; }
.import-error:empty { display: none; }
.upgrade-card h3:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: 3px; }
.layout > .panel, .node-title { scroll-margin-top: .75rem; }
.clue-item summary, .action-feedback summary { min-height: 44px; }
.settlement-summary { margin: 1rem 0; padding: .8rem 1rem; border-left: 3px solid var(--accent); background: var(--bg-soft); border-radius: 0 8px 8px 0; }
.settlement-summary h3 { font-size: 1rem; margin: 0 0 .35rem; color: var(--accent); }
.settlement-summary p { margin: 0; font-size: .9rem; }
.settlement-summary[data-kind="unavailable"] { border-color: var(--danger); }
.backup-feedback { flex-basis: 100%; margin: .35rem 0 0; color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
.history-search-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.history-search-row input { flex: 1 1 180px; min-width: 0; }
.history-search-row button { font-size: .85rem; }
.history-entry h3:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 3px; }
.dossier-dialog { overscroll-behavior: contain; }
.side-block > button[data-dossier-open] { margin-top: .8rem; font-size: .85rem; }
.art .placeholder { padding: .75rem; text-align: center; }
.art .placeholder button { padding: .3rem .75rem; font-size: .85rem; min-height: 44px; }
.art:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
