/* ==========================================================================
 * 抽象人生 · style.css —— 旧档案 / 生命卷宗
 *
 * 目标优先级：
 *   1) 连续阅读舒适度（一屏最多上百条文字流水，行高 / 字距 / 对比度优先）
 *   2) 结构清晰（纸页叠放、印章、竖脊线，不用玻璃、不用霓虹）
 *   3) 手机优先（390×844），桌面限宽居中
 *
 * 硬约束：无 filter: blur / 无 backdrop-filter / 无外部字体 / 无外部图片。
 * 纸纹全部由 CSS 渐变 + 内联 SVG data-URI 实现。
 * ========================================================================== */

/* ==========================================================================
 * 1. 设计变量
 * ========================================================================== */
:root {
  /* 纸 */
  --paper-0: #e6dbc4;   /* 桌面 / 页面外框 */
  --paper:   #f0e7d5;   /* 卷宗纸（app 底色） */
  --paper-1: #f8f2e4;   /* 卡片 / 面板 */
  --paper-2: #eadfc8;   /* 控件底色 */
  --paper-3: #ddcfb4;   /* 按下 / 禁用 */

  /* 墨：三级都要在"叠了 multiply 纸纹"的纸面上过对比度
     --ink      纸面对比 13.5:1（正文）
     --ink-soft 9.5:1（次要正文 / 标签）
     --ink-mute 7.3:1（元信息小字；长文阅读下限 5.5 也稳过） */
  --ink:      #241f1a;
  --ink-soft: #3f372c;
  --ink-mute: #514838;

  /* 线 */
  --rule:     rgba(36, 31, 26, 0.12);
  --rule-2:   rgba(36, 31, 26, 0.16);
  --rule-ink: rgba(36, 31, 26, 0.26);

  /* 朱红（只用在关键处） */
  --red:      #b23b2e;
  --red-deep: #8e2b20;
  --red-soft: rgba(178, 59, 46, 0.10);

  /* 稀有档的旧金 / 负向的冷灰 */
  --gold:      #66501f;
  --cold:      #3f474b;

  /* 阴影：只有 1px 高光 + 很浅的投影，模拟纸页叠放 */
  --sh-1: 0 1px 0 rgba(255, 255, 255, 0.66) inset, 0 1px 2px rgba(72, 52, 32, 0.10);
  --sh-2: 0 1px 0 rgba(255, 255, 255, 0.72) inset, 0 3px 8px rgba(72, 52, 32, 0.14);

  /* 字体：全部系统字体，不引外部 */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC",
               "Noto Sans CJK SC", "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Songti SC", "STSong", "Source Han Serif SC", "Noto Serif CJK SC",
                "SimSun", Georgia, "Times New Roman", serif;

  /* 圆角系统：全站只用这三档 */
  --r-xs: 2px;
  --r-sm: 3px;
  --r-md: 5px;

  /* 印章 */
  --seal-ink: #b23b2e;
  --seal-ink-deep: #8a2a1f;
  --seal-mute: #8b8375;
  /* 印泥遮罩：多尺度噪点 -> 缺墨斑 + 毛边 */
  --seal-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='m'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.055' numOctaves='4' seed='17' stitchTiles='stitch'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='discrete' tableValues='1 1 1 1 1 1 1 1 0.78 0.34 0'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23m)'/%3E%3C/svg%3E");

  /* 纸纤维素材（做旧纸张，768×768） */
  --paper-tex: url("assets/paper.jpg");

  --ease: cubic-bezier(0.25, 0.7, 0.3, 1);
  --app-max: 640px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

/* ==========================================================================
 * 2. 重置 / 基础
 * ========================================================================== */
*,
*::before,
*::after { box-sizing: border-box; }

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;               /* 全站不出现第二根滚动条 */
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.75;
  color: var(--ink);
  background-color: var(--paper-0);
  display: flex;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, figure { margin: 0; }

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
}

button:disabled { cursor: not-allowed; }

b, strong { font-weight: 600; }

::selection {
  background: rgba(178, 59, 46, 0.18);
  color: var(--ink);
}

:focus { outline: none; }

:focus-visible {
  outline: 2px solid var(--red-deep);
  outline-offset: 2px;
}

/* 滚动条：细、浅，不抢文字 */
.life-feed,
.talent-grid,
.attr-list,
.codex-grid,
.screen {
  scrollbar-width: thin;
  scrollbar-color: rgba(36, 31, 26, 0.22) transparent;
}
.life-feed::-webkit-scrollbar,
.talent-grid::-webkit-scrollbar,
.attr-list::-webkit-scrollbar,
.codex-grid::-webkit-scrollbar,
.screen::-webkit-scrollbar { width: 6px; height: 6px; }
.life-feed::-webkit-scrollbar-thumb,
.talent-grid::-webkit-scrollbar-thumb,
.attr-list::-webkit-scrollbar-thumb,
.codex-grid::-webkit-scrollbar-thumb,
.screen::-webkit-scrollbar-thumb {
  background: rgba(36, 31, 26, 0.18);
  border-radius: 3px;
}
.life-feed::-webkit-scrollbar-track,
.talent-grid::-webkit-scrollbar-track,
.attr-list::-webkit-scrollbar-track,
.codex-grid::-webkit-scrollbar-track,
.screen::-webkit-scrollbar-track { background: transparent; }

/* ==========================================================================
 * 3. 纸面与骨架
 * ========================================================================== */
#app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--app-max);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;               /* 结构：顶栏 + 屏幕 + 内部独立滚动区 */
  background-color: var(--paper);
  /* 纸纹：高光 / 暗角 / 噪点 / 极细纤维 */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.92' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.13'/%3E%3C/svg%3E"),
    radial-gradient(120% 72% at 50% -14%, #fcf6e8 0%, rgba(252, 246, 232, 0) 62%),
    radial-gradient(110% 64% at 50% 112%, #ded0b3 0%, rgba(222, 208, 179, 0) 62%);
  background-repeat: repeat, no-repeat, no-repeat;
  background-size: 200px 200px, 100% 100%, 100% 100%;
  box-shadow: 0 0 0 1px rgba(36, 31, 26, 0.06), 0 10px 40px rgba(80, 60, 35, 0.10);
  isolation: isolate;             /* 让纸纹的混合模式只作用在卷宗纸内部 */
}

/* 纸纤维：一层很淡的做旧纸纹（assets/paper.jpg），不参与滚动、不吃点击 */
#app::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: var(--paper-tex);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.11;
  mix-blend-mode: multiply;
  pointer-events: none;
}

/* 所有内容层都浮在纸纹之上 */
#app > * {
  position: relative;
  z-index: 1;
}

/* ==========================================================================
 * 4. 顶栏
 * ========================================================================== */
#topbar {
  position: relative;
  z-index: 5;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px 6px 14px;
  padding-top: calc(8px + var(--safe-t));
  border-bottom: 1px solid var(--rule);
  background: linear-gradient(to bottom, rgba(255, 252, 244, 0.62), rgba(255, 252, 244, 0));
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.brand-mark {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 2px;
  background: linear-gradient(160deg, #c04a3a, var(--red) 60%, var(--red-deep));
  color: #fdf6e8;
  font-family: var(--font-serif);
  font-size: 14px;
  line-height: 1;
  transform: rotate(-3deg);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset, 0 1px 2px rgba(90, 40, 30, 0.25);
}

.brand-text {
  font-family: var(--font-serif);
  font-size: 16px;
  letter-spacing: 0.14em;
  color: var(--ink);
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
  color: var(--ink-soft);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease),
              color 0.15s var(--ease);
}

/* 线描图标：尺寸固定、居中、颜色跟随父级 currentColor */
.icon-btn svg {
  display: block;
  width: 21px;
  height: 21px;
  stroke-width: 1.6;
}
.icon-btn:active { transform: translateY(1px); }
.icon-btn.is-off,
.icon-btn.is-muted,
.icon-btn[aria-pressed="true"] { opacity: 0.42; }

@media (hover: hover) {
  .icon-btn:hover {
    background: rgba(36, 31, 26, 0.055);
    border-color: var(--rule);
  }
}

/* ==========================================================================
 * 5. 屏幕容器
 * ========================================================================== */
.screen {
  display: none;
  flex-direction: column;
  min-height: 0;
  overscroll-behavior: contain;
}

.screen.is-active {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;               /* 横向永不出现滚动条 */
  animation: screen-in 220ms var(--ease) both;
}

/* 开始页 / 结算页：整页可滚（用 margin:auto 居中，内容超高时不会切头） */
#screen-start.is-active,
#screen-end.is-active {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
 * 6. 面板 / 按钮 / 通用件
 * ========================================================================== */
.panel {
  width: calc(100% - 28px);
  max-width: 540px;
  margin: auto;
  padding: 24px 20px;
  background: var(--paper-1);
  border: 1px solid var(--rule-ink);
  border-radius: 4px;
  box-shadow: var(--sh-1), 0 4px 14px rgba(72, 52, 32, 0.07);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  padding: 0 20px;
  border-radius: var(--r-sm);
  font-size: 15px;
  letter-spacing: 0.09em;
  line-height: 1;
  text-align: center;
  border: 1px solid var(--rule-ink);
  background: var(--paper-2);
  color: var(--ink);
  box-shadow: var(--sh-1);
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease),
              transform 0.1s var(--ease), box-shadow 0.12s var(--ease);
  -webkit-user-select: none;
  user-select: none;
  font-variant-emoji: text;       /* 万一有符号字符，也走文本字形，不要彩色 emoji */
}
.btn:active { transform: translateY(1px); box-shadow: none; }

/* 主按钮 = 一枚实心朱红印块：实色 + 细描边 + 内阴影做出压感 */
.btn-primary {
  color: #fdf6e8;
  border: 1px solid #7d261c;
  background-color: var(--red);
  background-image: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -2px 0 rgba(90, 30, 22, 0.26),
    0 2px 5px rgba(96, 44, 32, 0.16);
  text-shadow: 0 1px 0 rgba(88, 30, 22, 0.28);
}
.btn-primary:active {
  transform: translateY(1px);
  background-color: var(--red-deep);
  box-shadow:
    inset 0 2px 4px rgba(80, 25, 18, 0.34),
    0 1px 2px rgba(96, 44, 32, 0.14);
}

/* 幽灵按钮 = 素纸卡，只有一道墨线 */
.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--rule-ink);
  box-shadow: none;
}
.btn-ghost:active {
  background: rgba(36, 31, 26, 0.05);
  transform: translateY(1px);
}

.btn-sm {
  min-height: 44px;
  padding: 0 14px;
  font-size: 13.5px;
  letter-spacing: 0.06em;
}

.btn:disabled,
.btn-primary:disabled,
.btn-ghost:disabled {
  color: var(--ink-mute);
  background: var(--paper-3);
  border-color: var(--rule);
  box-shadow: none;
  transform: none;
  opacity: 0.9;
}

@media (hover: hover) {
  .btn-primary:not(:disabled):hover {
    transform: translateY(-1px);
    background-color: #bb4437;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.2),
      inset 0 -2px 0 rgba(90, 30, 22, 0.26),
      0 4px 10px rgba(96, 44, 32, 0.2);
  }
  .btn-ghost:not(:disabled):hover {
    background: rgba(36, 31, 26, 0.05);
    border-color: var(--rule-ink);
  }
  .btn:not(:disabled):hover { border-color: var(--rule-ink); }
  .icon-btn:hover { color: var(--red-deep); }
}

.counter {
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ==========================================================================
 * 7. 舞台头 / 脚（天赋页、属性页共用）
 * ========================================================================== */
.stage-head {
  flex: 0 0 auto;
  padding: 16px 16px 10px;
}

.stage-title {
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1.4;
  color: var(--ink);
}
.stage-title::after {
  content: "";
  display: block;
  width: 26px;
  height: 2px;
  margin-top: 7px;
  background: var(--red);
  opacity: 0.85;
}

.stage-hint {
  margin-top: 6px;
  font-size: 12.5px;
  line-height: 1.7;
  letter-spacing: 0.02em;
  color: var(--ink-mute);
}
.stage-hint b {
  color: var(--red-deep);
  font-size: 1.18em;
  font-variant-numeric: tabular-nums;
}

.stage-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  padding-bottom: calc(10px + var(--safe-b));
  border-top: 1px solid var(--rule);
  background: linear-gradient(to top, rgba(255, 252, 244, 0.7), rgba(255, 252, 244, 0));
}

.stage-foot-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stage-foot .btn {
  width: auto;
  min-width: 84px;
}
.stage-foot .btn-primary { min-width: 96px; }

/* ==========================================================================
 * 8. 开始页
 * ========================================================================== */
.start-panel {
  position: relative;
  text-align: center;
  padding: 34px 22px 26px;
  border-radius: var(--r-md);
}

/* 卷宗封面的内框 */
.start-panel::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid var(--rule);
  border-radius: var(--r-xs);
  opacity: 0.75;
  pointer-events: none;
}

/* 「重开」印章：和结算印章同一套印泥质感 */
.start-seal {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 700;
  line-height: 0.94;
  letter-spacing: 1px;
  color: var(--seal-ink);
  border: 2.5px solid currentColor;
  border-radius: 1px;
  transform: rotate(-6.5deg);
  opacity: 0.88;
  -webkit-mask-image: var(--seal-mask);
  mask-image: var(--seal-mask);
  -webkit-mask-size: 90px 90px;
  mask-size: 90px 90px;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-user-select: none;
  user-select: none;
  pointer-events: none;
}

.start-title {
  position: relative;
  font-family: var(--font-serif);
  font-size: clamp(34px, 10.4vw, 42px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.18em;
  text-indent: 0.18em;             /* 抵消末字 letter-spacing，视觉居中 */
  color: var(--ink);
  margin: 18px 0 10px;
}

/* 标题上方一道短墨线，像封面上的压印 */
.start-title::before {
  content: "";
  display: block;
  width: 26px;
  height: 1px;
  margin: 0 auto 16px;
  background: var(--seal-ink);
  opacity: 0.6;
}

.start-sub {
  font-size: 14px;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
}

.start-desc {
  margin: 16px 0 18px;
  font-size: 13.5px;
  line-height: 1.95;
  letter-spacing: 0.02em;
  color: var(--ink-mute);
}

/* 卷宗编号 / 保存年限：一条档案标签 */
.start-file {
  display: inline-block;
  margin: 2px auto 12px;
  padding: 4px 12px 5px;
  font-size: 10.5px;
  line-height: 1.6;
  letter-spacing: 0.16em;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
  background: rgba(36, 31, 26, 0.035);
  border-top: 1px solid var(--rule-ink);
  border-bottom: 1px solid var(--rule-ink);
}
.start-file:empty { display: none; }

.start-record {
  min-height: 0;
  margin-bottom: 18px;
  font-size: 12px;
  line-height: 1.9;
  letter-spacing: 0.04em;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
}
.start-record:empty { display: none; }
.start-record p { margin: 0; }
.start-record b { color: var(--ink-soft); }

/* ui.js 生成的存档行 */
.start-record .record-row {
  display: block;
  font-size: 12px;
  line-height: 1.95;
  letter-spacing: 0.06em;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
}
.start-record .record-row + .record-row {
  margin-top: 1px;
  padding-top: 2px;
  border-top: 1px dashed rgba(36, 31, 26, 0.08);
}

.start-panel .btn {
  display: flex;
  width: 100%;
}
.start-panel .btn + .btn { margin-top: 10px; }
.start-panel .btn-primary { min-height: 50px; font-size: 16px; }

/* ==========================================================================
 * 9. 天赋卡
 * ========================================================================== */
.talent-grid {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 14px 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  align-content: start;
  -webkit-overflow-scrolling: touch;
}

.talent-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  min-height: 96px;
  padding: 9px 10px 10px;
  text-align: left;
  color: var(--ink);
  background: var(--paper-1);
  border: 1px solid var(--rule-ink);
  border-radius: 3px;
  box-shadow: var(--sh-1);
  transition: transform 0.16s var(--ease), box-shadow 0.16s var(--ease),
              border-color 0.16s var(--ease), background-color 0.16s var(--ease),
              opacity 0.16s var(--ease);
}

.talent-tier {
  display: inline-block;
  padding: 1px 6px;
  font-size: 10.5px;
  line-height: 1.6;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--ink-soft);         /* 深墨小字，不再接近纸色 */
  background: rgba(36, 31, 26, 0.055);
  border: 1px solid var(--rule-ink);
  border-radius: 2px;
}

.talent-name {
  font-family: var(--font-serif);
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.talent-desc {
  font-size: 11.5px;
  line-height: 1.68;
  letter-spacing: 0.01em;
  color: #443b30;                 /* ≈ 8.6:1，小字也清楚 */
}

/* 普通：什么都不加，虚线圈的档位标签让它一眼是最低档 */
.talent-card.tier-1 {
  border-color: var(--rule-ink);
  background: var(--paper-1);
}
.talent-card.tier-1 .talent-tier { border-style: dashed; }

/* 稀有：旧金描边 + 内框 */
.talent-card.tier-2 {
  border-color: rgba(138, 111, 51, 0.5);
  background: linear-gradient(180deg, rgba(186, 158, 96, 0.13), var(--paper-1) 62%);
}
.talent-card.tier-2 .talent-tier {
  color: var(--gold);
  border-color: rgba(138, 111, 51, 0.34);
  background: rgba(186, 158, 96, 0.18);
}
.talent-card.tier-2 .talent-name { color: #6d5626; }

/* 传说：朱红描边 + 双框 + 一点光 */
.talent-card.tier-3 {
  border-color: rgba(178, 59, 46, 0.62);
  background: linear-gradient(180deg, rgba(178, 59, 46, 0.11), var(--paper-1) 66%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 2px 7px rgba(150, 60, 40, 0.14);
}
.talent-card.tier-3::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(178, 59, 46, 0.22);
  border-radius: 2px;
  pointer-events: none;
}
.talent-card.tier-3 .talent-tier {
  color: #fdf6e8;
  background: var(--red);
  border-color: var(--red-deep);
  letter-spacing: 0.18em;
}
.talent-card.tier-3 .talent-name { color: #7a2419; }

/* 选中 */
.talent-card.is-selected {
  border-color: var(--red-deep);
  background: linear-gradient(180deg, rgba(178, 59, 46, 0.15), #fbf3e6 74%);
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--red-deep),
              0 3px 9px rgba(140, 50, 35, 0.18);
}
.talent-card.is-selected .talent-tier {
  color: #fdf6e8;
  background: var(--red-deep);
  border-color: var(--red-deep);
}
.talent-card.is-selected .talent-name { color: var(--red-deep); }
.talent-card.is-selected::after {
  content: "";
  position: absolute;
  right: 7px;
  bottom: 7px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: var(--red-deep);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fdf6e8' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.6l4.6 4.6L19 7'/%3E%3C/svg%3E");
  background-size: 11px 11px;
  background-position: center;
  background-repeat: no-repeat;
  box-shadow: 0 1px 2px rgba(90, 40, 30, 0.25);
}

/* 名额满后的余卡：压暗但保留可读性，方便玩家反悔对比 */
.talent-card.is-dimmed {
  opacity: 0.56;
}
.talent-card.is-dimmed::after { display: none; }

@media (hover: hover) {
  .talent-card:not(.is-dimmed):hover {
    transform: translateY(-1px);
    box-shadow: var(--sh-2);
  }
  .talent-card.is-selected:hover {
    box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--red-deep),
                0 4px 12px rgba(140, 50, 35, 0.22);
  }
}

/* ==========================================================================
 * 10. 属性分配
 * ========================================================================== */
.attr-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  -webkit-overflow-scrolling: touch;
}

.attr-row {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 11px;
  background: var(--paper-1);
  border: 1px solid var(--rule-ink);
  border-radius: 4px;
  box-shadow: var(--sh-1);
}

.attr-icon {
  display: grid;
  place-items: center;
  color: var(--ink-soft);
}
.attr-icon svg {
  display: block;
  width: 19px;
  height: 19px;
  stroke-width: 1.7;
}

.attr-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.attr-name {
  font-size: 13px;
  letter-spacing: 0.09em;
  color: var(--ink-soft);
  white-space: nowrap;
}

.attr-track {
  height: 7px;
  border-radius: 4px;
  background: rgba(36, 31, 26, 0.10);
  box-shadow: inset 0 1px 1px rgba(36, 31, 26, 0.12);
  overflow: hidden;
}

.attr-fill {
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: linear-gradient(90deg, #c8a06c, var(--red));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset;
  transition: width 0.26s var(--ease);
}

.attr-controls {
  display: flex;
  align-items: center;
  gap: 3px;
}

.attr-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  font-size: 19px;
  line-height: 1;
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--rule-ink);
  border-radius: var(--r-sm);
  box-shadow: var(--sh-1), 0 2px 0 rgba(36, 31, 26, 0.07);
  transition: background-color 0.14s var(--ease), transform 0.1s var(--ease),
              box-shadow 0.12s var(--ease);
}
.attr-btn:active {
  transform: translateY(1px);
  box-shadow: none;
  background: var(--paper-3);
}
.attr-btn:disabled {
  color: var(--ink-mute);
  background: transparent;
  border-color: var(--rule);
  box-shadow: none;
  opacity: 0.45;
}
@media (hover: hover) {
  .attr-btn:not(:disabled):hover { background: #f2e8d4; }
}

.attr-val {
  min-width: 30px;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* ==========================================================================
 * 11. 人生 HUD
 * ========================================================================== */
.life-hud {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px 8px;
  border-bottom: 1px solid var(--rule);
  background: linear-gradient(to bottom, rgba(255, 252, 244, 0.66), rgba(255, 252, 244, 0));
}
.life-hud:empty { display: none; }

.hud-age {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  flex: 0 0 auto;
  min-width: 62px;
  padding-right: 10px;
  border-right: 1px solid var(--rule);
}

.hud-age-num {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 700;
  line-height: 0.92;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.hud-age-unit {
  font-size: 10.5px;
  line-height: 1;
  padding-bottom: 3px;
  letter-spacing: 0.04em;
  color: var(--ink-mute);
}

/* 年龄下方的细刻度，像卷宗边上的年龄标尺 */
.hud-age::after {
  content: "";
  position: absolute;
  left: 1px;
  right: 10px;
  bottom: -3px;
  height: 3px;
  background-image: repeating-linear-gradient(
    90deg,
    var(--rule-ink) 0 1px,
    transparent 1px 4px
  );
  opacity: 0.5;
  pointer-events: none;
}

.hud-attrs {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-left: auto;
  min-width: 0;
  flex-wrap: nowrap;
}

.hud-attr {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px 3px 5px;
  border: 1px solid var(--rule);
  border-radius: var(--r-xs);
  background: rgba(255, 252, 244, 0.46);
  line-height: 1.15;
  white-space: nowrap;
}

.hud-attr-icon {
  display: inline-flex;
  align-items: center;
  color: var(--ink-mute);
}
.hud-attr-icon svg {
  display: block;
  width: 14.5px;
  height: 14.5px;
  stroke-width: 1.95;       /* 小尺寸下略加粗，14px 也不糊 */
  transform: translateY(0.5px);
}

.hud-attr-val {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  min-width: 13px;
  text-align: center;
}

/* 属性变化的一次性高亮（不用 blur，只动颜色和 1px 位移） */
.hud-attr.is-up { animation: hud-up 620ms ease-out; }
.hud-attr.is-up .hud-attr-val { animation: hud-val-up 620ms ease-out; }

.hud-attr.is-down { animation: hud-down 620ms ease-out; }
.hud-attr.is-down .hud-attr-val { animation: hud-val-down 620ms ease-out; }

/* ==========================================================================
 * 12. 人生流水（核心阅读区）
 *
 * 结构：左侧年龄列（窄、灰、等宽数字）+ 右侧正文（竖脊线 + 正文）
 * 目标：单条高度尽量小、行高 1.85、字距微开，连读一百条不累。
 * ========================================================================== */
.life-feed {
  flex: 1 1 auto;
  min-height: 108px;              /* 选项再长也留一条能读的流水 */
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px 26px;
  scroll-padding-bottom: 18px;
  position: relative;
  /* 上下缘渐隐：滚到中间时上一条不会被生硬切断 */
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0,
    #000 14px,
    #000 calc(100% - 10px),
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    transparent 0,
    #000 14px,
    #000 calc(100% - 10px),
    transparent 100%
  );
}

.log-entry {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  column-gap: 9px;
  padding: 6px 0 7px;
  animation: entry-in 260ms var(--ease) both;
}

/* 条目之间一道极淡的账簿线 */
.log-entry + .log-entry {
  border-top: 1px solid rgba(36, 31, 26, 0.055);
}

.log-age {
  position: relative;
  grid-column: 1;
  padding-top: 5px;
  padding-left: 10px;
  text-align: right;
  font-size: 10.5px;
  line-height: 1.4;
  letter-spacing: 0.02em;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 左侧年份刻度 */
.log-age::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 9px;
  width: 5px;
  height: 1px;
  background: var(--rule-ink);
  opacity: 0.65;
}

/* 最新一条：年龄刻度与数字用朱红点亮，读到哪一眼就知道 */
.log-entry:last-child .log-age {
  color: var(--seal-ink-deep);
  font-weight: 600;
}
.log-entry:last-child .log-age::before {
  width: 8px;
  background: var(--seal-ink);
  opacity: 0.9;
}

.log-body {
  grid-column: 2;
  min-width: 0;
  padding-left: 11px;
  border-left: 1px solid var(--rule-2);   /* 逐条相接 = 一条连续的卷宗脊线 */
}

.log-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.85;
  letter-spacing: 0.012em;
  color: #221d18;                 /* 纸面对比 ≈ 14:1，长文连读不累眼 */
  overflow-wrap: break-word;
  word-break: break-word;
}
.log-text p { margin: 0; }

/* ---- 属性变化小签 ---- */
.fx-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.fx-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border: 1px solid transparent;
  border-radius: 2px;
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.fx-up {
  color: var(--red-deep);
  background: rgba(178, 59, 46, 0.10);
  border-color: rgba(178, 59, 46, 0.20);
}

.fx-down {
  color: var(--cold);
  background: rgba(63, 71, 75, 0.075);
  border-color: rgba(63, 71, 75, 0.18);
}

/* ---- 变体 1：天赋汇总 —— 弱化、居中、小字 ---- */
.log-entry.log-meta {
  display: block;
  padding: 4px 0 12px;
  text-align: center;
  animation: none;
}
.log-entry.log-meta .log-age {
  display: inline;
  padding: 0;
  margin-right: 5px;
  font-size: 10px;
  color: var(--ink-mute);
}
.log-entry.log-meta .log-body {
  display: block;
  padding-left: 0;
  border-left: 0;
}
.log-entry.log-meta .log-text {
  font-size: 11.5px;
  line-height: 1.7;
  letter-spacing: 0.07em;
  color: var(--ink-soft);
}

/* ---- 变体 2：出生 —— 强调，印章感 ---- */
.log-entry.log-birth { padding: 6px 0 10px; }
.log-entry.log-birth .log-body {
  border-left: 2px solid var(--red);
  background: linear-gradient(90deg, rgba(178, 59, 46, 0.06), rgba(178, 59, 46, 0) 78%);
}
.log-entry.log-birth .log-text {
  font-size: 16.5px;
  font-weight: 600;
  line-height: 1.8;
  letter-spacing: 0.035em;
  color: #2a231d;
}
.log-entry.log-birth .log-age { color: var(--red-deep); font-weight: 600; }

/* ---- 变体 3：天赋专属剧情 —— 朱红竖线 ---- */
.log-entry.log-extra .log-body {
  border-left: 3px solid var(--red);
  padding-left: 10px;
  background: linear-gradient(90deg, rgba(178, 59, 46, 0.06), rgba(178, 59, 46, 0) 72%);
}
.log-entry.log-extra .log-text { color: #382e26; }
.log-entry.log-extra .log-age { color: var(--red-deep); }

/* ---- 天赋来源小注（ui.js 的 .log-from） ---- */
.log-from {
  display: inline-block;
  margin-top: 6px;
  padding: 1px 6px 1px 0;
  font-size: 10.5px;
  line-height: 1.7;
  letter-spacing: 0.1em;
  color: var(--red-deep);
  opacity: 0.8;
}
.log-entry.log-extra .log-from { opacity: 0.9; }

/* ---- 变体 4：玩家选择 —— 缩进 + 箭头，和旁白区分开 ---- */
.log-entry.log-choice .log-body {
  border-left: 1px dashed var(--rule-2);
  padding-left: 11px;
}
.log-entry.log-choice .log-text {
  position: relative;
  padding-left: 15px;
  font-size: 14px;
  line-height: 1.8;
  color: #4a4137;
}
.log-entry.log-choice .log-text::before {
  content: "\2192";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--red);
  font-weight: 600;
  letter-spacing: 0;
}

/* ---- 变体 5：死亡 —— 加重、双横线 ---- */
.log-entry.log-death { padding: 10px 0 8px; }
.log-entry.log-death .log-body {
  border-left: 2px solid var(--ink);
}
.log-entry.log-death .log-age {
  color: var(--red-deep);
  font-weight: 600;
}
.log-entry.log-death .log-text {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.8;
  letter-spacing: 0.03em;
  color: #1d1915;
  padding: 10px 0;
  border-top: 1px solid rgba(36, 31, 26, 0.22);
  border-bottom: 1px solid rgba(36, 31, 26, 0.22);
}

/* 等待玩家选择的条目（ui.js 若加 is-waiting 则轻微呼吸提示） */
.log-entry.is-waiting .log-body { border-left-color: rgba(178, 59, 46, 0.55); }

/* ==========================================================================
 * 13. 选项区 / 加速条
 * ========================================================================== */
.life-actions {
  flex: 0 0 auto;
  /* 极窄/极矮屏上三个长选项也不会把底部挤出屏幕：超出就在选项区内滚动 */
  max-height: min(52vh, 380px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 9px 14px;
  padding-bottom: calc(9px + var(--safe-b));
  border-top: 1px solid var(--rule);
  background: linear-gradient(to top, rgba(255, 252, 244, 0.74), rgba(255, 252, 244, 0));
  scrollbar-width: none;
}
.life-actions::-webkit-scrollbar { width: 0; height: 0; }
.life-actions:empty { display: none; }

.feed-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.mini-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 44px;
  padding: 0 14px;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  background: var(--paper-2);
  border: 1px solid var(--rule-ink);
  border-radius: var(--r-sm);
  box-shadow: var(--sh-1), 0 2px 0 rgba(36, 31, 26, 0.06);
  transition: background-color 0.14s var(--ease), border-color 0.14s var(--ease),
              transform 0.1s var(--ease), box-shadow 0.12s var(--ease);
}
.mini-btn:active {
  transform: translateY(1px);
  box-shadow: none;
  background: var(--paper-3);
}
/* 兜底：ui.js 里若还有符号字符，强制文本字形而不是彩色 emoji */
.mini-btn,
.choice-btn {
  font-variant-emoji: text;
}
.mini-btn.is-active,
.mini-btn[aria-pressed="true"] {
  color: var(--red-deep);
  border-color: rgba(178, 59, 46, 0.5);
  background: rgba(178, 59, 46, 0.08);
}
@media (hover: hover) {
  .mini-btn:hover { background: #f2e8d4; }
}

.choice-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.choice-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 11.5px;
  letter-spacing: 0.16em;
  color: var(--ink-mute);
}
.choice-title::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--rule);
}

.choice-box .choice-title + .choice-btn { margin-top: 1px; }

.choice-btn {
  position: relative;
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 11px 14px 11px 34px;
  text-align: left;
  font-size: 14.5px;
  line-height: 1.55;
  letter-spacing: 0.01em;
  color: var(--ink);
  background: var(--paper-1);
  border: 1px solid var(--rule-ink);
  border-radius: var(--r-sm);
  box-shadow: var(--sh-1), 0 2px 0 rgba(36, 31, 26, 0.06);
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease),
              transform 0.1s var(--ease), box-shadow 0.12s var(--ease);
}
.choice-btn:active {
  transform: translateY(1px);
  box-shadow: none;
  background: var(--paper-2);
}
.choice-btn::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -3.5px;
  border-right: 1.8px solid var(--seal-ink);
  border-bottom: 1.8px solid var(--seal-ink);
  transform: rotate(-45deg);
  opacity: 0.85;
  pointer-events: none;
}
.choice-btn:active { transform: translateY(1px); box-shadow: none; }
@media (hover: hover) {
  .choice-btn:hover {
    background: #fcf5e7;
    border-color: rgba(178, 59, 46, 0.45);
  }
}

/* ==========================================================================
 * 14. 结算页
 * ========================================================================== */
.end-panel {
  position: relative;
  text-align: center;
  padding: 26px 22px 20px;
  border-radius: var(--r-md);
  background-image: linear-gradient(180deg, rgba(255, 253, 247, 0.55), rgba(255, 253, 247, 0));
}

/* 鉴定书内框 */
.end-panel::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid var(--rule-ink);
  border-radius: var(--r-xs);
  opacity: 0.45;
  pointer-events: none;
}

/* 印章宿主 */
.end-seal {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 108px;
  margin-bottom: 2px;
  animation: seal-stamp 280ms var(--ease) both;
}
.end-seal:empty { display: none; }

.end-name {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 2px;
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 1.4;
  color: var(--ink);
}

/* 名字两侧各一道落款线 */
.end-name::before,
.end-name::after {
  content: "";
  flex: 0 0 auto;
  width: 22px;
  height: 1px;
  background: var(--rule-ink);
  opacity: 0.7;
}

.end-text {
  margin: 12px 0 4px;
  font-size: 14.5px;
  line-height: 1.95;
  letter-spacing: 0.02em;
  text-align: left;
  color: var(--ink-soft);
}
.end-text:empty { display: none; }

.end-stats {
  margin: 12px 0 2px;
  text-align: left;
}
.end-stats:empty { display: none; }

.end-stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 7px 2px;
  border-bottom: 1px dashed var(--rule);
  font-size: 13px;
  line-height: 1.7;
}
.end-stat:last-child { border-bottom: 0; }
.end-stat span {
  color: var(--ink-mute);
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.end-stat b {
  font-weight: 600;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-align: right;
}

.end-score {
  margin: 12px 0 2px;
  padding-top: 10px;
  border-top: 1px dashed var(--rule);
  font-size: 12.5px;
  letter-spacing: 0.14em;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
}
.end-score:empty { display: none; }

/* 「图鉴 +1」当一枚小印泥章 */
.end-new {
  display: inline-block;
  margin: 10px 0 2px;
  padding: 4px 12px 5px;
  font-size: 11.5px;
  letter-spacing: 0.18em;
  color: var(--seal-ink-deep);
  background: rgba(178, 59, 46, 0.07);
  border: 1.5px solid rgba(178, 59, 46, 0.55);
  border-radius: 1px;
  transform: rotate(-2.4deg);
  -webkit-mask-image: var(--seal-mask);
  mask-image: var(--seal-mask);
  -webkit-mask-size: 110px 110px;
  mask-size: 110px 110px;
  animation: stamp-in 340ms var(--ease) both;
}

.end-panel .btn {
  display: flex;
  width: 100%;
}
.end-panel .btn + .btn { margin-top: 10px; }
.end-panel #btn-restart { margin-top: 20px; }
.end-panel .end-new + .btn { margin-top: 18px; }

/* ==========================================================================
 * 15. 图鉴弹层
 * ========================================================================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 14px;
  padding-bottom: calc(14px + var(--safe-b));
  background: rgba(36, 31, 26, 0.44);
  animation: fade-in 180ms var(--ease) both;
}

.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: min(86dvh, 760px);
  display: flex;
  flex-direction: column;
  background-color: var(--paper-1);
  background-image: radial-gradient(120% 70% at 50% -10%, #fdf8ec 0%, rgba(253, 248, 236, 0) 60%);
  border: 1px solid var(--rule-ink);
  border-radius: 5px;
  box-shadow: 0 14px 36px rgba(40, 28, 18, 0.28);
  overflow: hidden;
  animation: modal-in 240ms var(--ease) both;
}

.modal-head {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 11px;
  border-bottom: 1px solid var(--rule);
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--ink);
}

.modal-progress {
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
}

.codex-grid {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  align-content: start;
}

.codex-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  min-height: 104px;
  padding: 11px 10px 10px;
  background: var(--paper-1);
  border: 1px solid var(--rule-ink);
  border-radius: var(--r-sm);
  box-shadow: var(--sh-1);
}

/* 印章位 */
.codex-seal {
  display: flex;
  align-items: center;
  min-height: 50px;
  margin-bottom: 1px;
}

.codex-name {
  font-family: var(--font-serif);
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: 0.05em;
  color: var(--ink);
}

.codex-text {
  font-size: 11.5px;
  line-height: 1.65;
  letter-spacing: 0.01em;
  color: var(--ink-mute);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.codex-card.is-locked {
  background-color: var(--paper-2);
  background-image: repeating-linear-gradient(
    135deg,
    rgba(36, 31, 26, 0.025) 0 7px,
    rgba(36, 31, 26, 0.055) 7px 8px
  );
  border-style: dashed;
  border-color: var(--rule);
  box-shadow: none;
}
.codex-card.is-locked .codex-name {
  color: var(--ink-mute);
  letter-spacing: 0.2em;
}
.codex-card.is-locked .codex-text { opacity: 0.18; }

.modal-card > .btn {
  flex: 0 0 auto;
  margin: 0 14px 14px;
  width: calc(100% - 28px);
}
.modal-head + .codex-grid { margin-bottom: 12px; }

/* ==========================================================================
 * 15.5 印章系统
 *
 * 印泥质感的做法（全部是 CSS，没有位图）：
 *   1. 一道 turbulence 噪点遮罩（--seal-mask）作用在整个印章上 —— 边框和字形
 *      一起被"啃掉"随机的小块，边缘自然出毛刺，不是光滑色块。
 *   2. 印框内再叠两层极淡的径向色斑，模拟印泥浓一处淡一处。
 *   3. ::after 是一道错位 1px 的低透明复框 = 按第二次时没对准的"重影"。
 *   4. 尺寸不同用同样的遮罩尺寸，颗粒尺度保持一致。
 * ========================================================================== */
.seal {
  --s: 46px;
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  flex: 0 0 auto;
  width: var(--s);
  height: var(--s);
  color: var(--seal-ink);
  font-family: var(--font-serif);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  text-indent: 0;
  white-space: nowrap;
  border: 2.5px solid currentColor;
  border-radius: 1px;
  background-image:
    radial-gradient(40% 44% at 26% 20%, rgba(178, 59, 46, 0.17), rgba(178, 59, 46, 0) 72%),
    radial-gradient(46% 42% at 78% 82%, rgba(178, 59, 46, 0.15), rgba(178, 59, 46, 0) 74%),
    radial-gradient(60% 60% at 50% 50%, rgba(178, 59, 46, 0.06), rgba(178, 59, 46, 0) 78%);
  -webkit-mask-image: var(--seal-mask);
  mask-image: var(--seal-mask);
  -webkit-mask-size: 132px 132px;
  mask-size: 132px 132px;
  -webkit-mask-position: center;
  mask-position: center;
  transform: rotate(-2.2deg);
}

.seal-ch {
  display: block;
  line-height: 0.92;
}

/* 大印章：结算页，方框 + 内细线 + 复框重影 */
.seal-lg {
  --s: 108px;
  border-width: 4px;
  font-size: 39px;
}
.seal-lg .seal-ch { line-height: 0.9; }

.seal-lg::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid currentColor;
  border-radius: 1px;
  opacity: 0.72;
  pointer-events: none;
}

.seal-lg::after {
  content: "";
  position: absolute;
  inset: -1.5px;
  border: 1px solid currentColor;
  border-radius: 1px;
  opacity: 0.24;
  transform: translate(1px, 1.5px) rotate(0.7deg);
  pointer-events: none;
}

/* 小印章：图鉴 */
.seal-sm {
  --s: 46px;
  border-width: 2px;
  font-size: 16px;
}

/* 未解锁：灰墨虚框 + ？，干净但不示弱 */
.seal.is-locked {
  color: var(--seal-mute);
  border: 1.5px dashed currentColor;
  background-image: none;
  -webkit-mask-image: none;
  mask-image: none;
  opacity: 0.9;
  transform: rotate(-1.6deg);
}
.seal.is-locked::before,
.seal.is-locked::after { display: none; }
.seal.is-locked .seal-ch { font-size: 1.05em; opacity: 0.92; }

/* 图鉴里每一枚印章的倾角都不一样，像一面盖歪了的章墙 */
.codex-card:nth-child(3n + 1) .seal { transform: rotate(-2.6deg); }
.codex-card:nth-child(3n + 2) .seal { transform: rotate(1.8deg); }
.codex-card:nth-child(3n)     .seal { transform: rotate(-0.9deg); }
.codex-card:nth-child(4n)     .seal { transform: rotate(2.4deg); }

/* 结算页的大印 */
.end-seal .seal-lg { transform: rotate(-2.9deg); }

/* ==========================================================================
 * 16. Toast
 * ========================================================================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(26px + var(--safe-b));
  z-index: 80;
  display: inline-flex;
  align-items: center;
  max-width: calc(100% - 44px);
  padding: 10px 16px;
  font-size: 13.5px;
  line-height: 1.6;
  letter-spacing: 0.04em;
  color: #f8f0e0;
  background: rgba(36, 31, 26, 0.93);
  border-radius: 4px;
  box-shadow: 0 6px 18px rgba(30, 20, 10, 0.26);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 8px);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease),
              visibility 0.2s linear;
  pointer-events: none;
  text-align: center;
}

.toast.is-shown {
  display: inline-flex;          /* 比 .hidden 更具体：即使 hidden 没被移除也能显示 */
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

/* ==========================================================================
 * 17. 动画（只用 transform / opacity / 颜色，绝不用 blur）
 * ========================================================================== */
@keyframes screen-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes entry-in {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes stamp-in {
  from { opacity: 0; transform: rotate(-9deg) scale(0.9); }
  to   { opacity: 1; transform: rotate(-2deg) scale(1); }
}

/* 盖章：压下去、回弹、落定 */
@keyframes seal-stamp {
  0%   { opacity: 0; transform: scale(1.16); }
  55%  { opacity: 1; transform: scale(0.985); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes hud-up {
  0%   { background-color: rgba(178, 59, 46, 0.22); border-color: rgba(178, 59, 46, 0.5); }
  100% { background-color: rgba(255, 252, 244, 0.42); border-color: rgba(36, 31, 26, 0.12); }
}

@keyframes hud-down {
  0%   { background-color: rgba(63, 71, 75, 0.18); border-color: rgba(63, 71, 75, 0.42); }
  100% { background-color: rgba(255, 252, 244, 0.42); border-color: rgba(36, 31, 26, 0.12); }
}

@keyframes hud-val-up {
  0%   { color: var(--red-deep); transform: translateY(-2px); }
  100% { color: var(--ink-soft); transform: translateY(0); }
}

@keyframes hud-val-down {
  0%   { color: var(--cold); transform: translateY(2px); }
  100% { color: var(--ink-soft); transform: translateY(0); }
}

/* ==========================================================================
 * 18. 响应式
 * ========================================================================== */

/* 小屏：更紧的边距，保证 390 宽下正文还有 20 字左右一行 */
@media (max-width: 359px) {
  .life-feed { padding-left: 11px; padding-right: 11px; }
  .log-entry { grid-template-columns: 34px minmax(0, 1fr); column-gap: 7px; }
  .log-body { padding-left: 9px; }
  .log-text { font-size: 14.5px; }
  .talent-grid { padding-left: 10px; padding-right: 10px; gap: 7px; }
  .talent-card { min-height: 96px; padding: 9px; }
  .talent-name { font-size: 14.5px; }
  .attr-list { padding-left: 10px; padding-right: 10px; }
  .attr-row { padding: 8px 9px; gap: 7px; }
  /* 点击目标仍保持 44×44，靠压缩行内边距让出空间 */
  .stage-head { padding-left: 12px; padding-right: 12px; }
  .stage-foot { padding-left: 10px; padding-right: 10px; }
}

/* 桌面 / 平板：把纸页放在桌面上，正文放宽到 34~36 字一行 */
@media (min-width: 641px) {
  /* 桌面：把卷宗纸放在一张更深的桌面上，纸页边界才看得出来 */
  body {
    background-color: #d8cbb0;
    background-image:
      radial-gradient(120% 86% at 50% -6%, #e9dec7 0%, rgba(233, 222, 199, 0) 62%),
      radial-gradient(100% 80% at 50% 108%, #cbbca0 0%, rgba(203, 188, 160, 0) 64%);
    background-repeat: no-repeat, no-repeat;
  }
  #app {
    border-left: 1px solid rgba(36, 31, 26, 0.10);
    border-right: 1px solid rgba(36, 31, 26, 0.10);
    box-shadow: 0 0 0 1px rgba(36, 31, 26, 0.06), 0 22px 64px rgba(70, 52, 30, 0.22);
  }
  .log-entry { grid-template-columns: 46px minmax(0, 1fr); column-gap: 12px; }
  .log-body { padding-left: 13px; }
  .log-text { font-size: 15.8px; line-height: 1.9; }
  .log-age { font-size: 11px; }
  .life-feed { padding-left: 20px; padding-right: 20px; }
  .talent-grid { padding-left: 20px; padding-right: 20px; gap: 11px; }
  .attr-list { padding-left: 20px; padding-right: 20px; }
  .stage-head { padding-left: 22px; padding-right: 22px; }
  .stage-foot { padding-left: 20px; padding-right: 20px; }
  .codex-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .modal { align-items: center; }
  .life-hud { padding-left: 20px; padding-right: 20px; }
  .life-actions { padding-left: 20px; padding-right: 20px; }
}

@media (min-width: 1000px) {
  .log-text { font-size: 16.2px; }
  .panel { max-width: 560px; }
}

/* 矮屏（1366×768 / 1432×768 这类笔记本）：结算页必须一屏放下 */
@media (max-height: 820px) {
  .end-panel { padding: 18px 18px 16px; }

  .end-seal { min-height: 84px; margin-bottom: 0; }
  .end-seal .seal-lg { --s: 84px; border-width: 3px; font-size: 29px; }
  .end-seal .seal-lg::before { inset: 3px; }

  .end-name { font-size: 22px; margin-top: 2px; }
  .end-text { margin: 10px 0 2px; font-size: 14px; line-height: 1.8; }

  /* 属性统计转两列，省掉一半高度 */
  .end-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 18px;
    margin: 10px 0 2px;
  }
  .end-stat { padding: 5px 2px; font-size: 12.5px; }

  .end-score { margin: 10px 0 2px; padding-top: 8px; }
  .end-new { margin: 6px 0 0; }
  .end-panel #btn-restart { margin-top: 12px; }
  .end-panel .btn + .btn { margin-top: 8px; }
  .end-panel .end-new + .btn { margin-top: 12px; }
}

/* ==========================================================================
 * 19. 无障碍 / 降级
 * ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .screen.is-active,
  .log-entry {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --ink: #14100c;
    --ink-soft: #2b241d;
    --ink-mute: #3a332a;
    --rule: rgba(20, 16, 12, 0.24);
    --rule-2: rgba(20, 16, 12, 0.3);
    --rule-ink: rgba(20, 16, 12, 0.5);
  }
  .log-text { color: #14100c; }
}

/* 内容超高时宁可内部滚动，也不制造第二根滚动条 */
@supports (height: 100dvh) {
  #app { height: 100dvh; }
}

/* ==========================================================================
 * 20. 工具类 —— 必须放在文件最后：
 *     .hidden 与 .end-new / .toast 同为单类选择器，靠顺序取胜；
 *     .toast.is-shown 用双类选择器，优先级高，仍然可以正常显示。
 * ========================================================================== */
.hidden { display: none; }
