:root {
  --bg: #f1eadc;
  --paper: #fffcf4;
  --paper2: #faf4e6;
  --ink: #2a241d;
  --ink2: #4a4136;
  --muted: #8b7f6d;
  --line: #e3d7c1;
  --line2: #d3c4a8;
  --red: #b8322a;
  --red-soft: #f6dfd9;
  --green: #2f7d4f;
  --green-soft: #dcefe2;
  --gold: #b07f22;
  --gold-soft: #f5e9cc;
  --blue: #3c6aa8;
  --blue-soft: #dde7f4;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 2px 10px rgba(80, 60, 30, 0.07);
  --serif: 'Songti SC', 'STSong', 'Noto Serif SC', 'Source Han Serif SC', 'SimSun', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  background-image: radial-gradient(rgba(150, 120, 70, 0.07) 1px, transparent 1px);
  background-size: 18px 18px;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; font-size: inherit; cursor: pointer; color: inherit; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
input { font-family: inherit; font-size: inherit; }
h1, h2, h3, h4 { font-family: var(--serif); margin: 0; font-weight: 700; letter-spacing: 0.02em; }
small { color: var(--muted); }
.num { font-family: var(--serif); font-variant-numeric: tabular-nums; font-weight: 700; }
.up { color: var(--red); }
.down { color: var(--green); }
.muted { color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line2); background: var(--paper); border-radius: 9px; padding: 7px 14px;
  transition: transform 0.08s, background 0.15s, box-shadow 0.15s; box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}
@media (hover: hover) { .btn:hover:not(:disabled) { background: #fff; box-shadow: 0 2px 8px rgba(80, 60, 30, 0.12); } }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: var(--ink); color: #fbf5e6; border-color: var(--ink); }
@media (hover: hover) { .btn.primary:hover:not(:disabled) { background: #3b3228; } }
.btn.red { background: var(--red); color: #fff; border-color: var(--red); }
.btn.ghost { background: transparent; border-color: transparent; }
@media (hover: hover) { .btn.ghost:hover:not(:disabled) { background: rgba(0, 0, 0, 0.04); box-shadow: none; } }
.btn.sm { padding: 3px 9px; font-size: 12px; border-radius: 7px; }
.btn.big { padding: 12px 22px; font-size: 16px; font-weight: 600; border-radius: 11px; }

/* ---------- cards ---------- */
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 14px;
}
.card-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 8px; }
.card-h h3 { font-size: 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px;
  background: var(--paper2); border: 1px solid var(--line); color: var(--ink2); white-space: nowrap;
}
.chip.good { background: var(--gold-soft); border-color: #e8d29e; color: #7a5612; }
.chip.bad { background: #eee; color: #666; }
.chip.red { background: var(--red-soft); border-color: #eebcb3; color: var(--red); }
.chip.green { background: var(--green-soft); border-color: #b9dcc4; color: var(--green); }
.chip.blue { background: var(--blue-soft); border-color: #bccfe8; color: var(--blue); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(42, 36, 29, 0.97); color: #f4ecda;
  display: flex; align-items: center; gap: 16px; padding: 10px 20px; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}
.brand { font-family: var(--serif); font-size: 20px; font-weight: 800; letter-spacing: 0.1em; white-space: nowrap; }
.brand small { color: #b9ab90; font-size: 12px; letter-spacing: 0; margin-left: 6px; font-family: var(--sans); font-weight: 400; }
.tb-mid { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: 1; }
.tb-pill { padding: 3px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); font-size: 13px; white-space: nowrap; border: 1px solid rgba(255, 255, 255, 0.1); }
.tb-pill b { font-family: var(--serif); }
.phase-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.tb-nw { text-align: right; white-space: nowrap; }
.tb-nw .label { font-size: 11px; color: #b9ab90; }
.tb-nw .v { font-family: var(--serif); font-size: 22px; font-weight: 800; line-height: 1.1; }
.tb-btns { display: flex; gap: 4px; }
.tb-btns .btn { background: transparent; border-color: rgba(255, 255, 255, 0.15); color: #f4ecda; padding: 5px 10px; }
@media (hover: hover) { .tb-btns .btn:hover { background: rgba(255, 255, 255, 0.1); } }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 290px minmax(0, 1fr) 330px; gap: 16px; max-width: 1400px; margin: 0 auto; padding: 16px 20px 60px; }
@media (max-width: 1150px) {
  .layout { grid-template-columns: 260px minmax(0, 1fr); }
  .col-right { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .col-right .card { margin-bottom: 0; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; padding: 10px; }
  .col-center { order: -1; }
  .col-right { grid-template-columns: 1fr; }
}

/* ---------- left ---------- */
.who { display: flex; gap: 12px; align-items: center; }
.avatar {
  width: 58px; height: 58px; border-radius: 50%; background: var(--paper2); border: 2px solid var(--line2);
  display: grid; place-items: center; font-size: 32px; flex-shrink: 0;
}
.who h2 { font-size: 20px; }
.who .sub { color: var(--muted); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.stat { margin: 7px 0; }
.stat-top { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink2); }
.stat-top b { font-family: var(--serif); }
.bar { height: 7px; background: #efe6d4; border-radius: 99px; overflow: hidden; margin-top: 3px; }
.bar > i { display: block; height: 100%; border-radius: 99px; transition: width 0.5s; }
.kv { display: grid; grid-template-columns: 64px 1fr; gap: 5px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.fam-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.fam-row:last-child { border-bottom: none; }

/* ---------- center ---------- */
.news { padding: 10px 14px; }
.news-list { list-style: none; margin: 0; padding: 0; }
.news-list li { display: flex; gap: 8px; align-items: baseline; padding: 4px 0; font-size: 13.5px; border-bottom: 1px dashed var(--line); }
.news-list li:last-child { border-bottom: none; }
.news-tag { font-size: 11px; padding: 0 6px; border-radius: 4px; background: var(--ink); color: #f4ecda; flex-shrink: 0; }
.news-tag.trend { background: var(--red); }
.news-tag.house { background: var(--gold); }
.news-tag.flavor { background: #9a8d78; }
.news-hint { color: var(--blue); font-size: 12px; margin-left: 4px; }

.event {
  background: var(--paper); border: 1px solid var(--line2); border-radius: 16px; padding: 22px 24px; margin-bottom: 14px;
  box-shadow: 0 6px 24px rgba(80, 60, 30, 0.12); position: relative; overflow: hidden; animation: pop 0.25s ease-out;
}
.event::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--gold); }
.event.big::before { background: var(--red); }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
.ev-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.ev-icon { font-size: 34px; }
.ev-head h2 { font-size: 22px; }
.ev-age { font-size: 12px; color: var(--muted); }
.ev-text { font-size: 15px; color: var(--ink2); margin: 6px 0 18px; line-height: 1.75; }
.choices { display: grid; gap: 9px; }
.choice {
  text-align: left; border: 1px solid var(--line2); background: var(--paper2); border-radius: 11px; padding: 11px 14px;
  transition: all 0.15s; display: flex; flex-direction: column; gap: 2px;
}
@media (hover: hover) { .choice:hover:not(:disabled) { border-color: var(--ink); background: #fff; transform: translateX(3px); } }
.choice:active:not(:disabled) { border-color: var(--ink); background: #fff; }
.choice b { font-size: 15px; }
.choice small { font-size: 12.5px; }
.choice .why { color: var(--red); font-size: 12px; }
.ev-queue { font-size: 12px; color: var(--muted); margin-top: 12px; text-align: right; }

.result { text-align: left; }
.result .ev-text { white-space: pre-line; }

.plan .alloc { display: grid; gap: 6px; }
.arow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; }
.arow.off { opacity: 0.4; }
.alabel { display: flex; align-items: center; gap: 8px; min-width: 0; }
.alabel .ic { font-size: 18px; width: 24px; text-align: center; }
.alabel b { font-size: 14px; white-space: nowrap; }
.alabel small { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actrl { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.actrl button { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line2); background: var(--paper2); font-size: 16px; line-height: 1; }
@media (hover: hover) { .actrl button:hover:not(:disabled) { background: #fff; border-color: var(--ink); } }
.actrl button:active:not(:disabled) { background: #fff; border-color: var(--ink); }
.pips { display: flex; gap: 3px; }
.pips i { width: 10px; height: 10px; border-radius: 3px; background: #ebe1cd; }
.pips i.on { background: var(--ink); }
.pips i.on.hot { background: var(--red); }
.aval { width: 18px; text-align: right; font-family: var(--serif); font-weight: 700; }
.energy { font-size: 13px; }
.energy b { font-family: var(--serif); font-size: 16px; }
@media (max-width: 560px) { .alabel small { display: none; } .pips i { width: 7px; } }

.preview { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 13px; }
.preview span b { font-family: var(--serif); }
.warns { margin-top: 10px; display: grid; gap: 6px; }
.warn { background: var(--gold-soft); border: 1px solid #ead7a6; color: #6d4e12; padding: 6px 10px; border-radius: 8px; font-size: 13px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.warn.red { background: var(--red-soft); border-color: #eebcb3; color: var(--red); }

.actions { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.act {
  border: 1px solid var(--line); background: var(--paper2); border-radius: 11px; padding: 10px 4px; display: flex; flex-direction: column;
  align-items: center; gap: 2px; transition: all 0.15s; position: relative;
}
@media (hover: hover) { .act:hover:not(:disabled) { background: #fff; border-color: var(--ink); transform: translateY(-2px); } }
.act:active:not(:disabled) { background: #fff; border-color: var(--ink); }
.act .ic { font-size: 22px; }
.act span { font-size: 12.5px; }
.act .dot { position: absolute; top: 6px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--red); }
@media (max-width: 900px) { .actions { grid-template-columns: repeat(4, 1fr); } }

.endbar { display: flex; gap: 10px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.endbar .grow { flex: 1; font-size: 13px; color: var(--muted); }

/* ---------- right ---------- */
.nwbig { margin-bottom: 8px; }
.nwbig .v { font-family: var(--serif); font-size: 28px; font-weight: 800; }
.nwbig small { display: block; }
.bs-sec { margin-top: 10px; }
.bs-sec h4 { font-size: 12px; color: var(--muted); font-family: var(--sans); font-weight: 600; letter-spacing: 0.08em; border-bottom: 1px solid var(--line); padding-bottom: 3px; margin-bottom: 4px; display: flex; justify-content: space-between; }
.bs-row { display: flex; justify-content: space-between; font-size: 13px; padding: 2px 0; gap: 8px; }
.bs-row span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spark { width: 100%; height: 110px; display: block; margin-top: 10px; }
.log ul { list-style: none; padding: 0; margin: 0; max-height: 420px; overflow-y: auto; }
.log li { font-size: 12.5px; padding: 4px 0; border-bottom: 1px dashed var(--line); display: flex; gap: 8px; }
.log li .a { color: var(--muted); width: 34px; flex-shrink: 0; font-family: var(--serif); }
.log li.good { color: var(--green); }
.log li.bad { color: var(--red); }
.log li.big { font-weight: 600; }

/* ---------- modal ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(30, 24, 16, 0.45); z-index: 100; display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; animation: fade 0.15s;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--paper); border-radius: 16px; width: 100%; max-width: 820px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); animation: pop 0.2s; }
.modal.sm { max-width: 480px; }
.modal-h { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-h h2 { font-size: 20px; }
.modal-b { padding: 16px 20px 20px; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tab { border: none; background: none; padding: 8px 14px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; }
.tab.on { color: var(--ink); border-bottom-color: var(--ink); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px 6px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 9px 6px; border-bottom: 1px dashed var(--line); vertical-align: middle; }
.tbl td.r, .tbl th.r { text-align: right; }
.amt { width: 76px; padding: 4px 6px; border: 1px solid var(--line2); border-radius: 6px; background: #fff; text-align: right; }
.trade { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.icard { border: 1px solid var(--line); border-radius: 11px; padding: 12px; background: var(--paper2); display: flex; flex-direction: column; gap: 6px; }
.icard h4 { font-size: 15px; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.icard .row { display: flex; justify-content: space-between; font-size: 12.5px; }
.icard .desc { font-size: 12.5px; color: var(--muted); }
.icard .btns { display: flex; gap: 5px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }
.icard.dim { opacity: 0.6; }
.note { font-size: 12.5px; color: var(--muted); background: var(--paper2); border-radius: 8px; padding: 8px 10px; margin-bottom: 12px; border: 1px dashed var(--line2); }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg .btn.on { background: var(--ink); color: #fbf5e6; border-color: var(--ink); }
.section-t { font-family: var(--serif); font-size: 15px; margin: 16px 0 8px; }
.section-t:first-child { margin-top: 0; }

/* ---------- report ---------- */
.rep-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .rep-grid { grid-template-columns: 1fr; } }
.rep-col h4 { font-size: 14px; margin-bottom: 6px; display: flex; justify-content: space-between; }
.rep-sum { display: flex; justify-content: space-around; text-align: center; background: var(--paper2); border-radius: 12px; padding: 12px; margin-bottom: 14px; border: 1px solid var(--line); }
.rep-sum .v { font-family: var(--serif); font-size: 22px; font-weight: 800; }
.rep-sum small { display: block; }
.rep-notes { margin-top: 12px; display: grid; gap: 5px; }
.rep-notes div { background: var(--paper2); padding: 6px 10px; border-radius: 8px; font-size: 13px; }

/* ---------- toast ---------- */
#toast-root { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; pointer-events: none; }
.toast { background: var(--ink); color: #fbf5e6; padding: 10px 18px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); font-size: 14px; animation: pop 0.2s; max-width: 90vw; }
.toast.bad { background: var(--red); }
.toast.good { background: var(--green); }

/* ---------- title ---------- */
.title-screen { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 30px 16px; }
.title-box { max-width: 640px; width: 100%; text-align: center; }
.ledger-cover {
  background: linear-gradient(135deg, #3b2f22, #2a2119); color: #f1e4c4; border-radius: 6px 18px 18px 6px; padding: 54px 40px 44px;
  box-shadow: 0 30px 60px rgba(40, 25, 10, 0.35), inset 10px 0 0 rgba(0, 0, 0, 0.25), inset 12px 0 0 rgba(255, 255, 255, 0.05);
  position: relative;
}
.ledger-cover::after { content: ''; position: absolute; inset: 14px 14px 14px 26px; border: 1px solid rgba(241, 228, 196, 0.25); border-radius: 4px 12px 12px 4px; pointer-events: none; }
.ledger-cover h1 { font-size: 54px; letter-spacing: 0.3em; margin-bottom: 6px; }
.ledger-cover .sub { color: #c7b58f; letter-spacing: 0.25em; font-size: 14px; }
.ledger-cover .stamp { display: inline-block; margin-top: 22px; border: 2px solid #c9483d; color: #e0675b; padding: 3px 12px; font-family: var(--serif); transform: rotate(-4deg); letter-spacing: 0.2em; border-radius: 4px; }
.title-desc { color: var(--ink2); margin: 26px auto 18px; max-width: 520px; font-size: 15px; line-height: 1.8; }
.title-btns { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.title-btns .btn { min-width: 220px; }
.title-btns .row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.title-btns .row .btn { min-width: 0; }
.meta-line { margin-top: 18px; font-size: 13px; color: var(--muted); }

.origin-screen { max-width: 980px; margin: 0 auto; padding: 30px 16px 60px; }
.origin-screen h1 { text-align: center; font-size: 30px; margin-bottom: 4px; }
.origin-screen .lead { text-align: center; color: var(--muted); margin-bottom: 24px; }
.ocards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 760px) { .ocards { grid-template-columns: 1fr; } }
.ocard {
  border: 2px solid var(--line); background: var(--paper); border-radius: 16px; padding: 20px; text-align: left; transition: all 0.18s;
  display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow);
}
@media (hover: hover) { .ocard:hover { transform: translateY(-4px); border-color: var(--line2); } }
.ocard.on { border-color: var(--ink); box-shadow: 0 10px 30px rgba(42, 36, 29, 0.2); }
.ocard .ic { font-size: 40px; }
.ocard h3 { font-size: 20px; }
.ocard p { margin: 0; color: var(--ink2); font-size: 13.5px; min-height: 42px; }
.ocard .stats { font-size: 12.5px; color: var(--muted); display: grid; gap: 2px; }
.setup { margin: 24px auto 0; max-width: 560px; display: grid; gap: 14px; }
.setup .field { display: flex; align-items: center; gap: 10px; justify-content: center; flex-wrap: wrap; }
.setup input[type='text'] { padding: 8px 12px; border-radius: 9px; border: 1px solid var(--line2); background: #fff; width: 90px; text-align: center; font-size: 16px; font-family: var(--serif); }

/* ---------- ending ---------- */
.ending { max-width: 1100px; margin: 0 auto; padding: 30px 16px 70px; }
.tomb {
  text-align: center; background: linear-gradient(#fffcf4, #f6eedb); border: 1px solid var(--line2); border-radius: 120px 120px 16px 16px;
  padding: 44px 24px 30px; margin: 0 auto 24px; max-width: 560px; box-shadow: 0 16px 40px rgba(80, 60, 30, 0.15);
}
.tomb .nm { font-family: var(--serif); font-size: 36px; font-weight: 800; letter-spacing: 0.2em; }
.tomb .life { color: var(--muted); margin-top: 4px; }
.tomb .tier { display: inline-block; margin: 16px 0 6px; font-family: var(--serif); font-size: 26px; color: var(--red); border: 2px solid var(--red); padding: 2px 18px; border-radius: 6px; transform: rotate(-2deg); }
.tomb .epi { font-family: var(--serif); font-size: 16px; color: var(--ink2); margin-top: 12px; font-style: italic; }
.end-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.end-grid .wide { grid-column: 1 / -1; }
@media (max-width: 760px) { .end-grid { grid-template-columns: 1fr; } }
.scorebox { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; text-align: center; }
@media (max-width: 600px) { .scorebox { grid-template-columns: 1fr 1fr; } }
.scorebox .v { font-family: var(--serif); font-size: 24px; font-weight: 800; }
.endchart { width: 100%; height: 280px; display: block; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); justify-content: center; margin-top: 6px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 4px; vertical-align: 3px; }
.srcbar { display: grid; grid-template-columns: 90px 1fr 80px; gap: 8px; align-items: center; font-size: 12.5px; margin: 4px 0; }
.srcbar .track { height: 10px; background: #efe6d4; border-radius: 3px; position: relative; overflow: hidden; }
.srcbar .track i { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.dec { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.achs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.ach { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--paper2); font-size: 12px; }
.ach b { display: block; font-size: 13.5px; font-family: var(--serif); }
.ach.new { border-color: var(--gold); background: var(--gold-soft); }
.ach.new b::after { content: ' NEW'; color: var(--red); font-size: 10px; font-family: var(--sans); }
.ach.locked { opacity: 0.45; }
.heir { display: grid; gap: 10px; }
.heir-kid { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--paper2); }
.timeline { display: grid; gap: 2px; max-height: 260px; overflow-y: auto; }
.timeline div { font-size: 12.5px; display: flex; gap: 8px; }
.timeline .a { width: 40px; color: var(--muted); font-family: var(--serif); flex-shrink: 0; }

.lineage { display: grid; gap: 8px; }
.lin-row { display: grid; grid-template-columns: 60px 1fr auto; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: var(--paper2); }
.lin-row .g { font-family: var(--serif); font-weight: 800; color: var(--red); }
.help h4 { font-size: 15px; margin: 14px 0 4px; }
.help p, .help li { font-size: 13.5px; color: var(--ink2); }
.help ul { padding-left: 18px; margin: 4px 0; }

/* =====================================================================
   移动端 / 触屏
   ===================================================================== */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
  padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
}
button, input, label { touch-action: manipulation; }
body.modal-open { overflow: hidden; }
.overlay { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.event, .plan { scroll-margin-top: 70px; }

/* 触屏：放大点击区域 */
@media (pointer: coarse) {
  .btn.sm { min-height: 34px; padding: 6px 11px; font-size: 13px; }
  .actrl button { width: 34px; height: 34px; }
  .tab { padding: 10px 14px; }
  input[type='checkbox'] { width: 18px; height: 18px; vertical-align: -3px; }
}

@media (max-width: 760px) {
  /* iOS 输入框 <16px 会在聚焦时自动放大页面 */
  input[type='text'], input[type='number'] { font-size: 16px; }
  .amt { width: 84px; padding: 6px 8px; }

  /* 顶栏：单行，状态标签横向滑动 */
  .topbar { flex-wrap: nowrap; gap: 8px; padding: max(6px, env(safe-area-inset-top)) 10px 6px; }
  .brand { display: none; }
  .tb-mid {
    flex-wrap: nowrap; overflow-x: auto; gap: 6px; min-width: 0; scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 16px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 16px), transparent);
  }
  .tb-mid::-webkit-scrollbar { display: none; }
  .tb-pill { font-size: 12px; padding: 2px 9px; }
  .tb-pill:last-child { margin-right: 14px; }
  .tb-nw .label { font-size: 10px; }
  .tb-nw .v { font-size: 17px; }
  .tb-btns .btn { padding: 6px 11px; font-size: 16px; }

  /* 卡片、事件更紧凑 */
  .card { padding: 12px 14px; margin-bottom: 10px; }
  .event { padding: 16px 16px 16px 20px; border-radius: 14px; margin-bottom: 10px; }
  .ev-icon { font-size: 30px; }
  .ev-head h2 { font-size: 20px; }
  .ev-text { font-size: 15px; margin-bottom: 14px; }
  .choice { padding: 12px 14px; }
  .news-list li { font-size: 13px; }

  /* 精力分配 */
  .arow { padding: 3px 0; }
  .alabel { gap: 6px; }
  .actrl { gap: 5px; }
  .pips { gap: 2px; }
  .preview { gap: 6px 12px; }
  .preview small { flex-basis: 100%; }

  /* 面板入口 */
  .actions { gap: 6px; }
  .act { padding: 8px 2px; }
  .act .ic { font-size: 20px; }

  /* “过完这一年”吸底 */
  .yearbar {
    position: sticky; bottom: 0; z-index: 15; flex-wrap: nowrap; gap: 8px;
    margin: 0 -10px; padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
    background: rgba(241, 234, 220, 0.94); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    border-top: 1px solid var(--line);
  }
  .yearbar .grow { display: none; }
  .yearbar .btn { white-space: nowrap; }
  .yearbar .btn.big { flex: 1; padding: 12px 10px; }
  .layout { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

  .log ul { max-height: 320px; }

  /* 弹窗：全屏底部抽屉 */
  .overlay { padding: calc(env(safe-area-inset-top) + 12px) 0 0; }
  .modal {
    border-radius: 16px 16px 0 0; min-height: 100%; max-width: none;
    padding-bottom: env(safe-area-inset-bottom); animation: sheet 0.22s ease-out;
  }
  .modal.sm { min-height: 0; margin-top: auto; }
  .modal-h {
    position: sticky; top: 0; z-index: 2; background: var(--paper); border-radius: 16px 16px 0 0; padding: 10px 10px 10px 16px;
  }
  .modal-h h2 { font-size: 18px; }
  .modal-h .btn.ghost { min-width: 44px; min-height: 44px; font-size: 18px; }
  .modal-b { padding: 12px 14px 20px; }
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tab { white-space: nowrap; }
  .cards { grid-template-columns: 1fr; }
  .rep-sum { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .rep-sum .v { font-size: 19px; }

  /* 表格 → 卡片行 */
  .tbl.stack thead { display: none; }
  .tbl.stack tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
  .tbl.stack td { display: block; padding: 0; border: none; }
  .tbl.stack td:first-child { flex-basis: 100%; }
  .tbl.stack td.r { text-align: left; }
  .tbl.stack td[data-l]::before { content: attr(data-l) ' '; color: var(--muted); font-size: 12px; }
  .tbl.stack td:last-child:not(:first-child) { flex-basis: 100%; }
  .tbl.stack .trade { justify-content: flex-start; margin-top: 4px; }

  /* toast 移到顶部，避开吸底按钮 */
  #toast-root { bottom: auto; top: calc(64px + env(safe-area-inset-top)); }

  /* 首页 / 投胎 */
  .title-screen { padding: calc(20px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom)); }
  .ledger-cover { padding: 40px 24px 34px; }
  .ledger-cover h1 { font-size: 42px; letter-spacing: 0.22em; }
  .title-desc { font-size: 14px; margin: 20px auto 16px; }
  .origin-screen { padding: calc(20px + env(safe-area-inset-top)) 12px calc(30px + env(safe-area-inset-bottom)); }
  .origin-screen h1 { font-size: 26px; }
  .origin-screen .lead { margin-bottom: 16px; }
  .ocards { gap: 10px; }
  .ocard { display: grid; grid-template-columns: 44px 1fr; gap: 4px 10px; padding: 14px; }
  .ocard .ic { font-size: 32px; grid-row: span 2; line-height: 1.2; }
  .ocard h3 { font-size: 18px; align-self: center; }
  .ocard p { min-height: 0; }
  .ocard .chips, .ocard .stats { grid-column: 1 / -1; }
  .ocard .chips { margin-top: 2px; }
  .setup { margin-top: 16px; }
  .setup input[type='text'] { width: 76px; }

  /* 结局 */
  .ending { padding: calc(20px + env(safe-area-inset-top)) 10px calc(40px + env(safe-area-inset-bottom)); }
  .tomb { padding: 36px 18px 24px; border-radius: 100px 100px 14px 14px; }
  .tomb .nm { font-size: 30px; }
  .end-grid { gap: 10px; }
  .endchart { height: 220px; }
  .srcbar { grid-template-columns: 64px 1fr 72px; }
  .heir-kid .seg { width: 100%; }
  .lin-row { grid-template-columns: 52px 1fr; }
  .lin-row > span:last-child { grid-column: 2; }
}
@media (max-width: 380px) {
  .pips i { width: 5px; }
  .alabel b { font-size: 13px; }
  .actions { grid-template-columns: repeat(4, 1fr); }
}
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
