* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #1a1a1a;
    color: #fff;
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* 页面容器 */
.page {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.page.active {
    display: block;
}

/* 角色选择页面 */
#roleSelect {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a1a 0%, #2c3e50 100%);
}

.container {
    width: 90%;
    max-width: 400px;
    text-align: center;
    padding: 20px;
}

.container h1 {
    color: #f39c12;
    margin-bottom: 20px;
    font-size: 28px;
    text-shadow: 0 2px 10px rgba(243, 156, 18, 0.5);
}

.rules {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    font-size: 14px;
    line-height: 1.8;
    text-align: left;
    backdrop-filter: blur(10px);
}

.btn-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.btn {
    padding: 18px 30px;
    border: none;
    border-radius: 10px;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: scale(0.95);
}

.red-team {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.blue-team {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

.editor-btn {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

.footer {
    margin-top: 30px;
    font-size: 12px;
    color: #888;
}

/* 游戏页面 */
#gamePage {
    background: #000;
}

#gameCanvas {
    display: block;
    width: 351px;
    height: 351px;
    margin: 0 auto;
    background: #000;
    image-rendering: pixelated;
}

/* 状态栏 */
.status-bar {
    background: rgba(44, 62, 80, 0.95);
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: bold;
    border-bottom: 2px solid #34495e;
}

.status-bar span {
    color: #ecf0f1;
}

.status-bar .score {
    font-size: 16px;
    font-weight: bold;
}

.status-bar .score.red {
    color: #e74c3c;
}

.status-bar .score.blue {
    color: #3498db;
}

/* 控制区域 */
.controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 180px;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    gap: 20px;
}

/* 方向键 */
.direction-pad {
    position: relative;
    width: 140px;
    height: 140px;
}

.dir-btn {
    position: absolute;
    width: 45px;
    height: 45px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #34495e, #2c3e50);
    color: #fff;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
    transition: all 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dir-btn:active {
    background: linear-gradient(135deg, #3498db, #2980b9);
    transform: scale(0.9);
}

.dir-btn.up {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

.dir-btn.down {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

.dir-btn.left {
    left: 0;
    top: 50%;
    transform: translateY(-50%);
}

.dir-btn.right {
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

/* 开火按钮 */
.fire-btn {
    width: 100px;
    height: 100px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: #fff;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 5px 20px rgba(231, 76, 60, 0.6);
    transition: all 0.1s;
}

.fire-btn:active {
    background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
    transform: scale(0.9);
}

/* 返回按钮 */
.back-btn {
    position: fixed;
    top: 10px;
    left: 10px;
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    background: rgba(52, 73, 94, 0.9);
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    z-index: 100;
}

.back-btn:active {
    background: rgba(44, 62, 80, 1);
}

/* 加载遮罩 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #34495e;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay p {
    font-size: 16px;
    color: #ecf0f1;
}

/* 响应式设计 */
@media (max-width: 480px) {
    .container h1 {
        font-size: 24px;
    }
    
    .rules {
        font-size: 13px;
        padding: 15px;
    }
    
    .btn {
        font-size: 18px;
        padding: 15px 25px;
    }
    
    .controls {
        height: 160px;
        padding: 10px 15px;
    }
    
    .direction-pad {
        width: 120px;
        height: 120px;
    }
    
    .dir-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .fire-btn {
        width: 90px;
        height: 90px;
        font-size: 16px;
    }
}
