/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #ff3e00;
    --bg-dark: #0a0a0a;
    --bg-medium: #1a1a1a;
    --bg-light: #2c3e50;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --success-color: #4CAF50;
    --warning-color: #ffeb3b;
    --danger-color: #FF5252;
    --info-color: #2196F3;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    user-select: none;
    touch-action: manipulation;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 游戏容器 */
.game-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    /* 移动设备安全区域适配 */
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

/* 移动设备触摸区域 */
.touch-controls {
    display: none;
    position: absolute;
    bottom: 20px;
    width: 100%;
    justify-content: space-between;
    padding: 0 20px;
    pointer-events: none;
    z-index: 15;
}

.touch-button {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    touch-action: manipulation;
    pointer-events: auto;
    transition: all 0.1s ease;
}

.touch-button:active {
    transform: scale(0.9);
    background-color: rgba(255, 62, 0, 0.5);
    border-color: rgba(255, 62, 0, 0.8);
}

/* 星空背景 */
.game-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at bottom, #1b2735 0%, #090a0f 100%);
    z-index: -1;
}

/* 星星效果 - 已注释 */
/*
#start-screen::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(white, rgba(255,255,255,.2) 2px, transparent 40px),
        radial-gradient(white, rgba(255,255,255,.15) 1px, transparent 30px),
        radial-gradient(white, rgba(255,255,255,.1) 2px, transparent 40px),
        radial-gradient(rgba(255,255,255,.4), rgba(255,255,255,.1) 2px, transparent 30px);
    background-size: 550px 550px, 350px 350px, 250px 250px, 150px 150px;
    background-position: 0 0, 40px 60px, 130px 270px, 70px 100px;
    animation: starMove 60s linear infinite;
}*/

@keyframes starMove {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(-1000px);
    }
}

/* 屏幕通用样式 */
.screen {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #1a1a1a, #0a0a0a);
    transition: opacity 0.3s ease;
}

.hidden {
    display: none;
}

/* 游戏标题 */
.game-title {
    font-size: 3.5rem;
    margin-bottom: 2rem;
    color: #ff3e00;
    text-shadow: 0 0 20px rgba(255, 62, 0, 0.7);
    text-align: center;
    animation: titlePulse 2s infinite alternate;
}

@keyframes titlePulse {
    from {
        text-shadow: 0 0 20px rgba(255, 62, 0, 0.7);
        transform: scale(1);
    }
    to {
        text-shadow: 0 0 30px rgba(255, 62, 0, 0.9), 0 0 10px rgba(255, 255, 255, 0.5);
        transform: scale(1.05);
    }
}

/* 按钮样式 */
.btn {
    padding: 1rem 2rem;
    margin: 0.8rem;
    font-size: 1.2rem;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    min-width: 180px;
}

.primary-btn {
    background-color: #ff3e00;
    color: white;
    box-shadow: 0 4px 15px rgba(255, 62, 0, 0.4);
}

.primary-btn:hover {
    background-color: #ff5722;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(255, 62, 0, 0.6);
}

.secondary-btn {
    background-color: #2c3e50;
    color: white;
    box-shadow: 0 4px 15px rgba(44, 62, 80, 0.4);
}

.secondary-btn:hover {
    background-color: #34495e;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(44, 62, 80, 0.6);
}

.pause-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    min-width: auto;
}

/* 游戏状态栏 */
.game-status {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 12px 16px;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    border-bottom: 2px solid rgba(255, 62, 0, 0.3);
    z-index: 10;
    /* 考虑移动设备刘海屏 */
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
}

.score-display,
.level-display,
.lives-display {
    font-size: clamp(1rem, 3vw, 1.5rem);
    font-weight: bold;
    color: var(--text-primary);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    padding: 8px 16px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    min-width: 100px;
    text-align: center;
    transition: all 0.3s ease;
    flex: 1;
    margin: 0 4px;
}

.score-display {
    color: var(--success-color);
    border: 1px solid rgba(76, 175, 80, 0.5);
}

.level-display {
    color: var(--info-color);
    border: 1px solid rgba(33, 150, 243, 0.5);
}

.lives-display {
    color: var(--danger-color);
    border: 1px solid rgba(255, 82, 82, 0.5);
}

/* 画布样式 */
#game-canvas {
    width: 100%;
    height: 100%;
    background-color: #121212;
    position: absolute;
    top: 0;
    left: 0;
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(60, 60, 80, 0.15) 0%, transparent 20%),
        radial-gradient(circle at 80% 70%, rgba(60, 60, 80, 0.1) 0%, transparent 25%);
}

/* 分数更新动画 */
@keyframes scoreUpdate {
    0% { transform: scale(1); color: inherit; }
    50% { transform: scale(1.2); color: #ffeb3b; text-shadow: 0 0 15px #ffeb3b; }
    100% { transform: scale(1); color: inherit; }
}

.score-display.score-updating {
    animation: scoreUpdate 0.5s ease-out;
}

/* 关卡提升消息 */
.level-up-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    font-weight: bold;
    color: #4CAF50;
    text-shadow: 0 0 20px rgba(76, 175, 80, 0.8), 0 0 30px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: levelUpMessage 1.5s ease-out;
    pointer-events: none;
}

@keyframes levelUpMessage {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }
    20% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 1;
    }
    80% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

.level-up-message.fade-out {
    animation: levelUpFadeOut 0.5s ease-out;
}

@keyframes levelUpFadeOut {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
}

/* 瞄准器 */
.crosshair {
    width: 32px;
    height: 32px;
    position: fixed;
    pointer-events: none;
    background-color: transparent;
    border: 2px solid #ff3e00;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    animation: crosshairPulse 2s infinite alternate;
    box-shadow: 0 0 10px rgba(255, 62, 0, 0.7);
}

@keyframes crosshairPulse {
    from {
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 0 10px rgba(255, 62, 0, 0.7);
    }
    to {
        transform: translate(-50%, -50%) scale(1.1);
        box-shadow: 0 0 15px rgba(255, 62, 0, 0.9);
    }
}

.crosshair::before,
.crosshair::after {
    content: '';
    position: absolute;
    background-color: #ff3e00;
}

.crosshair::before {
    width: 2px;
    height: 12px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.crosshair::after {
    width: 12px;
    height: 2px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* 瞄准器点击效果 */
.crosshair.shoot {
    animation: shootEffect 0.2s ease-out;
}

@keyframes shootEffect {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0.7;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* 模态框样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: #2c3e50;
    padding: 2rem;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: modalAppear 0.3s ease;
}

@keyframes modalAppear {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    color: #ff3e00;
}

.modal-content p {
    margin-bottom: 0.8rem;
    text-align: left;
    line-height: 1.5;
}

/* 暂停菜单 */
#pause-menu .modal-content {
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.95), rgba(20, 20, 30, 0.95));
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

#pause-menu .modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(white, rgba(255,255,255,.1) 1px, transparent 10px),
        radial-gradient(white, rgba(255,255,255,.05) 1px, transparent 15px);
    background-size: 300px 300px, 500px 500px;
    animation: pauseStars 15s linear infinite;
    pointer-events: none;
}

@keyframes pauseStars {
    from {
        background-position: 0 0;
    }
    to {
        background-position: 0 -500px;
    }
}

#pause-menu h2 {
    font-size: 2.5rem;
    color: #4CAF50;
    margin-bottom: 2rem;
    text-shadow: 0 0 15px rgba(76, 175, 80, 0.7);
    animation: pauseTitleAppear 0.5s ease-out;
    position: relative;
    z-index: 1;
}

@keyframes pauseTitleAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.buttons-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    animation: pauseButtonsAppear 0.7s ease-out;
    position: relative;
    z-index: 1;
}

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

/* 设置项 */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.setting-item label {
    font-size: 1.2rem;
}

.setting-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.setting-item input[type="range"] {
    width: 60%;
    cursor: pointer;
}

/* 游戏结束页 */
#game-over-screen {
    background: linear-gradient(135deg, rgba(10,10,10,0.95), rgba(30,30,40,0.95));
    position: relative;
    overflow: hidden;
}

/* #game-over-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(white, rgba(255,255,255,.1) 1px, transparent 10px),
        radial-gradient(white, rgba(255,255,255,.05) 1px, transparent 15px);
    background-size: 300px 300px, 500px 500px;
    animation: gameOverStars 20s linear infinite;
} */

@keyframes gameOverStars {
    from {
        background-position: 0 0;
    }
    to {
        background-position: 0 -500px;
    }
}

#game-over-screen h2 {
    font-size: 3rem;
    color: #ff3e00;
    margin-bottom: 2rem;
    text-shadow: 0 0 20px rgba(255, 62, 0, 0.7);
    animation: gameOverTitle 2s ease-out;
}

@keyframes gameOverTitle {
    0% {
        transform: scale(0.8);
        opacity: 0;
        text-shadow: 0 0 10px rgba(255, 62, 0, 0.5);
    }
    50% {
        transform: scale(1.1);
        text-shadow: 0 0 30px rgba(255, 62, 0, 1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
        text-shadow: 0 0 20px rgba(255, 62, 0, 0.7);
    }
}

.final-score,
.high-score {
    font-size: clamp(1.5rem, 5vw, 2rem);
    margin: 1.5rem 0;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 1rem 2rem;
    border-radius: 10px;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: scoreReveal 1s ease-out forwards;
    opacity: 0;
    transform: translateY(20px);
}

.final-score {
    animation-delay: 0.3s;
    color: #ffeb3b;
    border-color: rgba(255, 235, 59, 0.3);
}

.high-score {
    animation-delay: 0.6s;
    color: #4CAF50;
    border-color: rgba(76, 175, 80, 0.3);
}

@keyframes scoreReveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 新纪录动画 */
.new-record {
    position: relative;
    color: #ffeb3b;
    animation: newRecord 0.5s ease-out infinite alternate;
}

@keyframes newRecord {
    from {
        text-shadow: 0 0 10px rgba(255, 235, 59, 0.7);
        transform: scale(1);
    }
    to {
        text-shadow: 0 0 20px rgba(255, 235, 59, 1), 0 0 30px rgba(255, 62, 0, 0.7);
        transform: scale(1.05);
    }
}

/* 游戏结束页按钮容器 */
#game-over-screen .buttons-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 2rem;
    animation: buttonsReveal 1s ease-out forwards;
    opacity: 0;
    transform: translateY(20px);
    animation-delay: 0.9s;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .game-title {
        font-size: clamp(1.8rem, 8vw, 2.5rem);
    }
    
    .btn {
        font-size: clamp(0.9rem, 3vw, 1rem);
        padding: 0.8rem 1.5rem;
        min-width: 150px;
    }
    
    .game-status {
        padding: 8px 12px;
    }
    
    .crosshair {
        width: 25px;
        height: 25px;
    }
    
    .modal-content {
        padding: 1.5rem;
        margin: 1rem;
        max-width: 95vw;
    }
}

@media (max-width: 480px) {
    .game-title {
        font-size: clamp(1.5rem, 8vw, 2rem);
    }
    
    .btn {
        font-size: clamp(0.8rem, 3vw, 0.9rem);
        padding: 0.7rem 1.2rem;
        margin: 0.6rem;
        min-width: 120px;
        width: 80%;
    }
    
    .game-status {
        flex-wrap: wrap;
    }
    
    .score-display,
    .level-display,
    .lives-display {
        margin: 2px 0;
        padding: 6px 12px;
    }
    
    .crosshair {
        width: 24px;
        height: 24px;
        border-width: 2px;
    }
    
    /* 显示移动设备触摸控制 */
    .touch-controls {
        display: flex;
    }
    
    /* 移动设备上隐藏鼠标指针 */
    body {
        cursor: default;
    }
    
    #game-screen {
        cursor: default;
    }
}

/* 平板设备专用样式 */
@media (min-width: 481px) and (max-width: 768px) {
    .touch-controls {
        display: flex;
        padding: 0 30px;
    }
    
    .touch-button {
        width: 90px;
        height: 90px;
        font-size: 1.8rem;
    }
}

/* 横屏模式优化 */
@media screen and (orientation: landscape) and (max-height: 500px) {
    .game-status {
        flex-direction: row;
        padding: 4px 8px;
    }
    
    .score-display,
    .level-display,
    .lives-display {
        padding: 4px 8px;
        min-width: 80px;
    }
    
    .touch-controls {
        bottom: 10px;
    }
    
    .touch-button {
        width: 70px;
        height: 70px;
    }
}

/* 隐藏默认鼠标指针 */
#game-screen {
    cursor: none;
}