/* =====================================================
 * 嘉豪模拟器 —— 黑白酸性潮牌风（Acid Brutalism）
 * 主色：墨黑 #0c0c0e / 纸白 #f2f2ef / 酸性荧光 #d8ff3e
 * ===================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --ink: #0c0c0e;
    --ink-2: #141417;
    --ink-3: #1c1c21;
    --paper: #f2f2ef;
    --grey: #8b8b93;
    --grey-2: #55555e;
    --line: #2c2c34;
    --acid: #d8ff3e;
    --acid-dim: rgba(216, 255, 62, 0.14);
    --red: #ff5a4e;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
    height: 100%;
    /* 移动端用 dvh 避免地址栏伸缩导致的高度跳变 */
    height: 100dvh;
    overflow: hidden;
}
body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;           /* 禁止整页橡皮筋滚动 */
    -webkit-text-size-adjust: 100%;      /* 防止 iOS 自动放大文字 */
    text-size-adjust: 100%;
    font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", -apple-system, sans-serif;
    background: var(--ink);
    color: var(--paper);
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

/* ========== 背景：噪点 + 几何块 ========== */
.bg-effects { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

.bg-noise {
    position: absolute; inset: 0; opacity: 0.05;
    background-image: repeating-conic-gradient(#fff 0 0.6deg, transparent 0.6deg 1.8deg);
    background-size: 5px 5px;
}

.bg-shape { position: absolute; border: 1px solid var(--line); }

.shape-1 {
    width: 42vmin; height: 42vmin; right: -14vmin; top: -14vmin;
    transform: rotate(18deg);
    background: linear-gradient(135deg, rgba(216,255,62,0.05), transparent 60%);
}
.shape-2 {
    width: 30vmin; height: 30vmin; left: -12vmin; bottom: -10vmin;
    transform: rotate(-12deg);
    background: linear-gradient(315deg, rgba(216,255,62,0.04), transparent 60%);
}
.shape-3 {
    width: 12px; height: 34vmin; left: 6vw; top: 12vh;
    background: var(--acid); border: none; opacity: 0.85;
    transform: rotate(24deg);
}

/* ========== 屏幕切换 ========== */
.screen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;  /* 覆盖整个视口 */
    z-index: 1;
    display: flex; align-items: flex-start; justify-content: center;
    opacity: 0; visibility: hidden; transform: translateY(10px);
    transition: opacity 0.35s ease, transform 0.35s ease, visibility 0s 0.35s;
    overflow-y: auto; overflow-x: hidden;
    overscroll-behavior: contain;       /* 容器内滚动不穿透 */
    -webkit-overflow-scrolling: touch;
}
.screen.active {
    opacity: 1; visibility: visible; transform: translateY(0);
    transition: opacity 0.35s ease, transform 0.35s ease, visibility 0s;
}

/* ========== 开始界面 ========== */
.start-container {
    width: 100%; max-width: 880px;
    padding: calc(26px + env(safe-area-inset-top, 0px)) 20px calc(26px + var(--safe-bottom));
    margin: auto 0;
    text-align: center;
    animation: fadeUp 0.55s ease;
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}

.game-logo { margin-bottom: 30px; }

.logo-en {
    font-size: clamp(11px, 2.2vw, 14px);
    letter-spacing: 0.6em; text-indent: 0.6em;
    color: var(--acid);
    font-weight: 700;
    margin-bottom: 10px;
}

.logo-cn {
    font-size: clamp(46px, 10vw, 84px);
    font-weight: 900;
    letter-spacing: 0.04em;
    line-height: 1.05;
    color: var(--paper);
}
.logo-cn span {
    color: var(--acid);
    margin-left: 0.08em;
    text-shadow: 0.06em 0.06em 0 rgba(216, 255, 62, 0.25);
}

.logo-tag {
    margin-top: 16px;
    display: flex; align-items: center; justify-content: center; gap: 14px;
    font-size: clamp(12px, 2.6vw, 14px);
    color: var(--grey);
    letter-spacing: 0.22em;
}
.logo-tag i {
    display: block; width: 34px; height: 1px; background: var(--grey-2);
}

.select-hint {
    color: var(--grey); font-size: 13px;
    letter-spacing: 0.2em; margin-bottom: 20px;
}

/* ---- 角色卡片 ---- */
.char-select {
    display: flex; gap: 22px; justify-content: center; align-items: stretch; flex-wrap: wrap;
}

.char-card {
    position: relative;
    flex: 1 1 250px; max-width: 330px;
    background: var(--ink-2);
    border: 1.5px solid var(--line);
    border-radius: 4px;               /* 硬朗小圆角 */
    padding: 30px 22px 24px;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

/* 角标装饰 */
.char-corner {
    position: absolute; top: 10px; right: 10px;
    width: 14px; height: 14px;
    border-top: 2px solid var(--grey-2);
    border-right: 2px solid var(--grey-2);
    transition: border-color 0.18s;
}

.char-card:active {
    transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--acid);
    border-color: var(--acid);
}
@media (hover: hover) {
    .char-card:hover, .char-card:focus-visible {
        transform: translate(-3px, -3px);
        border-color: var(--acid);
        box-shadow: 6px 6px 0 var(--acid);
        outline: none;
    }
    .char-card:hover .char-corner, .char-card:focus-visible .char-corner { border-color: var(--acid); }
    .char-card:hover .char-avatar { border-color: var(--acid); transform: rotate(-3deg) scale(1.03); }
}

.char-avatar {
    width: 128px; height: 128px;
    margin: 0 auto 18px; display: block;
    border-radius: 50%;
    border: 2px solid var(--line);
    background: var(--ink-3);
    transition: border-color 0.18s, transform 0.3s ease;
}
/* char-avatar hover 已移入 @media(hover:hover) 块 */

.char-name {
    font-size: 30px; font-weight: 900; letter-spacing: 0.12em;
    color: var(--paper); margin-bottom: 6px;
}

.char-title {
    font-size: 12px; color: var(--acid);
    letter-spacing: 0.12em; margin-bottom: 12px; font-weight: 700;
}

.char-desc {
    font-size: 13px; color: var(--grey);
    line-height: 1.75; font-style: italic; margin-bottom: 14px;
}

.char-perk {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11px; font-weight: 700;
    color: var(--acid);
    border: 1px solid rgba(216,255,62,0.45);
    border-radius: 2px;
    padding: 5px 12px;
    background: var(--acid-dim);
    letter-spacing: 0.05em;
}
.perk-icon { width: 13px; height: 13px; }

.start-footer {
    margin-top: 36px;
    font-size: 12px; color: var(--grey-2);
    letter-spacing: 0.14em;
}

/* ---- 继续游戏区域 ---- */
.load-section {
    margin-bottom: 24px;
    animation: fadeUp 0.5s ease 0.15s both;
}

.btn-continue-game {
    display: inline-flex; align-items: center; gap: 10px;
    background: var(--ink-2);
    border: 1.5px solid var(--acid);
    border-radius: 3px;
    padding: 12px 28px;
    color: var(--acid);
    font-size: 15px; font-weight: 900; font-family: inherit;
    letter-spacing: 0.12em;
    cursor: pointer;
    box-shadow: 4px 4px 0 rgba(216,255,62,0.18);
    transition: all 0.18s ease;
}
.btn-continue-game:active { transform: scale(0.97); }
@media (hover: hover) {
    .btn-continue-game:hover {
        transform: translate(-2px, -2px);
        box-shadow: 6px 6px 0 rgba(216,255,62,0.28);
        background: var(--acid);
        color: var(--ink);
    }
    .btn-continue-game:hover .save-info {
        color: rgba(12,12,14,0.55);
        border-left-color: rgba(12,12,14,0.2);
    }
}
.btn-continue-game .btn-icon {
    width: 18px; height: 18px;
}
.save-info {
    font-size: 11px; font-weight: 600;
    color: var(--grey);
    letter-spacing: 0.04em;
    border-left: 1px solid var(--line);
    padding-left: 10px;
}
/* save-info hover 已移入 @media(hover:hover) 块 */

/* ---- 剧情简介（可折叠） ---- */
.story-synopsis {
    max-width: 580px;
    margin: 0 auto 24px;
    animation: fadeUp 0.5s ease 0.1s both;
}

.synopsis-toggle {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--ink-2);
    border: 1.5px solid var(--line);
    border-radius: 3px;
    padding: 8px 20px;
    color: var(--grey);
    font-size: 13px; font-weight: 700; font-family: inherit;
    letter-spacing: 0.12em;
    cursor: pointer;
    transition: all 0.18s ease;
}
.synopsis-toggle:active {
    border-color: var(--acid);
    color: var(--acid);
}
@media (hover: hover) {
    .synopsis-toggle:hover {
        border-color: var(--acid);
        color: var(--acid);
    }
}
.synopsis-toggle .synopsis-icon {
    width: 16px; height: 16px;
    transition: transform 0.25s ease;
}
.synopsis-toggle.open .synopsis-icon {
    transform: rotate(45deg);
}

.synopsis-body {
    margin-top: 0;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    background: var(--ink-2);
    border: 1.5px solid var(--line);
    border-left: 3px solid var(--acid);
    border-radius: 3px;
    padding: 0 24px;
    text-align: left;
    transition: max-height 0.35s ease, opacity 0.3s ease, padding 0.35s ease, margin-top 0.35s ease;
}
.synopsis-body.open {
    max-height: 520px;
    opacity: 1;
    padding: 20px 24px;
    margin-top: 10px;
}
.synopsis-body p {
    font-size: 13.5px; line-height: 1.95;
    color: var(--paper);
    margin-bottom: 6px;
}
.synopsis-body p:last-child { margin-bottom: 0; }
.synopsis-body strong { color: var(--acid); font-weight: 700; }

.synopsis-tag {
    margin-top: 12px !important;
    padding-top: 12px;
    border-top: 1px dashed var(--line);
    text-align: center !important;
    font-size: 12px !important;
    color: var(--grey) !important;
    letter-spacing: 0.22em;
    font-style: italic;
}

/* ========== 游戏主界面 ========== */
.game-container {
    width: 100%; max-width: 720px;
    min-height: 100%; min-height: 100dvh;
    display: flex; flex-direction: column;
    padding: calc(14px + env(safe-area-inset-top, 0px)) 16px calc(16px + var(--safe-bottom));
    margin: 0 auto;
    /* 弹性布局：保证选项区始终在可视范围内 */
    flex-shrink: 0;
}

.game-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 4px 2px 12px;
}

.day-badge {
    display: flex; align-items: baseline; gap: 8px;
    background: var(--acid);
    color: var(--ink);
    border-radius: 3px;
    padding: 6px 14px;
    box-shadow: 4px 4px 0 rgba(216,255,62,0.25);
}
.day-label { font-size: 10px; letter-spacing: 0.22em; font-weight: 800; }
#day-num { font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }

.player-info {
    display: flex; align-items: center; gap: 9px;
    font-size: 17px; font-weight: 900; letter-spacing: 0.12em;
}
.player-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    border: 1.5px solid var(--line);
    background: var(--ink-3);
}

.btn-restart {
    width: 44px; height: 44px;          /* 移动端触摸目标 ≥44px */
    border-radius: 3px;
    border: 1.5px solid var(--line);
    background: var(--ink-2);
    color: var(--grey);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.18s;
}
.btn-restart svg { width: 18px; height: 18px; }
@media (hover: hover) {
    .btn-restart:hover {
        color: var(--ink); background: var(--acid); border-color: var(--acid);
    }
}
.btn-restart:active { transform: scale(0.92); }

/* ---- 头部操作按钮组 ---- */
.header-actions {
    display: flex; gap: 8px;
}

.btn-save {
    width: 44px; height: 44px;          /* 移动端触摸目标 ≥44px */
    border-radius: 3px;
    border: 1.5px solid var(--line);
    background: var(--ink-2);
    color: var(--grey);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.18s;
}
.btn-save svg { width: 18px; height: 18px; }
@media (hover: hover) {
    .btn-save:hover {
        color: var(--ink); background: var(--acid); border-color: var(--acid);
    }
}
.btn-save:active { transform: scale(0.92); }

/* ---- 属性面板 ---- */
.stats-panel {
    display: grid; grid-template-columns: repeat(2, 1fr);
    gap: 12px 18px;
    background: var(--ink-2);
    border: 1.5px solid var(--line);
    border-radius: 4px;
    padding: 14px 16px;
}

.stat-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 6px;
}
.stat-name {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--grey); font-weight: 700;
    letter-spacing: 0.06em;
}
.stat-icon { width: 14px; height: 14px; }
.ico-hao { color: var(--acid); }
.ico-pop { color: var(--paper); }
.ico-san { color: #9ecfff; }
.ico-study { color: #ffb35a; }

.stat-val { font-size: 13px; font-weight: 900; font-variant-numeric: tabular-nums; }

.stat-bar {
    height: 6px; border-radius: 0;
    background: var(--ink-3);
    border: 1px solid var(--line);
    overflow: hidden;
}
.stat-fill {
    height: 100%; width: 50%;
    transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.fill-hao { background: var(--acid); }
.fill-pop { background: var(--paper); }
.fill-san { background: #9ecfff; }
.fill-study { background: #ffb35a; }

/* ---- 剧情区 ---- */
.story-area {
    flex: 1; display: flex; flex-direction: column;
    margin-top: 14px; min-height: 0;
}

.scene-tag {
    align-self: flex-start;
    font-size: 12px; font-weight: 800;
    color: var(--ink);
    background: var(--paper);
    border-radius: 2px;
    padding: 4px 12px;
    margin-bottom: 10px;
    letter-spacing: 0.08em;
}

.story-card {
    flex: 1;
    min-height: 120px;                  /* 移动端最小高度防塌缩 */
    background: var(--ink-2);
    border: 1.5px solid var(--line);
    border-left: 4px solid var(--acid);
    border-radius: 3px;
    padding: 20px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    /* 允许 story-card 收缩以适应小屏 */
    min-height: 0;
}

.speaker {
    font-size: 13px; font-weight: 900;
    color: var(--acid);
    letter-spacing: 0.1em;
    margin-bottom: 10px;
}
.speaker:empty { display: none; }

.story-text {
    font-size: 15.5px; line-height: 1.95;
    color: var(--paper);
    white-space: pre-wrap;
    user-select: text; -webkit-user-select: text;
}

.type-cursor {
    display: inline-block;
    width: 9px; height: 1.05em;
    background: var(--acid);
    margin-left: 2px; vertical-align: -0.15em;
    animation: blink 0.75s step-end infinite;
}
.type-cursor.hidden { display: none; }
@keyframes blink { 50% { opacity: 0; } }

/* 属性变化提示 */
.effect-toast {
    align-self: center;
    margin-top: 10px;
    font-size: 13px; font-weight: 800;
    padding: 7px 18px;
    border-radius: 2px;
    background: var(--ink);
    border: 1.5px solid var(--acid);
    color: var(--acid);
    opacity: 0; transform: translateY(8px);
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
    min-height: 20px;
    letter-spacing: 0.04em;
}
.effect-toast.show { opacity: 1; transform: translateY(0); }

/* ---- 选项区 ---- */
.choices-area {
    display: flex; flex-direction: column; gap: 10px;
    margin-top: 14px; padding-bottom: 4px;
}

.choice-btn {
    width: 100%; text-align: left;
    background: var(--ink-2);
    border: 1.5px solid var(--line);
    border-radius: 3px;
    padding: 15px 18px;
    color: var(--paper);
    font-size: 14.5px; font-family: inherit; line-height: 1.55;
    cursor: pointer;
    transition: all 0.16s ease;
    opacity: 0; transform: translateY(10px);
    animation: choiceIn 0.3s ease forwards;
}
.choice-btn:nth-child(1) { animation-delay: 0.04s; }
.choice-btn:nth-child(2) { animation-delay: 0.12s; }
.choice-btn:nth-child(3) { animation-delay: 0.20s; }
.choice-btn:nth-child(4) { animation-delay: 0.28s; }
@keyframes choiceIn { to { opacity: 1; transform: translateY(0); } }

.choice-btn:active {
    transform: scale(0.985);
    background: var(--acid);
    border-color: var(--acid);
    color: var(--ink);
}
@media (hover: hover) {
    .choice-btn:hover, .choice-btn:focus-visible {
        background: var(--acid);
        border-color: var(--acid);
        color: var(--ink);
        transform: translateX(6px);
        outline: none;
    }
    .choice-btn:hover .choice-hint, .choice-btn:focus-visible .choice-hint { color: rgba(12,12,14,0.6); }
}

.choice-btn .choice-hint {
    display: block;
    font-size: 11px; color: var(--grey);
    margin-top: 4px; letter-spacing: 0.05em;
    transition: color 0.16s;
}

/* 继续按钮 */
.btn-continue {
    width: 100%;
    background: var(--acid);
    border: 1.5px solid var(--acid);
    border-radius: 3px;
    padding: 15px;
    color: var(--ink);
    font-size: 15px; font-weight: 900; font-family: inherit;
    letter-spacing: 0.24em;
    cursor: pointer;
    box-shadow: 5px 5px 0 rgba(216,255,62,0.22);
    transition: all 0.16s;
    opacity: 0; transform: translateY(10px);
    animation: choiceIn 0.3s ease forwards;
}
.btn-continue:active { transform: scale(0.985); }
@media (hover: hover) {
    .btn-continue:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 rgba(216,255,62,0.3); }
}

/* ========== 结局界面 ========== */
.ending-container {
    width: 100%; max-width: 620px;
    padding: calc(30px + env(safe-area-inset-top, 0px)) 24px calc(30px + var(--safe-bottom));
    margin: auto 0;
    text-align: center;
    animation: fadeUp 0.6s ease;
}

.ending-badge {
    display: inline-block;
    font-size: 12px; font-weight: 900;
    letter-spacing: 0.4em; text-indent: 0.4em;
    color: var(--ink);
    background: var(--acid);
    border-radius: 2px;
    padding: 7px 18px;
    margin-bottom: 24px;
    box-shadow: 4px 4px 0 rgba(216,255,62,0.25);
}

.ending-title {
    font-size: clamp(30px, 7vw, 44px);
    font-weight: 900; letter-spacing: 0.05em;
    margin-bottom: 22px;
    color: var(--paper);
}
.ending-title em {
    font-style: normal;
    color: var(--acid);
    text-shadow: 0.05em 0.05em 0 rgba(216, 255, 62, 0.25);
}

.ending-desc {
    font-size: 15px; line-height: 2.05;
    color: var(--paper);
    background: var(--ink-2);
    border: 1.5px solid var(--line);
    border-left: 4px solid var(--acid);
    border-radius: 3px;
    padding: 24px;
    margin-bottom: 18px;
    text-align: left;
    white-space: pre-wrap;
}

.ending-stats {
    display: flex; justify-content: center; gap: 10px 22px; flex-wrap: wrap;
    font-size: 12.5px; color: var(--grey); font-weight: 700;
    margin-bottom: 20px;
}
.ending-stats b { color: var(--paper); margin-left: 4px; }

.ending-quote {
    font-size: 14px; font-style: italic;
    color: var(--acid);
    margin-bottom: 30px; line-height: 1.9;
}

.btn-primary {
    background: var(--acid);
    border: 1.5px solid var(--acid);
    border-radius: 3px;
    padding: 15px 48px;
    color: var(--ink);
    font-size: 16px; font-weight: 900; font-family: inherit;
    letter-spacing: 0.24em;
    cursor: pointer;
    box-shadow: 6px 6px 0 rgba(216,255,62,0.25);
    transition: all 0.18s;
}
.btn-primary:active { transform: scale(0.97); }
@media (hover: hover) {
    .btn-primary:hover { transform: translate(-2px, -2px); box-shadow: 8px 8px 0 rgba(216,255,62,0.32); }
}

/* ========== 响应式 ========== */
@media (max-width: 640px) {
    .char-select { gap: 14px; }
    .char-card { flex: 1 1 100%; max-width: 100%; padding: 22px 18px; }
    .char-avatar { width: 104px; height: 104px; margin-bottom: 12px; }
    .stats-panel { padding: 12px 14px; gap: 10px 14px; }
    .story-card { padding: 16px; }
    .story-text { font-size: 15px; line-height: 1.9; }
    .choice-btn { padding: 14px 16px; font-size: 14px; }
    .shape-3 { display: none; }
    .synopsis-body { padding: 16px 18px; }
    .synopsis-body p { font-size: 12.5px; line-height: 1.85; }
    .game-container { padding: 10px 12px calc(14px + var(--safe-bottom)); }
    .game-header { padding: 2px 0 10px; }
    .day-badge { padding: 5px 12px; }
    #day-num { font-size: 20px; }
    .player-info { font-size: 15px; gap: 7px; }
    .player-avatar { width: 30px; height: 30px; }
}

/* 超小屏幕（≤380px）：老款 iPhone SE / Android 小屏 */
@media (max-width: 380px) {
    .logo-cn { font-size: 38px; }
    .char-avatar { width: 88px; height: 88px; }
    .char-name { font-size: 24px; }
    .stats-panel { padding: 10px 12px; gap: 8px 10px; }
    .stat-name { font-size: 11px; }
    .stat-val { font-size: 12px; }
    .story-text { font-size: 14px; line-height: 1.85; }
    .choice-btn { padding: 12px 14px; font-size: 13px; }
    .choice-btn .choice-hint { font-size: 10px; }
    .speaker { font-size: 12px; }
    .scene-tag { font-size: 11px; padding: 3px 10px; }
    .btn-save, .btn-restart { width: 40px; height: 40px; }
    .day-badge { padding: 4px 10px; }
    .day-label { font-size: 9px; }
    #day-num { font-size: 18px; }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .game-container { max-width: 640px; }
}

/* 横屏矮屏 */
@media (max-height: 560px) {
    .game-logo { margin-bottom: 12px; }
    .char-avatar { width: 84px; height: 84px; }
    .char-card { padding: 16px; }
    .story-card { padding: 14px 16px; }
    .story-synopsis { margin-bottom: 16px; }
    .synopsis-body { padding: 12px 16px; }
    .synopsis-body p { font-size: 12px; line-height: 1.7; margin-bottom: 4px; }
    .stats-panel { padding: 8px 12px; gap: 6px 12px; }
    .stat-bar { height: 4px; }
    .story-text { font-size: 14px; line-height: 1.75; }
    .choice-btn { padding: 10px 14px; font-size: 13px; }
    .choices-area { gap: 8px; margin-top: 10px; }
    .effect-toast { margin-top: 6px; padding: 5px 14px; font-size: 12px; }
    .game-container { padding: 8px 12px calc(10px + var(--safe-bottom)); }
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
