/* 留学重开模拟器 — 手机优先 */
:root {
  --bg: #f6f1e7;
  --paper: #fffdf8;
  --ink: #2a2622;
  --muted: #857b6f;
  --line: #e4dccd;
  --accent: #b8432f;
  --accent-ink: #fff;
  --real: #7a4b14;
  --real-bg: #fbf0dc;
  --up: #14855f;
  --down: #c0392b;
  --money: #c98a0b;
  --study: #2f6fdb;
  --mind: #d6453d;
  --id: #14936b;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(60, 40, 20, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 16px; line-height: 1.6; -webkit-text-size-adjust: 100%;
}
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; padding: 0 14px env(safe-area-inset-bottom); }
[hidden] { display: none !important; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.center { text-align: center; }
h2, h3, h4 { margin: .4em 0; }
h4 { font-size: 15px; margin-top: 1.2em; color: var(--muted); font-weight: 600; }

/* 按钮 */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  border-radius: 999px; padding: 10px 18px; font-size: 15px; cursor: pointer; font-family: inherit;
  transition: transform .05s ease, background .15s; min-height: 44px;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.big { width: 100%; padding: 14px; font-size: 17px; }
.btn.small { padding: 6px 12px; font-size: 14px; min-height: 36px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--down); }
.btn:focus-visible { outline: 3px solid #e7b9a8; outline-offset: 2px; }

/* 开始页 */
.start-hero { text-align: center; padding: 14vh 0 4vh; }
.start-plane { font-size: 48px; }
.title { font-size: 34px; letter-spacing: 2px; margin: 8px 0; font-weight: 800; }
.subtitle { color: var(--muted); font-size: 15px; }
.start-actions { display: grid; gap: 12px; margin: 18px 0; }
.settings { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.settings summary { cursor: pointer; color: var(--muted); }
.field { display: grid; gap: 4px; margin: 10px 0; font-size: 14px; }
.field select, .field input { font-size: 16px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-family: inherit; }
.footnote { color: var(--muted); font-size: 12px; text-align: center; margin: 28px 0 20px; }

/* 卡片 */
.card { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin: 18px 0; border: 1px solid var(--line); }
.row-actions { display: flex; gap: 10px; justify-content: center; margin-bottom: 28px; }
.row-actions.wrap { flex-wrap: wrap; }
.row-actions .btn { flex: 1 1 40%; }

/* 身份卡 */
.id-era { color: var(--muted); font-size: 14px; }
.id-dest { font-size: 22px; margin: 4px 0; }
.id-year { font-weight: 800; color: var(--accent); }
.id-sub { font-size: 13px; color: var(--muted); }
.id-grid { display: grid; grid-template-columns: 5.5em 1fr; gap: 6px 10px; margin: 14px 0; font-size: 15px; }
.id-grid dt { color: var(--muted); }
.id-grid dd { margin: 0; }
.id-notes { font-size: 13px; color: var(--muted); margin-top: 12px; }
.id-notes summary { cursor: pointer; }
.seed { font-size: 12px; margin-top: 10px; word-break: break-all; }

/* 徽章 */
.badge { display: inline-block; font-size: 11px; line-height: 1; padding: 3px 6px; border-radius: 6px; margin-left: 6px; vertical-align: 2px; font-weight: 600; }
.badge.est { background: #eee6d6; color: #7d6b4d; }
.badge.real { background: var(--real-bg); color: var(--real); border: 1px solid #ecd3a8; }
.badge.ph { background: #e8e8f4; color: #55558a; }

/* HUD */
.hud { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 10px 0 8px; border-bottom: 1px solid var(--line); }
.hud-line { font-size: 14px; margin-bottom: 6px; }
.stat-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.stat-bars.static { margin-top: 10px; }
.stat { display: grid; grid-template-columns: 5.6em 1fr 2em; align-items: center; gap: 6px; font-size: 13px; }
.stat-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-val { text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: #e9e1d2; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; transition: width .4s ease; }
.stat[data-k="钱"] .bar i { background: var(--money); }
.stat[data-k="学业"] .bar i { background: var(--study); }
.stat[data-k="心态"] .bar i { background: var(--mind); }
.stat[data-k="身份"] .bar i { background: var(--id); }
.stat.low .stat-val { color: var(--down); font-weight: 700; }

/* 日志 */
.log { padding: 10px 0 120px; }
.entry { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 8px 0; animation: fadein .25s ease; }
.entry.real { border-color: #ecd3a8; background: #fffaf0; }
.entry.kind-crisis { border-color: #efb7ae; background: #fff6f4; }
.entry.kind-death { background: #2a2622; color: #f6f1e7; border-color: #2a2622; }
.entry.kind-death .entry-meta { color: #bdb3a4; }
.entry.kind-quiet { opacity: .75; }
.entry.kind-start { border-style: dashed; }
.entry-meta { font-size: 12px; color: var(--muted); }
.entry-title { font-weight: 700; }
.entry-text { font-size: 15px; }
.entry-choice { font-size: 14px; color: var(--accent); margin-top: 4px; }
.entry-result { font-size: 14px; color: var(--muted); }
.oc { font-size: 11px; margin-left: 6px; padding: 1px 6px; border-radius: 6px; }
.oc.success { background: #dcf3e9; color: var(--up); }
.oc.fail { background: #fbe3df; color: var(--down); }
.deltas { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 6px; }
.d { font-size: 12px; padding: 1px 7px; border-radius: 99px; font-variant-numeric: tabular-nums; }
.d.up { background: #e2f4ec; color: var(--up); }
.d.down { background: #fbe6e2; color: var(--down); }
.source { font-size: 12px; color: var(--muted); margin-top: 4px; word-break: break-all; }
.phase-div { text-align: center; margin: 18px 0 8px; position: relative; color: var(--muted); font-size: 13px; letter-spacing: 4px; }
.phase-div::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--line); }
.phase-div span { position: relative; background: var(--bg); padding: 0 10px; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* 控制条 */
.controls {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(246, 241, 231, .96); border-top: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.controls #btn-step { flex: 1 1 30%; max-width: 220px; }
.toggle { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 4px; user-select: none; }
.toggle input { width: 18px; height: 18px; }

/* 弹窗 */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(30, 22, 15, .45); display: flex; align-items: flex-end; justify-content: center; }
.modal-box {
  width: 100%; max-width: 560px; background: var(--paper); border-radius: 18px 18px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); max-height: 88vh; overflow: auto;
  animation: up .2s ease;
}
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-box h3 { font-size: 20px; }
.choices { display: grid; gap: 10px; margin-top: 14px; }
.btn.choice { border-radius: 12px; text-align: left; padding: 12px 14px; font-size: 16px; }
.btn.choice:hover:not(:disabled) { border-color: var(--accent); }
.dice { float: right; opacity: .7; }
@media (min-width: 600px) {
  .modal { align-items: center; }
  .modal-box { border-radius: 18px; }
}

/* 结局卡 */
.ending { text-align: left; }
.end-icon { font-size: 44px; text-align: center; }
.end-name { text-align: center; font-size: 26px; }
.end-line { text-align: center; color: var(--muted); font-size: 14px; }
.end-desc { text-align: center; }
.end-bio { font-size: 14px; background: var(--bg); padding: 10px 12px; border-radius: 10px; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { font-size: 9px; fill: var(--muted); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); justify-content: center; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.comps, .reals, .ach-new { padding-left: 1.2em; font-size: 14px; }
.comps li, .reals li { margin: 4px 0; }

/* 图鉴 */
.codex-head { display: flex; align-items: center; gap: 8px; padding-top: 12px; }
.tabs { display: flex; gap: 6px; margin: 10px 0; overflow-x: auto; }
.tab { border: 1px solid var(--line); background: var(--paper); padding: 6px 12px; border-radius: 99px; font-size: 14px; cursor: pointer; white-space: nowrap; font-family: inherit; color: var(--ink); }
.tab.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.codex-era { margin: 10px 0; }
.codex-era-name { font-size: 13px; color: var(--muted); }
.codex-cells { display: flex; flex-wrap: wrap; gap: 6px; }
.cell { font-size: 13px; padding: 6px 10px; border-radius: 8px; background: #ece5d8; color: #b3a893; }
.cell.on { background: var(--accent); color: #fff; }
.codex-list { display: grid; gap: 8px; }
.codex-item { display: flex; gap: 10px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; opacity: .6; }
.codex-item.on { opacity: 1; }
.ci-icon { font-size: 22px; width: 1.4em; text-align: center; }

/* 提示 */
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 16px; border-radius: 99px; font-size: 14px; z-index: 30; }

/* 里程碑回望 */
.entry.kind-reflect { border-color: #c9b98f; background: #fbf6ea; }
.entry.kind-quiet { opacity: .7; padding: 6px 12px; font-size: 13px; }
.snap-grid, .death-rec { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 8px 0; font-size: 14px; }
.snap-grid dt, .death-rec dt { color: var(--muted); }
.snap-grid dd, .death-rec dd { margin: 0; }
.snap-stats { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 13px; color: var(--muted); }
.snap { margin: 6px 0 10px; }
.snap-since { margin: 8px 0 4px; padding-left: 18px; font-size: 13px; color: var(--muted); }
.snap-diff { font-size: 13px; margin: 4px 0; }
.modal-now { font-size: 12px; color: var(--muted); margin: 4px 0 8px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.modal-result { margin: 6px 0; }
.modal-result .entry-choice { margin-bottom: 4px; }
/* 结局页 */
.end-title-card { text-align: center; padding: 18px 10px; margin: -4px 0 12px; border-radius: 12px; color: #fff;
  background: linear-gradient(135deg, var(--life, #888), #2a2622); }
.end-title-card .big { font-size: 34px; font-weight: 700; letter-spacing: 2px; }
.recap { font-size: 14px; padding-left: 20px; margin: 4px 0 8px; }
.recap li { margin: 2px 0; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; border: 1px solid rgba(0,0,0,.2); }

/* 出发卡：资金缺口 */
.gap-red { color: #c0392b; font-weight: 700; }
.dc-cell.bad { background: #fdecea; border-color: #e6a39b; }
.dc-cell .ok { color: #2e7d32; font-weight: 700; }

/* 多选卡（选校 10 选 5） */
.btn.choice.pick.on { background: #fff4d6; border-color: #d4a017; box-shadow: inset 0 0 0 2px #d4a017; }
.btn.choice .tick { font-family: monospace; }
.by-focus { display: inline-block; font-size: 11px; padding: 0 4px; margin-right: 4px; border-radius: 3px; background: #eef3e6; color: #5a7a3a; }
/* 被偷/被抢/诈骗：纪录流里高亮 */
.entry.alert { background: #fff1ec; border-left: 4px solid #d9534f; }
