/* ============================================================
 * 一签人生 · style.css
 * 视觉体系：灰绿底 #F7F7F2 · 酒红主色 #8C2A3F · 苔绿 #1F6F5C
 * ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: #F7F7F2;
  color: #242926;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; touch-action: manipulation; }
ul { list-style: none; }
.dim { color: #5F6B66; }

/* ============ 首页 ============ */
#view-home {
  min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 40px 20px; text-align: center;
}
.home-title { font-size: 52px; font-weight: 800; letter-spacing: 2px; color: #242926; }
.home-title em { font-style: normal; color: #8C2A3F; }
.home-sub { margin: 18px 0 8px; color: #5F6B66; font-size: 15px; max-width: 520px; }
.home-tag { color: #17544A; font-size: 13px; letter-spacing: 4px; margin-bottom: 10px; }
.mode-row { display: flex; gap: 10px; margin: 26px 0 6px; flex-wrap: wrap; justify-content: center; }
.mode-btn {
  padding: 8px 18px; border-radius: 18px; font-size: 13px; color: #4A544F;
  border: 1px solid #CFCFC9; background: #FFFFFF;
}
.mode-btn.on { background: #242926; color: #fff; border-color: #242926; }
.mode-note { font-size: 12px; color: #5F6B66; margin-bottom: 26px; }
.btn-primary {
  background: #8C2A3F; color: #fff; font-size: 18px; font-weight: 600;
  padding: 14px 64px; border-radius: 10px; letter-spacing: 6px;
  box-shadow: 0 4px 14px rgba(148, 31, 66, .3); transition: transform .15s;
}
.btn-primary:hover { transform: translateY(-2px); }
.home-foot { margin-top: 60px; font-size: 12px; color: #97A19C; }

/* ============ 抽签动画 ============ */
#view-birth { min-height: 100vh; min-height: 100svh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.birth-wrap { max-width: 640px; width: 100%; }
.roll-title { text-align: center; color: #5F6B66; font-size: 14px; letter-spacing: 2px; margin-bottom: 20px; }
.roll-country { text-align: center; font-size: 56px; font-weight: 800; color: #242926; min-height: 90px; }
.roll-prob { text-align: center; color: #8C2A3F; font-size: 14px; }

/* ============ 护照卡 ============ */
.passport {
  background: #FFFFFF; border: none; border-radius: 8px;
  padding: 22px 24px 18px;
  box-shadow: 0 1px 2px rgba(31,35,33,.06), 0 1px 1px rgba(31,35,33,.04);
  position: relative; overflow: hidden;
}
.passport-band { height: 6px; background: linear-gradient(90deg, #8C2A3F, #A85468); position: absolute; top: 0; left: 0; right: 0; }
.passport-band.dark { background: linear-gradient(90deg, #242926, #4a5a55); }
.passport-head { display: flex; justify-content: space-between; color: #5F6B66; font-size: 12px; letter-spacing: 1px; margin-top: 6px; }
.passport-name { font-size: 30px; font-weight: 800; color: #242926; margin: 10px 0 6px; }
.passport-name.sm { font-size: 22px; }
.passport-desc { font-size: 14px; color: #242926; margin-bottom: 14px; }
.passport-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; }
.prow { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; border-bottom: 1px dashed #ECECE9; }
.prow span { color: #5F6B66; }
.prow b { color: #242926; font-weight: 600; text-align: right; }
.passport-mrz {
  margin-top: 14px; font-family: Consolas, monospace; font-size: 12px; color: #97A19C;
  letter-spacing: 1px; border-top: 1px solid #ECECE9; padding-top: 10px; word-break: break-all;
}
.passport.mini { padding: 18px 20px 12px; }
.passport.death { border-color: #c8cfc9; }

/* 出生页附属卡 */
.others-card {
  background: #FFFFFF; border: none; border-radius: 8px;
  padding: 18px 22px; margin-top: 16px;
  box-shadow: 0 1px 2px rgba(31,35,33,.06), 0 1px 1px rgba(31,35,33,.04);
}
.others-card h3 { font-size: 15px; color: #242926; margin-bottom: 10px; }
.others-card ul { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; }
.others-card li { font-size: 13px; display: flex; gap: 8px; align-items: baseline; }
.others-card li b { color: #242926; }
.others-card li span { color: #69A77; color: #5F6B66; flex: 1; }
.others-card p { font-size: 12px; color: #5F6B66; margin-top: 12px; }
.birth-actions { text-align: center; margin-top: 24px; }

/* ============ 主界面（v2.0 参考图风格） ============ */
#view-game { max-width: 1080px; margin: 0 auto; padding: 14px 16px calc(40px + env(safe-area-inset-bottom, 0px)); }

/* 顶栏：桌面一行（年龄+信息 / 进度条 / 控制按钮），手机堆叠；v1.5 需求9：下拉时始终置顶 */
.game-header {
  background: #FFFFFF; border-radius: 8px;
  padding: 14px 16px; margin-bottom: 12px;
  display: flex; align-items: center; gap: 18px;
  position: sticky; top: 0; z-index: 20;
  box-shadow: 0 1px 2px rgba(31,35,33,.06), 0 4px 14px rgba(31,35,33,.08);
}
.gh-top { display: flex; align-items: flex-end; gap: 14px; flex-shrink: 0; }
.gh-age { font-size: 44px; font-weight: 800; line-height: 1; color: #242926; letter-spacing: -1px; flex-shrink: 0; }
.gh-age small { font-size: 16px; font-weight: 600; color: #5F6B66; margin-left: 2px; letter-spacing: 0; }
.gh-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.gh-yearline { font-size: 12.5px; color: #97A19C; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gh-yearline #hdr-year { color: #5F6B66; font-weight: 500; }
.choice-flag {
  display: inline-block; background: #8C2A3F; color: #fff; font-size: 12px; font-weight: 600;
  padding: 5px 12px; border-radius: 999px;
}
.choice-flag:active { transform: scale(.97); }

/* 细进度条 */
.tl-track { flex: 1; min-width: 120px; height: 4px; border-radius: 2px; background: #ECECE9; overflow: hidden; }
.tl-fill { height: 100%; width: 0%; background: #8C2A3F; border-radius: 2px; transition: width .12s linear; }

/* 控制按钮行 */
.gh-controls { display: flex; gap: 6px; align-items: center; flex-shrink: 0; margin-left: auto; }
.ctl-btn {
  font-size: 12.5px; font-weight: 500; color: #3A403C; border: none; border-radius: 5px;
  padding: 8px 12px; background: #ECECE9;
}
.ctl-btn:hover { background: #E2E2DD; }
.ctl-btn.on { background: #272729; color: #fff; }
.ctl-btn.primary { min-width: 42px; text-align: center; }
.spd-group { display: inline-flex; gap: 3px; border-radius: 6px; background: #ECECE9; padding: 2px; }
.spd-group .spd {
  border: none; padding: 6px 10px; font-size: 12.5px; color: #3A403C;
  background: transparent; border-radius: 4px;
}
.spd-group .spd.on { background: #272729; color: #fff; font-weight: 700; }

/* 更多（…）下拉菜单 */
.more-menu {
  position: absolute; right: 16px; top: calc(100% - 6px); z-index: 30;
  background: #fff; border-radius: 8px; padding: 6px; min-width: 176px;
  box-shadow: 0 6px 24px rgba(31,35,33,.14), 0 1px 3px rgba(31,35,33,.08);
}
.more-menu .mitem {
  display: block; width: 100%; text-align: left; font-size: 13px; color: #242926;
  padding: 10px 12px; border-radius: 6px;
}
.more-menu .mitem:hover { background: #F1F1EC; }
.more-menu .mitem.on { color: #1F6F5C; font-weight: 600; }
.more-menu .mitem.off { color: #97A19C; }
.more-menu .mitem.danger { color: #8C2A3F; }
.more-menu .mitem + .mitem { margin-top: 2px; }

/* 内容网格：桌面 = 主栏（场景+纪录） + 侧栏；手机 = 单列（DOM 顺序） */
.game-cols {
  display: grid; gap: 12px; align-items: start;
  grid-template-columns: minmax(0, 1fr) 320px;
  grid-template-areas:
    "scene id"
    "log stats"
    "log money"
    "log income"
    "log family"
    "log relations"
    "log map";
}
#scene-box { grid-area: scene; }
#card-stats { grid-area: stats; }
#card-log { grid-area: log; }
#card-id { grid-area: id; }
#card-money { grid-area: money; }
#card-income { grid-area: income; }
#card-family { grid-area: family; }
#card-relations { grid-area: relations; }
#card-map { grid-area: map; }

/* 卡片基类：白底、无描边、微阴影 */
.col-card {
  background: #FFFFFF; border-radius: 8px; padding: 16px;
  box-shadow: 0 1px 2px rgba(31,35,33,.06), 0 1px 1px rgba(31,35,33,.04);
}
.col-card h3 {
  font-size: 13px; color: #242926; font-weight: 700; margin-bottom: 10px;
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.card-note { font-size: 11px; font-weight: 400; color: #97A19C; }

/* 十二维状态：4 列小格（名字 → 数值 → 细条） */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 8px; }
.stat { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.stat span { font-size: 11px; color: #97A19C; order: 1; }
.stat b { font-size: 18px; font-weight: 700; color: #242926; order: 2; line-height: 1.1; }
.stat .bar { height: 4px; background: #ECECE9; border-radius: 2px; overflow: hidden; order: 3; }
.stat .bar i { display: block; height: 100%; border-radius: 2px; transition: width .4s; }

/* 金钱 */
.money-row { display: flex; justify-content: space-between; font-size: 13px; padding: 6px 0; border-bottom: 1px solid #F1F1EC; }
.money-row span { color: #5F6B66; }
.money-row b { color: #242926; font-weight: 600; }
.btn-shop {
  display: block; width: 100%; margin-top: 12px; padding: 10px;
  background: #ECECE9; color: #242926; border-radius: 8px; font-size: 13px; font-weight: 600;
}
.btn-shop:hover { background: #E2E2DD; }
.btn-shop.alt { background: #E8F0ED; color: #1F6F5C; }

/* 家人 */
#card-family ul li { display: flex; font-size: 13px; padding: 7px 0; gap: 10px; }
#card-family li span { color: #97A19C; width: 52px; flex-shrink: 0; }
#card-family li b { color: #242926; font-weight: 500; }

/* 场景：图 + 主描述 + 家人概况小字 */
.scene-box { text-align: center; padding: 20px 12px 16px; }
.scene-emoji { font-size: 52px; line-height: 1.2; }
.scene-desc { margin-top: 6px; font-size: 14px; font-weight: 600; color: #242926; }
.scene-sub { margin-top: 3px; font-size: 12px; color: #97A19C; }

/* 事件流：参考图风格（左侧灰色年龄 + 正文，细线分隔） */
.log-box { max-height: 560px; overflow-y: auto; }
.log-item {
  display: flex; gap: 10px; padding: 10px 2px; font-size: 13.5px;
  border-bottom: 1px solid #F1F1EC; align-items: baseline;
}
.log-age { flex-shrink: 0; width: 32px; font-size: 11.5px; font-weight: 500; color: #97A19C; }
.log-t { color: #242926; line-height: 1.55; min-width: 0; }
.log-item.is-choice .log-age { color: #1F6F5C; font-weight: 700; }
.log-item.is-choice .log-t::before { content: '▸ '; color: #1F6F5C; }
.log-item.is-death .log-t { color: #97A19C; }
.log-item.is-death .log-t::before { content: '† '; }
.log-item.is-disease .log-age { color: #B07C2E; font-weight: 700; }
.log-item.is-wish .log-t { color: #8a6a2e; }
.log-item.is-world .log-t { color: #4a5568; font-weight: 600; }
.who { color: #8C2A3F; border-bottom: 1px dashed #c98fa1; cursor: pointer; padding: 0 1px; }
.who:hover { background: #F2E9EC; border-bottom-style: solid; }
/* v1.9.8（实测反馈#5）：日志金额入账提示框 */
.log-money {
  display: inline-block; padding: 0 6px; margin-left: 4px; border-radius: 4px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap; vertical-align: 1px;
  background: #F1F1EC; color: #242926; border: 1px solid #E2E2DA;
}
.log-money.plus { background: #EAF3EC; color: #1F6F5C; border-color: #CBE3D3; }
.log-money.minus { background: #F6ECEA; color: #8C2A3F; border-color: #E8CFC9; }

/* 对照者 */
#others-box li { padding: 8px 0; border-bottom: 1px dashed #ECECE9; font-size: 13px; }
#others-box li b { color: #242926; display: block; }
#others-box li span { color: #5F6B66; font-size: 12px; margin-right: 6px; }
#others-box li i { float: right; font-style: normal; color: #8C2A3F; font-size: 12px; }

/* 人生地图 */
.map-box { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.cell { width: 13px; height: 13px; border-radius: 3px; background: #8C2A3F; opacity: .75; }
.cell.future { background: #ECECE9; opacity: 1; }
.cell.avg { outline: 2px solid #242926; outline-offset: 1px; }
.map-legend { width: 100%; font-size: 11px; color: #5F6B66; margin-top: 10px; }

/* ============ 弹窗（v2.0 参考图风格：居中模态 + 顶部信息条） ============ */
#modal {
  position: fixed; inset: 0; background: rgba(31,35,33,.45); z-index: 50;
  display: none; align-items: center; justify-content: center; padding: 16px;
  overscroll-behavior: contain;
}
.modal-card {
  background: #F9F9F6; border-radius: 10px; max-width: 560px; width: 100%;
  padding: 0 0 18px; box-shadow: 0 12px 48px rgba(31,35,33,.22);
  max-height: 88vh; max-height: 88dvh; overflow-y: auto; position: relative;
}
.modal-card > *:not(.modal-head):not(.modal-close) { margin-left: 18px; margin-right: 18px; }

/* 顶部信息条：分类标签 · 进度 · 先收起来 */
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 18px; margin-bottom: 4px;
  border-bottom: 1px solid #ECECE9;
  position: sticky; top: 0; background: #F9F9F6; z-index: 2;
}
.modal-head .modal-tag { margin: 0; }
.modal-tag { display: block; font-size: 12px; color: #8C2A3F; letter-spacing: 2px; font-weight: 700; margin: 14px 18px 0; }
/* v1.5.2：工具面板右上角关闭按钮（花钱/股市/投资/收入/AI；抉择弹窗不适用） */
.modal-close {
  position: absolute; top: 10px; right: 10px; z-index: 3;
  width: 30px; height: 30px; border: none; border-radius: 8px;
  background: transparent; color: #97A19C;
  font-size: 15px; line-height: 30px; padding: 0; cursor: pointer;
}
.modal-close:hover { background: #ECECE9; color: #5F6B66; }
.modal-close:active { transform: scale(.92); }
.modal-prog { font-size: 12px; color: #97A19C; white-space: nowrap; }
.modal-collapse {
  margin-left: auto; font-size: 12px; color: #3A403C; background: #ECECE9;
  padding: 5px 10px; border-radius: 5px; flex-shrink: 0;
}
.modal-collapse:hover { background: #E2E2DD; }

.modal-card h3 { font-size: 19px; color: #242926; margin: 12px 18px 8px; }
.modal-desc { font-size: 14px; color: #242926; margin: 0 18px 14px; line-height: 1.65; }
.modal-opts { display: flex; flex-direction: column; gap: 9px; margin-top: 4px; }
.opt {
  display: flex; gap: 12px; align-items: flex-start; text-align: left;
  border: 1px solid #E0E0DB; border-radius: 8px; padding: 12px 14px; background: #FFFFFF;
}
.opt:hover { background: #F1F1EC; }
.opt:active { background: #EBEBE6; }
.opt.disabled { opacity: .45; cursor: not-allowed; }
.opt b { flex-shrink: 0; min-width: 14px; color: #97A19C; font-weight: 700; font-size: 13px; line-height: 1.5; }
.opt div { flex: 1; min-width: 0; }
.opt div span { display: block; font-size: 14px; color: #242926; font-weight: 600; }
.opt div small { display: block; font-size: 12px; color: #5F6B66; margin-top: 2px; }
.opt em { font-style: normal; font-size: 13px; color: #8C2A3F; font-weight: 700; flex-shrink: 0; margin-top: 2px; }
.opt.loan { border-color: #d9b98f; }
.opt.loan b { color: #8a5a00; }

/* 底部次要按钮：居中窄条 */
.modal-card > .close-opt { margin: 14px auto 0; width: auto; min-width: 200px; max-width: 280px; }
.modal-card > .btn-ghost { margin: 14px auto 0; }
.btn-ghost {
  display: block; width: auto; margin: 14px auto 0; min-width: 240px; max-width: 320px;
  padding: 10px; background: #FFFFFF; border: 1px solid #E0E0DB; border-radius: 6px;
  font-size: 13px; color: #5F6B66;
}
.btn-ghost:hover { background: #F1F1EC; }
.auto-tip { margin-top: 12px; font-size: 12px; color: #1F6F5C; text-align: center; }
.shop-foot { margin-top: 16px; font-size: 12.5px; color: #5F6B66; }
.shop-foot input { vertical-align: -2px; margin-right: 4px; }

/* ============ 结局 ============ */
#view-end { min-height: 100vh; min-height: 100svh; padding: 40px 20px; }
.end-wrap { max-width: 720px; margin: 0 auto; }
.death-years { font-size: 15px; color: #8C2A3F; font-weight: 700; margin-bottom: 10px; }
.death-cause {
  display: inline-block; background: #242926; color: #fff; font-size: 12px;
  padding: 4px 12px; border-radius: 14px; margin-bottom: 12px;
}
.end-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.end-card {
  background: #FFFFFF; border: none; border-radius: 8px; padding: 18px 20px;
  box-shadow: 0 1px 2px rgba(31,35,33,.06), 0 1px 1px rgba(31,35,33,.04);
}
.end-card.wide { grid-column: 1 / -1; }
.end-card h3 { font-size: 15px; margin-bottom: 12px; }
.end-card ul li { font-size: 13px; padding: 6px 0; color: #242926; border-bottom: 1px solid #F1F1EC; display: flex; gap: 8px; }
.end-card ul li span { color: #5F6B66; }
.end-card ul li i { margin-left: auto; font-style: normal; color: #8C2A3F; font-size: 12px; }
.end-log { max-height: 400px; overflow-y: auto; }

/* ============ v1.1 新增 ============ */

/* 年度进度条（需求1） */
.progress-track {
  height: 6px; background: #ECECE9; border-radius: 3px; overflow: hidden;
  margin-bottom: 14px;
}
.progress-fill {
  height: 100%; width: 0%; background: linear-gradient(90deg, #8C2A3F, #A85468);
  border-radius: 3px; transition: width .12s linear;
}

/* Toast 提示 */
.toast {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%) translateY(20px);
  background: #242926; color: #fff; font-size: 13px; padding: 10px 22px;
  border-radius: 20px; opacity: 0; pointer-events: none; transition: all .3s; z-index: 60;
  max-width: 80vw; text-align: center;
}
.toast.show { opacity: .95; transform: translateX(-50%) translateY(0); }

/* 12 维状态 */
.stat-gap { height: 8px; border-bottom: 1px dashed #dfe5e1; margin: 6px 0 10px; }

/* 金钱按钮行 */
.btn-row { display: flex; gap: 8px; margin-top: 12px; }
.btn-row .btn-shop { flex: 1; margin-top: 0; }
/* v1.5.2 需求3：股市按钮未解锁（未引入投资）时只剩一个按钮，保持自然宽度不拉伸 */
.btn-row.solo { justify-content: flex-start; }
.btn-row.solo .btn-shop { flex: 0 0 auto; width: auto; }
.btn-shop.alt { background: #E8F0ED; color: #1F6F5C; }
.btn-shop.alt:hover { background: #d5e5e1; }
.money-row.debt b { color: #B07C2E; }

/* 人名徽章（需求5）— 已并入事件流区块 */

/* 关系表 */
#relations-box li {
  display: flex; align-items: baseline; gap: 8px; padding: 8px 2px;
  border-bottom: 1px solid #F1F1EC; font-size: 12.5px; cursor: pointer;
}
#relations-box li:hover { background: #F1F1EC; }
#relations-box li .rel-ic { flex-shrink: 0; }
#relations-box li b { color: #242926; white-space: nowrap; }
#relations-box li i { margin-left: auto; font-style: normal; color: #5F6B66; font-size: 11px; text-align: right; }

/* 事件流疾病行 */
.log-item.is-disease .log-age { color: #B07C2E; font-weight: 700; }

/* 弹窗内小组件 */
.rel-closeness { display: flex; align-items: center; gap: 10px; margin: 12px 0; font-size: 13px; }
.rel-closeness span { color: #5F6B66; }
.rel-closeness .bar { flex: 1; height: 8px; background: #ECECE9; border-radius: 4px; overflow: hidden; }
.rel-closeness .bar i { display: block; height: 100%; }
.rel-closeness b { width: 30px; text-align: right; }
.modal-sec h4 { font-size: 13px; color: #5F6B66; margin: 14px 0 8px; }
.mini-log { max-height: 220px; overflow-y: auto; border: 1px solid #ECECE9; border-radius: 8px; padding: 6px 10px; background: #fff; }
.close-opt { margin-top: 14px; }

/* 投资面板 */
.inv-amounts { display: flex; gap: 8px; margin-top: 14px; }
.amt-btn {
  flex: 1; padding: 8px 0; border: 1px solid #E0E0DB; border-radius: 8px;
  background: #fff; color: #5F6B66; font-size: 13px;
}
.amt-btn.on { border-color: #272729; color: #fff; background: #272729; font-weight: 700; }
.inv-foot { display: flex; gap: 8px; margin-top: 10px; }
.opt.loan b { color: #8a5a00; }
.hint { color: #97A19C; font-size: 11px; font-style: normal; }

/* 结局关系回顾 */
.end-rel li span { color: #242926; }

/* ============ v2.0 响应式 ============ */
@media (max-width: 980px) {
  /* 单列：按 DOM 顺序排（场景 → 状态 → 纪录 → 身份 → 金钱 → 收入 → 家人 → 关系 → 地图） */
  .game-cols { grid-template-columns: 1fr; grid-template-areas: none; }
  .game-cols > * { grid-area: auto !important; }
  .passport-grid { grid-template-columns: 1fr; }
  .end-grid { grid-template-columns: 1fr; }
  .others-card ul { grid-template-columns: 1fr; }
  .home-title { font-size: 38px; }
}

/* ============ v1.2 新增组件 ============ */
/* 购物四 Tab */
.shop-tabs { display: flex; gap: 6px; margin: 12px 0 14px; }
.stab {
  flex: 1; padding: 8px 0; border: 1px solid #E0E0DB; border-radius: 8px;
  background: #fff; color: #5F6B66; font-size: 13px; cursor: pointer;
}
.stab.on { background: #272729; color: #fff; border-color: #272729; font-weight: 700; }

/* 股票面板 */
.stock-list { max-height: 340px; overflow-y: auto; border: 1px solid #ECECE9; border-radius: 8px; background: #fff; }
.stock-row { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid #F1F1EC; }
.stock-row:last-child { border-bottom: none; }
.stock-row.holding { background: #f3f8f5; }
.stock-info { flex: 1; min-width: 0; }
.stock-info b { display: block; font-size: 14px; color: #242926; }
.stock-info i { font-style: normal; font-size: 11px; color: #97A19C; }
.stock-info em.own { font-style: normal; font-size: 11px; color: #1F6F5C; margin-left: 6px; font-weight: 700; }
.stock-price { text-align: right; min-width: 78px; }
.stock-price b { display: block; font-size: 14px; color: #242926; }
.stock-price i { font-style: normal; font-size: 11px; }
.stock-price i.up { color: #8C2A3F; }
.stock-price i.down { color: #1F6F5C; }
.stock-acts { display: flex; gap: 6px; }
.sbtn {
  padding: 6px 12px; border: 1px solid #E0E0DB; border-radius: 6px;
  background: #fff; font-size: 12px; cursor: pointer; color: #5F6B66;
}
.sbtn.buy { border-color: #8C2A3F; color: #8C2A3F; }
.sbtn.buy:hover { background: #F2E9EC; }
.sbtn.sell { border-color: #1F6F5C; color: #1F6F5C; }
.sbtn.sell:hover { background: #E8F0ED; }

/* 世界事件徽章 */
.we-badge {
  display: flex; align-items: center; gap: 6px; margin-top: 8px;
  padding: 6px 10px; border-radius: 8px; background: #f4efe7;
  border: 1px solid #e0d5c0; font-size: 12px; width: fit-content;
}
.we-badge .we-ic { font-size: 14px; }
.we-badge b { color: #6b4f16; }
.we-badge i { font-style: normal; color: #97A19C; font-size: 11px; }

/* 心愿输入框 */
.wish-box { margin: 14px 0; }
.wish-box input {
  width: 100%; box-sizing: border-box; padding: 12px 14px;
  border: 1px solid #E0E0DB; border-radius: 10px; font-size: 15px;
  background: #fff; color: #242926; outline: none;
}
.wish-box input:focus { border-color: #8C2A3F; }
.log-item.is-wish .log-t { color: #6b4f16; }
.log-item.is-world .log-t { color: #4a5568; font-weight: 600; }

/* AI 设置表单 */
.ai-form { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.ai-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #5F6B66; }
.ai-form input[type="text"], .ai-form input:not([type]) {
  padding: 9px 12px; border: 1px solid #E0E0DB; border-radius: 8px;
  font-size: 13px; background: #fff; color: #242926;
}
.ai-form label.ck { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; }
.ai-status { margin-top: 10px; font-size: 12px; color: #5F6B66; min-height: 18px; }

/* 收入明细 */
.income-rows { border: 1px solid #ECECE9; border-radius: 8px; padding: 4px 12px; background: #fff; margin: 12px 0; }
.irow { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #F1F1EC; font-size: 13px; }
.irow:last-child { border-bottom: none; }
.irow span { color: #5F6B66; }
.irow b.pos { color: #1F6F5C; }
.irow b.neg { color: #8C2A3F; }
.irow.total { border-top: 2px solid #E0E0DB; font-weight: 700; }

/* 结局：legacy 与大时代 */
.end-card.legacy { box-shadow: inset 0 0 0 1px #d9b98f; background: #fdf9f0; }
.end-card.legacy h3 { color: #8a5a00; }
.end-card.legacy li { color: #6b5530; }
.we-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.we-list li { display: flex; justify-content: space-between; font-size: 13px; color: #4a5568; }
.we-list li i { font-style: normal; color: #97A19C; font-size: 12px; }

/* 结局：奇遇徽章（v1.5） */
.badge-list { display: flex; flex-wrap: wrap; gap: 8px; }
.badge-chip { display: inline-block; background: #F9F1EA; border: 1px solid #E8D5C6; color: #8C2A3F; border-radius: 999px; padding: 5px 14px; font-size: 12.5px; font-weight: 600; }

/* 顶部 AI 按钮 */
#btn-ai.on { border-color: #1F6F5C; color: #1F6F5C; }

/* ============ v1.2.1 人种头像（护照证件照） ============ */
.passport-photo {
  float: right; width: 84px; height: 84px; margin: 4px 0 8px 16px;
  border: 3px solid #fff; outline: 1px solid #cfd8d3; border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,.14); overflow: hidden; background: #EFEAE0;
}
.passport-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.passport-photo.sm { width: 54px; height: 54px; margin: 2px 0 6px 10px; border-width: 2px; }
.passport-photo.aged img { filter: grayscale(.75) sepia(.15) contrast(.95); }
.passport-grid { clear: both; }

/* ============ v1.3 时间轴控制条（需求8）→ v2.0 已并入主界面区块，旧定义移除 ============ */

/* ============ v1.3 人生地图：寿命格 + 年度单字（需求6/7） ============ */
.map-box { display: flex; flex-wrap: wrap; gap: 3px; }
.map-box .cell {
  width: 22px; height: 26px; border-radius: 4px;
  background: #F1F1EC; border: 1px solid #E6EBE7;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #7d8a86; position: relative; cursor: default;
}
.map-box .cell .tg { line-height: 1; font-weight: 700; }
.map-box .cell.past { background: #E4ECE8; border-color: #D3DDD7; }
.map-box .cell.lived { background: #8C2A3F; border-color: #6E2132; color: #fff; }
.map-box .cell.lived.mild { background: #A85468; border-color: #8C2A3F; }
.map-box .cell.now { outline: 2px solid #8C2A3F; outline-offset: 1px; box-shadow: 0 0 0 3px rgba(148,31,66,.15); }
.map-box .cell.future { opacity: .45; }
.map-box .cell.avg { border-color: #8C2A3F; box-shadow: inset 0 0 0 1px #8C2A3F; }
.map-box .cell.death { background: #242926; border-color: #242926; color: #fff; }
.map-legend { margin-top: 8px; font-size: 11px; color: #97A19C; }

/* ============ v1.3 收入明细常驻面板（需求4） ============ */
#card-income h3 { display: flex; justify-content: space-between; align-items: center; }
#card-income .inc-year { font-size: 11px; color: #97A19C; font-weight: 400; }
.inc-rows-compact { display: flex; flex-direction: column; }
.inc-rows-compact .irow { display: flex; justify-content: space-between; font-size: 12px; padding: 5px 0; border-bottom: 1px dashed #F1F1EC; }
.inc-rows-compact .irow:last-child { border-bottom: none; }
.inc-rows-compact .irow span { color: #5F6B66; }
.inc-rows-compact .irow b { font-weight: 600; }
.inc-rows-compact .irow b.pos { color: #1F6F5C; }
.inc-rows-compact .irow b.neg { color: #8C2A3F; }
.inc-rows-compact .irow b.info { color: #4a6fa5; }
.inc-hint { font-size: 10px; color: #b0bab6; margin-top: 6px; }

/* ============ v1.3 购物弹框：侧导航 + 滚动列表（需求3） ============ */
.shop-layout { display: flex; gap: 12px; margin-top: 12px; position: relative; }
.shop-nav {
  flex: 0 0 108px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; align-self: flex-start;
}
.shop-nav .snav {
  padding: 9px 10px; border: 1px solid #ECECE9; border-radius: 8px;
  background: #fff; color: #5F6B66; font-size: 12px; text-align: left;
  cursor: pointer; border-left: 3px solid transparent;
}
.shop-nav .snav.on { border-left-color: #8C2A3F; color: #8C2A3F; font-weight: 700; background: #F2E9EC; }
.shop-nav .snav .cnt { float: right; font-size: 10px; color: #b0bab6; }
.shop-list-scroll {
  flex: 1; max-height: 52vh; overflow-y: auto; padding-right: 6px;
  border: 1px solid #F1F1EC; border-radius: 10px; background: #fff;
}
.shop-list-scroll::-webkit-scrollbar { width: 6px; }
.shop-list-scroll::-webkit-scrollbar-thumb { background: #E0E0DB; border-radius: 3px; }
.shop-cat-title { font-size: 11px; color: #97A19C; letter-spacing: 1px; padding: 10px 12px 4px; font-weight: 700; }
.auto-spend-box { padding: 10px 12px; }
.auto-spend-box label {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: #4a5568; padding: 6px 0; border-bottom: 1px dashed #F1F1EC;
}
.auto-spend-box label:last-child { border-bottom: none; }
.auto-spend-box label i { font-style: normal; font-size: 10px; color: #97A19C; }
.auto-spend-box input[type="checkbox"] { accent-color: #8C2A3F; }

/* 幼年抉择隐藏属性提示（需求13） */
.modal-opts.young .opt small { display: none; }

/* ============ v1.4 年度回顾 & 出生档案 ============ */
.modal-card.year-review { max-width: 420px; }
.yr-list { max-height: 46vh; overflow-y: auto; border: 1px solid #ECECE9; border-radius: 10px; padding: 8px 12px; background: #fff; margin: 12px 0; }
.yr-list .log-item { padding: 7px 0; border-bottom: 1px dashed #F1F1EC; }
.yr-list .log-item:last-child { border-bottom: none; }
.ctl-btn.off { color: #c5cfc9; border-color: #ECECE9; opacity: .6; }
.irow.fam { border-top: 2px solid #E0E0DB; font-weight: 700; background: #f7f9f8; }

/* v1.5：收入结构面板 */
.inc-sec-title { font-size: 11px; color: #97A19C; letter-spacing: 1px; margin-top: 10px; padding-top: 6px; border-top: 1px dashed #ECECE9; font-weight: 700; }
.irow.fam { border-top: 2px solid #E0E0DB; font-weight: 700; background: #f7f9f8; }

/* v1.5：倾向调整弹窗——当前项高亮 */
.opt.incl-on { border-color: #1F6F5C; background: #E8F0ED; }
.opt.incl-on b { color: #1F6F5C; }

/* ============ v2.0 移动端适配 ============ */

/* 触屏设备：中和 hover 粘滞（触屏点击后 hover 态残留），按压反馈见下方 :active */
@media (hover: none) {
  .opt:hover { background: #fff; border-color: #E0E0DB; }
  .ctl-btn:hover { background: #ECECE9; }
  .btn-primary:hover { transform: none; }
  .who:hover { background: none; border-bottom-style: dashed; }
  .btn-shop:hover { background: #ECECE9; }
  .btn-shop.alt:hover { background: #E8F0ED; }
  #relations-box li:hover { background: none; }
  .sbtn.buy:hover { background: #fff; }
  .sbtn.sell:hover { background: #fff; }
  .more-menu .mitem:hover { background: none; }
  .modal-collapse:hover { background: #ECECE9; }
  .btn-ghost:hover { background: #fff; }
  .modal-card h3:hover { }
}

/* 按压反馈（触屏替代 hover） */
.ctl-btn:active, .spd:active, .mode-btn:active, .sbtn:active, .amt-btn:active,
.stab:active, .snav:active, .btn-shop:active, .mitem:active, .modal-collapse:active { transform: scale(.96); }
.btn-primary:active { transform: scale(.98); }
.opt:active { background: #EBEBE6; }
.who:active { background: #F2E9EC; border-bottom-style: solid; }

/* ---------- 手机（≤760px） ---------- */
@media (max-width: 760px) {

  /* 首页 */
  #view-home { padding: 32px 18px; }
  .home-title { font-size: 34px; letter-spacing: 1px; }
  .home-sub { font-size: 14px; line-height: 1.75; }
  .home-tag { letter-spacing: 3px; }
  .btn-primary { padding: 13px 46px; font-size: 17px; letter-spacing: 4px; }
  .home-foot { margin-top: 40px; }

  /* 抽签动画 / 护照 */
  .roll-country { font-size: 40px; min-height: 64px; }
  .birth-actions { margin-top: 18px; }
  .passport { padding: 18px 16px 14px; }
  .passport-name { font-size: 24px; }
  .passport-name.sm { font-size: 20px; }
  .passport-photo { width: 64px; height: 64px; margin: 4px 0 8px 12px; }
  .passport-photo.sm { width: 46px; height: 46px; margin: 2px 0 6px 8px; }
  .passport-mrz { font-size: 10px; }

  /* 主界面：顶栏与卡片 */
  #view-game { padding: 10px 12px calc(32px + env(safe-area-inset-bottom, 0px)); }
  .game-cols { gap: 10px; }
  .col-card { padding: 14px; }
  .game-header { display: block; padding: 12px 12px 10px; }
  .gh-top { margin-bottom: 8px; }
  .tl-track { min-width: 0; margin-bottom: 8px; }
  .more-menu { right: 12px; min-width: 168px; }
  .gh-age { font-size: 36px; }
  .gh-top { gap: 10px; }
  .gh-controls { flex-wrap: wrap; gap: 5px; }

  /* 状态格 */
  .stats-grid { gap: 10px 6px; }
  .stat b { font-size: 16px; }

  /* 场景 / 纪录 / 各卡 */
  .scene-box { padding: 16px 10px 12px; }
  .scene-emoji { font-size: 44px; }
  .log-box { max-height: 46vh; }
  .log-item { padding: 9px 0; font-size: 13px; }
  .log-age { width: 30px; font-size: 11px; }
  #card-family ul li { padding: 8px 0; }
  .inc-rows-compact .irow { padding: 6px 0; }
  .btn-row .btn-shop, .btn-shop { padding: 11px; font-size: 13.5px; }
  #relations-box li { padding: 10px 2px; }

  /* 人生地图：grid 自适应填满屏幕宽度 */
  .map-box { display: grid; grid-template-columns: repeat(auto-fill, minmax(19px, 1fr)); gap: 3px; }
  .map-box .cell { width: auto; height: 24px; }
  .map-legend { grid-column: 1 / -1; line-height: 1.5; }

  /* 弹窗：居中模态（参考图） */
  #modal { padding: 10px; }
  .modal-card { max-height: 90vh; max-height: 90dvh; }
  .modal-card > *:not(.modal-head) { margin-left: 14px; margin-right: 14px; }
  .modal-head { padding: 12px 14px; }
  .modal-head .modal-tag { letter-spacing: 1px; }
  .modal-collapse { padding: 6px 10px; }
  .modal-card h3 { margin: 10px 14px 6px; font-size: 17px; }
  .modal-desc { margin: 0 14px 12px; font-size: 13.5px; }
  .modal-tag { margin: 12px 14px 0; }
  .modal-opts { gap: 8px; }
  .opt { padding: 12px; min-height: 44px; }
  .modal-card > .btn-ghost, .modal-card > .close-opt { margin: 12px auto 0; min-width: 180px; padding: 11px; }

  /* 购物弹窗：分类改 3×3 网格，一屏全见（v1.5 加「保险」后共 9 类，横滑 Tab 易漏看后面的类别） */
  .shop-layout { flex-direction: column; gap: 8px; }
  .shop-layout::after { display: none; }
  .shop-nav {
    flex: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
    position: static;
  }
  .shop-nav .snav {
    padding: 9px 2px; border: 1px solid #ECECE9; border-radius: 8px;
    text-align: center; font-size: 12px; white-space: nowrap; overflow: hidden;
  }
  .shop-nav .snav.on { border-color: #8C2A3F; background: #F2E9EC; }
  .shop-nav .snav .cnt { float: none; margin-left: 3px; font-size: 10px; }
  .shop-list-scroll { max-height: 46vh; }

  /* 股票 / 投资面板 */
  .stock-price { min-width: 60px; }
  .sbtn { padding: 9px 11px; }
  .amt-btn { padding: 11px 0; }
  .mini-log { max-height: 32vh; }
  .yr-list { max-height: 38vh; }

  /* 输入框 16px：避免 iOS 聚焦时整页缩放 */
  .wish-box input, .ai-form input[type="text"], .ai-form input:not([type]) { font-size: 16px; }

  /* 结局页 */
  #view-end { padding: 28px 14px calc(40px + env(safe-area-inset-bottom, 0px)); }
  .end-card { padding: 16px 14px; }
  .we-list { grid-template-columns: 1fr; }
  .end-log { max-height: 44vh; }
}

/* ---------- 小屏手机（≤480px） ---------- */
@media (max-width: 480px) {
  .home-title { font-size: 30px; }
  .roll-country { font-size: 32px; min-height: 52px; }
  .passport-name { font-size: 21px; }
  .passport-photo { width: 56px; height: 56px; }
  .btn-primary { padding: 12px 38px; font-size: 16px; }
  .gh-age { font-size: 30px; }
  .map-box { grid-template-columns: repeat(auto-fill, minmax(16px, 1fr)); }
  .map-box .cell { height: 21px; font-size: 9px; }
  .opt { padding: 11px 10px; gap: 10px; }
  .opt div span { font-size: 13.5px; }
  .gh-controls { gap: 4px; }
  .ctl-btn { padding: 8px 10px; font-size: 12px; }
  .spd-group .spd { padding: 6px 8px; font-size: 12px; }
}
