/* ==========================================================================
   《刘宇存希的折叠屏营救计划》样式表
   校园 + 悬疑 · 深色主题 · 纯 CSS（零外链、零字体文件、零图片文件）
   移动端优先（竖屏），桌面端同时保证好用。
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. 变量与重置
   -------------------------------------------------------------------------- */

:root {
    --bg: #070a11;
    --bg-2: #0b111d;
    --bg-3: #101a2b;

    --panel: rgba(19, 28, 45, 0.86);
    --panel-2: rgba(26, 38, 60, 0.72);
    --panel-3: rgba(12, 19, 32, 0.7);

    --line: rgba(125, 170, 235, 0.16);
    --line-strong: rgba(125, 170, 235, 0.34);

    --text: #e9eff9;
    --text-2: #b9c6dc;
    --dim: #8494b0;

    --teal: #5eead4;
    --teal-deep: #0d9488;
    --blue: #60a5fa;
    --amber: #fbbf24;
    --red: #f87171;
    --red-deep: #b91c1c;
    --violet: #a78bfa;
    --green: #4ade80;

    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
    --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.35);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC",
        "WenQuanYi Micro Hei", sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

    --tap: 44px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

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

body {
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.65;
    color: var(--text);
    background-color: var(--bg);
    background-image:
        radial-gradient(1100px 620px at 12% -10%, rgba(94, 234, 212, 0.10), transparent 60%),
        radial-gradient(900px 520px at 92% 4%, rgba(167, 139, 250, 0.10), transparent 62%),
        radial-gradient(760px 560px at 50% 110%, rgba(248, 113, 113, 0.07), transparent 65%),
        linear-gradient(180deg, #070a11 0%, #0a101b 45%, #070a11 100%);
    background-attachment: fixed;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* 极淡的网格质感，营造校园夜色的“规矩感” */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(rgba(125, 170, 235, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(125, 170, 235, 0.045) 1px, transparent 1px);
    background-size: 46px 46px, 46px 46px;
    mask-image: radial-gradient(circle at 50% 30%, rgba(0, 0, 0, 0.9), transparent 78%);
    -webkit-mask-image: radial-gradient(circle at 50% 30%, rgba(0, 0, 0, 0.9), transparent 78%);
}

h1, h2, h3, h4, p, ul, ol {
    margin: 0;
}

ul, ol {
    padding-left: 1.2em;
}

b, strong {
    color: #fff;
}

a {
    color: var(--teal);
}

button,
input,
textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

img, svg {
    max-width: 100%;
}

::selection {
    background: rgba(94, 234, 212, 0.28);
}

/* 滚动条（桌面） */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(125, 170, 235, 0.28) transparent;
}

*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-thumb {
    background: rgba(125, 170, 235, 0.26);
    border-radius: 8px;
}

/* --------------------------------------------------------------------------
   2. 屏幕容器
   -------------------------------------------------------------------------- */

.screen {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 0 14px calc(18px + env(safe-area-inset-bottom));
    animation: screen-in 0.26s ease both;
}

/* ★ hidden 必须压过 .screen 的 display:flex（UA 样式优先级低于作者样式） */
.screen[hidden] {
    display: none !important;
}

@keyframes screen-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.pad {
    width: 100%;
    max-width: 940px;
    margin: 0 auto;
    padding: 14px 0 34px;
}

.tiny {
    font-size: 0.8rem;
    line-height: 1.5;
}

.dim {
    color: var(--dim);
}

.hl {
    color: var(--teal);
    text-shadow: 0 0 18px rgba(94, 234, 212, 0.4);
}

.lead-text {
    color: var(--text-2);
    background: var(--panel-3);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 14px;
    font-size: 0.94rem;
}

/* --------------------------------------------------------------------------
   3. 通用控件：按钮 / 输入框 / 卡片
   -------------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--tap);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-strong);
    background: linear-gradient(180deg, rgba(38, 54, 82, 0.94), rgba(22, 32, 50, 0.94));
    color: var(--text);
    font-size: 0.98rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    text-align: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    transition: transform 0.12s ease, box-shadow 0.16s ease, border-color 0.16s ease, filter 0.16s ease;
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
}

.btn:hover {
    border-color: rgba(94, 234, 212, 0.5);
    filter: brightness(1.08);
}

.btn:active {
    transform: translateY(1px) scale(0.995);
    filter: brightness(0.95);
}

.btn:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 2px;
}

.btn[disabled],
.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

.btn-primary {
    background: linear-gradient(135deg, #0f766e 0%, #14b8a6 55%, #5eead4 130%);
    border-color: rgba(94, 234, 212, 0.65);
    color: #04211d;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
    box-shadow: 0 10px 26px rgba(20, 184, 166, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.btn-primary:hover {
    filter: brightness(1.06) saturate(1.06);
}

.btn-danger {
    background: linear-gradient(180deg, rgba(120, 30, 40, 0.95), rgba(80, 20, 30, 0.95));
    border-color: rgba(248, 113, 113, 0.5);
    color: #ffe4e6;
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--line);
    color: var(--text-2);
    font-weight: 500;
}

.btn-sm {
    min-height: var(--tap);
    padding: 8px 12px;
    font-size: 0.9rem;
}

.btn-lg {
    min-height: 56px;
    font-size: 1.08rem;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    min-width: var(--tap);
    min-height: var(--tap);
    width: var(--tap);
    height: var(--tap);
    padding: 0;
    font-size: 1.15rem;
    line-height: 1;
    border-radius: 50%;
    flex: 0 0 auto;
}

.btn-ico {
    font-size: 1.12em;
    line-height: 1;
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.btn-row > .btn {
    flex: 1 1 auto;
    min-width: 132px;
}

.btn-row-stack {
    flex-direction: column;
}

.btn-row-stack > .btn {
    width: 100%;
    min-width: 0;
}

.input,
.textarea {
    width: 100%;
    max-width: 100%;
    min-height: var(--tap);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-strong);
    background: rgba(8, 13, 22, 0.86);
    color: var(--text);
    font-size: 1rem;
    touch-action: manipulation;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.input::placeholder,
.textarea::placeholder {
    color: rgba(132, 148, 176, 0.75);
}

.input:focus,
.textarea:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.16);
}

.textarea {
    min-height: 140px;
    font-family: var(--mono);
    font-size: 0.82rem;
    line-height: 1.5;
    resize: vertical;
    white-space: pre;
    overflow: auto;
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.box-title {
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--teal);
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.76rem;
    line-height: 1.5;
    background: rgba(96, 165, 250, 0.12);
    border: 1px solid rgba(96, 165, 250, 0.28);
    color: #cfe0ff;
    white-space: nowrap;
}

.chip-warn {
    background: rgba(251, 191, 36, 0.14);
    border-color: rgba(251, 191, 36, 0.35);
    color: #ffe6b3;
}

.chip-dim {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--line);
    color: var(--dim);
}

.chip-clue {
    background: rgba(94, 234, 212, 0.12);
    border-color: rgba(94, 234, 212, 0.32);
    color: #bff7ec;
}

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    line-height: 1.6;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    color: var(--text-2);
    white-space: nowrap;
}

.tag-cost {
    color: #ffe6b3;
    border-color: rgba(251, 191, 36, 0.3);
}

/* 顶部条 */
.bar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 940px;
    margin: 0 auto;
    padding: 10px 0;
    background: linear-gradient(180deg, rgba(7, 10, 17, 0.96), rgba(7, 10, 17, 0.72) 70%, transparent);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.bar-title {
    flex: 1 1 auto;
    font-size: 1.06rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bar-right {
    min-width: var(--tap);
    text-align: right;
    font-size: 0.85rem;
    color: var(--dim);
    font-variant-numeric: tabular-nums;
}

/* 通知块 */
.notice {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow-sm);
    margin-bottom: 14px;
}

.notice-info {
    border-color: rgba(96, 165, 250, 0.3);
    background: linear-gradient(180deg, rgba(30, 58, 95, 0.5), rgba(15, 23, 42, 0.7));
}

.notice-warn {
    border-color: rgba(251, 191, 36, 0.36);
    background: linear-gradient(180deg, rgba(80, 60, 15, 0.42), rgba(15, 23, 42, 0.7));
}

.notice-ok {
    border-color: rgba(74, 222, 128, 0.34);
}

.notice-ico {
    font-size: 1.6rem;
    line-height: 1;
}

.notice-body {
    flex: 1 1 auto;
    min-width: 0;
}

.notice-title {
    font-weight: 700;
    margin-bottom: 4px;
}

.notice-text {
    font-size: 0.88rem;
    color: var(--text-2);
}

.notice .btn {
    margin-top: 10px;
}

.spin {
    display: inline-block;
    animation: spin 1.1s linear infinite;
}

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

/* --------------------------------------------------------------------------
   4. 加载页
   -------------------------------------------------------------------------- */

#screen-boot {
    align-items: center;
    justify-content: center;
    text-align: center;
}

.boot-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 24px;
    max-width: 520px;
}

.boot-logo {
    font-size: 3.6rem;
    line-height: 1;
    filter: drop-shadow(0 0 22px rgba(94, 234, 212, 0.5));
    animation: float 3.4s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-9px); }
}

.boot-title {
    font-size: 1.5rem;
    line-height: 1.45;
    letter-spacing: 0.04em;
    background: linear-gradient(120deg, #ffffff 10%, var(--teal) 55%, var(--violet) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.boot-status {
    color: var(--dim);
    font-size: 0.92rem;
}

.boot-status.is-error {
    color: var(--red);
    font-weight: 700;
}

.boot-error {
    color: var(--amber);
}

.boot-detail {
    max-width: 90vw;
    overflow: auto;
    text-align: left;
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--dim);
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 10px;
}

/* --------------------------------------------------------------------------
   5. 主菜单
   -------------------------------------------------------------------------- */

#screen-home {
    justify-content: center;
}

.home-wrap {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 26px 0 20px;
}

.home-head {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.home-emoji {
    font-size: 3.1rem;
    line-height: 1;
    filter: drop-shadow(0 0 24px rgba(94, 234, 212, 0.45));
    animation: float 4s ease-in-out infinite;
}

.home-title {
    font-size: 1.62rem;
    line-height: 1.42;
    letter-spacing: 0.03em;
    background: linear-gradient(120deg, #ffffff 5%, #d7e6ff 40%, var(--teal) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.home-sub {
    font-size: 0.86rem;
    color: var(--text-2);
}

.home-menu {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.home-menu .btn {
    width: 100%;
    justify-content: flex-start;
    padding-left: 18px;
    font-size: 1.02rem;
}

.home-menu .btn-primary {
    justify-content: center;
    padding-left: 16px;
}

.home-menu .btn .btn-ico {
    width: 1.5em;
    text-align: center;
}

.home-foot {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.home-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
}

.stat-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 4px;
    border-radius: var(--radius-sm);
    background: var(--panel-3);
    border: 1px solid var(--line);
    min-width: 0;
}

.stat-ico {
    font-size: 1rem;
    line-height: 1;
    opacity: 0.9;
}

.stat-val {
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--teal);
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 0.68rem;
    color: var(--dim);
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
   6. 选关页
   -------------------------------------------------------------------------- */

.seed-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-radius: var(--radius);
    background: var(--panel-3);
    border: 1px solid var(--line);
    margin-bottom: 16px;
}

.seed-label {
    font-size: 0.86rem;
    color: var(--dim);
    white-space: nowrap;
}

.seed-row .input {
    flex: 1 1 150px;
    min-width: 0;
    font-family: var(--mono);
    font-size: 0.9rem;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
}

.level-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    border-radius: var(--radius);
    background: linear-gradient(165deg, rgba(26, 38, 60, 0.86), rgba(12, 19, 32, 0.9));
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
    min-width: 0;
}

.level-card:hover {
    transform: translateY(-2px);
    border-color: rgba(94, 234, 212, 0.4);
    box-shadow: var(--shadow);
}

.level-card.has-result {
    border-color: rgba(94, 234, 212, 0.28);
}

.level-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.level-id {
    font-family: var(--mono);
    font-size: 0.76rem;
    letter-spacing: 0.08em;
    color: var(--dim);
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.25);
}

.level-diff {
    color: var(--amber);
    font-size: 0.82rem;
    letter-spacing: 2px;
}

.level-name {
    font-size: 1.06rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.level-summary {
    font-size: 0.86rem;
    color: var(--text-2);
    min-height: 2.6em;
}

.level-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: auto;
}

.level-best {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.campaign-box {
    margin-top: 20px;
    padding: 16px;
    border-radius: var(--radius);
    background: linear-gradient(150deg, rgba(20, 184, 166, 0.14), rgba(12, 19, 32, 0.85));
    border: 1px solid rgba(94, 234, 212, 0.28);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* --------------------------------------------------------------------------
   7. 游戏页
   -------------------------------------------------------------------------- */

.screen-game {
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    padding-left: 10px;
    padding-right: 10px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    animation: none;
}

.game-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0 8px;
    flex: 0 0 auto;
    border-bottom: 1px solid var(--line);
}

.game-bar-mid {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    text-align: center;
}

.game-level-name {
    font-weight: 700;
    font-size: 0.98rem;
    letter-spacing: 0.03em;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.game-seed {
    font-family: var(--mono);
    font-size: 0.68rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* HUD */
.hud {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    padding: 8px 0;
    width: 100%;
    max-width: 940px;
    margin: 0 auto;
}

.hud-item {
    min-width: 0;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    background: var(--panel-3);
    border: 1px solid var(--line);
}

.hud-top {
    display: flex;
    align-items: baseline;
    gap: 4px;
    min-width: 0;
}

.hud-ico {
    font-size: 0.82rem;
    line-height: 1;
}

.hud-label {
    font-size: 0.7rem;
    color: var(--dim);
    flex: 1 1 auto;
    overflow: hidden;
    white-space: nowrap;
}

.hud-val {
    font-size: 0.86rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.pbar {
    position: relative;
    height: 6px;
    margin-top: 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.pbar > i {
    display: block;
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(96, 165, 250, 0.85), rgba(94, 234, 212, 0.95));
    transition: width 0.32s cubic-bezier(0.22, 1, 0.36, 1), background 0.3s ease;
}

.pbar-time > i { background: linear-gradient(90deg, #38bdf8, #5eead4); }
.pbar-composure > i { background: linear-gradient(90deg, #a78bfa, #60a5fa); }
.pbar-clue > i { background: linear-gradient(90deg, #fbbf24, #5eead4); }
.pbar-safe > i { background: linear-gradient(90deg, #22c55e, #4ade80); }
.pbar-warn > i { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.pbar-danger > i { background: linear-gradient(90deg, #dc2626, #f87171); }
.pbar-score > i { background: linear-gradient(90deg, #0d9488, #5eead4); }

/* 嫌疑越高越红 */
.hud-suspicion.is-suspect.tone-safe .hud-val { color: var(--green); }
.hud-suspicion.tone-warn {
    border-color: rgba(251, 191, 36, 0.45);
    background: linear-gradient(180deg, rgba(120, 80, 10, 0.3), rgba(12, 19, 32, 0.7));
}
.hud-suspicion.tone-warn .hud-val { color: var(--amber); }
.hud-suspicion.tone-danger {
    border-color: rgba(248, 113, 113, 0.55);
    background: linear-gradient(180deg, rgba(150, 30, 40, 0.4), rgba(12, 19, 32, 0.7));
    animation: pulse-danger 1.5s ease-in-out infinite;
}
.hud-suspicion.tone-danger .hud-val { color: #ffb4b4; }

.hud-time.tone-warn .hud-val { color: var(--amber); }
.hud-time.tone-danger .hud-val { color: var(--red); }
.hud-composure.tone-warn .hud-val { color: var(--amber); }
.hud-composure.tone-danger .hud-val { color: var(--red); }

@keyframes pulse-danger {
    0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0); }
    50% { box-shadow: 0 0 14px 0 rgba(248, 113, 113, 0.35); }
}

.hud-chips {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* 正文区 */
.story {
    flex: 1 1 auto;
    min-height: 120px;
    width: 100%;
    max-width: 940px;
    margin: 0 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 12px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(9, 14, 24, 0.92), rgba(13, 20, 33, 0.86));
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.45);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    cursor: pointer;
    font-size: 0.97rem;
}

.story-line {
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 12px;
    color: var(--text-2);
    animation: line-in 0.22s ease both;
}

.story-line:last-child {
    margin-bottom: 4px;
}

@keyframes line-in {
    from { opacity: 0.35; }
    to { opacity: 1; }
}

.story-line.is-done {
    color: var(--text);
}

.story-line.kind-intro {
    color: #dbe7ff;
    border-left: 3px solid var(--violet);
    padding-left: 10px;
}

.story-line.kind-ok {
    color: #d7fbf2;
}

.story-line.kind-warn {
    color: #ffe3b0;
    border-left: 3px solid var(--amber);
    padding-left: 10px;
}

.story-line.kind-bad {
    color: #ffd0d0;
    border-left: 3px solid var(--red);
    padding-left: 10px;
}

.story-line.kind-clue {
    color: #c7f9ee;
    border-left: 3px solid var(--teal);
    padding-left: 10px;
}

.story-line.kind-system {
    color: var(--dim);
    font-size: 0.86rem;
    font-style: italic;
}

/* 状态摘要 */
.game-status {
    flex: 0 0 auto;
    width: 100%;
    max-width: 940px;
    margin: 6px auto 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
}

.game-status[hidden] {
    display: none;
}

.gs-label {
    color: var(--dim);
}

/* 选项区 */
.choices {
    flex: 0 0 auto;
    width: 100%;
    max-width: 940px;
    margin: 8px auto 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    max-height: 46dvh;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
}

.choices.is-locked {
    opacity: 0.55;
    pointer-events: none;
}

.choices-empty {
    text-align: center;
    color: var(--dim);
    padding: 14px;
    font-size: 0.88rem;
}

.choice {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    /* ★ 修「手机端文字超出选项框」的关键一行。
     *
     *   .choice 是 <button>（见 ui.js）。button 是 replaced-ish 元素，
     *   它的实际高度**不会**像 div 那样从 flex 子元素的长文本里自然撑开：
     *   当文字在窄屏上折成 4~5 行时，按钮高度仍停在 min-height，
     *   内容就溢出到边框外面。实测 320px 宽下最严重的一条溢出 34px。
     *
     *   修法：显式 height:auto + 允许纵向内容撑高，并把「最小高度」
     *   表达成 min-height（44px 的可点区域保持不变，这是无障碍底线）。
     */
    height: auto;
    min-height: var(--tap);
    box-sizing: border-box;
    /* ★ 真正修「手机端文字超出选项框」的一行：禁止被压缩。
     *
     *   .choices 是「限高的纵向 flex 容器」（max-height: 42dvh + overflow-y:auto）。
     *   而 flex 子项默认 flex-shrink:1 —— 于是当选项总高度超过 42dvh 时，
     *   浏览器把每条 .choice **压扁**去适配，文字却不会跟着缩，
     *   结果就是文字溢出到卡片边框外面（320px 屏实测被压掉 16~34px）。
     *
     *   正确行为是：卡片保持自己的自然高度，由 .choices 滚动。
     *   实测改完后 320px 屏上溢出从 16px 降到 0。
     */
    flex-shrink: 0;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-strong);
    border-left-width: 4px;
    background: linear-gradient(180deg, rgba(30, 43, 66, 0.9), rgba(16, 24, 38, 0.92));
    color: var(--text);
    text-align: left;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.12s ease, border-color 0.16s ease, filter 0.16s ease, box-shadow 0.16s ease;
    box-shadow: var(--shadow-sm);
    font-size: 0.95rem;
}

/* ★ hover 反馈必须只用「不改变几何」的属性（颜色/亮度/阴影）。
 *
 *   这里原来写的是 `transform: translateX(2px)`，会引发**反馈循环抖动**：
 *     鼠标进入按钮 → hover 生效 → 按钮右移 2px
 *     → 按钮的左边缘离开了指针 → 指针落到按钮外 → hover 失效
 *     → 按钮弹回原位 → 指针又进入按钮 → 无限重复 = 画面抖动
 *   因为 .choice 是 width:100% 且紧贴容器左边缘，指针停在靠近左边缘时
 *   必然反复触发/取消 hover。
 *
 *   注意：transform 不会改变 hit-test 区域，但元素**移动**了，
 *   所以指针相对元素的坐标变了 —— 对于「指针正好在边缘外 2px 内」的情况，
 *   就等于指针"离开"了元素。
 *
 *   同理不要用会改变尺寸的属性（border-width / padding / margin / font-size）。
 */
.choice:hover {
    filter: brightness(1.18);
    border-color: var(--teal, #3ad1c4);
    border-left-color: var(--teal, #3ad1c4);
    background: linear-gradient(180deg, rgba(40, 58, 88, 0.95), rgba(20, 30, 48, 0.96));
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(58, 209, 196, 0.25);
}

.choice:active {
    transform: scale(0.994);
}

.choice:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 2px;
}

.choice-idx {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-family: var(--mono);
    color: var(--dim);
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--line);
}

.choice-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* ★ 窄屏（<=380px）改用两行网格：第一行「序号 + 正文」，第二行「标签」。
 *
 *   为什么不用 flex-wrap（踩过的坑）：
 *     `.choice-main { flex: 1 1 100% }` 会把它挤到独立一行，
 *     而 flex 换行后 .choice-idx 仍留在第一行，两者**视觉重叠** 22px，
 *     卡片还被撑到 123~146px 高。实测被 mobile-visual-audit.mjs 抓到。
 *
 *   grid 能明确指定每个元素的格子，不会重叠：
 *     ┌───┬──────────────────────────┐
 *     │ 1 │ 正文文字……                │
 *     ├───┴──────────────────────────┤
 *     │ [安全] [线索] [⏱2]           │
 *     └──────────────────────────────┘
 */
@media (max-width: 380px) {
    .choice {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: center;
        column-gap: 8px;
        row-gap: 4px;
        /* 窄屏本来高度就紧张，适当收一点内边距；仍远高于 44px 触控底线 */
        padding: 8px 10px;
    }

    .choice-idx {
        grid-column: 1;
        grid-row: 1;
        align-self: start;
        margin-top: 1px;
    }

    .choice-main {
        grid-column: 2;
        grid-row: 1;
        min-width: 0;
    }

    .choice-meta {
        grid-column: 1 / -1;
        grid-row: 2;
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
        justify-content: flex-start;
        width: 100%;
        gap: 6px;
    }

    .choice-hint {
        font-size: 0.74rem;
    }
}

.choice-label {
    font-weight: 600;
    word-break: break-word;
}

.choice-hint {
    font-size: 0.78rem;
    color: var(--dim);
    word-break: break-word;
}

.choice-meta {
    /* 允许收缩：窄屏上标签（风险/时间）不该把正文挤成 4 行。
       原来写的是 flex: 0 0 auto，在 320px 屏上 meta 独占 125px，
       正文只剩 108px → 文案折成 4~5 行 → 溢出。 */
    flex: 0 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.risk-tag {
    font-size: 0.68rem;
    padding: 2px 7px;
    border-radius: 999px;
    white-space: nowrap;
    border: 1px solid transparent;
}

/* 风险配色（risk 0..4 仅用于 UI 提示）
 * ★ 补上 risk-4：此前 UI 把 risk 夹到 3，导致关卡里的 risk:4（极高风险）
 *   与 risk:3（高风险）在界面上完全同色、同标签，玩家无法区分。
 *   现在 4 单独配色（更深的红 + 实心强调），五档可辨。 */
.risk-0 { border-left-color: var(--green); }
.risk-1 { border-left-color: var(--blue); }
.risk-2 { border-left-color: var(--amber); }
.risk-3 { border-left-color: var(--red); }
.risk-4 { border-left-color: #ff4d4d; }

.risk-tag-0 { background: rgba(74, 222, 128, 0.14); border-color: rgba(74, 222, 128, 0.35); color: #b8f5cb; }
.risk-tag-1 { background: rgba(96, 165, 250, 0.14); border-color: rgba(96, 165, 250, 0.35); color: #c6dcff; }
.risk-tag-2 { background: rgba(251, 191, 36, 0.16); border-color: rgba(251, 191, 36, 0.4); color: #ffe6b3; }
.risk-tag-3 { background: rgba(248, 113, 113, 0.16); border-color: rgba(248, 113, 113, 0.42); color: #ffc9c9; }
.risk-tag-4 {
    background: rgba(255, 77, 77, 0.28);
    border-color: rgba(255, 77, 77, 0.7);
    color: #ffdede;
    font-weight: 700;
}

.choice.risk-3 {
    background: linear-gradient(180deg, rgba(60, 26, 34, 0.9), rgba(16, 24, 38, 0.92));
}

.choice.risk-4 {
    background: linear-gradient(180deg, rgba(78, 22, 28, 0.95), rgba(16, 24, 38, 0.94));
    border-left-width: 5px;
}

.choice.is-hinted {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.2), var(--shadow);
    animation: hint-pulse 1.1s ease-in-out 3;
}

@keyframes hint-pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.14), var(--shadow); }
    50% { box-shadow: 0 0 0 6px rgba(94, 234, 212, 0.24), var(--shadow); }
}

/* --------------------------------------------------------------------------
   8. 结算页
   -------------------------------------------------------------------------- */

.result-pad {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ending-card {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius);
    border: 1px solid var(--line-strong);
    padding: 22px 16px 18px;
    text-align: center;
    background: linear-gradient(180deg, rgba(24, 34, 54, 0.95), rgba(10, 16, 27, 0.95));
    box-shadow: var(--shadow);
}

.ending-card::after {
    content: "";
    position: absolute;
    inset: -40% -10% auto -10%;
    height: 70%;
    background: radial-gradient(closest-side, rgba(94, 234, 212, 0.16), transparent);
    pointer-events: none;
}

.ending-card.tone-triumph { border-color: rgba(94, 234, 212, 0.55); }
.ending-card.tone-triumph::after { background: radial-gradient(closest-side, rgba(94, 234, 212, 0.28), transparent); }
.ending-card.tone-good { border-color: rgba(96, 165, 250, 0.45); }
.ending-card.tone-good::after { background: radial-gradient(closest-side, rgba(96, 165, 250, 0.22), transparent); }
.ending-card.tone-neutral { border-color: rgba(148, 163, 184, 0.35); }
.ending-card.tone-neutral::after { background: radial-gradient(closest-side, rgba(148, 163, 184, 0.14), transparent); }
.ending-card.tone-bad { border-color: rgba(248, 113, 113, 0.45); }
.ending-card.tone-bad::after { background: radial-gradient(closest-side, rgba(248, 113, 113, 0.22), transparent); }
.ending-card.tone-secret { border-color: rgba(167, 139, 250, 0.55); }
.ending-card.tone-secret::after { background: radial-gradient(closest-side, rgba(167, 139, 250, 0.26), transparent); }

.ending-emoji {
    font-size: 3rem;
    line-height: 1;
    filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.55));
    animation: pop-in 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

@keyframes pop-in {
    from { transform: scale(0.6); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.ending-title {
    font-size: 1.4rem;
    margin: 8px 0 10px;
    letter-spacing: 0.05em;
    background: linear-gradient(120deg, #fff, var(--teal));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.ending-text {
    font-size: 0.96rem;
    color: var(--text-2);
    white-space: pre-wrap;
    text-align: left;
    max-width: 620px;
    margin: 0 auto;
}

.ending-outcome {
    display: inline-block;
    margin-top: 12px;
    font-size: 0.78rem;
    color: var(--dim);
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.3);
}

.score-hero {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px;
    border-radius: var(--radius);
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.score-num {
    display: flex;
    align-items: baseline;
    gap: 2px;
    flex: 0 0 auto;
}

.score-value {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    background: linear-gradient(160deg, #ffffff, var(--teal));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.score-unit {
    font-size: 0.9rem;
    color: var(--dim);
}

.score-right {
    flex: 1 1 auto;
    min-width: 0;
}

.score-grade {
    display: flex;
    align-items: center;
    gap: 6px;
}

.score-comment {
    font-size: 0.88rem;
    color: var(--text-2);
    margin-top: 6px;
}

.score-penalty {
    font-size: 0.8rem;
    color: var(--amber);
    margin-top: 4px;
}

/* 评级徽章 */
.grade {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    padding: 0 7px;
    border-radius: 8px;
    font-weight: 800;
    font-size: 0.86rem;
    letter-spacing: 0.04em;
    border: 1px solid transparent;
    font-variant-numeric: tabular-nums;
}

.grade-lg {
    min-width: 44px;
    height: 44px;
    font-size: 1.5rem;
    border-radius: 12px;
}

.grade-s {
    background: linear-gradient(150deg, #fde68a, #f59e0b);
    color: #422006;
    box-shadow: 0 0 18px rgba(245, 158, 11, 0.45);
}

.grade-a {
    background: linear-gradient(150deg, #99f6e4, #14b8a6);
    color: #04221f;
    box-shadow: 0 0 14px rgba(20, 184, 166, 0.35);
}

.grade-b {
    background: linear-gradient(150deg, #bfdbfe, #3b82f6);
    color: #0a1e3d;
}

.grade-c {
    background: linear-gradient(150deg, #ddd6fe, #8b5cf6);
    color: #25104d;
}

.grade-d {
    background: linear-gradient(150deg, #e5e7eb, #94a3b8);
    color: #1e293b;
}

.grade-- {
    background: rgba(255, 255, 255, 0.08);
    color: var(--dim);
    border-color: var(--line);
}

.breakdown {
    margin-top: 14px;
    padding: 14px;
    border-radius: var(--radius);
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.bd-row {
    margin-bottom: 10px;
}

.bd-row:last-child {
    margin-bottom: 0;
}

.bd-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    font-size: 0.86rem;
}

.bd-label {
    color: var(--text-2);
}

.bd-val {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: var(--teal);
}

.bd-note {
    margin-top: 2px;
}

.campaign-summary .cs-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    font-size: 0.95rem;
}

/* 排行榜提交面板 */
.submit-card {
    border-color: rgba(94, 234, 212, 0.3);
    background: linear-gradient(180deg, rgba(17, 40, 45, 0.7), rgba(12, 19, 32, 0.9));
}

.submit-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    font-size: 0.92rem;
    margin-bottom: 10px;
}

.submit-note {
    margin-top: 10px;
}

.submit-result-line {
    font-size: 0.92rem;
    color: var(--text-2);
    margin-bottom: 6px;
}

.submit-card.notice-ok {
    border-color: rgba(74, 222, 128, 0.45);
    background: linear-gradient(180deg, rgba(16, 60, 40, 0.5), rgba(12, 19, 32, 0.9));
}

.submit-card.notice-warn {
    border-color: rgba(251, 191, 36, 0.45);
    background: linear-gradient(180deg, rgba(70, 52, 12, 0.5), rgba(12, 19, 32, 0.9));
}

.submit-card.notice-info {
    border-color: rgba(96, 165, 250, 0.4);
}

/* --------------------------------------------------------------------------
   9. 排行榜
   -------------------------------------------------------------------------- */

.lb-head,
.lb-row {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) 56px 52px 84px;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
}

.lb-head {
    font-size: 0.74rem;
    color: var(--dim);
    letter-spacing: 0.08em;
    border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.3);
    margin-bottom: 6px;
    position: sticky;
    top: 52px;
    z-index: 2;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.lb-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.lb-row {
    border: 1px solid var(--line);
    background: var(--panel-3);
    font-size: 0.92rem;
    transition: border-color 0.16s ease, transform 0.16s ease;
}

.lb-row:hover {
    border-color: rgba(94, 234, 212, 0.35);
}

.lb-top {
    background: linear-gradient(90deg, rgba(20, 184, 166, 0.16), rgba(12, 19, 32, 0.7));
    border-color: rgba(94, 234, 212, 0.35);
}

.lb-top-1 {
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.2), rgba(12, 19, 32, 0.7));
    border-color: rgba(251, 191, 36, 0.5);
}

.lb-rank {
    text-align: center;
    font-variant-numeric: tabular-nums;
    color: var(--dim);
    font-size: 0.95rem;
}

.lb-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: baseline;
    gap: 2px;
}

.lb-nick {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-nick.is-anon {
    color: var(--violet);
    font-style: italic;
}

.lb-total {
    text-align: right;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--teal);
}

.lb-grade {
    text-align: center;
}

.lb-date {
    text-align: right;
    font-size: 0.74rem;
}

.lb-foot {
    margin-top: 8px;
    text-align: center;
}

.local-section {
    margin-top: 22px;
    padding-top: 14px;
    border-top: 1px dashed var(--line);
}

.lb-list-local .lb-row {
    background: rgba(0, 0, 0, 0.22);
    border-style: dashed;
}

/* --------------------------------------------------------------------------
   10. 成就
   -------------------------------------------------------------------------- */

.ach-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
    gap: 10px;
}

.ach-card {
    display: flex;
    gap: 10px;
    padding: 12px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--panel-3);
    min-width: 0;
    transition: transform 0.16s ease, border-color 0.16s ease;
}

.ach-card.is-unlocked {
    border-color: rgba(94, 234, 212, 0.4);
    background: linear-gradient(160deg, rgba(20, 184, 166, 0.14), rgba(12, 19, 32, 0.85));
    box-shadow: 0 0 0 1px rgba(94, 234, 212, 0.1), var(--shadow-sm);
}

.ach-card.is-unlocked:hover {
    transform: translateY(-2px);
}

.ach-card.is-locked {
    filter: grayscale(1);
    opacity: 0.55;
}

.ach-emoji {
    font-size: 1.8rem;
    line-height: 1;
    flex: 0 0 auto;
}

.ach-body {
    min-width: 0;
}

.ach-name {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.ach-desc {
    font-size: 0.8rem;
    color: var(--text-2);
    word-break: break-word;
}

.ach-state {
    margin-top: 4px;
    color: var(--dim);
    letter-spacing: 0.06em;
}

.ach-card.is-unlocked .ach-state {
    color: var(--teal);
    font-weight: 700;
}

/* --------------------------------------------------------------------------
   11. 设置
   -------------------------------------------------------------------------- */

.set-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.set-label {
    min-width: 0;
}

.set-name {
    font-weight: 600;
}

.set-desc {
    font-size: 0.84rem;
    color: var(--text-2);
    margin-top: 2px;
}

.set-desc.ok { color: var(--green); }
.set-desc.warn { color: var(--amber); }

.set-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
    gap: 8px;
    margin: 12px 0;
}

.set-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.24);
    border: 1px solid var(--line);
    min-width: 0;
}

.set-stat-k {
    font-size: 0.7rem;
}

.set-stat-v {
    font-weight: 700;
    color: var(--teal);
    font-variant-numeric: tabular-nums;
}

/* 开关 */
.switch {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: var(--tap);
    padding: 6px 12px 6px 6px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: rgba(0, 0, 0, 0.35);
    color: var(--dim);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.switch-knob {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(180deg, #94a3b8, #64748b);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s cubic-bezier(0.3, 1.4, 0.5, 1), background 0.2s ease;
}

.switch-text {
    font-size: 0.82rem;
    font-weight: 700;
}

.switch.is-on {
    border-color: rgba(94, 234, 212, 0.6);
    background: linear-gradient(90deg, rgba(13, 148, 136, 0.45), rgba(20, 184, 166, 0.2));
    color: var(--teal);
}

.switch.is-on .switch-knob {
    transform: translateX(4px);
    background: linear-gradient(180deg, #5eead4, #14b8a6);
    box-shadow: 0 0 12px rgba(94, 234, 212, 0.6);
}

.switch:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   12. 玩法说明
   -------------------------------------------------------------------------- */

.help-card .help-p {
    font-size: 0.9rem;
    color: var(--text-2);
    margin-bottom: 6px;
}

.help-card .help-p:last-child {
    margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   13. Toast / Modal / 特效层
   -------------------------------------------------------------------------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(22px + env(safe-area-inset-bottom));
    transform: translate(-50%, 16px);
    z-index: 90;
    max-width: min(92vw, 460px);
    padding: 11px 16px;
    border-radius: 999px;
    font-size: 0.88rem;
    line-height: 1.45;
    text-align: center;
    color: var(--text);
    background: rgba(15, 23, 38, 0.96);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.24s cubic-bezier(0.2, 1.2, 0.4, 1);
}

.toast[hidden] {
    display: none !important;
}

.toast.is-show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.toast.kind-ok { border-color: rgba(74, 222, 128, 0.55); color: #d6ffe4; }
.toast.kind-warn { border-color: rgba(251, 191, 36, 0.6); color: #ffedc4; }
.toast.kind-error { border-color: rgba(248, 113, 113, 0.65); color: #ffd6d6; }

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    opacity: 0;
    transition: opacity 0.18s ease;
}

.modal[hidden] {
    display: none !important;
}

.modal.is-open {
    opacity: 1;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(3, 6, 12, 0.72);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-card {
    position: relative;
    width: 100%;
    max-width: 520px;
    max-height: 86dvh;
    overflow-y: auto;
    padding: 18px;
    border-radius: var(--radius);
    border: 1px solid var(--line-strong);
    background: linear-gradient(180deg, rgba(22, 32, 50, 0.99), rgba(11, 17, 29, 0.99));
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
    transform: translateY(10px) scale(0.985);
    transition: transform 0.2s cubic-bezier(0.2, 1.2, 0.4, 1);
}

.modal.is-open .modal-card {
    transform: none;
}

.modal-title {
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: var(--teal);
    letter-spacing: 0.03em;
}

.modal-text {
    font-size: 0.92rem;
    color: var(--text-2);
    margin-bottom: 10px;
    white-space: pre-wrap;
    word-break: break-word;
}

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.modal-actions > .btn {
    flex: 1 1 auto;
    min-width: 120px;
}

#fx-layer {
    position: fixed;
    inset: 0;
    z-index: 80;
    pointer-events: none;
    overflow: hidden;
}

.fx-flash {
    position: absolute;
    inset: 0;
    animation: fx-out 0.68s ease-out forwards;
}

.fx-flash.fx-danger { background: radial-gradient(circle at 50% 50%, rgba(248, 113, 113, 0) 35%, rgba(220, 38, 38, 0.42) 100%); }
.fx-flash.fx-warn { background: radial-gradient(circle at 50% 50%, rgba(251, 191, 36, 0) 40%, rgba(245, 158, 11, 0.3) 100%); }
.fx-flash.fx-ok { background: radial-gradient(circle at 50% 50%, rgba(94, 234, 212, 0) 40%, rgba(20, 184, 166, 0.3) 100%); }
.fx-flash.fx-info { background: radial-gradient(circle at 50% 50%, rgba(96, 165, 250, 0) 45%, rgba(59, 130, 246, 0.22) 100%); }

@keyframes fx-out {
    0% { opacity: 0.95; }
    100% { opacity: 0; }
}

/* --------------------------------------------------------------------------
   14. 响应式：手机优先，桌面增强
   -------------------------------------------------------------------------- */

/* 中等屏幕：HUD 两行 */
@media (max-width: 720px) {
    .hud {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .lb-head,
    .lb-row {
        grid-template-columns: 38px minmax(0, 1fr) 48px 44px;
    }

    .lb-date {
        display: none;
    }

    .lb-head span:nth-child(5) {
        display: none;
    }
}

/* 手机竖屏 */
@media (max-width: 640px) {
    body {
        font-size: 15.5px;
    }

    .screen {
        padding-left: 10px;
        padding-right: 10px;
    }

    .home-title {
        font-size: 1.42rem;
    }

    .home-emoji {
        font-size: 2.7rem;
    }

    .level-grid {
        grid-template-columns: 1fr;
    }

    .level-summary {
        min-height: 0;
    }

    .score-hero {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .score-value {
        font-size: 2.6rem;
    }

    .btn-row > .btn {
        min-width: 0;
        flex: 1 1 100%;
    }

    .bar-title {
        font-size: 1rem;
    }

    .story {
        font-size: 0.95rem;
        padding: 10px;
    }

    .choices {
        max-height: 42dvh;
    }

    .choice {
        padding: 9px 10px;
    }

    .hud-item {
        padding: 5px 7px;
    }

    .hud-label {
        font-size: 0.66rem;
    }

    .hud-val {
        font-size: 0.8rem;
    }

    .ach-grid {
        grid-template-columns: 1fr;
    }

    .modal-card {
        max-height: 90dvh;
    }

    .set-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .switch {
        justify-content: space-between;
    }
}

/* 窄屏微调 */
@media (max-width: 380px) {
    .home-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .hud {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .choice-meta {
        flex-direction: row;
        align-items: center;
    }
}

/* 横屏手机：HUD 回到一行，正文与选项分配高度 */
@media (max-height: 520px) and (orientation: landscape) {
    .screen-game {
        height: 100dvh;
    }

    .hud {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .story {
        min-height: 80px;
    }

    .choices {
        max-height: 34dvh;
    }
}

/* 桌面增强 */
@media (min-width: 900px) {
    body {
        font-size: 16.5px;
    }

    .home-wrap {
        max-width: 600px;
    }

    .home-menu {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .home-menu .btn-primary {
        grid-column: 1 / -1;
    }

    .choices {
        max-height: 52dvh;
    }

    .level-grid {
        grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
    }
}

/* 无障碍 / 省电：尊重系统的「减少动态效果」 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

/* 打印：仅打印结算信息（顺手支持一下） */
@media print {
    body {
        background: #fff;
        color: #000;
    }

    body::before,
    #fx-layer,
    .toast,
    .modal,
    .btn {
        display: none !important;
    }
}
