* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #222;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-x: auto;
}

.game-container {
    text-align: center;
    background-color: #333;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

#gameCanvas {
    border: 3px solid #666;
    border-radius: 5px;
    background-color: #2d2d2d;
    max-width: 100%;
    height: auto;
}

.controls {
    margin-top: 20px;
    display: flex;
    justify-content: space-around;
    color: #fff;
}

.player1, .player2 {
    background-color: #444;
    padding: 10px 20px;
    border-radius: 5px;
}

.player1 h3 {
    color: #4af;
}

.player2 h3 {
    color: #f44;
}

.player1 p, .player2 p {
    font-size: 12px;
    margin-top: 5px;
    color: #ccc;
}

.game-info {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    color: #fff;
    font-size: 14px;
}

.game-info span {
    background-color: #444;
    padding: 5px 10px;
    border-radius: 5px;
    white-space: nowrap;
}

.score-info {
    display: none;
}

.strategy-info {
    display: none;
}

.p1-strategy {
    background-color: #4af;
    color: #fff;
    padding: 8px 20px;
    border-radius: 5px;
    font-weight: bold;
}

.p2-strategy {
    background-color: #f44;
    color: #fff;
    padding: 8px 20px;
    border-radius: 5px;
    font-weight: bold;
}

.cannot-attack {
    color: #ff6b6b;
}

.can-attack {
    color: #6bff6b;
}

.start-menu {
    text-align: center;
    background-color: #333;
    padding: 40px 60px;
    border-radius: 15px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
    color: #fff;
}

.start-menu h1 {
    font-size: 48px;
    margin-bottom: 40px;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.menu-section {
    margin-bottom: 25px;
    text-align: left;
}

.menu-section label {
    display: block;
    font-size: 18px;
    margin-bottom: 10px;
    color: #aaa;
}

.button-group {
    display: flex;
    gap: 10px;
}

.option-btn {
    padding: 12px 24px;
    font-size: 16px;
    border: 2px solid #555;
    background-color: #444;
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.option-btn:hover {
    border-color: #888;
    background-color: #555;
}

.option-btn.active {
    border-color: #ffd700;
    background-color: #ffd700;
    color: #333;
    font-weight: bold;
}

.start-button {
    margin-top: 30px;
    padding: 15px 60px;
    font-size: 24px;
    border: none;
    background-color: #4caf50;
    color: #fff;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.start-button:hover {
    background-color: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.hidden {
    display: none !important;
}

/* ---------- 手机虚拟按键 ---------- */
.touch-controls {
    display: none;
}

/* 触屏设备或窄屏：收起键盘说明，换成虚拟按键 */
@media (pointer: coarse), (max-width: 820px) {
    body {
        align-items: flex-start;
        overflow-x: hidden;
    }

    .start-menu {
        width: 100%;
        padding: 20px 16px;
    }
    .start-menu h1 {
        font-size: 30px;
        margin-bottom: 20px;
    }
    .menu-section {
        margin-bottom: 18px;
    }
    .button-group {
        flex-wrap: wrap;
    }
    .option-btn {
        flex: 1 1 auto;
        padding: 10px 14px;
        font-size: 15px;
    }
    .start-button {
        width: 100%;
        margin-top: 18px;
        padding: 15px;
        font-size: 20px;
    }

    .game-container {
        width: 100%;
        padding: 8px;
        border-radius: 0;
    }
    .controls {
        display: none;
    }
    #gameCanvas {
        max-height: 56vh;
    }
    .game-info {
        margin-top: 8px;
        gap: 6px;
        font-size: 12px;
    }
    .game-info span {
        padding: 3px 7px;
    }

    .touch-controls {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 14px;
        margin-top: 10px;
        padding: 0 4px max(6px, env(safe-area-inset-bottom));
        touch-action: none;
        -webkit-user-select: none;
        user-select: none;
    }
    .tc-pad {
        display: grid;
        grid-template-columns: repeat(3, 54px);
        grid-template-rows: repeat(2, 54px);
        gap: 6px;
    }
    .tc-up    { grid-column: 2; grid-row: 1; }
    .tc-left  { grid-column: 1; grid-row: 2; }
    .tc-down  { grid-column: 2; grid-row: 2; }
    .tc-right { grid-column: 3; grid-row: 2; }
    .tc-actions {
        display: flex;
        align-items: center;
        gap: 12px;
    }
    .tc-btn {
        border: 2px solid #666;
        background: rgba(68, 68, 68, .92);
        color: #fff;
        border-radius: 12px;
        font-family: inherit;
        font-size: 18px;
        line-height: 1;
        cursor: pointer;
        touch-action: none;
        -webkit-tap-highlight-color: transparent;
    }
    .tc-btn.active {
        background: #ffd700;
        border-color: #ffd700;
        color: #333;
    }
    .tc-skill {
        width: 62px;
        height: 62px;
        border-radius: 50%;
        font-size: 15px;
    }
    .tc-fire {
        width: 86px;
        height: 86px;
        border-radius: 50%;
        font-size: 20px;
        font-weight: bold;
    }
}