/* ===== CSS 变量 - 统一配色系统 (Dark Subtle Theme) ===== */
:root {
    /* 主色调 - 深灰蓝 */
    --primary: #4a5568;
    --primary-light: #5a6578;
    --primary-dark: #3a4558;
    --primary-glow: rgba(74, 85, 104, 0.3);

    /* 辅助色 - 深灰青 */
    --secondary: #4a5a6a;
    --secondary-light: #5a6a7a;
    --secondary-glow: rgba(74, 90, 106, 0.25);

    /* 强调色 - 深灰紫 */
    --accent: #556677;
    --accent-light: #657687;
    --accent-glow: rgba(85, 102, 119, 0.25);

    /* 功能色 - 深灰调 */
    --success: #4a6655;
    --success-glow: rgba(74, 102, 85, 0.25);
    --warning: #66604a;
    --warning-glow: rgba(102, 96, 74, 0.25);
    --danger: #664a4a;
    --danger-glow: rgba(102, 74, 74, 0.25);

    /* 中性色 - 高透明度 */
    --bg-deep: #0a0a1a;
    --bg-dark: #0f0f2a;
    --bg-card: rgba(15, 15, 35, 0.75);
    --bg-hover: rgba(255, 255, 255, 0.05);
    --bg-active: rgba(255, 255, 255, 0.08);

    /* 文字色 - 低对比度 */
    --text-primary: #a0aec0;
    --text-secondary: #718096;
    --text-muted: #4a5568;
    --text-inverse: #0a0a1a;

    /* 边框 - 高透明度 */
    --border-subtle: rgba(255, 255, 255, 0.04);
    --border-medium: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.12);

    /* 阴影 - 更柔和 */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.6);
    --shadow-glow-primary: 0 0 20px var(--primary-glow);
    --shadow-glow-secondary: 0 0 15px var(--secondary-glow);

    /* 动画变量 */
    --animate-duration: 1s;
    --animate-delay: 1s;
    --animate-repeat: 1;
    --swiper-theme-color: #4a5568;
    --swiper-navigation-size: 44px;
    --screen-width: 1536;
}

/* ===== 全局重置与基础样式 ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation; /* 优化触摸响应 */
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000000;
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    color: var(--text-primary);
    /* 禁止移动端默认触摸行为 */
    -webkit-touch-callout: none;
    overscroll-behavior: none;
}

/* 移动端横屏提示（可选） */
@media screen and (orientation: portrait) and (max-width: 600px) {
    body::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.95);
        z-index: 9999;
        display: none; /* 默认不显示，需要时启用 */
        justify-content: center;
        align-items: center;
        flex-direction: column;
        gap: 20px;
    }
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* ===== 画布层 ===== */
canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#game-canvas {
    z-index: 1;
}

#starfield-canvas {
    z-index: 0;
}

/* ===== 屏幕管理 ===== */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: none;
    pointer-events: none;
    /* 确保居中显示，避免闪烁 */
    justify-content: center;
    align-items: center;
}

.screen.active {
    display: flex;
    pointer-events: auto;
}

/* ===== 主菜单（左右分栏布局） ===== */
#main-menu {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 40px;
}

.menu-container {
    display: flex;
    width: 100%;
    max-width: 1400px;
    height: 80vh;
    gap: 40px;
}

/* 左侧区域 */
.menu-left {
    flex: 0 0 35%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 25px;
    padding: 20px;
}

/* 右侧区域 */
.menu-right {
    flex: 0 0 60%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 20px;
}

.ship-select-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    text-shadow: 0 0 20px var(--primary-glow);
    letter-spacing: 3px;
    margin-bottom: 10px;
}

/* 飞船选择器容器 */
.ship-selector {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    width: 100%;
    max-width: 700px;
    /* 参考样式优化 */
    box-sizing: border-box;
    margin: 0px;
    padding: 0px;
}

.ship-preview-hint {
    font-size: 0.9rem;
    color: var(--text-secondary);
    opacity: 0.7;
    margin-top: 10px;
}

.menu-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* 半透明黑色背景，让星空透过来 */
    background:
        radial-gradient(ellipse at 20% 50%, rgba(79, 70, 229, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(168, 85, 247, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(6, 182, 212, 0.06) 0%, transparent 50%),
        rgba(0, 0, 0, 0.55);
    z-index: -1;
    animation: bgPulse 8s ease-in-out infinite;
}

@keyframes bgPulse {
    0%, 100% {
        opacity: 1;
        filter: brightness(1);
    }
    50% {
        opacity: 0.9;
        filter: brightness(1.1);
    }
}

.menu-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    padding: 20px;
    max-width: 400px;
    width: 90%;
}

.game-title {
    text-align: center;
    margin-bottom: 20px;
    animation: titleFloat 4s ease-in-out infinite;
}

.title-main {
    display: block;
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--text-primary);
    text-shadow:
        0 0 20px var(--primary-glow),
        0 0 40px rgba(99, 102, 241, 0.3),
        0 0 60px rgba(79, 70, 229, 0.2);
    letter-spacing: 4px;
    animation: titlePulse 3s ease-in-out infinite;
}

.title-sub {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary-light);
    letter-spacing: 6px;
    margin-top: 8px;
    opacity: 0.8;
    animation: subtitleGlow 2s ease-in-out infinite alternate;
}

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

@keyframes titlePulse {
    0%, 100% {
        text-shadow:
            0 0 20px var(--primary-glow),
            0 0 40px rgba(99, 102, 241, 0.3);
    }
    50% {
        text-shadow:
            0 0 30px var(--primary-glow),
            0 0 60px rgba(99, 102, 241, 0.5),
            0 0 90px rgba(79, 70, 229, 0.3);
    }
}

@keyframes subtitleGlow {
    0% {
        opacity: 0.6;
        text-shadow: 0 0 10px var(--primary-glow);
    }
    100% {
        opacity: 1;
        text-shadow: 0 0 20px var(--primary-glow), 0 0 30px rgba(99, 102, 241, 0.4);
    }
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

/* 模式选择卡片式布局 */
.mode-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    margin-bottom: 12px;
}

.mode-card {
    position: relative;
    padding: 12px 8px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: center;
    overflow: hidden;
}

/* 正常模式卡片 */
.mode-card.normal {
    background: linear-gradient(135deg, rgba(74, 85, 104, 0.1), rgba(58, 69, 88, 0.08));
    border: 1px solid var(--border-medium);
    box-shadow:
        0 0 10px var(--primary-glow),
        inset 0 0 10px rgba(74, 85, 104, 0.05);
}

.mode-card.normal:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow:
        0 0 15px var(--primary-glow),
        0 4px 20px rgba(74, 85, 104, 0.2),
        inset 0 0 15px rgba(74, 85, 104, 0.1);
}

/* 无敌模式卡片 */
.mode-card.god {
    background: linear-gradient(135deg, rgba(74, 90, 106, 0.1), rgba(58, 74, 90, 0.08));
    border: 1px solid var(--border-medium);
    box-shadow:
        0 0 10px var(--secondary-glow),
        inset 0 0 10px rgba(74, 90, 106, 0.05);
}

.mode-card.god:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow:
        0 0 15px var(--secondary-glow),
        0 4px 20px rgba(74, 90, 106, 0.2),
        inset 0 0 15px rgba(74, 90, 106, 0.1);
}

.mode-icon {
    font-size: 2rem;
    margin-bottom: 6px;
    display: block;
}

.mode-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 3px;
}

.mode-desc {
    font-size: 0.7rem;
    color: var(--text-secondary);
    opacity: 0.8;
}

.menu-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    width: 100%;
    text-align: left;
    position: relative;
    overflow: hidden;
    font-family: inherit;
}

/* 按钮光效扫过 */
.menu-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transition: left 0.5s;
}

.menu-btn:hover::before,
.menu-btn:active::before {
    left: 100%;
}

/* 按钮悬停时的粒子效果 */
.menu-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.menu-btn:hover::after {
    width: 300px;
    height: 300px;
}

/* 主按钮 - 深灰渐变 */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: var(--text-primary);
    box-shadow:
        0 2px 10px var(--primary-glow),
        inset 0 0 8px rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-medium);
}

.btn-primary:hover,
.btn-primary:active {
    transform: translateY(-1px) scale(1.01);
    box-shadow:
        0 3px 15px var(--primary-glow),
        0 0 20px rgba(74, 85, 104, 0.2),
        inset 0 0 12px rgba(255, 255, 255, 0.08);
    border-color: var(--primary-light);
}

/* 次要按钮 - 深灰青渐变 */
.btn-secondary {
    background: linear-gradient(135deg, #3a4a5a, var(--secondary));
    color: var(--text-primary);
    box-shadow:
        0 2px 10px var(--secondary-glow),
        inset 0 0 8px rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-medium);
}

.btn-secondary:hover,
.btn-secondary:active {
    transform: translateY(-1px) scale(1.01);
    box-shadow:
        0 3px 15px var(--secondary-glow),
        0 0 20px rgba(74, 90, 106, 0.2),
        inset 0 0 12px rgba(255, 255, 255, 0.08);
    border-color: var(--secondary-light);
}

/* 第三按钮 - 高透明黑色 */
.btn-tertiary {
    background: rgba(0, 0, 0, 0.4);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.3);
}

.btn-tertiary:hover,
.btn-tertiary:active {
    background: rgba(10, 10, 30, 0.6);
    border-color: var(--border-medium);
    transform: translateY(-1px);
    box-shadow:
        0 0 10px var(--primary-glow),
        inset 0 0 8px rgba(74, 85, 104, 0.08);
}

.btn-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.btn-text {
    font-size: 1.1rem;
    font-weight: 700;
}

.btn-desc {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-left: auto;
    font-weight: 400;
    color: var(--text-secondary);
}

.version-info {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 20px;
}

/* ===== HUD 游戏界面 ===== */
#hud {
    flex-direction: column;
    justify-content: space-between;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* 左上角信息 */
.hud-top-left {
    position: absolute;
    top: 16px;
    left: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 20;
}

.health-bar-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.health-bar-bg {
    width: 120px;
    height: 14px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 7px;
    overflow: hidden;
    border: 1px solid var(--border-medium);
}

.health-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--primary-dark), var(--primary));
    border-radius: 7px;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px var(--primary-glow);
}

.health-text {
    font-size: 0.75rem;
    color: var(--text-primary);
    font-weight: 700;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.score-info, .wave-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.score-label, .wave-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.score-value, .wave-value {
    font-size: 1rem;
    color: var(--secondary-light);
    font-weight: 800;
    text-shadow: 0 0 10px var(--secondary-glow);
}

/* 能源条 */
.energy-bar-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.energy-bar-bg {
    width: 120px;
    height: 10px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid var(--border-medium);
}

.energy-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #0891b2, var(--secondary));
    border-radius: 5px;
    transition: width 0.3s ease;
    box-shadow: 0 0 8px var(--secondary-glow);
}

.energy-text {
    font-size: 0.7rem;
    color: var(--secondary-light);
    font-weight: 700;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* 经验条 */
.exp-bar-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.exp-bar-bg {
    width: 100px;
    height: 6px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid var(--border-medium);
}

.exp-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    border-radius: 3px;
    transition: width 0.3s ease;
    box-shadow: 0 0 6px var(--accent-glow);
}

.level-text {
    font-size: 0.7rem;
    color: var(--accent-light);
    font-weight: 800;
    text-shadow: 0 0 8px var(--accent-glow);
}

/* 最高分显示 */
.high-score-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.high-score-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.high-score-value {
    font-size: 0.85rem;
    color: var(--warning);
    font-weight: 700;
    text-shadow: 0 0 8px var(--warning-glow);
}

/* 右上角自动瞄准 */
.hud-top-right {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 20;
}

.auto-aim-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 2px solid var(--border-medium);
    border-radius: 20px;
    background: rgba(10, 10, 26, 0.6);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    font-family: inherit;
}

.auto-aim-btn.active {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    box-shadow: 0 0 20px var(--success-glow);
}

.aim-icon {
    font-size: 1rem;
}

.aim-text {
    font-size: 0.7rem;
    font-weight: 600;
}

.aim-status {
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg-hover);
}

/* 模式标识 */
.mode-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    pointer-events: none;
}

.mode-text {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 4px;
    text-transform: uppercase;
}

/* ===== 无敌模式倒计时 ===== */
.god-mode-timer {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #f59e0b;
    border-radius: 12px;
    z-index: 20;
    backdrop-filter: blur(10px);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.3);
    animation: godModePulse 2s ease-in-out infinite;
    min-width: 180px;
}

@keyframes godModePulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(245, 158, 11, 0.3);
        border-color: #f59e0b;
    }
    50% {
        box-shadow: 0 0 30px rgba(245, 158, 11, 0.6);
        border-color: #fbbf24;
    }
}

.timer-icon {
    font-size: 1.8rem;
    animation: timerIconSpin 3s linear infinite;
}

@keyframes timerIconSpin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.timer-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.timer-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.timer-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fbbf24;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.8);
    font-family: 'Courier New', monospace;
    min-width: 60px;
    text-align: center;
}

.timer-value.warning {
    color: #ef4444;
    text-shadow: 0 0 10px rgba(239, 68, 68, 0.8);
    animation: timerWarning 0.5s ease-in-out infinite;
}

@keyframes timerWarning {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* 进度条 */
.timer-progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(245, 158, 11, 0.2);
    border-radius: 0 0 10px 10px;
    overflow: hidden;
}

.timer-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.timer-progress-fill.warning {
    background: linear-gradient(90deg, #ef4444, #f87171);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

/* 无敌模式结束警告 */
.god-mode-end-warning {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px 40px;
    background: rgba(0, 0, 0, 0.9);
    border: 3px solid #ef4444;
    border-radius: 16px;
    color: #ef4444;
    font-size: 1.5rem;
    font-weight: 700;
    z-index: 1000;
    text-align: center;
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.6);
    animation: warningPulse 0.5s ease-in-out infinite;
}

@keyframes warningPulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 0 30px rgba(239, 68, 68, 0.6);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.05);
        box-shadow: 0 0 50px rgba(239, 68, 68, 0.9);
    }
}

/* ===== 虚拟摇杆 ===== */
.joystick {
    position: absolute;
    bottom: 80px;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.joystick-left {
    left: 40px;
}

.joystick-right {
    right: 40px;
}

.joystick-base {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(10, 10, 26, 0.3);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    backdrop-filter: blur(3px);
}

.joystick-knob {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: absolute;
    transition: transform 0.05s linear;
    box-shadow: 0 0 8px var(--primary-glow);
}

.joystick.active .joystick-base {
    background: rgba(74, 85, 104, 0.15);
    border-color: var(--border-medium);
}

.joystick-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 2px;
}

/* 暂停按钮 */
.pause-btn {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--border-medium);
    background: rgba(10, 10, 26, 0.6);
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    font-family: inherit;
}

.pause-btn:hover,
.pause-btn:active {
    background: var(--bg-active);
    border-color: var(--border-strong);
    transform: translateX(-50%) scale(1.1);
}

/* ===== 弹窗/覆盖层 ===== */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* 科幻风格 - 深色半透明背景 */
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    z-index: 30;
}

.modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* 科幻风格 - 黑色背景 + 边缘发光 */
    background: rgba(0, 0, 0, 0.95);
    border: 2px solid var(--primary);
    border-radius: 24px;
    padding: 30px;
    min-width: 280px;
    max-width: 90%;
    z-index: 31;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    box-shadow:
        0 0 20px var(--primary-glow),
        0 0 40px rgba(99, 102, 241, 0.3),
        inset 0 0 30px rgba(99, 102, 241, 0.1);
    /* 添加扫描线效果 */
    background-image: 
        linear-gradient(rgba(99, 102, 241, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(99, 102, 241, 0.03) 1px, transparent 1px);
    background-size: 20px 20px;
    /* 出现动画 */
    animation: modalAppear 0.3s ease-out;
}

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.modal h2 {
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 800;
    text-align: center;
    /* 科幻发光效果 */
    text-shadow: 
        0 0 10px var(--primary-glow),
        0 0 20px rgba(99, 102, 241, 0.5);
    letter-spacing: 2px;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.modal-btn {
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    font-family: inherit;
    /* 科幻风格基础样式 */
    position: relative;
    overflow: hidden;
}

/* 弹窗按钮样式 */
.modal-btn.btn-primary {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: var(--text-primary);
    box-shadow: 
        0 4px 15px var(--primary-glow),
        inset 0 0 10px rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.5);
}

.modal-btn.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 
        0 6px 20px var(--primary-glow),
        0 0 30px rgba(99, 102, 241, 0.4),
        inset 0 0 15px rgba(255, 255, 255, 0.2);
}

.modal-btn.btn-secondary {
    background: linear-gradient(135deg, #0891b2, var(--secondary));
    color: var(--text-primary);
    box-shadow: 
        0 4px 15px var(--secondary-glow),
        inset 0 0 10px rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.5);
}

.modal-btn.btn-secondary:hover {
    transform: translateY(-1px);
    box-shadow: 
        0 6px 20px var(--secondary-glow),
        0 0 30px rgba(6, 182, 212, 0.4),
        inset 0 0 15px rgba(255, 255, 255, 0.2);
}

.modal-btn.btn-tertiary {
    background: rgba(0, 0, 0, 0.6);
    color: var(--text-secondary);
    border: 1px solid var(--border-medium);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.modal-btn.btn-tertiary:hover {
    background: rgba(20, 20, 50, 0.8);
    border-color: var(--primary);
    box-shadow: 
        0 0 15px var(--primary-glow),
        inset 0 0 10px rgba(99, 102, 241, 0.1);
}

/* 设置列表 */
.settings-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.setting-label {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 600;
}

/* 开关按钮 */
.toggle-btn {
    width: 50px;
    height: 28px;
    border: none;
    border-radius: 14px;
    background: var(--bg-hover);
    position: relative;
    cursor: pointer;
    transition: background 0.3s ease;
    padding: 0;
}

.toggle-btn.active {
    background: var(--primary);
}

.toggle-track {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 14px;
}

.toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--text-primary);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-sm);
}

.toggle-btn.active .toggle-thumb {
    transform: translateX(22px);
}

/* 游戏结束统计 */
.final-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    padding: 10px 0;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    /* 科幻风格 - 黑色背景 */
    background: rgba(0, 0, 0, 0.6);
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.5);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.stat-value {
    color: var(--secondary-light);
    font-size: 1.2rem;
    font-weight: 800;
    text-shadow: 0 0 10px var(--secondary-glow);
}

/* ===== 能源条 ===== */
.energy-bar-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.energy-bar-bg {
    width: 120px;
    height: 10px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid var(--border-medium);
}

.energy-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #0891b2, var(--secondary));
    border-radius: 5px;
    transition: width 0.3s ease;
    box-shadow: 0 0 8px var(--secondary-glow);
}

.energy-text {
    font-size: 0.7rem;
    color: var(--secondary-light);
    font-weight: 700;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* ===== 经验条 ===== */
.exp-bar-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.exp-bar-bg {
    width: 100px;
    height: 6px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid var(--border-medium);
}

.exp-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    border-radius: 3px;
    transition: width 0.3s ease;
    box-shadow: 0 0 6px var(--accent-glow);
}

.level-text {
    font-size: 0.7rem;
    color: var(--accent-light);
    font-weight: 800;
    text-shadow: 0 0 8px var(--accent-glow);
}

/* ===== 最高分显示 ===== */
.high-score-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.high-score-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.high-score-value {
    font-size: 0.85rem;
    color: var(--warning);
    font-weight: 700;
    text-shadow: 0 0 8px var(--warning-glow);
}

/* ===== 主菜单最高分 ===== */
.high-score-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-bottom: 10px;
}

.high-score-label-menu {
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 2px;
}

.high-score-value-menu {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--warning);
    text-shadow: 0 0 15px var(--warning-glow);
}

/* ===== 战舰选择界面 ===== */
.screen-title {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--text-primary);
    text-shadow: 0 0 20px var(--primary-glow);
    margin-bottom: 10px;
}

.ship-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 400px;
}

.ship-card {
    /* 科幻风格 - 透明背景 + 无边框 */
    background: transparent;
    border: none;
    border-radius: 16px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: center;
    box-shadow: none;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
    /* 参考样式优化 */
    box-sizing: border-box;
    margin: 0px;
    width: 100%;
    height: 100%;
}

/* 飞船图标容器 - 使用object-fit优化 */
.ship-card .ship-icon {
    animation: shipFloat 3s ease-in-out infinite;
    margin-bottom: 8px;
    width: 100%;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    object-fit: contain;
}

@keyframes shipFloat {
    0%, 100% {
        transform: translateY(0) rotateY(0deg);
    }
    25% {
        transform: translateY(-5px) rotateY(5deg);
    }
    75% {
        transform: translateY(-3px) rotateY(-5deg);
    }
}

/* 悬停时的3D效果 */
.ship-card:hover,
.ship-card.selected {
    border: none;
    background: rgba(0, 0, 0, 0.15);
    transform: translateY(-4px) scale(1.02);
    box-shadow: none;
    /* 增强过渡效果 */
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.ship-card.selected {
    background: rgba(99, 102, 241, 0.1);
}

.ship-card:hover .ship-icon {
    animation-play-state: paused;
    transform: scale(1.1) rotateY(10deg);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.ship-card h3 {
    color: var(--text-primary);
    font-size: 0.9rem;
    margin: 6px 0 3px;
}

.ship-desc {
    color: var(--text-muted);
    font-size: 0.65rem;
    margin-bottom: 6px;
}

.ship-icon {
    margin-bottom: 8px;
    width: 100%;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    object-fit: contain;
}

.fighter-icon { filter: drop-shadow(0 0 12px var(--primary-glow)); }
.interceptor-icon { filter: drop-shadow(0 0 12px var(--secondary-glow)); }
.destroyer-icon { filter: drop-shadow(0 0 12px var(--accent-glow)); }
.bomber-icon { filter: drop-shadow(0 0 12px var(--warning-glow)); }

.ship-stats {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.ship-stats .stat {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.55rem;
}

.ship-stats .stat span {
    color: var(--text-muted);
    width: 24px;
    text-align: right;
}

.stat-bar {
    flex: 1;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.stat-bar div {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 2px;
}

/* ===== 升级界面 ===== */
.upgrade-modal {
    max-width: 360px;
}

.upgrade-info {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 0 10px;
}

.upgrade-level {
    color: var(--accent-light);
    font-weight: 700;
    font-size: 1.1rem;
}

.upgrade-points {
    color: var(--secondary-light);
    font-weight: 700;
    font-size: 1rem;
}

.upgrade-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
}

.upgrade-item {
    /* 科幻风格 - 黑色背景 */
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    transition: all 0.3s ease;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.5);
}

.upgrade-item:hover {
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.8);
    box-shadow: 
        0 0 15px var(--primary-glow),
        inset 0 0 20px rgba(99, 102, 241, 0.1);
}

.upgrade-icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.upgrade-details h4 {
    color: var(--text-primary);
    font-size: 0.85rem;
    margin-bottom: 2px;
}

.upgrade-details p {
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-bottom: 8px;
}

.upgrade-btn {
    padding: 6px 14px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upgrade-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.upgrade-btn:disabled {
    background: var(--bg-hover);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

/* ===== 背包界面 ===== */
.inventory-modal {
    max-width: 360px;
}

.inventory-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.inventory-item {
    display: flex;
    align-items: center;
    gap: 12px;
    /* 科幻风格 - 黑色背景 */
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 12px;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

.inventory-item:hover {
    border-color: var(--primary);
    box-shadow: 
        0 0 15px var(--primary-glow),
        inset 0 0 20px rgba(99, 102, 241, 0.1);
}

.item-icon {
    font-size: 1.8rem;
    width: 40px;
    text-align: center;
}

.item-info {
    flex: 1;
}

.item-info h4 {
    color: var(--text-primary);
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.item-info p {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.item-effect {
    color: var(--secondary-light) !important;
    font-size: 0.7rem !important;
}

.use-item-btn {
    padding: 6px 14px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--secondary-dark, #0891b2), var(--secondary));
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
}

.use-item-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--secondary-glow);
}

/* ===== 游戏结束高亮 ===== */
.stat-item.highlight {
    border: 1px solid var(--warning);
    background: rgba(245, 158, 11, 0.1);
}

.stat-item.highlight .stat-value {
    color: var(--warning);
    text-shadow: 0 0 10px var(--warning-glow);
}

/* ===== 响应式适配 ===== */
@media (max-width: 480px) {
    .title-main {
        font-size: 1.6rem;
    }

    .title-sub {
        font-size: 0.6rem;
        letter-spacing: 3px;
    }

    .joystick-base {
        width: 70px;
        height: 70px;
    }

    .joystick-knob {
        width: 28px;
        height: 28px;
    }

    .health-bar-bg {
        width: 100px;
    }
}

/* 移动端竖屏额外优化 */
@media screen and (orientation: portrait) and (max-width: 480px) {
    /* 主菜单优化 */
    #main-menu {
        padding: 15px;
    }

    .menu-container {
        gap: 20px;
    }

    .menu-left {
        gap: 15px;
    }

    .game-title {
        margin-bottom: 10px;
    }

    .title-main {
        font-size: 1.5rem;
    }

    .title-sub {
        font-size: 0.55rem;
    }

    .high-score-display {
        margin-bottom: 8px;
    }

    .high-score-value-menu {
        font-size: 1.3rem;
    }

    /* 模式选择卡片 - 紧凑 */
    .mode-selector {
        gap: 8px;
        margin-bottom: 10px;
    }

    .mode-card {
        padding: 10px 8px;
        border-radius: 12px;
    }

    .mode-icon {
        font-size: 1.6rem;
        margin-bottom: 4px;
    }

    .mode-title {
        font-size: 0.8rem;
        margin-bottom: 2px;
    }

    .mode-desc {
        font-size: 0.52rem;
    }

    /* 按钮 */
    .menu-buttons {
        gap: 8px;
    }

    .menu-btn {
        padding: 10px 14px;
        gap: 8px;
    }

    .btn-icon {
        font-size: 1rem;
    }

    .btn-text {
        font-size: 0.8rem;
    }

    /* 飞船选择器 - 紧凑布局 */
    .ship-select-title {
        font-size: 1.1rem;
        margin-bottom: 8px;
    }

    .ship-selector {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        max-width: 100%;
    }

    .ship-card {
        min-height: 125px;
        padding: 8px;
        border-radius: 12px;
    }

    .ship-card .ship-icon {
        height: 58px;
        margin-bottom: 4px;
    }

    .ship-card h3 {
        font-size: 0.72rem;
        margin: 4px 0 2px;
    }

    .ship-desc {
        font-size: 0.48rem;
        margin-bottom: 4px;
        line-height: 1.2;
    }

    .ship-stats {
        gap: 2px;
    }

    .ship-stats .stat {
        font-size: 0.4rem;
        gap: 2px;
    }

    .ship-stats .stat span {
        width: 18px;
    }

    .stat-bar {
        height: 2px;
    }

    .ship-preview-hint {
        font-size: 0.58rem;
        margin-top: 6px;
    }

    /* 左上角HUD紧凑化 */
    .hud-top-left {
        top: 12px;
        left: 12px;
        gap: 6px;
    }

    .health-bar-bg {
        width: 90px;
        height: 12px;
    }

    .energy-bar-bg {
        width: 90px;
        height: 8px;
    }

    .exp-bar-bg {
        width: 70px;
        height: 5px;
    }

    .health-text,
    .energy-text {
        font-size: 0.65rem;
    }

    .level-text {
        font-size: 0.6rem;
    }

    .score-value,
    .wave-value {
        font-size: 0.85rem;
    }

    .score-label,
    .wave-label {
        font-size: 0.65rem;
    }

    /* 虚拟摇杆 */
    .joystick {
        bottom: 70px;
    }

    .joystick-left {
        left: 25px;
    }

    .joystick-right {
        right: 25px;
    }

    .joystick-base {
        width: 65px;
        height: 65px;
    }

    .joystick-knob {
        width: 26px;
        height: 26px;
    }

    .joystick-label {
        font-size: 0.6rem;
    }

    /* 发射按钮 */
    .fire-button {
        width: 55px;
        height: 55px;
        right: 15px;
    }

    .fire-icon {
        font-size: 1.2rem;
    }

    .fire-text {
        font-size: 0.5rem;
    }

    /* 背包栏 */
    .inventory-bar {
        bottom: 8px;
        gap: 5px;
        padding: 5px 8px;
    }

    .inventory-slot {
        width: 42px;
        height: 52px;
    }

    .slot-icon {
        font-size: 1.05rem;
    }

    .slot-count {
        font-size: 0.7rem;
    }

    .slot-name {
        font-size: 0.48rem;
    }
}

/* ===== 超小屏幕极致优化（iPhone SE等） ===== */
@media screen and (max-width: 375px) {
    /* 主菜单标题 */
    .title-main {
        font-size: 1.3rem;
    }

    .title-sub {
        font-size: 0.48rem;
    }

    /* 模式卡片更小 */
    .mode-card {
        padding: 8px 6px;
    }

    .mode-icon {
        font-size: 1.4rem;
    }

    .mode-title {
        font-size: 0.72rem;
    }

    .mode-desc {
        font-size: 0.48rem;
    }

    /* 飞船卡片更小 */
    .ship-card {
        min-height: 110px;
        padding: 6px;
    }

    .ship-card .ship-icon {
        height: 50px;
    }

    .ship-card h3 {
        font-size: 0.65rem;
    }

    .ship-desc {
        font-size: 0.45rem;
    }

    .ship-stats .stat {
        font-size: 0.38rem;
    }

    .ship-stats .stat span {
        width: 16px;
    }

    /* 按钮 */
    .menu-btn {
        padding: 8px 12px;
    }

    .btn-text {
        font-size: 0.72rem;
    }
}

@media (min-width: 768px) {
    .title-main {
        font-size: 3rem;
    }

    .menu-content {
        max-width: 500px;
    }

    .joystick-base {
        width: 100px;
        height: 100px;
    }

    .joystick-knob {
        width: 40px;
        height: 40px;
    }
}

/* ===== 横屏模式优化 - 通用横屏 ===== */
@media screen and (orientation: landscape) {
    .joystick-left {
        left: 30px;
        bottom: 40px;
    }

    .joystick-right {
        right: 80px;
        bottom: 40px;
    }

    .fire-button {
        right: 15px;
        width: 50px;
        height: 50px;
    }

    .fire-icon {
        font-size: 1.2rem;
    }

    .fire-text {
        font-size: 0.5rem;
    }

    .inventory-bar {
        bottom: 5px;
        gap: 4px;
        padding: 4px 8px;
    }

    .inventory-slot {
        width: 40px;
        height: 50px;
    }

    .slot-icon {
        font-size: 1rem;
    }

    .slot-count {
        font-size: 0.7rem;
    }

    .slot-name {
        font-size: 0.45rem;
    }

    .hud-top-left {
        top: 10px;
        left: 10px;
        gap: 4px;
    }

    .health-bar-bg {
        width: 100px;
        height: 10px;
    }

    .energy-bar-bg {
        width: 100px;
        height: 8px;
    }

    .exp-bar-bg {
        width: 80px;
        height: 4px;
    }

    .score-value, .wave-value {
        font-size: 0.8rem;
    }

    .health-text, .energy-text, .level-text {
        font-size: 0.6rem;
    }

    .hud-top-right {
        top: 10px;
        right: 10px;
    }

    .auto-aim-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
}

/* ===== 移动端横屏极致紧凑布局 ===== */
@media screen and (orientation: landscape) and (max-height: 500px) {
    /* 左上角HUD - 极致紧凑 */
    .hud-top-left {
        top: 8px;
        left: 8px;
        gap: 3px;
    }

    .health-bar-container,
    .energy-bar-container,
    .exp-bar-container {
        gap: 4px;
    }

    .health-bar-bg {
        width: 80px;
        height: 8px;
    }

    .energy-bar-bg {
        width: 80px;
        height: 6px;
    }

    .exp-bar-bg {
        width: 60px;
        height: 4px;
    }

    .health-text,
    .energy-text {
        font-size: 0.55rem;
    }

    .level-text {
        font-size: 0.55rem;
    }

    .score-info,
    .wave-info,
    .high-score-info {
        gap: 4px;
    }

    .score-label,
    .wave-label,
    .high-score-label {
        font-size: 0.55rem;
    }

    .score-value,
    .wave-value {
        font-size: 0.7rem;
    }

    .high-score-value {
        font-size: 0.65rem;
    }

    /* 右上角自动瞄准 */
    .hud-top-right {
        top: 8px;
        right: 8px;
    }

    .auto-aim-btn {
        padding: 4px 8px;
        gap: 4px;
    }

    .aim-icon {
        font-size: 0.85rem;
    }

    .aim-text {
        font-size: 0.6rem;
    }

    .aim-status {
        font-size: 0.55rem;
        padding: 1px 4px;
    }

    /* 暂停按钮 */
    .pause-btn {
        top: 8px;
        width: 30px;
        height: 30px;
        font-size: 0.85rem;
    }

    /* 虚拟摇杆 - 缩小尺寸 */
    .joystick {
        bottom: 50px;
    }

    .joystick-left {
        left: 15px;
    }

    .joystick-right {
        right: 60px;
    }

    .joystick-base {
        width: 55px;
        height: 55px;
    }

    .joystick-knob {
        width: 22px;
        height: 22px;
    }

    .joystick-label {
        font-size: 0.55rem;
        margin-top: 3px;
    }

    /* 发射按钮 - 右侧居中 */
    .fire-button {
        right: 8px;
        top: 50%;
        transform: translateY(-50%);
        width: 45px;
        height: 45px;
    }

    .fire-button:hover,
    .fire-button:active,
    .fire-button.pressed {
        transform: translateY(-50%) scale(1.05);
    }

    .fire-icon {
        font-size: 1.1rem;
    }

    .fire-text {
        font-size: 0.45rem;
    }

    /* 底部背包栏 - 三列紧凑布局 */
    .inventory-bar {
        bottom: 5px;
        left: 50%;
        transform: translateX(-50%);
        gap: 3px;
        padding: 3px 6px;
        max-width: 280px;
    }

    .inventory-slot {
        width: 35px;
        height: 42px;
        padding: 2px;
    }

    .slot-icon {
        font-size: 0.9rem;
        margin-top: 1px;
    }

    .slot-count {
        font-size: 0.65rem;
    }

    .slot-name {
        font-size: 0.4rem;
        line-height: 1;
    }

    /* 无敌模式倒计时 */
    .god-mode-timer {
        top: 50px;
        padding: 6px 12px;
        min-width: 140px;
        gap: 8px;
    }

    .timer-icon {
        font-size: 1.3rem;
    }

    .timer-label {
        font-size: 0.55rem;
    }

    .timer-value {
        font-size: 1.1rem;
    }

    /* 模式标识 */
    .mode-indicator {
        top: 50%;
    }

    .mode-text {
        font-size: 0.65rem;
        letter-spacing: 2px;
    }
}

/* ===== 动画 ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.screen.active .menu-content,
.screen.active .modal {
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 触摸反馈动画 */
@keyframes touchFeedback {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.95);
    }
    100% {
        transform: scale(1);
    }
}

.touch-feedback {
    animation: touchFeedback 0.2s ease-out;
}

/* ===== 发射按钮 ===== */
.fire-button {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(102, 74, 74, 0.3);
    border: 2px solid var(--border-medium);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(3px);
    box-shadow: 0 0 10px var(--danger-glow);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.fire-button:hover,
.fire-button:active,
.fire-button.pressed {
    background: rgba(102, 74, 74, 0.5);
    border-color: var(--border-strong);
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 0 15px var(--danger-glow);
}

.fire-button-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

.fire-icon {
    font-size: 1.4rem;
    filter: drop-shadow(0 0 4px rgba(102, 74, 74, 0.6));
}

.fire-text {
    font-size: 0.55rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 1px;
    text-shadow: 0 0 5px rgba(102, 74, 74, 0.6);
}

/* 发射按钮脉冲动画 */
@keyframes firePulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(239, 68, 68, 0.6), 0 0 60px rgba(239, 68, 68, 0.3);
    }
}

.fire-button.active {
    animation: firePulse 1.5s ease-in-out infinite;
}

/* 响应式适配 */
@media (max-width: 480px) {
    .fire-button {
        width: 60px;
        height: 60px;
        right: 20px;
    }

    .fire-icon {
        font-size: 1.4rem;
    }

    .fire-text {
        font-size: 0.55rem;
    }
}

@media (min-width: 768px) {
    .fire-button {
        width: 100px;
        height: 100px;
        right: 60px;
    }

    .fire-icon {
        font-size: 2.2rem;
    }

    .fire-text {
        font-size: 0.75rem;
    }
}

/* ===== 响应式布局 - 主菜单 ===== */
@media (max-width: 1024px) {
    #main-menu {
        padding: 20px;
    }

    .menu-container {
        flex-direction: column;
        height: auto;
        gap: 30px;
    }

    .menu-left,
    .menu-right {
        flex: 0 0 100%;
        width: 100%;
    }

    .ship-selector {
        max-width: 500px;
    }
}

@media (max-width: 600px) {
    .ship-selector {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .ship-card {
        min-height: 130px;
        padding: 8px;
    }

    .ship-card .ship-icon {
        height: 60px;
    }

    .ship-card h3 {
        font-size: 0.75rem;
    }

    .ship-desc {
        font-size: 0.5rem;
    }

    .ship-stats .stat {
        font-size: 0.45rem;
    }

    /* 模式选择卡片也缩小 */
    .mode-selector {
        gap: 8px;
    }

    .mode-card {
        padding: 10px 8px;
    }

    .mode-icon {
        font-size: 1.6rem;
    }

    .mode-title {
        font-size: 0.8rem;
    }

    .mode-desc {
        font-size: 0.55rem;
    }
}

/* ===== 移动端横屏主菜单优化 ===== */
@media screen and (orientation: landscape) and (max-height: 500px) {
    #main-menu {
        padding: 8px 12px;
    }

    .menu-container {
        flex-direction: row;
        height: 92vh;
        gap: 12px;
    }

    .menu-left {
        flex: 0 0 38%;
        gap: 10px;
        padding: 8px;
    }

    .menu-right {
        flex: 0 0 60%;
        gap: 8px;
        padding: 8px;
    }

    /* 标题缩小 */
    .game-title {
        margin-bottom: 6px;
    }

    .title-main {
        font-size: 1.1rem;
        letter-spacing: 1.5px;
    }

    .title-sub {
        font-size: 0.5rem;
        letter-spacing: 2px;
        margin-top: 3px;
    }

    /* 最高分显示 */
    .high-score-display {
        margin-bottom: 5px;
        gap: 2px;
    }

    .high-score-label-menu {
        font-size: 0.55rem;
    }

    .high-score-value-menu {
        font-size: 1rem;
    }

    /* 模式选择卡片 - 极致紧凑 */
    .mode-selector {
        gap: 6px;
        margin-bottom: 6px;
    }

    .mode-card {
        padding: 8px 6px;
        border-radius: 10px;
    }

    .mode-icon {
        font-size: 1.4rem;
        margin-bottom: 3px;
    }

    .mode-title {
        font-size: 0.7rem;
        margin-bottom: 2px;
    }

    .mode-desc {
        font-size: 0.5rem;
        line-height: 1.2;
    }

    /* 按钮缩小 */
    .menu-buttons {
        gap: 6px;
    }

    .menu-btn {
        padding: 8px 12px;
        gap: 6px;
        border-radius: 10px;
    }

    .btn-icon {
        font-size: 0.95rem;
    }

    .btn-text {
        font-size: 0.75rem;
    }

    .version-info {
        font-size: 0.55rem;
        margin-top: 8px;
    }

    /* 右侧飞船选择 - 极致紧凑 */
    .ship-select-title {
        font-size: 1rem;
        margin-bottom: 5px;
    }

    .ship-selector {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        max-width: 100%;
    }

    .ship-card {
        min-height: 115px;
        padding: 8px;
        border-radius: 10px;
    }

    .ship-card .ship-icon {
        height: 55px;
        margin-bottom: 4px;
    }

    .ship-card h3 {
        font-size: 0.7rem;
        margin: 4px 0 2px;
    }

    .ship-desc {
        font-size: 0.48rem;
        margin-bottom: 4px;
        line-height: 1.2;
    }

    .ship-stats {
        gap: 2px;
    }

    .ship-stats .stat {
        font-size: 0.4rem;
        gap: 2px;
    }

    .ship-stats .stat span {
        width: 18px;
    }

    .stat-bar {
        height: 2px;
    }

    .ship-preview-hint {
        font-size: 0.55rem;
        margin-top: 5px;
    }
}

/* ===== 底部背包道具栏 ===== */
.inventory-bar {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    z-index: 20;
    backdrop-filter: blur(5px);
}

.inventory-slot {
    position: relative;
    width: 45px;
    height: 55px;
    background: rgba(15, 15, 35, 0.6);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 3px;
}

.inventory-slot:hover {
    border-color: var(--border-medium);
    background: rgba(25, 25, 45, 0.7);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px var(--primary-glow);
}

.inventory-slot:active {
    transform: translateY(0px) scale(0.95);
}

/* 使用动画 */
.inventory-slot.using {
    animation: slotUse 0.3s ease-out;
}

@keyframes slotUse {
    0% {
        transform: scale(1);
        filter: brightness(1);
    }
    50% {
        transform: scale(1.15);
        filter: brightness(1.5);
    }
    100% {
        transform: scale(1);
        filter: brightness(1);
    }
}

/* 数量变化提示 */
.inventory-slot .count-change {
    position: absolute;
    top: -15px;
    right: -10px;
    font-size: 0.9rem;
    font-weight: 700;
    color: #10b981;
    text-shadow: 0 0 5px rgba(16, 185, 129, 0.8);
    animation: countFloat 0.8s ease-out forwards;
    pointer-events: none;
}

.inventory-slot .count-change.negative {
    color: #ef4444;
    text-shadow: 0 0 5px rgba(239, 68, 68, 0.8);
}

@keyframes countFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-20px) scale(1.2);
    }
}

.inventory-slot.empty {
    opacity: 0.4;
    cursor: not-allowed;
}

.inventory-slot.empty:hover {
    border-color: var(--border-subtle);
    background: rgba(20, 20, 50, 0.8);
    transform: none;
    box-shadow: none;
}

.slot-icon {
    font-size: 1.2rem;
    margin-top: 2px;
    opacity: 0.8;
}

.slot-count {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
    text-shadow: 0 0 4px var(--primary-glow);
}

.slot-name {
    font-size: 0.55rem;
    color: var(--text-secondary);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    opacity: 0.8;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .inventory-bar {
        bottom: 10px;
        gap: 6px;
        padding: 8px 10px;
    }

    .inventory-slot {
        width: 50px;
        height: 60px;
    }

    .slot-icon {
        font-size: 1.2rem;
    }

    .slot-count {
        font-size: 0.8rem;
    }

    .slot-name {
        font-size: 0.5rem;
    }
}

/* ===== 升级选择弹窗样式 ===== */
.upgrade-selection-modal {
    max-width: 800px;
    width: 90%;
    background: linear-gradient(135deg, rgba(20, 20, 50, 0.98) 0%, rgba(30, 30, 70, 0.98) 100%);
    border: 2px solid var(--primary);
    box-shadow: 
        0 0 60px var(--primary-glow),
        0 0 120px rgba(99, 102, 241, 0.3),
        inset 0 0 60px rgba(99, 102, 241, 0.1);
    padding: 30px;
    animation: upgradeSelectionAppear 0.5s ease-out;
}

@keyframes upgradeSelectionAppear {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-30px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.upgrade-selection-modal h2 {
    text-align: center;
    font-size: 2.2rem;
    margin-bottom: 20px;
    color: var(--text-primary);
    text-shadow: 0 0 30px var(--primary-glow);
    letter-spacing: 2px;
}

.upgrade-selection-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 15px 20px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 10px;
    border: 1px solid var(--border-medium);
}

.selection-level {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-light);
    text-shadow: 0 0 15px var(--primary-glow);
}

.selection-hint {
    font-size: 1rem;
    color: var(--text-secondary);
    font-style: italic;
}

.upgrade-selection-grid {
    display: flex;
    flex-direction: row;
    gap: 15px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding: 10px 0;
}

.upgrade-option-card {
    background: linear-gradient(135deg, rgba(30, 30, 70, 0.9) 0%, rgba(40, 40, 90, 0.9) 100%);
    border: 2px solid var(--border-medium);
    border-radius: 15px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
    min-width: 180px;
    flex: 1;
}

.upgrade-option-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.upgrade-option-card:hover {
    border-color: var(--primary);
    transform: translateY(-5px) scale(1.02);
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.5),
        0 0 40px var(--primary-glow);
}

.upgrade-option-card:hover::before {
    opacity: 1;
}

.upgrade-option-card:active {
    transform: translateY(-2px) scale(1.01);
}

.option-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    filter: drop-shadow(0 0 15px currentColor);
    z-index: 1;
}

.option-info {
    z-index: 1;
}

.option-info h4 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
    text-shadow: 0 0 10px var(--primary-glow);
}

.option-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .upgrade-selection-modal {
        padding: 25px;
        max-width: 95%;
    }
    
    .upgrade-selection-modal h2 {
        font-size: 1.8rem;
    }
    
    .upgrade-selection-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .upgrade-option-card {
        padding: 20px;
    }
    
    .option-icon {
        font-size: 3rem;
    }
    
    .option-info h4 {
        font-size: 1.1rem;
    }
}

/* ===== 移动端横屏弹窗优化 ===== */
@media screen and (orientation: landscape) and (max-height: 500px) {
    .modal {
        padding: 15px 20px;
        min-width: 250px;
        max-width: 85%;
        max-height: 85vh;
        overflow-y: auto;
    }

    .modal h2 {
        font-size: 1.2rem;
        margin-bottom: 10px;
    }

    .modal-buttons {
        gap: 8px;
    }

    .modal-btn {
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    /* 设置界面 */
    .settings-list {
        gap: 10px;
    }

    .setting-item {
        padding: 5px 0;
    }

    .setting-label {
        font-size: 0.8rem;
    }

    .toggle-btn {
        width: 42px;
        height: 24px;
    }

    .toggle-thumb {
        width: 18px;
        height: 18px;
        top: 3px;
        left: 3px;
    }

    .toggle-btn.active .toggle-thumb {
        transform: translateX(18px);
    }

    /* 升级界面 */
    .upgrade-modal {
        max-width: 320px;
    }

    .upgrade-info {
        padding: 0 5px;
        gap: 10px;
    }

    .upgrade-level,
    .upgrade-points {
        font-size: 0.9rem;
    }

    .upgrade-grid {
        gap: 8px;
    }

    .upgrade-item {
        padding: 10px;
    }

    .upgrade-icon {
        font-size: 1.2rem;
        margin-bottom: 3px;
    }

    .upgrade-details h4 {
        font-size: 0.75rem;
        margin-bottom: 2px;
    }

    .upgrade-details p {
        font-size: 0.6rem;
        margin-bottom: 6px;
    }

    .upgrade-btn {
        padding: 5px 12px;
        font-size: 0.7rem;
    }

    /* 背包界面 */
    .inventory-modal {
        max-width: 320px;
    }

    .inventory-grid {
        gap: 8px;
    }

    .inventory-item {
        padding: 10px;
        gap: 10px;
    }

    .item-icon {
        font-size: 1.4rem;
        width: 35px;
    }

    .item-info h4 {
        font-size: 0.8rem;
        margin-bottom: 2px;
    }

    .item-info p {
        font-size: 0.65rem;
    }

    .item-effect {
        font-size: 0.6rem !important;
    }

    .use-item-btn {
        padding: 5px 12px;
        font-size: 0.7rem;
    }

    /* 游戏结束界面 */
    .game-over-modal {
        max-width: 320px;
    }

    .final-stats {
        gap: 8px;
        padding: 5px 0;
    }

    .stat-item {
        padding: 6px 12px;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    .stat-value {
        font-size: 1rem;
    }

    /* 升级选择弹窗 */
    .upgrade-selection-modal {
        padding: 15px 20px;
        max-width: 90%;
    }

    .upgrade-selection-modal h2 {
        font-size: 1.4rem;
        margin-bottom: 12px;
    }

    .upgrade-selection-info {
        margin-bottom: 15px;
        padding: 10px 15px;
    }

    .selection-level {
        font-size: 1rem;
    }

    .selection-hint {
        font-size: 0.8rem;
    }

    .upgrade-selection-grid {
        gap: 10px;
        padding: 5px 0;
    }

    .upgrade-option-card {
        padding: 12px;
        min-width: 140px;
    }

    .option-icon {
        font-size: 1.8rem;
        margin-bottom: 8px;
    }

    .option-info h4 {
        font-size: 0.85rem;
        margin-bottom: 4px;
    }

    .option-info p {
        font-size: 0.7rem;
    }
}

/* ===== 经验值调参界面样式 ===== */
.exp-config-modal {
    max-width: 600px;
    width: 90%;
    padding: 30px;
}

.exp-config-info {
    margin-bottom: 25px;
    text-align: center;
}

.config-hint {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.exp-config-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 25px;
}

.config-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 18px;
    transition: all 0.3s ease;
}

.config-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-medium);
}

.config-item label {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.config-slider-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 8px;
}

.config-slider-container input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.config-slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px var(--accent-glow);
    transition: all 0.2s ease;
}

.config-slider-container input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 15px var(--accent-glow);
}

.config-slider-container input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 10px var(--accent-glow);
    transition: all 0.2s ease;
}

.config-slider-container input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 15px var(--accent-glow);
}

.config-value {
    min-width: 60px;
    text-align: right;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-light);
    font-family: 'Courier New', monospace;
}

.config-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 8px;
    line-height: 1.4;
}

.config-preview {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    padding: 20px;
    margin-top: 10px;
}

.config-preview h4 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 15px;
    text-align: center;
}

.exp-preview-table {
    max-height: 300px;
    overflow-y: auto;
    overflow-x: auto;
}

.exp-preview-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.exp-preview-table thead {
    position: sticky;
    top: 0;
    background: rgba(15, 15, 35, 0.95);
    z-index: 1;
}

.exp-preview-table th {
    padding: 10px 8px;
    text-align: center;
    font-weight: 600;
    color: var(--accent-light);
    border-bottom: 2px solid var(--border-medium);
    white-space: nowrap;
}

.exp-preview-table td {
    padding: 8px;
    text-align: center;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
}

.exp-preview-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.exp-preview-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.exp-preview-table tbody tr:nth-child(even):hover {
    background: rgba(255, 255, 255, 0.05);
}

/* 设置菜单中的按钮项 */
.setting-button-item {
    justify-content: center;
    padding: 10px 0;
}

.full-width {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-icon {
    font-size: 1.2rem;
}

.btn-text {
    font-size: 0.95rem;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .exp-config-modal {
        padding: 20px;
        width: 95%;
    }
    
    .config-item {
        padding: 15px;
    }
    
    .config-slider-container input[type="range"] {
        height: 8px;
    }
    
    .config-slider-container input[type="range"]::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }
    
    .config-slider-container input[type="range"]::-moz-range-thumb {
        width: 24px;
        height: 24px;
    }
    
    .exp-preview-table {
        max-height: 250px;
        font-size: 0.8rem;
    }
    
    .exp-preview-table th,
    .exp-preview-table td {
        padding: 6px 4px;
    }
}
