/* 重置默认样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #87CEEB 0%, #98FB98 50%, #F0E68C 100%);
    min-height: 100vh;
    margin: 0;
    padding: 20px 0;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* 改为flex-start，避免垂直居中 */
    overflow-x: hidden; /* 只禁用水平滚动 */
    overflow-y: auto; /* 允许垂直滚动 */
}

.game-container {
    text-align: center;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    max-width: 600px;
    width: 100%;
    margin: 20px auto;
    min-height: auto; /* 移除固定高度限制 */
}

.game-header {
    margin-bottom: 15px;
}

.game-header h1 {
    color: #2E8B57;
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    font-weight: bold;
}

.score-board {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 1.1em;
    font-weight: bold;
}

#score, #high-score {
    color: #FF6347;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

#gameCanvas {
    border: 3px solid #2E8B57;
    border-radius: 10px;
    background: linear-gradient(180deg, #87CEEB 0%, #E0F6FF 50%, #F0F8FF 100%);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    display: block;
    margin: 0 auto;
}

.game-controls {
    margin-top: 20px;
    margin-bottom: 20px; /* 添加底部边距 */
}

.instructions {
    background: rgba(46, 139, 87, 0.1);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    border: 2px solid #2E8B57;
}

.instructions p {
    color: #2E8B57;
    font-weight: bold;
    margin-bottom: 5px;
}

.game-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 20px; /* 添加底部边距 */
}

button {
    background: linear-gradient(45deg, #32CD32, #228B22);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(50, 205, 50, 0.3);
}

button:hover {
    background: linear-gradient(45deg, #228B22, #32CD32);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(50, 205, 50, 0.4);
}

button:active {
    transform: translateY(0);
}

.game-over {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    text-align: center;
    border: 3px solid #FF6347;
    max-width: 90vw; /* 确保不超出屏幕 */
    max-height: 90vh; /* 确保不超出屏幕 */
    overflow-y: auto; /* 内容过多时允许滚动 */
}

.game-over h2 {
    color: #FF6347;
    font-size: 2em;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.game-over p {
    font-size: 1.3em;
    margin-bottom: 20px;
    color: #2E8B57;
    font-weight: bold;
}

#playAgainBtn {
    background: linear-gradient(45deg, #FF6347, #FF4500);
    font-size: 1.1em;
    padding: 15px 30px;
}

#playAgainBtn:hover {
    background: linear-gradient(45deg, #FF4500, #FF6347);
}

/* 响应式设计 */
@media (max-width: 768px) {
    body {
        padding: 10px 0;
    }
    
    .game-container {
        padding: 15px;
        margin: 10px;
        max-width: none;
    }
    
    .game-header h1 {
        font-size: 2em;
    }
    
    #gameCanvas {
        width: 400px;
        height: 533px;
        max-width: calc(100vw - 40px); /* 确保不超出屏幕 */
        height: auto; /* 保持宽高比 */
    }
    
    .score-board {
        font-size: 1em;
    }
    
    .instructions p {
        font-size: 0.9em;
    }
    
    button {
        padding: 10px 20px;
        font-size: 0.9em;
    }
}

@media (max-width: 480px) {
    body {
        padding: 5px 0;
    }
    
    .game-container {
        margin: 5px;
        padding: 10px;
    }
    
    #gameCanvas {
        width: 360px;
        height: 480px;
        max-width: calc(100vw - 30px);
        height: auto;
    }
    
    .game-header h1 {
        font-size: 1.7em;
    }
    
    .game-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    button {
        width: 200px;
        margin: 5px 0;
    }
    
    .instructions {
        padding: 10px;
    }
    
    .instructions p {
        font-size: 0.85em;
    }
}