* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    touch-action: none; /* 禁止默认的触摸行为，如双指缩放 */
}

body {
    font-family: Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: #fff;
    overflow: hidden; /* 禁止滚动 */
    -webkit-user-select: none; /* 禁止选择文本 */
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.game-container {
    text-align: center;
    background: rgba(0, 0, 0, 0.7);
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    max-width: 100%;
    width: 100%;
    position: relative;
}

h1 {
    margin-bottom: 15px;
    font-size: 1.8em;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    word-wrap: break-word;
}

#gameCanvas {
    border: 3px solid #fff;
    border-radius: 5px;
    background-color: #000;
    margin: 15px 0;
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    margin-left: auto;
    margin-right: auto;
    max-height: 50vh; /* 进一步限制画布高度，适应移动设备 */
    object-fit: contain; /* 保持宽高比 */
}

.game-controls {
    margin: 15px 0;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

button {
    background: #667eea;
    color: white;
    border: none;
    padding: 12px 18px;
    margin: 5px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.3s;
    min-width: 80px;
    flex: 1;
    max-width: 120px;
}

button:hover {
    background: #5a6fd8;
}

.score-board {
    display: flex;
    justify-content: space-around;
    font-size: 1.2em;
    margin-top: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.score-board p {
    display: inline-block;
    margin: 5px 10px;
    min-width: 100px;
}

/* 移动设备适配 */
@media screen and (max-width: 768px) {
    body {
        align-items: stretch;
    }

    .game-container {
        min-height: 100dvh;
        height: 100dvh;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }

    h1 {
        font-size: 1.5em;
        flex-shrink: 0;
    }

    #gameCanvas {
        flex: 1 1 auto;
        height: 100%;
        max-height: none;
        margin: 10px 0;
    }
    
    button {
        padding: 10px 15px;
        font-size: 14px;
        min-width: 70px;
        max-width: 100px;
    }
    
    .game-controls,
    .score-board {
        flex-shrink: 0;
    }

    .score-board {
        font-size: 1em;
    }
    
    .game-container {
        padding: 10px;
    }
}

@media screen and (max-width: 480px) {
    h1 {
        font-size: 1.3em;
    }
    
    #gameCanvas {
        margin: 10px 0;
    }
    
    button {
        padding: 8px 12px;
        font-size: 12px;
        min-width: 60px;
        max-width: 80px;
    }
    
    .score-board p {
        margin: 5px;
        min-width: 80px;
        font-size: 0.9em;
    }
}
