* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
}

body {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: 'Arial', 'Microsoft YaHei', sans-serif;
    color: white;
    overflow: hidden;
    touch-action: none;
}

#gameContainer {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#gameHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px 15px 10px;
}

#gameHeader h1 {
    font-size: 24px;
    background: linear-gradient(135deg, #f7971e, #ffd200);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: none;
}

#score {
    font-size: 20px;
    font-weight: bold;
    color: #ffd700;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 20px;
    border-radius: 30px;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

#gameArea {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.5);
    touch-action: none;
}

#gameCanvas {
    display: block;
    background: #2c3e50;
    width: 400px;
    height: 600px;
    touch-action: none;
}

/* ========== 虚拟摇杆 ========== */
#joystickContainer {
    position: absolute;
    bottom: 30px;
    left: 30px;
    width: 130px;
    height: 130px;
    z-index: 5; /* 降低层级，让开始界面在上面 */
    touch-action: none;
    display: block !important;
    pointer-events: auto; /* 允许点击 */
}

#joystickBase {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 3px solid rgba(255, 255, 255, 0.2);
    position: relative;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    touch-action: none;
    cursor: grab;
    transition: border-color 0.3s;
}

#joystickBase:hover {
    border-color: rgba(255, 215, 0, 0.4);
}

#joystickBase:active {
    cursor: grabbing;
}

#joystickBase::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    height: 60%;
    border-radius: 50%;
    border: 2px dashed rgba(255, 255, 255, 0.08);
}

#joystickBase .dot {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

#joystickBase .dot-top { top: 15%; left: 50%; transform: translateX(-50%); }
#joystickBase .dot-bottom { bottom: 15%; left: 50%; transform: translateX(-50%); }
#joystickBase .dot-left { left: 15%; top: 50%; transform: translateY(-50%); }
#joystickBase .dot-right { right: 15%; top: 50%; transform: translateY(-50%); }

#joystickKnob {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #ffd700, #f7971e);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 5px 25px rgba(247, 151, 30, 0.4);
    pointer-events: none;
    transition: box-shadow 0.2s;
    touch-action: none;
}

#joystickKnob::after {
    content: '◆';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.15);
    font-size: 16px;
}

#joystickKnob.active {
    box-shadow: 0 5px 35px rgba(247, 151, 30, 0.7);
}

/* ========== 开始界面 ========== */
#startScreen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 20;
    padding: 20px;
    animation: fadeIn 0.5s ease;
    pointer-events: auto; /* 允许点击 */
}

#startContent {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 350px;
    pointer-events: auto; /* 确保子元素可点击 */
}

#startScreen h2 {
    font-size: 38px;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #f7971e, #ffd200);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    pointer-events: none;
}

#lifeSelector {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 20px 30px;
    margin-bottom: 25px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    width: 100%;
    pointer-events: auto;
}

#lifeSelector label {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.8);
    display: block;
    margin-bottom: 12px;
    pointer-events: none;
}

#lifeControls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 12px;
    pointer-events: auto;
}

#lifeControls button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

#lifeControls button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: #ffd700;
    transform: scale(1.05);
}

#lifeControls button:active {
    transform: scale(0.9);
}

#lifeDisplay {
    font-size: 36px;
    font-weight: bold;
    color: #ffd700;
    min-width: 50px;
    text-align: center;
    pointer-events: none;
}

#lifePresets {
    display: flex;
    gap: 8px;
    justify-content: center;
    pointer-events: auto;
}

.presetBtn {
    padding: 4px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    pointer-events: auto;
}

.presetBtn:hover {
    background: rgba(255, 215, 0, 0.2);
    border-color: #ffd700;
    color: #ffd700;
}

.presetBtn.active {
    background: rgba(255, 215, 0, 0.25);
    border-color: #ffd700;
    color: #ffd700;
}

#startBtn {
    background: linear-gradient(135deg, #f7971e, #ffd200);
    color: #1a1a2e;
    border: none;
    padding: 14px 50px;
    font-size: 22px;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 30px rgba(247, 151, 30, 0.4);
    pointer-events: auto;
    position: relative;
    z-index: 25;
}

#startBtn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 40px rgba(247, 151, 30, 0.6);
}

#startBtn:active {
    transform: scale(0.95);
}

#controlsHint {
    margin-top: 15px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.4);
    pointer-events: none;
}

/* ========== 游戏结束界面 ========== */
#gameOver {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.85);
    padding: 40px 50px;
    border-radius: 20px;
    text-align: center;
    border: 2px solid #ff6b6b;
    box-shadow: 0 0 50px rgba(255, 0, 0, 0.3);
    animation: fadeIn 0.5s ease;
    z-index: 25;
    pointer-events: auto;
}

#gameOver h2 {
    font-size: 36px;
    color: #ff6b6b;
    margin-bottom: 15px;
    pointer-events: none;
}

#gameOver p {
    font-size: 20px;
    color: #ddd;
    margin-bottom: 20px;
    pointer-events: none;
}

#gameOver #finalScore {
    color: #ffd700;
    font-size: 28px;
    font-weight: bold;
}

#restartBtn {
    background: linear-gradient(135deg, #f7971e, #ffd200);
    color: #1a1a2e;
    border: none;
    padding: 12px 40px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 20px rgba(247, 151, 30, 0.4);
    pointer-events: auto;
}

#restartBtn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 30px rgba(247, 151, 30, 0.6);
}

#restartBtn:active {
    transform: scale(0.95);
}

/* ========== 底部控制 ========== */
#controls {
    text-align: center;
    padding-top: 15px;
}

#controls p {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 5px;
}

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

/* ========== 响应式 ========== */
@media (max-width: 480px) {
    #gameContainer {
        padding: 10px;
        border-radius: 12px;
    }
    
    #gameHeader h1 {
        font-size: 18px;
    }
    
    #score {
        font-size: 16px;
        padding: 5px 15px;
    }
    
    #gameCanvas {
        width: 100%;
        height: auto;
        aspect-ratio: 2 / 3;
    }
    
    #joystickContainer {
        width: 95px;
        height: 95px;
        bottom: 20px;
        left: 15px;
    }
    
    #joystickBase {
        width: 95px;
        height: 95px;
    }
    
    #joystickKnob {
        width: 40px;
        height: 40px;
    }
    
    #startScreen h2 {
        font-size: 28px;
    }
    
    #lifeSelector {
        padding: 15px 20px;
        width: 100%;
        max-width: 280px;
    }
    
    #lifeDisplay {
        font-size: 28px;
    }
    
    #startBtn {
        padding: 12px 35px;
        font-size: 18px;
    }
    
    #gameOver {
        padding: 25px 30px;
    }
    
    #gameOver h2 {
        font-size: 28px;
    }
    
    #controls p {
        font-size: 12px;
    }
}

@media (min-width: 481px) and (max-width: 1024px) {
    #joystickContainer {
        width: 110px;
        height: 110px;
        bottom: 25px;
        left: 25px;
    }
    
    #joystickBase {
        width: 110px;
        height: 110px;
    }
    
    #joystickKnob {
        width: 46px;
        height: 46px;
    }
}