/* 基础样式 */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100vh;
    font-family: 'Press Start 2P', cursive;
    background-color: #0a0a1a;
    color: #00ff00;
    line-height: 1.5;
    touch-action: manipulation;
}

.game-container {
    width: 100%;
    height: 100vh;
    padding: 10px;
    display: flex;
    flex-direction: column;
    background-color: #111122;
    border: 2px solid #0055ff;
    box-shadow: 0 0 20px #0055ff;
    overflow: auto;
}

/* 头部样式 */
.game-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #0055ff;
    position: sticky;
    top: 0;
    background-color: #111122;
    z-index: 50;
}

.game-header h1 {
    font-size: 22px;
    text-shadow: 0 0 10px #00ffff;
    margin: 5px 0;
    letter-spacing: 2px;
    text-align: center;
}

.game-stats {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
}

.stat {
    background-color: #002244;
    padding: 8px 12px;
    border-radius: 5px;
    border: 1px solid #0055ff;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    min-width: 120px;
    justify-content: center;
    position: relative;
}

.stat-icon {
    font-size: 14px;
}

.health-bar {
    display: inline-block;
    width: 60px;
    height: 12px;
    background-color: #ff000033;
    border-radius: 6px;
    margin: 0 5px;
    overflow: hidden;
}

.health-fill {
    display: block;
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ff0000, #ff5555);
    border-radius: 6px;
    transition: width 0.3s;
}

.health-value {
    min-width: 35px;
    display: inline-block;
    text-align: right;
}

.compute-display {
    background-color: #0055ff33;
    border: 1px solid #00ffff;
    color: #00ffff;
    font-weight: bold;
}

/* 游戏区域 */
.game-area {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    gap: 10px;
    min-height: 0;
}

@media (min-width: 768px) {
    .game-area {
        flex-direction: row;
    }
}

.tower-selector {
    display: flex;
    flex-direction: row;
    gap: 10px;
    padding: 5px;
    overflow-x: auto;
    min-height: 120px;
}

@media (min-width: 768px) {
    .tower-selector {
        flex-direction: column;
        width: 160px;
        min-height: auto;
        overflow-x: visible;
    }
}

.tower-option {
    background-color: #002244;
    padding: 10px;
    border: 1px solid #0055ff;
    border-radius: 5px;
    cursor: grab;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 140px;
    user-select: none;
}

.tower-option:hover {
    background-color: #003366;
    transform: scale(1.05);
    box-shadow: 0 0 10px #0055ff;
}

.tower-icon {
    font-size: 24px;
}

.tower-info {
    display: flex;
    flex-direction: column;
}

.tower-name {
    font-size: 12px;
    white-space: nowrap;
}

.tower-cost {
    font-size: 11px;
    color: #00ffff;
}

.game-board {
    flex-grow: 1;
    background-color: #000011;
    border: 1px solid #0055ff;
    position: relative;
    overflow: hidden;
    min-height: 300px;
}

.path {
    position: absolute;
    background-color: #0055ff33;
}

/* 游戏元素 */
.tower {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
    font-size: 16px;
    box-shadow: 0 0 10px currentColor;
    user-select: none;
}

.tower.laser {
    background-color: #ff0000;
    color: white;
}

.tower.firewall {
    background-color: #00ff00;
    color: black;
}

.tower.virus {
    background-color: #0000ff;
    color: white;
}

.enemy-container {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 5;
    user-select: none;
}

.enemy {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: #ff00ff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    color: white;
    box-shadow: 0 0 10px #ff00ff;
}

.enemy-health {
    width: 30px;
    height: 4px;
    background-color: #ff000033;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 2px;
}

.enemy-health-fill {
    display: block;
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #00ff00, #55ff55);
    border-radius: 2px;
}

.projectile {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    z-index: 8;
    box-shadow: 0 0 5px currentColor;
}

.core {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    background-color: #9900ff;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    z-index: 20;
    box-shadow: 0 0 20px #9900ff;
    font-size: 10px;
    text-align: center;
    line-height: 1.2;
    user-select: none;
}

/* 控制按钮 */
.game-controls {
    margin-top: 10px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 5px;
    position: sticky;
    bottom: 0;
    background-color: #111122;
    z-index: 50;
}

button {
    background-color: #0055ff;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    transition: all 0.2s;
    min-width: 120px;
    user-select: none;
}

button:hover {
    background-color: #0077ff;
    transform: scale(1.05);
    box-shadow: 0 0 10px #0055ff;
}

button:disabled {
    background-color: #555555;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 弹窗样式 */
.tutorial, .modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #111133;
    border: 2px solid #0055ff;
    padding: 20px;
    border-radius: 5px;
    z-index: 100;
    max-width: 90%;
    width: 500px;
    display: none;
    box-shadow: 0 0 20px #0055ff;
}

.tutorial h2, .modal h2 {
    margin-top: 0;
    color: #00ffff;
    text-align: center;
}

.tutorial p, .modal p {
    margin: 15px 0;
    font-size: 12px;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

/* 工具提示 */
.tooltip {
    position: absolute;
    background-color: #002244;
    border: 1px solid #0055ff;
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 12px;
    z-index: 200;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    max-width: 200px;
    text-align: center;
}

/* 动画 */
@keyframes floatUp {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-30px); opacity: 0; }
}

@keyframes shake {
    0%, 100% { transform: translateY(-50%); }
    25% { transform: translateY(-50%) translateX(-5px); }
    75% { transform: translateY(-50%) translateX(5px); }
}

@keyframes pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.1); }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* 全屏样式 */
:-webkit-full-screen .game-container {
    width: 100%;
    height: 100%;
    padding: 20px;
}

:-moz-full-screen .game-container {
    width: 100%;
    height: 100%;
    padding: 20px;
}

:fullscreen .game-container {
    width: 100%;
    height: 100%;
    padding: 20px;
}

/* 移动设备优化 */
@media (max-width: 480px) {
    .game-header h1 {
        font-size: 18px;
    }
    
    .stat {
        min-width: 100px;
        font-size: 10px;
        padding: 5px 8px;
    }
    
    button {
        padding: 8px 10px;
        font-size: 10px;
        min-width: 100px;
    }
    
    .tower-selector {
        min-height: 100px;
    }
    
    .tower-option {
        min-width: 120px;
        padding: 8px;
    }
}

.sound-control {
    position: fixed;
    bottom: 10px;
    right: 10px;
    width: 50px;
    height: 50px;
    background-color: #0055ff;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.sound-control:hover {
    background-color: #0077ff;
    transform: scale(1.1);
}

/* 调整全屏按钮位置 */
#fullscreen-btn {
    position: fixed;
    bottom: 70px;
    right: 10px;
}

/* 添加新塔的颜色样式 */
.tower.missile {
    background-color: #ff9900;
    color: black;
}

.tower.sniper {
    background-color: #9900ff;
    color: white;
}

.tower.tesla {
    background-color: #ffff00;
    color: black;
}

.tower.frost {
    background-color: #00ffff;
    color: black;
}

/* 新投射物样式 */
.projectile.missile {
    background-color: #ff9900;
    box-shadow: 0 0 10px #ff9900;
}

.projectile.sniper {
    background-color: #9900ff;
    box-shadow: 0 0 10px #9900ff;
}

.projectile.tesla {
    background-color: #ffff00;
    box-shadow: 0 0 10px #ffff00;
}

.projectile.frost {
    background-color: #00ffff;
    box-shadow: 0 0 10px #00ffff;
}

/* 自动波次控制样式 */
.auto-wave-control {
    display: flex;
    align-items: center;
    gap: 5px;
    background-color: #002244;
    padding: 5px 10px;
    border-radius: 5px;
    border: 1px solid #0055ff;
}

.auto-wave-settings {
    display: none; /* 默认隐藏 */
    align-items: center;
    gap: 5px;
    font-size: 12px;
}

.auto-wave-control.active .auto-wave-settings {
    display: flex; /* 激活时显示 */
}

#auto-wave-limit {
    width: 40px;
    background: #001133;
    border: 1px solid #0055ff;
    color: #00ffff;
    text-align: center;
    padding: 2px;
}

#toggle-auto-wave {
    background-color: #0055ff33;
    transition: all 0.3s;
}

#toggle-auto-wave.active {
    background-color: #0055ff;
    box-shadow: 0 0 10px #0055ff;
}