* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #f0f0f0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.game-container {
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    padding: 20px;
    text-align: center;
    max-width: 500px;
    width: 100%;
}

h1 {
    color: #333;
    margin-bottom: 20px;
}

.game-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: bold;
}

.difficulty {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: bold;
}

.difficulty-buttons {
    display: flex;
    margin-left: 10px;
    gap: 5px;
}

.difficulty-btn {
    padding: 5px 10px;
    font-size: 14px;
    background-color: #e0e0e0;
    color: #333;
}

.difficulty-btn:hover {
    background-color: #d0d0d0;
}

.difficulty-btn.active {
    background-color: #4CAF50;
    color: white;
}

canvas {
    border: 2px solid #333;
    background-color: #f8f8f8;
    display: block;
    margin: 0 auto;
}

.controls {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

button {
    padding: 8px 16px;
    font-size: 16px;
    cursor: pointer;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #45a049;
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.instructions {
    margin-top: 20px;
    text-align: left;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 5px;
}

.instructions h2 {
    font-size: 18px;
    margin-bottom: 10px;
    color: #333;
}

.instructions p {
    margin-bottom: 5px;
    color: #555;
}

/* 游戏结束时的弹窗样式 */
.game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    z-index: 10;
}

.game-over h2 {
    font-size: 24px;
    margin-bottom: 10px;
}

.game-over p {
    margin-bottom: 15px;
}

.game-over button {
    background-color: #f44336;
}

.game-over button:hover {
    background-color: #d32f2f;
}

/* 触摸控制器样式 */
.touch-controls {
    display: none;
    margin: 20px auto;
    max-width: 200px;
}

.control-row {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.control-btn {
    width: 50px;
    height: 50px;
    font-size: 24px;
    font-weight: bold;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background-color 0.2s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.control-btn:active {
    background-color: #388E3C;
    transform: scale(0.95);
}

.control-btn:hover {
    background-color: #45a049;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .game-container {
        padding: 15px;
        max-width: 100%;
    }

    h1 {
        font-size: 24px;
        margin-bottom: 15px;
    }

    .game-info {
        font-size: 16px;
        margin-bottom: 10px;
    }

    .difficulty {
        font-size: 16px;
        flex-wrap: wrap;
        gap: 5px;
    }

    .difficulty-buttons {
        gap: 3px;
    }

    .difficulty-btn {
        padding: 4px 8px;
        font-size: 13px;
    }

    canvas {
        max-width: 100%;
        height: auto;
    }

    .controls {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 15px;
    }

    button {
        flex: 1;
        min-width: 80px;
        padding: 10px 12px;
        font-size: 14px;
    }

    .instructions {
        font-size: 14px;
        padding: 8px;
    }

    .instructions h2 {
        font-size: 16px;
    }

    /* 显示触摸控制器 */
    .touch-controls {
        display: block;
    }

    /* 隐藏游戏说明中的键盘提示 */
    .instructions p:first-child {
        display: none;
    }
}

@media (max-width: 480px) {
    .game-container {
        padding: 10px;
    }

    h1 {
        font-size: 20px;
        margin-bottom: 10px;
    }

    .game-info {
        font-size: 14px;
    }

    .difficulty {
        font-size: 14px;
        margin-bottom: 10px;
    }

    canvas {
        border-width: 1px;
    }

    .controls {
        flex-direction: column;
    }

    button {
        width: 100%;
        margin-bottom: 8px;
    }

    .control-btn {
        width: 45px;
        height: 45px;
        font-size: 20px;
    }

    .instructions {
        display: none;
    }
}

@media (max-width: 360px) {
    h1 {
        font-size: 18px;
    }

    .game-info {
        font-size: 12px;
    }

    .difficulty {
        font-size: 12px;
    }

    .difficulty-btn {
        padding: 3px 6px;
        font-size: 11px;
    }

    .control-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
}