/**
 * 口算太空射击 v0.5.2 - 主样式
 * 【v0.5.2】放射状速度线效果
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ==================== 桌面浏览器居中布局 ==================== */
@media (min-width: 768px) and (min-height: 600px) {
    body {
        display: flex;
        align-items: center;
        justify-content: center;
        background: linear-gradient(135deg, #0a0a1a 0%, #1a1a2e 50%, #0a0a1a 100%);
    }

    /* 添加背景网格效果 */
    body::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        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: 50px 50px;
        pointer-events: none;
    }

    #gameContainer {
        width: 450px;
        height: 800px;
        max-height: 95vh;
        border-radius: 20px;
        box-shadow:
            0 0 60px rgba(99, 102, 241, 0.4),
            0 0 120px rgba(99, 102, 241, 0.2),
            inset 0 0 20px rgba(99, 102, 241, 0.1);
        border: 2px solid rgba(99, 102, 241, 0.3);
        position: relative;
        overflow: hidden;
    }

    #portraitWrapper {
        width: 100%;
        height: 100%;
        border-radius: 18px;
        overflow: hidden;
    }

    /* 添加桌面端装饰边框 */
    #gameContainer::before {
        content: '';
        position: absolute;
        top: -2px;
        left: -2px;
        right: -2px;
        bottom: -2px;
        background: linear-gradient(45deg,
            #6366f1, #8b5cf6, #a855f7, #8b5cf6, #6366f1);
        border-radius: 22px;
        z-index: -1;
        opacity: 0.5;
        animation: borderGlow 3s ease-in-out infinite;
    }

    @keyframes borderGlow {
        0%, 100% { opacity: 0.3; }
        50% { opacity: 0.6; }
    }
}

/* ==================== 【v0.4.5】移动端等比缩放方案 ==================== */
/* 使用固定游戏尺寸 + transform scale，保证内容完整显示 */
@media (max-width: 767px), (max-height: 599px) {
    html, body {
        background: #000;
    }

    /* 缩放容器：将固定尺寸的游戏缩放到适应屏幕 */
    #gameContainer {
        /* 固定游戏尺寸（与PC版一致） */
        width: 450px;
        height: 800px;

        /* 居中并通过缩放适应屏幕 */
        position: absolute;
        top: 50%;
        left: 50%;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
        border: none;
        background: #000005;

        /* 使用CSS变量动态计算缩放比例 */
        transform: translate(-50%, -50%) scale(var(--game-scale, 1));
        transform-origin: center center;
    }

    #portraitWrapper {
        width: 100%;
        height: 100%;
        position: relative;
        perspective: 1000px;
    }

    /* 移除桌面端装饰效果 */
    #gameContainer::before {
        display: none;
    }
}

/* 游戏画布 */
#canvasContainer {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    z-index: 1;
    position: relative;
}

/* 3D HUD容器 */
#hud3D {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

/* ==================== 【v0.5.2】速度线效果 (放射状优化版) ==================== */
.speed-line {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(100, 255, 255, 0.8), rgba(255, 255, 255, 0));
    transform-origin: top center;
    mix-blend-mode: screen;
    opacity: 0;
    pointer-events: none;
    z-index: 4;
    animation: warpSpeed linear infinite;
}

@keyframes warpSpeed {
    0% {
        transform: rotate(var(--angle)) translateY(0px) scaleY(0.1);
        opacity: 0;
    }
    20% {
        opacity: 0.8;
    }
    100% {
        transform: rotate(var(--angle)) translateY(600px) scaleY(4);
        opacity: 0;
    }
}

/* 屏幕震动效果 */
.shake {
    animation: shake 0.3s ease-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0) translateY(0); }
    10% { transform: translateX(-5px) translateY(-5px); }
    20% { transform: translateX(5px) translateY(5px); }
    30% { transform: translateX(-5px) translateY(5px); }
    40% { transform: translateX(5px) translateY(-5px); }
    50% { transform: translateX(-3px) translateY(-3px); }
    60% { transform: translateX(3px) translateY(3px); }
    70% { transform: translateX(-2px) translateY(2px); }
    80% { transform: translateX(2px) translateY(-2px); }
    90% { transform: translateX(-1px) translateY(1px); }
}

/* ==================== 【v0.5.12】紧凑型顶部 HUD 整合设计 (防遮挡版) ==================== */
#ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

#top-hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 44px; /* 固定极小高度，腾出空间 */
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.5));
    backdrop-filter: blur(4px); /* 毛玻璃，稍微能看清后面 */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-sizing: border-box;
}

/* 通用文字样式 */
.hud-item {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: #fff;
    display: flex;
    align-items: center;
    text-shadow: 0 0 5px rgba(0,0,0,0.8);
}

/* 1. 左侧得分 */
.score-area {
    font-size: 18px;
    color: #00ffff;
}
.hud-label {
    font-size: 12px;
    color: #aaa;
    margin-right: 5px;
    font-weight: normal;
}
#multiplierDisplay {
    font-size: 14px;
    margin-left: 4px;
    color: #ffcc00;
}

/* 2. 中间关卡 */
.level-area {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 16px;
    color: #ffd700; /* 金色 */
    letter-spacing: 1px;
}

/* 3. 右侧生命 */
.lives-area {
    font-size: 14px;
    letter-spacing: -2px; /* 让心挨得紧一点 */
}

/* 4. 底部极细进度条 (核心防遮挡设计) */
#hud-progress-track {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px; /* 极细！只有3像素 */
    background: rgba(255, 255, 255, 0.1);
}

/* 进度条填充 (保留原本的炫彩动画，但压扁了) */
#scoreProgressFill {
    width: 0%;
    height: 100%;
    /* 依然使用之前的炫彩渐变 */
    background: linear-gradient(
        90deg,
        hsl(0, 100%, 50%), hsl(60, 100%, 50%), hsl(120, 100%, 50%),
        hsl(180, 100%, 50%), hsl(240, 100%, 50%), hsl(300, 100%, 50%)
    );
    background-size: 200% 100%;
    animation: rainbowFlowLeft 3s linear infinite;
    position: relative;
    /* 发光效果 */
    box-shadow: 0 0 10px currentColor;
    transition: width 0.3s ease-out;
}

/* 进度条高光 (让细线也能看清) */
#scoreProgressGlare {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.8), transparent);
    transform: translateX(-100%);
    animation: glareMove 2s infinite;
}

/* 动画定义 */
@keyframes rainbowFlowLeft {
    0% { background-position: 200% 0%; }
    100% { background-position: 0% 0%; }
}
@keyframes glareMove {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* 移除旧的 score-panel 定位 */
.score-panel { position: static; background: none; border: none; padding: 0; box-shadow: none; }

/* 保留旧的 ui-item 样式以防其他地方用到 */
.ui-item {
    background: rgba(0, 0, 0, 0.5);
    padding: 5px 10px;
    border-radius: 5px;
    border: 1px solid #4a9eff;
    font-size: 12px;
}

/* 输入显示区域 */
#inputArea {
    position: absolute;
    bottom: 22%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10000 !important;
    padding: 0;
}

#inputDisplay {
    color: #00ff88;
    font-size: clamp(28px, 8vw, 48px);
    font-weight: bold;
    text-shadow: 0 0 20px rgba(0, 255, 136, 0.9), 0 0 40px rgba(0, 255, 136, 0.5);
    padding: 0;
    min-width: 60px;
    text-align: center;
    letter-spacing: 8px;
    font-family: 'Courier New', monospace;
}

#inputDisplay .cursor {
    animation: blink 0.5s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* 3D战机模型展示 */
#shipModelContainer {
    position: absolute;
    bottom: 140px;
    left: 50%;
    transform: translateX(-50%);
    width: 280px;
    height: 180px;
    z-index: 25;
    pointer-events: none;
    display: none !important;
}

/* 【手机端修复】开始状态下显示 3D 战机模型 */
.game-state-start #shipModelContainer {
    display: block !important;
}

#shipModelCanvas {
    width: 100%;
    height: 100%;
}

/* ==================== 【v0.3.3】赛博风格紧凑键盘 Grid布局 ==================== */
#virtualKeyboard {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 95%;
    max-width: 380px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    grid-template-rows: 55px 55px 55px;
    gap: 6px;
    z-index: 10000 !important;
}

.key {
    background: rgba(0, 15, 30, 0.8);
    border: 1px solid rgba(0, 255, 255, 0.2);
    color: #00ffff;
    font-size: 22px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.1s;
    text-shadow: 0 0 5px #00ffff;
    clip-path: polygon(5px 0, 100% 0, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0 100%, 0 5px);
}

.key:active {
    background: #00ffff;
    color: #000;
    box-shadow: 0 0 15px #00ffff;
}

.key-del {
    grid-column: 4;
    grid-row: 1;
    border-color: #ff0055;
    color: #ff0055;
    text-shadow: 0 0 5px #ff0055;
}

.key-0 {
    grid-column: 4;
    grid-row: 2 / span 2;
    background: rgba(0, 40, 60, 0.8);
    font-size: 28px;
}

/* ==================== 游戏状态控制 ==================== */
.game-state-start #inputArea,
.game-state-start #virtualKeyboard {
    display: none !important;
}

.game-state-start #startScreen,
.game-state-start #settingsScreen,
.game-state-start #createSaveScreen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 1000;
    pointer-events: auto !important;
}

/* 【手机端修复】确保游戏画面不遮挡开始菜单 */
.game-state-start #gameCanvas {
    visibility: hidden;
}

/* 【手机端修复】游戏进行时显示画布 */
.game-state-playing #gameCanvas,
.game-state-gameover #gameCanvas {
    visibility: visible !important;
}

/* 【手机端修复】createSaveScreen 移除 hidden 时显示 */
#createSaveScreen:not(.hidden) {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 1001;
    pointer-events: auto !important;
}


.game-state-playing #inputArea {
    display: flex !important;
}

.game-state-playing #virtualKeyboard {
    display: grid !important;
}

.game-state-playing #virtualKeyboard {
    animation: keyboardSlideUp 0.6s ease-out forwards;
}

@keyframes keyboardSlideUp {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(100px);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.game-state-playing #inputArea {
    animation: inputFadeIn 0.4s ease-out 0.3s forwards;
}

@keyframes inputFadeIn {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.game-state-gameover #inputArea,
.game-state-gameover #virtualKeyboard {
    display: none !important;
}

.game-state-gameover #introContainer {
    display: none !important;
}

.game-state-gameover #gameOver {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 100000;
}

/* ==================== 游戏状态屏幕 ==================== */
#startScreen h1, #settingsScreen h1, #gameOver h1 {
    font-size: clamp(24px, 6vw, 36px);
    margin-bottom: 20px;
    text-align: center;
}

#startScreen h1 {
    color: #4a9eff;
    text-shadow: 0 0 20px #4a9eff;
}

#settingsScreen h1 {
    color: #9b59b6;
    text-shadow: 0 0 20px #9b59b6;
}

#gameOver h1 {
    color: #ff4a4a;
    text-shadow: 0 0 20px #ff4a4a;
}

#startScreen p, #settingsScreen p, #gameOver p {
    font-size: clamp(14px, 4vw, 16px);
    margin: 8px 0;
    text-align: center;
    padding: 0 20px;
}

.btn {
    margin-top: 30px;
    padding: 15px 50px;
    font-size: 20px;
    background: linear-gradient(180deg, #4a9eff, #2060cc);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn:active {
    background: linear-gradient(180deg, #6ab0ff, #3080ee);
    transform: scale(0.95);
}

.btn-secondary {
    background: linear-gradient(180deg, #9b59b6, #8e44ad);
}

.btn-secondary:active {
    background: linear-gradient(180deg, #a86cc4, #9b59b6);
}

.hidden {
    display: none !important;
}

/* 反馈提示 */
#feedback {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(32px, 8vw, 48px);
    font-weight: bold;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 70;
}

#feedback.correct {
    color: #00ff00;
    text-shadow: 0 0 20px #00ff00;
}

#feedback.wrong {
    color: #ff0000;
    text-shadow: 0 0 20px #ff0000;
}

/* ==================== 设置界面样式 ==================== */
.settings-container {
    background: rgba(30, 30, 50, 0.9);
    border-radius: 15px;
    padding: 25px;
    margin: 20px;
    max-width: 400px;
    border: 2px solid #9b59b6;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-label {
    font-size: 16px;
    color: #fff;
}

.setting-desc {
    font-size: 12px;
    color: #888;
    margin-top: 5px;
}

.settings-buttons {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.settings-buttons .btn {
    margin: 0;
    padding: 12px 30px;
    font-size: 16px;
}

/* 桌面端版本号 */
@media (min-width: 768px) {
    .version-badge {
        position: absolute;
        bottom: 10px;
        right: 10px;
        background: rgba(99, 102, 241, 0.3);
        color: #a5b4fc;
        padding: 5px 10px;
        border-radius: 5px;
        font-size: 11px;
        z-index: 50;
    }
}

/* ==================== 开场动画样式 ==================== */
#introContainer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9000;
    background: transparent;
    overflow: hidden;
    display: none;
    pointer-events: none;
}

#introContainer.active {
    display: block;
}

#intro-bg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 9001;
    transition: opacity 0.5s ease-out;
}

@media (min-width: 768px) and (min-height: 600px) {
    #introContainer {
        width: 450px;
        height: 800px;
        max-height: 95vh;
        border-radius: 20px;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }
}

#introCanvas {
    display: block;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 9005;
    pointer-events: none !important;
}

#intro-story-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9050;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: black;
    transition: opacity 1.5s, visibility 1.5s;
}

#intro-story-layer.fade-out {
    opacity: 0;
    visibility: hidden;
}

.intro-story-text {
    color: #fff;
    font-size: clamp(18px, 4.5vw, 28px);
    font-weight: bold;
    letter-spacing: 3px;
    text-shadow: 0 0 10px #00ffff;
    margin-bottom: 16px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s, transform 0.6s;
    text-align: center;
    line-height: 1.4;
    font-family: 'Courier New', monospace;
}

.intro-story-alert {
    color: #ff0055;
    text-shadow: 0 0 20px #ff0055;
    font-size: clamp(22px, 5.5vw, 36px);
    text-transform: uppercase;
}

.intro-visible {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

.intro-fade-out {
    opacity: 0 !important;
    transition: opacity 0.8s ease-out;
}

#intro-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #00ffff;
    font-family: 'Courier New', monospace;
    z-index: 9100;
    font-size: 14px;
}

#intro-skip {
    position: absolute;
    top: 80px;
    width: 100%;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    z-index: 9200;
    font-family: 'Courier New', monospace;
    animation: blink 2s infinite;
    cursor: pointer;
    pointer-events: auto;
    display: none;
}

/* ==================== 题库卡片样式 v0.4.2 ==================== */
.question-types-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 50vh;
    overflow-y: auto;
    padding: 10px;
}

.question-type-item {
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 16px 20px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 16px;
    user-select: none;
    min-height: 60px;
}

.question-type-item:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(74, 158, 255, 0.5);
    transform: scale(1.02);
}

.question-type-item:active {
    transform: scale(0.98);
}

.question-type-item.selected {
    background: rgba(74, 158, 255, 0.35);
    border-color: #4a9eff;
    box-shadow: 0 0 15px rgba(74, 158, 255, 0.4);
}

.qt-check-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #4a9eff;
    font-weight: bold;
    flex-shrink: 0;
    transition: all 0.25s ease;
}

.question-type-item.selected .qt-check-icon {
    background: #4a9eff;
    color: #fff;
}

.qt-info {
    flex: 1;
}

.qt-name {
    font-size: 16px;
    color: #fff;
    font-weight: 500;
}

.qt-difficulty {
    font-size: 14px;
    color: #ffd700;
    margin-top: 4px;
}

/* ==================== 【v0.5.3】积分能量条 (炫彩火焰版) ==================== */
#scoreProgressContainer {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    max-width: 300px;
    height: 40px;
    z-index: 1000;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#scoreProgressBar {
    width: 100%;
    height: 12px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

/* 【v0.5.4】进度条填充：从左到右流动的彩虹（HSL色相，无突变） */
#scoreProgressFill {
    width: 0%;
    height: 100%;
    /* HSL色相环：0°=红 → 60°=黄 → 120°=绿 → 180°=青 → 240°=蓝 → 300°=紫 → 360°=红 */
    background: linear-gradient(
        90deg,
        hsl(0, 100%, 50%) 0%,
        hsl(30, 100%, 50%) 8.33%,
        hsl(60, 100%, 50%) 16.67%,
        hsl(120, 100%, 50%) 25%,
        hsl(180, 100%, 50%) 33.33%,
        hsl(240, 100%, 50%) 41.67%,
        hsl(300, 100%, 50%) 50%,
        hsl(360, 100%, 50%) 50.01%,
        hsl(360, 100%, 50%) 50.01%,
        hsl(0, 100%, 50%) 50.02%,
        hsl(30, 100%, 50%) 58.33%,
        hsl(60, 100%, 50%) 66.67%,
        hsl(120, 100%, 50%) 75%,
        hsl(180, 100%, 50%) 83.33%,
        hsl(240, 100%, 50%) 91.67%,
        hsl(300, 100%, 50%) 100%
    );
    background-size: 200% 100%;
    border-radius: 8px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: rainbowFlowLeft 3s linear infinite;
    box-shadow: 
        0 0 10px rgba(255, 255, 255, 0.8),
        0 0 20px rgba(255, 0, 255, 0.6);
}

/* 进度条上的高光扫光 */
#scoreProgressGlare {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg, 
        transparent 0%, 
        rgba(255, 255, 255, 0.8) 50%, 
        transparent 100%
    );
    transform: skewX(-20deg) translateX(-150%);
    animation: glareMove 3s infinite;
}

#scoreText {
    margin-top: 5px;
    font-size: 12px;
    color: #00ffff;
    font-weight: bold;
    text-shadow: 0 0 5px #00ffff;
    font-family: 'Courier New', monospace;
}

/* 左右两侧UI定位调整 */
.ui-item.left-info { position: absolute; top: 60px; left: 10px; }
.ui-item.right-info { position: absolute; top: 60px; right: 10px; }

/* 动画定义 */
@keyframes rainbowFlowLeft {
    0% { background-position: 200% 0%; }
    100% { background-position: 0% 0%; }
}

@keyframes glareMove {
    0%, 70% { transform: skewX(-20deg) translateX(-150%); }
    100% { transform: skewX(-20deg) translateX(150%); }
}

/* 能量吸收粒子样式 */
.soul-particle {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 900;
    box-shadow: 0 0 15px currentColor, 0 0 8px white;
    mix-blend-mode: screen;
    transition: transform 0.016s linear;
}

/* 【v0.5.3】飘动分数文字动画 */
.floating-score-text {
    position: absolute;
    font-size: 18px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    pointer-events: none;
    z-index: 950;
    animation: floatUpFade 0.8s ease-out forwards;
    white-space: nowrap;
}

@keyframes floatUpFade {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-40px) scale(1.3);
    }
}

/* ==================== 【v0.5.4】调试控制台样式 ==================== */
#debugConsole {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 280px;
    background: rgba(0, 0, 0, 0.95);
    border: 2px solid #00ff00;
    border-radius: 12px;
    z-index: 10000;
    box-shadow: 0 0 30px rgba(0, 255, 0, 0.5);
    transition: opacity 0.3s, visibility 0.3s;
}

.debug-console-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.debug-console-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.debug-console-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(0, 255, 0, 0.1);
    border-bottom: 1px solid #00ff00;
    border-radius: 10px 10px 0 0;
    color: #00ff00;
    font-family: 'Courier New', monospace;
    font-weight: bold;
}

.debug-console-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.debug-btn {
    background: none;
    border: none;
    color: #00ff00;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.debug-btn:hover {
    background: rgba(0, 255, 0, 0.2);
    border-radius: 4px;
}

.debug-btn-action {
    background: rgba(0, 255, 0, 0.1);
    border: 1px solid #00ff00;
    color: #00ff00;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    transition: all 0.2s;
}

.debug-btn-action:hover {
    background: rgba(0, 255, 0, 0.3);
    transform: scale(1.02);
}

.debug-btn-action:active {
    transform: scale(0.98);
}

.debug-console-theme-title {
    text-align: center;
    color: #00ff00;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    margin-top: 10px;
    margin-bottom: 5px;
}

.debug-console-themes {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    padding: 0 10px 10px 10px;
}

.debug-theme-btn {
    background: rgba(0, 255, 0, 0.1);
    border: 1px solid #00ff00;
    padding: 6px 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Courier New', monospace;
    border-radius: 4px;
}

.debug-theme-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 10px currentColor;
}

/* ==================== v0.5.9 简单过渡动画 ==================== */
@keyframes promptPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.05); }
}

/* ==================== v0.5.11 得分面板 - PC端定位 ==================== */
@media (min-width: 768px) {
    .score-panel {
        position: absolute;
        /* Position above keyboard - keyboard is at bottom: 20px */
        bottom: 220px;
        left: 15px;
    }
}

@keyframes titleGlow {
    0%, 100% { text-shadow: 0 0 30px #ffcc00, 0 0 60px #ff6600; }
    50% { text-shadow: 0 0 50px #ffcc00, 0 0 100px #ff6600, 0 0 150px #ffcc00; }
}

/* ==================== 关卡飞入动画 ==================== */
#levelFloatText {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 15000;
    pointer-events: none;
}

.level-fly-text-container {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.level-fly-text {
    font-size: 72px;
    font-weight: bold;
    color: var(--theme-color);
    text-shadow: 0 0 30px var(--theme-color), 0 0 60px var(--theme-color);
    animation: levelFlyScale 2s ease-out forwards;
}

/* 【v0.5.19】倍率文字 */
.level-fly-text-multiplier {
    font-size: 36px;
    font-weight: bold;
    color: #ffcc00;
    text-shadow: 0 0 15px #ffcc00, 0 0 30px #ff6600;
    margin-top: 10px;
    animation: multiplierFadeIn 2s ease-out forwards;
}

@keyframes levelFlyToBar {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    30% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        opacity: 0;
        transform: translate(calc(var(--target-x) - 50vw), calc(var(--target-y) - 50vh)) scale(0.2);
    }
}

@keyframes levelFlyScale {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    20% {
        opacity: 1;
        transform: scale(1.2);
    }
    40% {
        transform: scale(1);
    }
    80% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.8);
    }
}

@keyframes multiplierFadeIn {
    0% {
        opacity: 0;
        transform: translateY(-20px);
    }
    30% {
        opacity: 1;
        transform: translateY(0);
    }
    70% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(10px);
    }
}

/* ==================== v0.5.11 得分面板 (键盘左上方) ==================== */
.score-panel {
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 1000;
    pointer-events: auto;
    padding: 10px 18px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    border: 2px solid;
    border-radius: 10px;
    font-size: 20px;
    font-weight: bold;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    transition: all 0.3s ease;
}

#multiplierDisplay {
    margin-left: 5px;
    font-size: 18px;
}

@media (min-width: 768px) {
    body {
        background: #0a0a0f;
        display: flex;
        justify-content: center;
        align-items: center;
        min-height: 100vh;
    }

    #gameContainer {
        margin: 0 auto;
    }
}

/* ==================== 【v0.5.12】暂停菜单样式 ==================== */
#pauseMenu, #quitConfirm {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 20000;
}

#pauseMenu h1, #quitConfirm h1 {
    font-size: clamp(28px, 6vw, 40px);
    margin-bottom: 30px;
    color: #4a9eff;
    text-shadow: 0 0 20px #4a9eff;
}

#quitConfirm p {
    font-size: clamp(14px, 4vw, 18px);
    margin: 10px 0;
    color: #ccc;
}

.confirm-buttons {
    display: flex;
    gap: 20px;
    margin-top: 30px;
}

.confirm-buttons .btn {
    margin: 0;
    padding: 12px 30px;
}

/* ==================== 【v0.5.15】积分规则弹窗样式 ==================== */
#scoringRulesModal {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 25000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-y: auto;
}

#scoringRulesModal .modal-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 2px solid #6366f1;
    border-radius: 20px;
    max-width: 420px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 0 40px rgba(99, 102, 241, 0.5);
}

#scoringRulesModal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid rgba(99, 102, 241, 0.3);
    position: sticky;
    top: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 18px 18px 0 0;
    z-index: 10;
}

#scoringRulesModal .modal-header h2 {
    color: #6366f1;
    font-size: 22px;
    margin: 0;
    text-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

#scoringRulesModal .modal-close {
    background: none;
    border: none;
    color: #888;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

#scoringRulesModal .modal-close:hover {
    background: rgba(255, 100, 100, 0.2);
    color: #ff6464;
}

#scoringRulesModal .modal-body {
    padding: 20px 25px;
}

#scoringRulesModal .rule-section {
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 12px;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

#scoringRulesModal .rule-section h3 {
    color: #ffd700;
    font-size: 16px;
    margin: 0 0 10px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

#scoringRulesModal .rule-section p {
    color: #ccc;
    font-size: 13px;
    margin: 5px 0;
    line-height: 1.5;
}

#scoringRulesModal .rule-note {
    color: #888;
    font-style: italic;
    font-size: 12px;
}

#scoringRulesModal .score-table,
#scoringRulesModal .example-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 13px;
}

#scoringRulesModal .score-table th,
#scoringRulesModal .score-table td,
#scoringRulesModal .example-table th,
#scoringRulesModal .example-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#scoringRulesModal .score-table th,
#scoringRulesModal .example-table th {
    color: #6366f1;
    font-weight: bold;
}

#scoringRulesModal .score-table td,
#scoringRulesModal .example-table td {
    color: #ddd;
}

#scoringRulesModal .example-table td:last-child {
    text-align: right;
    font-weight: bold;
    color: #00ff88;
}

/* 移动端优化 */
@media (max-width: 767px) {
    #scoringRulesModal .modal-content {
        max-height: 85vh;
    }

    #scoringRulesModal .modal-header h2 {
        font-size: 18px;
    }

    #scoringRulesModal .rule-section {
        padding: 12px;
    }

    #scoringRulesModal .example-table {
        font-size: 11px;
    }

    #scoringRulesModal .example-table td,
    #scoringRulesModal .example-table th {
        padding: 6px 5px;
    }
}
/* ==================== 【v0.5.20】玩家信息显示 ==================== */
.player-info {
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.4);
    border-radius: 12px;
    padding: 15px 25px;
    margin: 20px 0;
}

.player-name {
    color: #6366f1;
    font-size: 16px;
    margin: 5px 0;
}

.player-highscore {
    color: #ffd700;
    font-size: 18px;
    margin: 5px 0;
    font-weight: bold;
}

/* ==================== 【v0.5.20】创建存档界面样式 ==================== */
.create-save-form {
    background: rgba(30, 30, 50, 0.95);
    border-radius: 15px;
    padding: 25px;
    width: 90%;
    max-width: 400px;
}

.create-save-form label {
    display: block;
    color: #6366f1;
    font-size: 16px;
    margin-bottom: 10px;
    font-weight: bold;
}

.name-input {
    width: 100%;
    padding: 15px;
    font-size: 18px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(99, 102, 241, 0.5);
    border-radius: 10px;
    color: #fff;
    text-align: center;
    outline: none;
    transition: all 0.3s;
    /* 【iOS 输入修复】允许文本输入 */
    -webkit-user-select: text !important;
    user-select: text !important;
    -webkit-touch-callout: auto;
    pointer-events: auto !important;
    touch-action: auto !important;
    -webkit-appearance: none;
}

.name-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

.name-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* ==================== 【v0.5.20】排行榜按钮样式 ==================== */
.btn-leaderboard {
    background: linear-gradient(180deg, #ffd700, #ffaa00) !important;
    color: #000 !important;
    font-weight: bold;
}

.btn-leaderboard:active {
    background: linear-gradient(180deg, #ffeb3b, #ffd700) !important;
}

/* ==================== 【v0.5.20】游戏结束分数显示 ==================== */
.high-score-display {
    color: #00ff88;
    font-size: 18px;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
    margin: 10px 0;
}

.leaderboard-position {
    color: #ffd700;
    font-size: 18px;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    margin: 10px 0;
}

/* ==================== 【v0.5.20】排行榜弹窗样式 ==================== */
#leaderboardModal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5000;
}

#leaderboardModal.hidden {
    display: none !important;
}

.leaderboard-modal {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 2px solid #6366f1;
    border-radius: 20px;
    max-width: 450px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 0 40px rgba(99, 102, 241, 0.5);
}

.leaderboard-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid rgba(99, 102, 241, 0.3);
}

.leaderboard-modal .modal-title {
    color: #6366f1;
    font-size: 24px;
    margin: 0;
    text-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

.leaderboard-modal .modal-close {
    background: none;
    border: none;
    color: #888;
    font-size: 32px;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.leaderboard-modal .modal-close:hover {
    background: rgba(255, 100, 100, 0.2);
    color: #ff6464;
}

.leaderboard-modal .modal-body {
    padding: 20px 25px;
}

.leaderboard-modal .loading {
    text-align: center;
    color: #888;
    padding: 30px;
}

.leaderboard-modal .error {
    text-align: center;
    color: #ff6464;
    padding: 20px;
}

.leaderboard-modal .leaderboard-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.leaderboard-modal .leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    margin-bottom: 10px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 10px;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.leaderboard-modal .leaderboard-item.rank-1 {
    background: rgba(255, 215, 0, 0.2);
    border-color: rgba(255, 215, 0, 0.5);
}

.leaderboard-modal .leaderboard-item.rank-2 {
    background: rgba(192, 192, 192, 0.2);
    border-color: rgba(192, 192, 192, 0.5);
}

.leaderboard-modal .leaderboard-item.rank-3 {
    background: rgba(205, 127, 50, 0.2);
    border-color: rgba(205, 127, 50, 0.5);
}

.leaderboard-modal .item-rank {
    color: #ffd700;
    font-size: 18px;
    font-weight: bold;
    width: 40px;
}

.leaderboard-modal .item-name {
    color: #fff;
    font-size: 16px;
    flex: 1;
    text-align: left;
    padding: 0 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-modal .item-score {
    color: #00ff88;
    font-size: 18px;
    font-weight: bold;
}

.leaderboard-modal .empty-message {
    text-align: center;
    color: #888;
    padding: 30px;
    font-size: 16px;
}

/* 移动端优化 */
@media (max-width: 767px) {
    .leaderboard-modal {
        max-width: 95%;
        max-height: 85vh;
    }

    .leaderboard-modal .modal-title {
        font-size: 20px;
    }

    .leaderboard-modal .item-name {
        font-size: 14px;
    }

    .leaderboard-modal .item-score {
        font-size: 16px;
    }
}
