/* ==========================================================================
   人生重开模拟器 · 游戏页样式
   --------------------------------------------------------------------------
   设计语言与主站（assets/css/theme-heroui.css）对齐：
     同一组灰阶 / 主色 #0F8F83 / 卡片圆角 20px / 控件圆角 12px / 同一套阴影。
   另加：深色模式（跟随系统）、三模式各自的强调色、更细腻的层次。

   ⚠️ 改这个文件前必读：
   game.bundle.js（由 src/app.js 打包）会往 #main 里注入大量 HTML，
   类名全部写死在 JS 里。**只能改样式，不能改类名或结构**，
   否则 JS 找不到元素、游戏直接白屏。
   已依赖的选择器：#main #notice #current-mode .brand .brand-mark
   .site-header button .utility-nav button [data-entry-mode] [data-character]
   [data-inherit] .quiet .selected .error
   ========================================================================== */

:root {
    color-scheme: light;

    --bg: #F6F6F7;
    --bg-soft: #EDEDEF;
    --panel: #FFFFFF;
    --raised: #F4F4F5;
    --line: #E7E7EA;
    --line-soft: #EFEFF2;

    --text: #24292E;
    --muted: #5F6672;
    --faint: #9AA1AC;

    --primary: #0F8F83;
    --primary-hover: #0B756B;
    --tint: rgba(15, 143, 131, .12);
    --tint-strong: rgba(15, 143, 131, .18);

    --danger: #DC2626;
    --danger-soft: rgba(220, 38, 38, .1);
    --success: #16A34A;
    --warning: #D97706;

    --radius: 20px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --radius-xs: 8px;
    --radius-pill: 999px;

    --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
    --shadow-hover: 0 2px 4px rgba(16, 24, 40, .06), 0 16px 36px rgba(16, 24, 40, .1);

    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC",
                 "Microsoft YaHei", system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.65;
    font-synthesis: none;
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --bg: #17191C;
        --bg-soft: #1E2126;
        --panel: #22252A;
        --raised: #282C31;
        --line: #2F3339;
        --line-soft: #282C31;
        --text: #E8EAED;
        --muted: #A8AFB8;
        --faint: #767D87;
        --primary: #2BC0B0;
        --primary-hover: #3DD3C2;
        --tint: rgba(43, 192, 176, .16);
        --tint-strong: rgba(43, 192, 176, .24);
        --danger: #F87171;
        --danger-soft: rgba(248, 113, 113, .14);
        --success: #4ADE80;
        --warning: #FBBF24;
        --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 1px 3px rgba(0, 0, 0, .36);
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .4);
        --shadow-hover: 0 2px 4px rgba(0, 0, 0, .36), 0 16px 36px rgba(0, 0, 0, .5);
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3 {
    margin: 0;
    line-height: 1.35;
}

p {
    margin: 0;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    color: var(--primary-hover);
}

/* ==========================================================================
   跳过链接（无障碍）
   ========================================================================== */
.skip-link {
    position: absolute;
    top: -60px;
    left: 12px;
    z-index: 100;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font-size: .85rem;
    transition: top .18s ease;
}

.skip-link:focus {
    top: 12px;
    color: #fff;
}

/* ==========================================================================
   顶部栏
   ========================================================================== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 12px 20px 0;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid var(--line);
}

@supports not (background: color-mix(in srgb, red, blue)) {
    .site-header {
        background: var(--bg);
    }
}

.header-top {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    max-width: 1080px;
    margin: 0 auto;
    padding-bottom: 10px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--text);
    font-size: .95rem;
    font-weight: 600;
    white-space: nowrap;
}

.brand:hover {
    color: var(--text);
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-xs);
    background: var(--primary);
    color: #fff;
    font-size: .92rem;
    font-weight: 700;
    line-height: 1;
}

.current-mode {
    padding: 3px 11px;
    border-radius: var(--radius-pill);
    background: var(--tint);
    color: var(--primary);
    font-size: .75rem;
    font-weight: 500;
    white-space: nowrap;
}

.current-mode:empty {
    display: none;
}

.utility-nav {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

/* 顶部所有按钮（.quiet 变体与默认） */
.site-header button {
    padding: 6px 13px;
    border: 1px solid transparent;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--muted);
    font-family: inherit;
    font-size: .83rem;
    line-height: 1.5;
    cursor: pointer;
    transition: background .16s ease, color .16s ease, border-color .16s ease;
}

.site-header button:hover:not(:disabled) {
    background: var(--raised);
    color: var(--text);
}

.site-header button:disabled {
    opacity: .45;
    cursor: default;
}

.utility-nav button[aria-current="page"] {
    background: var(--tint);
    color: var(--primary);
}

/* 模式切换 */
.mode-nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    max-width: 1080px;
    margin: 0 auto;
    padding-bottom: 10px;
    scrollbar-width: none;
}

.mode-nav::-webkit-scrollbar {
    display: none;
}

.mode-nav button {
    flex: none;
    padding: 7px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: var(--panel);
    color: var(--muted);
    font-family: inherit;
    font-size: .83rem;
    line-height: 1.5;
    white-space: nowrap;
    cursor: pointer;
    transition: background .16s ease, color .16s ease, border-color .16s ease;
}

.mode-nav button:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.mode-nav button[aria-pressed="true"] {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 500;
}

.mode-nav button:disabled {
    opacity: .45;
    cursor: default;
}

/* ==========================================================================
   主内容
   ========================================================================== */
main {
    display: block;
    max-width: 1080px;
    margin: 0 auto;
    padding: 22px 20px 44px;
}

main:focus {
    outline: none;
}

/* 区块标题 */
.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.section-head h1 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -.01em;
}

.section-head p {
    margin-top: 4px;
    color: var(--muted);
    font-size: .86rem;
}

.section-head>button {
    flex: none;
    padding: 7px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius-xs);
    background: var(--panel);
    color: var(--muted);
    font-family: inherit;
    font-size: .8rem;
    cursor: pointer;
    transition: border-color .16s ease, color .16s ease;
}

.section-head>button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* 步骤条 */
.steps {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}

.step {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--faint);
    font-size: .82rem;
}

.step-index {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--raised);
    color: var(--faint);
    font-size: .72rem;
    font-weight: 600;
    line-height: 1;
}

.step.active {
    color: var(--primary);
    font-weight: 500;
}

.step.active .step-index {
    background: var(--primary);
    color: #fff;
}

.step-line {
    width: 22px;
    height: 1px;
    background: var(--line);
}

/* ==========================================================================
   通用面板 / 工具条 / 操作区
   ========================================================================== */
.panel {
    padding: 22px;
    border-radius: var(--radius);
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-xs);
}

.toolbar,
.actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.toolbar {
    margin-bottom: 16px;
}

.toolbar h2,
.toolbar p {
    margin: 0;
    font-size: .86rem;
    color: var(--muted);
}

.toolbar label {
    color: var(--muted);
    font-size: .84rem;
}

.actions {
    margin-top: 20px;
}

/* 主内容里所有按钮的基准样式 */
main button,
main select,
main input {
    font-family: inherit;
    font-size: .87rem;
}

main button {
    padding: 9px 17px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--panel);
    color: var(--text);
    line-height: 1.45;
    cursor: pointer;
    transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}

main button:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

main button:active:not(:disabled) {
    transform: scale(.985);
}

main button:disabled {
    opacity: .45;
    cursor: default;
}

main button.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 500;
}

main button.primary:hover:not(:disabled) {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #fff;
}

main button.quiet {
    background: transparent;
    border-color: transparent;
    color: var(--muted);
}

main button.quiet:hover:not(:disabled) {
    background: var(--raised);
    color: var(--text);
}

/* 输入控件 */
main input[type="search"],
main input[type="text"],
main select {
    padding: 8px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--panel);
    color: var(--text);
    line-height: 1.5;
    transition: border-color .16s ease, box-shadow .16s ease;
}

main input:focus,
main select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--tint);
}

/* ==========================================================================
   天赋网格
   ========================================================================== */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

#talents {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.talent {
    display: block;
    width: 100%;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--panel);
    text-align: left;
    cursor: pointer;
    transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.talent:hover:not(:disabled) {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.talent h3 {
    margin: 8px 0 5px;
    font-size: .92rem;
    font-weight: 600;
    color: var(--text);
}

.talent p {
    margin: 0;
    color: var(--muted);
    font-size: .82rem;
    line-height: 1.6;
}

.talent.selected {
    border-color: var(--primary);
    background: var(--tint);
    box-shadow: 0 0 0 3px var(--tint);
}

.talent.selected:hover {
    border-color: var(--primary);
}

.talent.locked {
    opacity: .5;
    cursor: default;
    background: var(--raised);
}

/* 稀有度徽章 */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: var(--radius-pill);
    background: var(--raised);
    color: var(--muted);
    font-size: .7rem;
    font-weight: 500;
    letter-spacing: .02em;
}

.grade-1 .badge {
    background: rgba(22, 163, 74, .12);
    color: var(--success);
}

.grade-2 .badge {
    background: rgba(14, 165, 233, .12);
    color: #0284C7;
}

.grade-3 .badge {
    background: rgba(217, 119, 6, .14);
    color: var(--warning);
}

@media (prefers-color-scheme: dark) {
    .grade-2 .badge {
        color: #38BDF8;
    }
}

.grade-3 .talent,
.talent.grade-3 {
    border-color: rgba(217, 119, 6, .3);
}

/* 选择计数 / 提示 / 错误 */
#selection-count {
    color: var(--muted);
    font-size: .84rem;
}

.action-hint {
    color: var(--muted);
    font-size: .82rem;
}

.hint {
    color: var(--faint);
    font-size: .8rem;
}

.small {
    color: var(--faint);
    font-size: .8rem;
}

.error {
    color: var(--danger);
    font-size: .84rem;
}

.message {
    margin-top: 12px;
    color: var(--muted);
    font-size: .84rem;
    min-height: 1.4em;
}

.message:empty {
    display: none;
}

.empty {
    padding: 26px 16px;
    border-radius: var(--radius-md);
    background: var(--raised);
    color: var(--faint);
    font-size: .85rem;
    text-align: center;
}

/* ==========================================================================
   属性分配
   ========================================================================== */
.allocation {
    display: grid;
    gap: 8px;
}

.allocation .toolbar {
    margin: 0 0 4px;
    justify-content: space-between;
}

.points {
    color: var(--primary);
    font-weight: 600;
    font-size: .9rem;
    font-variant-numeric: tabular-nums;
}

/* 一行四个元素：属性名 + 减号 + 数字 + 加号。
   ⚠️ 必须用 flex（或 4 列 grid）：JS 生成的 DOM 是
   label → button(−) → input → button(＋) 四个，
   写 3 列 grid 会让加号换行掉到下一行左侧。 */
.allocation-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--panel);
}

.allocation-row label {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--text);
    font-size: .88rem;
    font-weight: 500;
}

.allocation-row button {
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: var(--radius-xs);
    font-size: 1rem;
    line-height: 1;
}

.allocation-row input {
    flex: none;
    width: 50px;
    padding: 5px 6px;
    border: 1px solid var(--line);
    border-radius: var(--radius-xs);
    background: var(--raised);
    color: var(--text);
    font-size: .88rem;
    font-weight: 600;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.allocation-row input::-webkit-inner-spin-button,
.allocation-row input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ==========================================================================
   角色选择（名人模式）
   ========================================================================== */
.character-search {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.character-search label {
    color: var(--muted);
    font-size: .84rem;
}

.character-search input {
    flex: 1 1 200px;
    min-width: 0;
}

.character-layout {
    display: grid;
    grid-template-columns: minmax(200px, 280px) 1fr;
    gap: 16px;
    align-items: start;
}

.character-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 480px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--panel);
}

.character-list button {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid transparent;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--muted);
    font-size: .85rem;
    text-align: left;
    cursor: pointer;
    transition: background .14s ease, color .14s ease;
}

.character-list button:hover {
    background: var(--raised);
    color: var(--text);
}

.character-list button[aria-pressed="true"] {
    background: var(--tint);
    color: var(--primary);
    font-weight: 500;
}

.character-list .empty {
    padding: 16px 10px;
    background: transparent;
}

.character-detail h2 {
    margin-bottom: 12px;
    font-size: 1.1rem;
    font-weight: 600;
}

.character-detail .talent {
    margin-bottom: 10px;
}

.character-detail .stats {
    margin-top: 14px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--faint);
    font-size: .74rem;
    font-weight: 500;
    letter-spacing: .06em;
    text-transform: uppercase;
}

/* 属性表 */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
    gap: 8px;
    margin: 0;
    padding: 0;
}

.stat {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--raised);
    text-align: center;
}

.stat dt {
    color: var(--faint);
    font-size: .74rem;
    line-height: 1.4;
}

.stat dd {
    margin: 2px 0 0;
    color: var(--text);
    font-size: .98rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.character-detail .stat {
    background: var(--bg-soft);
}

/* ==========================================================================
   人生记录（游戏主界面）
   ========================================================================== */
.life-layout {
    display: grid;
    grid-template-columns: 1fr minmax(200px, 280px);
    gap: 16px;
    align-items: start;
}

.life-story {
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow-xs);
    min-width: 0;
}

.timeline {
    max-height: 460px;
    overflow-y: auto;
    margin: 0;
    padding: 0 4px 0 0;
    list-style: none;
    scroll-behavior: smooth;
}

.timeline:empty {
    display: none;
}

.year {
    position: relative;
    padding: 10px 0 12px 20px;
    border-left: 2px solid var(--line-soft);
}

.year::before {
    content: "";
    position: absolute;
    left: -5px;
    top: 16px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 0 3px var(--tint);
}

.year:last-child {
    border-left-color: transparent;
}

.year h3 {
    margin-bottom: 4px;
    color: var(--text);
    font-size: .88rem;
    font-weight: 600;
}

.year p {
    margin: 0 0 3px;
    color: var(--muted);
    font-size: .84rem;
    line-height: 1.65;
}

.year p.event-talent {
    color: var(--primary);
}

.life-side {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow-xs);
    position: sticky;
    top: 108px;
}

.life-side .stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.life-side .stat {
    padding: 8px 10px;
}

.life-side .stat dd {
    font-size: .9rem;
}

.life-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--line-soft);
}

.life-controls label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--muted);
    font-size: .82rem;
}

.life-controls select {
    flex: 1 1 auto;
    max-width: 110px;
}

.life-side>p {
    margin: 0;
    color: var(--faint);
    font-size: .76rem;
    line-height: 1.6;
}

/* ==========================================================================
   人生结算
   ========================================================================== */
.summary-score {
    padding: 20px;
    margin-bottom: 16px;
    border-radius: var(--radius);
    background: var(--tint);
    text-align: center;
}

.summary-score .eyebrow {
    color: var(--primary);
    opacity: .8;
}

.summary-score strong {
    display: block;
    color: var(--primary);
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

/* 结算页的 6 项成绩：固定 3 列 × 2 行。
   用 auto-fit 会在窄屏排成 4+2（一行 4 个、一行 2 个），看起来不齐；
   这里显式 3 列，桌面与手机都是整齐的 3×2。
   选择器带 .panel 前缀提高特异性，避免被窄屏断点里的 .stats 规则盖掉。 */
.panel .summary-score + .stats {
    grid-template-columns: repeat(3, 1fr);
}

.summary-inherit {
    margin-top: 22px;
}

.summary-inherit h2 {
    margin-bottom: 4px;
    font-size: 1rem;
    font-weight: 600;
}

.summary-inherit>p {
    margin: 0 0 14px;
    color: var(--muted);
    font-size: .84rem;
}

.summary-inherit .grid {
    margin-bottom: 4px;
}

.summary-inherit .talent[aria-pressed="true"] {
    border-color: var(--primary);
    background: var(--tint);
    box-shadow: 0 0 0 3px var(--tint);
}

/* ==========================================================================
   成就
   ========================================================================== */
.collection-stats {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    /* 用 --panel + 边框，而不是 --raised：
       --raised(#F4F4F5) 与页面底色 --bg(#F6F6F7) 几乎同色，
       整块统计会「消失」在背景里，看不出是一个独立区块 */
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: .84rem;
}

/* 统计块内部的格子不要再叠一层底色，避免同色看不清 */
.collection-stats .stat {
    flex: 1 1 auto;
    min-width: 64px;
    padding: 0;
    background: none;
    border-radius: 0;
    text-align: left;
}

.collection-stats .stat + .stat {
    padding-left: 10px;
    border-left: 1px solid var(--line-soft);
}

.collection-stats .stat dt {
    font-size: .74rem;
    color: var(--faint);
}

.collection-stats .stat dd {
    margin-top: 2px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.collection-stats strong {
    color: var(--text);
    font-weight: 600;
}

.achievement {
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--panel);
    transition: border-color .16s ease;
}

.achievement h3 {
    margin-bottom: 4px;
    font-size: .88rem;
    font-weight: 600;
}

.achievement p {
    color: var(--muted);
    font-size: .81rem;
    line-height: 1.6;
}

.achievement .state {
    display: inline-block;
    margin-top: 8px;
    padding: 2px 9px;
    border-radius: var(--radius-pill);
    background: var(--tint);
    color: var(--primary);
    font-size: .72rem;
    font-weight: 500;
}

.achievement.unearned {
    opacity: .6;
    background: var(--raised);
}

.achievement.unearned .state {
    background: var(--bg-soft);
    color: var(--faint);
}

/* 成就网格（JS 用 .grid 包，这里补一个三列节奏）*/
.grid .achievement:nth-child(3n+2) {
    border-color: var(--line);
}

/* ==========================================================================
   存档
   ========================================================================== */
.save-grid {
    display: grid;
    gap: 16px;
}

.save-grid h2 {
    margin-bottom: 6px;
    font-size: .95rem;
    font-weight: 600;
}

.save-grid label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: .84rem;
}

.save-grid button {
    margin-top: 10px;
}

.save-text-label {
    display: block;
    margin: 16px 0 6px;
    color: var(--muted);
    font-size: .84rem;
}

/* 文件选择框：浏览器默认样式（灰色「选择文件」按钮 + 系统字体）与页面格格不入，
   用 ::file-selector-button 单独美化按钮部分，其余保持原生行为 */
.save-grid input[type="file"] {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--raised);
    color: var(--muted);
    font-family: inherit;
    font-size: .8rem;
    line-height: 1.5;
    cursor: pointer;
}

.save-grid input[type="file"]::file-selector-button {
    margin-right: 10px;
    padding: 5px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-xs);
    background: var(--panel);
    color: var(--text);
    font-family: inherit;
    font-size: .8rem;
    cursor: pointer;
    transition: border-color .16s ease, color .16s ease;
}

.save-grid input[type="file"]::file-selector-button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.save-grid textarea {
    width: 100%;
    min-height: 150px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--raised);
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .78rem;
    line-height: 1.6;
    resize: vertical;
}

.save-grid textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--tint);
}

/* ==========================================================================
   提示条 / 页脚 / 加载
   ========================================================================== */
.notice {
    position: fixed;
    left: 50%;
    bottom: 26px;
    z-index: 90;
    transform: translate(-50%, 12px);
    max-width: min(440px, calc(100vw - 32px));
    padding: 11px 20px;
    border-radius: var(--radius-pill);
    background: rgba(36, 41, 46, .94);
    color: #fff;
    font-size: .84rem;
    line-height: 1.5;
    text-align: center;
    box-shadow: var(--shadow-hover);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease, transform .22s ease;
}

.notice[hidden] {
    display: none;
}

.notice:not([hidden]) {
    opacity: 1;
    transform: translate(-50%, 0);
}

@media (prefers-color-scheme: dark) {
    .notice {
        background: rgba(232, 234, 237, .96);
        color: #17191C;
    }
}

.site-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
    max-width: 1080px;
    margin: 0 auto;
    padding: 20px 20px 34px;
    color: var(--faint);
    font-size: .76rem;
    text-align: center;
}

.loading {
    display: grid;
    place-items: center;
    gap: 10px;
    padding: 60px 20px;
    text-align: center;
}

.loading h1 {
    font-size: 1.05rem;
    font-weight: 600;
}

.loading p {
    color: var(--muted);
    font-size: .85rem;
}

.loading-indicator {
    display: block;
    width: 30px;
    height: 30px;
    border: 2.5px solid var(--line);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes arrive {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.life-story .year {
    animation: arrive .24s ease;
}

/* ==========================================================================
   三模式强调色（body[data-mode] 由 JS 设置）
   ========================================================================== */
body[data-mode="cultivation"] {
    --primary: #7C5CD6;
    --primary-hover: #6A48C7;
    --tint: rgba(124, 92, 214, .12);
    --tint-strong: rgba(124, 92, 214, .18);
}

body[data-mode="celebrity"] {
    --primary: #C2760B;
    --primary-hover: #A96209;
    --tint: rgba(224, 138, 18, .14);
    --tint-strong: rgba(224, 138, 18, .2);
}

@media (prefers-color-scheme: dark) {
    body[data-mode="cultivation"] {
        --primary: #A88BF0;
        --primary-hover: #B79EF3;
        --tint: rgba(146, 118, 230, .2);
        --tint-strong: rgba(146, 118, 230, .28);
    }

    body[data-mode="celebrity"] {
        --primary: #EFAE43;
        --primary-hover: #F3BC63;
        --tint: rgba(240, 168, 62, .18);
        --tint-strong: rgba(240, 168, 62, .26);
    }
}

/* ==========================================================================
   响应式
   ========================================================================== */
@media (max-width: 1024px) {

    /* 单列堆叠：人生轨迹（主内容）在上，属性与控制在下。
       ⚠️ 早先给 .life-side 加过 order: -1 想「让操作区前移」，
       结果属性网格占了整屏顶部、时间轴被挤到看不见的地方 ——
       次要信息不该盖在主内容前面。 */
    .life-layout,
    .character-layout {
        grid-template-columns: 1fr;
    }

    .life-story {
        order: 1;
    }

    .life-side {
        position: static;
        order: 2;
    }

    /* 单列时时间轴限高，保证「时间轴 + 按钮」能同屏，不必来回滚动 */
    .timeline {
        max-height: 44vh;
    }

    /* 角色列表改成多列网格：单列布局下它占满整行，
       而角色名都很短，纵向排会变成又高又空的窄条。 */
    .character-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
        gap: 4px;
        max-height: 240px;
    }

    .character-list button {
        text-align: left;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .character-list .empty {
        grid-column: 1 / -1;
    }
}

@media (max-width: 768px) {
    .site-header {
        padding: 8px 12px 0;
    }

    /* 顶部栏压缩：品牌名缩小 + 导航按钮收紧，
       让「品牌 + 徽章 + 导航」尽量留在同一行，别撑成三层 */
    .header-top {
        gap: 8px;
        padding-bottom: 8px;
    }

    .brand-text {
        font-size: .82rem;
    }

    .brand-mark {
        width: 26px;
        height: 26px;
        font-size: .84rem;
    }

    .current-mode {
        font-size: .7rem;
        padding: 2px 8px;
    }

    .utility-nav {
        gap: 2px;
    }

    .utility-nav button {
        padding: 5px 9px;
        font-size: .78rem;
    }

    .mode-nav {
        gap: 5px;
        padding-bottom: 8px;
    }

    .mode-nav button {
        padding: 6px 13px;
        font-size: .78rem;
    }

    main {
        padding: 16px 14px 36px;
    }

    .panel,
    .life-story,
    .life-side {
        padding: 16px;
    }

    .section-head h1 {
        font-size: 1.15rem;
    }

    .grid,
    #talents {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 10px;
    }

    .talent {
        padding: 13px;
    }

    .talent h3 {
        font-size: .87rem;
    }

    .talent p {
        font-size: .78rem;
    }

    .stats {
        grid-template-columns: repeat(auto-fit, minmax(74px, 1fr));
        gap: 6px;
    }

    .stat {
        padding: 8px;
    }

    .stat dd {
        font-size: .88rem;
    }

    .steps {
        gap: 6px;
    }

    .step span:not(.step-index) {
        display: none;
    }

    .step.active span:not(.step-index) {
        display: inline;
    }

    .step-line {
        width: 14px;
    }

    .summary-score strong {
        font-size: 1.8rem;
    }

    /* 手机端点按目标不少于 40px */
    main button {
        min-height: 40px;
    }

    .mode-nav button {
        min-height: 36px;
    }
}


@media (max-height: 500px) and (orientation: landscape) {
    .timeline {
        max-height: 260px;
    }

    .character-list {
        max-height: 180px;
    }

    .site-header {
        position: static;
    }
}

@media (hover: none) {

    .talent:hover:not(:disabled),
    main button:hover:not(:disabled) {
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}
