* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg-deep: #0a0a18;
    --bg-dark: #0f1029;
    --bg-panel: #181a35;
    --bg-panel-light: #22254a;
    --bg-glass: rgba(24, 26, 53, 0.85);
    --border: #3d4070;
    --border-gold: #c9a24e;
    --text: #e8e6f0;
    --text-bright: #ffffff;
    --text-dim: #9b9bc0;
    --primary: #d4a853;
    --primary-light: #f0d080;
    --primary-dark: #9a7530;
    --accent: #6ea8fe;
    --accent-light: #9ecbff;
    --success: #7dd87d;
    --warning: #ffc166;
    --danger: #ff6b6b;
    --pink: #ff8fab;
    --purple: #b18aff;
    --gold-glow: 0 0 12px rgba(212, 168, 83, 0.5);
    --blue-glow: 0 0 12px rgba(110, 168, 254, 0.4);
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    background: var(--bg-deep);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: 
        radial-gradient(ellipse at 20% 0%, rgba(110, 168, 254, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(212, 168, 83, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(177, 138, 255, 0.04) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

#app {
    height: 100%;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
    background: linear-gradient(180deg, var(--bg-dark) 0%, var(--bg-deep) 100%);
    box-shadow: 0 0 60px rgba(0,0,0,0.5);
}

/* ============ 顶部状态栏 ============ */
.top-bar {
    background: linear-gradient(180deg, rgba(34, 37, 74, 0.98) 0%, rgba(24, 26, 53, 0.95) 100%);
    padding: 8px 12px 8px 10px;
    border-bottom: 1px solid var(--border-gold);
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    backdrop-filter: blur(10px);
}

.top-bar::after {
    content: '';
    position: absolute;
    bottom: -1px; left: 10%; right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary-light), transparent);
}

.player-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--primary);
    background: linear-gradient(135deg, var(--bg-panel-light), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    box-shadow: var(--gold-glow);
    overflow: hidden;
}

.player-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player-info {
    flex: 1;
    min-width: 0;
}

.player-name {
    font-size: 16px;
    font-weight: bold;
    color: var(--primary-light);
    text-shadow: 0 0 8px rgba(240, 208, 128, 0.3);
    line-height: 1.2;
}

.player-realm {
    color: var(--accent-light);
    font-size: 11px;
    margin-top: 2px;
}

.player-stats {
    flex: 1.2;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.stat-group {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.stat-label {
    font-size: 9px;
    color: var(--text-dim);
    display: flex;
    justify-content: space-between;
    line-height: 1.2;
}

.stat-bar {
    height: 5px;
    background: rgba(0,0,0,0.4);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.stat-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
    position: relative;
}

.stat-fill::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255,255,255,0.3), transparent);
    border-radius: 3px 3px 0 0;
}

.stat-fill.hp { 
    background: linear-gradient(90deg, #ff5252, #ff8a80); 
    box-shadow: 0 0 6px rgba(255, 82, 82, 0.5);
}
.stat-fill.qi { 
    background: linear-gradient(90deg, #448aff, #82b1ff); 
    box-shadow: 0 0 6px rgba(68, 138, 255, 0.5);
}
.stat-fill.progress { 
    background: linear-gradient(90deg, var(--primary-dark), var(--primary-light)); 
    box-shadow: 0 0 6px rgba(212, 168, 83, 0.5);
}
.stat-fill.gold { 
    background: linear-gradient(90deg, #ffb300, var(--primary-light)); 
    box-shadow: 0 0 6px rgba(255, 179, 0, 0.5);
}

.resources {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    flex-shrink: 0;
}

.res-stones {
    color: var(--primary-light);
    font-size: 13px;
    font-weight: bold;
    text-shadow: 0 0 8px rgba(212, 168, 83, 0.4);
}

.res-age {
    font-size: 10px;
    color: var(--text-dim);
}

.res-time {
    font-size: 10px;
    color: var(--accent);
}

/* ============ 主内容区 ============ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 6px;
    gap: 6px;
    position: relative;
}

.scene-bg {
    position: absolute;
    top: 6px; left: 6px; right: 6px; bottom: 6px;
    border-radius: 10px;
    overflow: hidden;
    opacity: 0.15;
    z-index: 0;
}

.scene-bg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-log {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.8;
    -webkit-overflow-scrolling: touch;
    position: relative;
    z-index: 1;
    backdrop-filter: blur(8px);
    box-shadow: inset 0 0 30px rgba(0,0,0,0.2);
}

.message-log::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 20px;
    background: linear-gradient(180deg, var(--bg-glass), transparent);
    pointer-events: none;
    z-index: 2;
    border-radius: 10px 10px 0 0;
}

.msg-item { 
    padding: 2px 0; 
    word-break: break-all;
    animation: msgFadeIn 0.3s ease;
}

@keyframes msgFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.msg-title { 
    color: var(--primary-light); 
    font-weight: bold; 
    font-size: 15px; 
    padding: 8px 0; 
    text-align: center;
    text-shadow: 0 0 10px rgba(212, 168, 83, 0.5);
    letter-spacing: 4px;
}
.msg-info { color: var(--text-dim); }
.msg-positive { color: var(--success); }
.msg-danger { color: var(--danger); }
.msg-warning { color: var(--warning); }
.msg-event { 
    color: var(--accent-light); 
    font-style: italic; 
}
.msg-story { color: var(--text); text-indent: 2em; }

/* ============ 快捷操作栏 ============ */
.quick-bar {
    display: flex;
    gap: 6px;
    padding: 0 2px;
    position: relative;
    z-index: 1;
}

.quick-btn {
    flex: 1;
    height: 36px;
    background: linear-gradient(180deg, var(--bg-panel-light), var(--bg-panel));
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-dim);
    font-size: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.quick-btn:active {
    transform: scale(0.95);
    background: linear-gradient(180deg, var(--primary-dark), var(--primary));
    border-color: var(--primary);
    color: white;
}

.quick-btn .icon {
    font-size: 16px;
}

.cultivate-panel {
    background: linear-gradient(180deg, rgba(34, 37, 74, 0.9), rgba(24, 26, 53, 0.9));
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 1;
    backdrop-filter: blur(8px);
}

.cycle-select {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.cycle-btn {
    min-width: 38px;
    height: 30px;
    padding: 0 8px;
    font-size: 12px;
    background: var(--bg-dark);
    color: var(--text-dim);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.cycle-btn.active { 
    color: var(--primary-light); 
    border-color: var(--primary);
    background: rgba(212, 168, 83, 0.15);
    box-shadow: 0 0 8px rgba(212, 168, 83, 0.2);
}

.cycle-btn:active { transform: scale(0.95); }

.btn-cultivate-main {
    flex: 1;
    height: 44px;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--bg-deep);
    border: none;
    border-radius: 22px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(212, 168, 83, 0.4), inset 0 1px 0 rgba(255,255,255,0.3);
    position: relative;
    overflow: hidden;
}

.btn-cultivate-main::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%; width: 200%; height: 200%;
    background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.2) 50%, transparent 70%);
    transform: translateX(-100%);
    animation: btnShine 3s infinite;
}

@keyframes btnShine {
    0%, 100% { transform: translateX(-100%); }
    50% { transform: translateX(100%); }
}

.btn-cultivate-main:active {
    transform: scale(0.97);
    box-shadow: 0 2px 8px rgba(212, 168, 83, 0.3);
}

/* ============ 底部导航栏 ============ */
.bottom-nav {
    background: linear-gradient(180deg, rgba(24, 26, 53, 0.98) 0%, rgba(15, 16, 41, 0.99) 100%);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    display: flex;
    gap: 2px;
    backdrop-filter: blur(10px);
    position: relative;
}

.bottom-nav::before {
    content: '';
    position: absolute;
    top: -1px; left: 10%; right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 2px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 8px;
    position: relative;
    min-height: 50px;
}

.nav-item .nav-icon {
    font-size: 22px;
    transition: all 0.2s;
}

.nav-item:active {
    transform: scale(0.9);
    color: var(--primary-light);
}

.nav-item.active {
    color: var(--primary-light);
}

.nav-item.active .nav-icon {
    text-shadow: 0 0 12px rgba(240, 208, 128, 0.6);
    transform: translateY(-2px);
}

.nav-item.primary-nav {
    margin-top: -16px;
}

.nav-item.primary-nav .nav-icon-wrap {
    width: 48px;
    height: 48px;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(212, 168, 83, 0.5), inset 0 2px 4px rgba(255,255,255,0.3);
    border: 2px solid var(--bg-dark);
    margin-bottom: 2px;
}

.nav-item.primary-nav .nav-icon {
    font-size: 24px;
    color: var(--bg-deep);
}

.nav-item.primary-nav span {
    color: var(--primary-light);
    font-weight: bold;
}

/* ============ z-index 层级体系 ============
 *  重要：所有全屏 fixed 覆盖层（combatView/introView/modalContainer/gameOver）
 *  必须是 <body> 的直接子元素，避免被 #app (position:relative; z-index:1)
 *  的 stacking context 困住，导致 z-index 失效。
 *  战斗特效（.crit-text/.damage-number）由 JS 直接 appendChild 到 body。
 *
 *  0     - 背景装饰层 (body::before, .scene-bg)
 *  1-10  - 应用内容层 (#app 及内部组件)
 *  50    - 战斗界面层 (#combatView) - 全屏战斗覆盖主界面
 *  100   - 通用弹窗遮罩 (.modal-overlay 在 modalContainer 内部)
 *  200   - 初始引导层 (#introView) - 灵根选择，覆盖战斗/主界面
 *  900   - 战斗特效层 (.crit-text, .damage-number) - 飘字特效，pointer-events:none 不拦截点击
 *  9999  - 弹窗容器 (#modalContainer) - 所有动态弹窗/确认框/丹药选择等，pointer-events:none 子层恢复 auto
 *  10000 - 游戏结束 (.game-over-overlay) - 终局画面，最高优先级
 */

/* ============ 战斗界面 ============ */
#combatView {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #1a0f2e, #0a0a18);
    max-width: 480px;
    margin: 0 auto;
}

/* ============ 初始引导界面 ============ */
#introView {
    z-index: 200;
}

/* ============ 弹窗 ============ */
/* 弹窗容器必须在最顶层，确保所有模态框/确认框不被其他遮罩覆盖 */
#modalContainer {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 9999;
    pointer-events: none;
}
#modalContainer .modal-overlay {
    pointer-events: auto;
}

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.75);
    z-index: 100;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.center-modal {
    align-items: center;
    padding: 16px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal {
    background: linear-gradient(180deg, var(--bg-panel) 0%, var(--bg-dark) 100%);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -8px 32px rgba(0,0,0,0.4);
}

.modal-header {
    padding: 14px 16px 10px;
    background: linear-gradient(180deg, var(--bg-panel-light), var(--bg-panel));
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.modal-header::after {
    content: '';
    position: absolute;
    bottom: -1px; left: 20%; right: 20%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
}

.modal-title {
    font-size: 16px;
    font-weight: bold;
    color: var(--primary-light);
    text-shadow: 0 0 8px rgba(240, 208, 128, 0.3);
}

.modal-close {
    background: var(--bg-panel-light);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 18px;
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:active {
    transform: scale(0.9);
    background: var(--danger);
    color: white;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    -webkit-overflow-scrolling: touch;
}

.modal-footer {
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
    background: var(--bg-panel);
}

/* ============ 列表项 ============ */
.list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: linear-gradient(180deg, var(--bg-panel-light), rgba(34, 37, 74, 0.6));
    border-radius: 10px;
    margin-bottom: 6px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.list-item:active { 
    border-color: var(--primary);
    transform: scale(0.98);
    background: linear-gradient(180deg, rgba(212, 168, 83, 0.15), rgba(212, 168, 83, 0.05));
}
.list-item.selected { 
    border-color: var(--accent); 
    background: rgba(110, 168, 254, 0.1); 
}

.tag {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg-panel-light);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 11px;
    color: var(--text);
}

.tag.gold {
    background: rgba(212, 168, 83, 0.2);
    border-color: var(--primary-dark);
    color: var(--primary-light);
}

.avatar-small {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--bg-panel-light), var(--primary-dark));
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.avatar-large {
    width: 120px;
    height: 120px;
    border-radius: 12px;
    object-fit: cover;
    border: 3px solid var(--primary);
    background: var(--bg-dark);
    box-shadow: 0 4px 20px rgba(212, 168, 83, 0.3);
}

.fullbody-img {
    max-width: 75vw;
    max-height: 45vh;
    object-fit: contain;
    border-radius: 12px;
    border: 3px solid var(--primary);
    background: var(--bg-dark);
    box-shadow: 0 4px 24px rgba(212, 168, 83, 0.3);
}

.encounter-img {
    max-width: 80vw;
    max-height: 50vh;
    object-fit: contain;
    border-radius: 12px;
    border: 3px solid var(--primary-light);
    background: var(--bg-dark);
    box-shadow: 0 0 32px rgba(212, 168, 83, 0.4);
}

.item-info { flex: 1; min-width: 0; }
.item-title { 
    font-weight: bold; 
    color: var(--text-bright); 
    font-size: 14px; 
}
.item-sub { 
    font-size: 12px; 
    color: var(--text-dim); 
    margin-top: 3px;
    line-height: 1.4;
}

/* ============ 按钮样式 ============ */
.btn {
    padding: 10px 18px;
    background: linear-gradient(180deg, var(--bg-panel-light), var(--bg-panel));
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    min-height: 42px;
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.97);
}

.btn.primary {
    background: linear-gradient(180deg, var(--primary), var(--primary-dark));
    border-color: var(--primary-light);
    color: var(--bg-deep);
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(212, 168, 83, 0.35);
}

.btn.success { 
    background: linear-gradient(180deg, var(--success), #5ab85a); 
    border-color: var(--success);
    color: var(--bg-deep);
    font-weight: bold;
}
.btn.danger { 
    background: linear-gradient(180deg, var(--danger), #d94848); 
    border-color: var(--danger);
    color: white;
    font-weight: bold;
}
.btn:disabled { 
    opacity: 0.4; 
    cursor: not-allowed;
    transform: none !important;
}

/* ============ 两列布局 ============ */
.two-col {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.col-left { flex: 0 0 110px; }
.col-right { flex: 1; min-width: 0; }

.detail-section {
    margin-bottom: 10px;
    padding: 10px;
    background: linear-gradient(180deg, rgba(34, 37, 74, 0.6), rgba(24, 26, 53, 0.8));
    border-radius: 10px;
    border: 1px solid var(--border);
}

.detail-label {
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.detail-value {
    font-size: 13px;
    color: var(--text);
    line-height: 1.6;
}

/* ============ 战斗UI ============ */
.combat-area {
    padding: 10px;
    background: linear-gradient(180deg, #1a0f2e 0%, #0d0d1a 100%);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 6px;
    position: relative;
    overflow: hidden;
}

.combat-area::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(ellipse at top, rgba(177, 138, 255, 0.1), transparent 60%);
    pointer-events: none;
}

.enemy-section {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    position: relative;
    z-index: 1;
}

.enemy-portrait {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    background: linear-gradient(135deg, #4a1515, #1a0808);
    border: 2px solid var(--danger);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    flex-shrink: 0;
    box-shadow: 0 0 20px rgba(255, 107, 107, 0.4);
    overflow: hidden;
}

.enemy-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.enemy-info { flex: 1; }
.enemy-name { font-weight: bold; color: var(--danger); font-size: 16px; text-shadow: 0 0 8px rgba(255, 107, 107, 0.5); }
.enemy-type { font-size: 11px; padding: 2px 8px; border-radius: 10px; margin-left: 8px; }

.combatant-panel {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    position: relative;
    z-index: 1;
}

.combatant-card {
    flex: 1;
    background: rgba(255,255,255,0.05);
    padding: 8px;
    border-radius: 10px;
    border: 1px solid var(--border);
    backdrop-filter: blur(4px);
}

.combatant-name {
    font-size: 13px;
    color: var(--primary-light);
    font-weight: bold;
    margin-bottom: 4px;
}

.skill-btn {
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    margin-bottom: 6px;
    background: linear-gradient(180deg, var(--bg-panel-light), var(--bg-panel));
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.skill-btn:active { 
    border-color: var(--accent); 
    background: linear-gradient(180deg, rgba(110, 168, 254, 0.2), rgba(110, 168, 254, 0.05));
    transform: scale(0.98);
}
.skill-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.skill-cost { color: var(--accent); font-size: 12px; float: right; }

/* 战斗按钮栏 */
.combat-actions {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    padding: 8px;
    background: linear-gradient(180deg, var(--bg-panel), var(--bg-dark));
    border-top: 1px solid var(--border);
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
}

.combat-action-btn {
    height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: linear-gradient(180deg, var(--bg-panel-light), var(--bg-panel));
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
}

.combat-action-btn .ca-icon {
    font-size: 20px;
}

.combat-action-btn:active {
    transform: scale(0.92);
}

.combat-action-btn.primary {
    background: linear-gradient(180deg, var(--danger), #c0392b);
    border-color: var(--danger);
    color: white;
    box-shadow: 0 2px 10px rgba(255, 107, 107, 0.4);
}

/* ============ 响应式 ============ */
@media (min-width: 768px) {
    body { font-size: 15px; }
    #app {
        border-radius: 16px;
        margin-top: 20px;
        margin-bottom: 20px;
        height: calc(100% - 40px);
    }
}

.hidden { display: none !important; }
.flex { display: flex; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.wrap { flex-wrap: wrap; }
.text-center { text-align: center; }

/* ============ 游戏结束 ============ */
.game-over-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.8s ease;
}

.game-over-content {
    text-align: center;
    padding: 30px 20px;
    max-width: 340px;
    width: 90%;
}

.game-over-title {
    font-size: 48px;
    font-weight: 900;
    color: #ff4757;
    text-shadow: 0 0 30px rgba(255, 71, 87, 0.7);
    margin-bottom: 16px;
    letter-spacing: 6px;
}

.game-over-reason {
    font-size: 16px;
    color: #e0e0e0;
    margin-bottom: 24px;
    line-height: 1.7;
}

.game-over-stats {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 24px;
    text-align: left;
    border: 1px solid rgba(255,255,255,0.1);
}

.game-over-stats-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    color: #bdbdbd;
    font-size: 13px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.game-over-stats-row:last-child {
    border-bottom: none;
}

.game-over-stats-label {
    color: #9e9e9e;
}

.game-over-stats-value {
    color: #fff;
    font-weight: 600;
}

.game-over-btn {
    background: linear-gradient(135deg, #ff4757, #c0392b);
    color: white;
    border: none;
    padding: 14px 40px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 25px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(255, 71, 87, 0.5);
    transition: all 0.3s;
}

.game-over-btn:active {
    transform: scale(0.95);
}

/* ============ 战斗特效 ============ */
@keyframes screen-shake {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-6px, 4px); }
    20% { transform: translate(6px, -4px); }
    30% { transform: translate(-5px, -3px); }
    40% { transform: translate(5px, 3px); }
    50% { transform: translate(-4px, 2px); }
    60% { transform: translate(4px, -2px); }
    70% { transform: translate(-3px, 1px); }
    80% { transform: translate(3px, -1px); }
    90% { transform: translate(-1px, 0); }
}

.screen-shake {
    animation: screen-shake 0.4s ease-in-out;
}

@keyframes crit-flash {
    0% { opacity: 0; background: rgba(255, 0, 0, 0); }
    30% { opacity: 1; background: rgba(255, 50, 50, 0.35); }
    100% { opacity: 0; background: rgba(255, 0, 0, 0); }
}

.crit-flash {
    animation: crit-flash 0.5s ease-out;
}

@keyframes crit-text-pop {
    0% {
        transform: translate(-50%, -50%) scale(0.2) rotate(-15deg);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.3) rotate(5deg);
        opacity: 1;
    }
    70% {
        transform: translate(-50%, -50%) scale(1.0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -80%) scale(1.0);
        opacity: 0;
    }
}

.crit-text {
    position: fixed;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    font-weight: 900;
    color: #ffd700;
    text-shadow:
        0 0 10px #ffd700,
        0 0 20px #ff8c00,
        0 0 30px #ff4500,
        2px 2px 0 #000,
        -2px -2px 0 #000,
        2px -2px 0 #000,
        -2px 2px 0 #000;
    pointer-events: none;
    z-index: 900;
    letter-spacing: 4px;
    animation: crit-text-pop 1.0s ease-out forwards;
}

@keyframes enemy-shake {
    0%, 100% { transform: translate(0, 0); }
    20% { transform: translate(-8px, 0) rotate(-3deg); }
    40% { transform: translate(8px, 0) rotate(3deg); }
    60% { transform: translate(-6px, 0) rotate(-2deg); }
    80% { transform: translate(6px, 0) rotate(2deg); }
}

.enemy-shake {
    animation: enemy-shake 0.4s ease-in-out;
}

@keyframes damage-float {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-50px) scale(1.3);
        opacity: 0;
    }
}

.damage-number {
    position: fixed;
    font-size: 24px;
    font-weight: bold;
    color: #ffeb3b;
    text-shadow: 2px 2px 0 #d32f2f, -1px -1px 0 #d32f2f, 1px -1px 0 #d32f2f, -1px 1px 0 #d32f2f;
    pointer-events: none;
    z-index: 900;
    animation: damage-float 0.9s ease-out forwards;
}

.damage-number.crit {
    font-size: 36px;
    color: #ffd700;
    text-shadow: 2px 2px 0 #000, -1px -2px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 0 0 15px #ffd700;
}

/* ============ 输入框美化 ============ */
input[type="text"] {
    background: var(--bg-dark) !important;
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    color: var(--text) !important;
    font-size: 14px !important;
    padding: 10px 12px !important;
    outline: none;
    transition: all 0.2s;
}

input[type="text"]:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 2px rgba(212, 168, 83, 0.2);
}

/* ============ 滚动条美化 ============ */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}
