/* 通用样式 */
* {
    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;
    color: #333;
}

.game-container {
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    padding: 20px;
    text-align: center;
    max-width: 400px;
    width: 100%;
}

h1 {
    color: #333;
    margin-bottom: 20px;
    font-size: 28px;
}

.game-area {
    margin: 0 auto 20px;
    background-color: #000;
    border-radius: 5px;
    padding: 5px;
    display: inline-block;
}

#snakeCanvas {
    display: block;
    background-color: #1a1a1a;
}

.game-controls {
    margin-bottom: 20px;
}

.btn {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 10px 20px;
    margin: 0 5px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.btn:hover {
    background-color: #0056b3;
}

.btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.game-instructions {
    background-color: #f5f5f5;
    padding: 15px;
    border-radius: 5px;
}

.game-instructions h3 {
    margin-bottom: 10px;
    font-size: 16px;
}

.game-instructions p {
    font-size: 12px;
    margin-bottom: 5px;
    line-height: 1.5;
}

/* 贪吃蛇游戏特定样式 */
.back-button {
    position: absolute;
    top: 20px;
    left: 20px;
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
}

.back-button:hover {
    background-color: #5a6268;
}

.snake-score-panel {
    background-color: #f5f5f5;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.snake-score-panel p {
    margin: 5px 0;
    font-size: 16px;
}

.snake-score-panel span {
    font-weight: bold;
    color: #28a745;
}

/* 速度控制样式 */
.speed-control {
    margin: 15px 0;
    padding: 10px;
    background-color: #f5f5f5;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.speed-control label {
    font-size: 14px;
    font-weight: 500;
    min-width: 80px;
}

.speed-control input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 150px;
    height: 5px;
    background: #ddd;
    border-radius: 3px;
    outline: none;
}

.speed-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #007bff;
    border-radius: 50%;
    cursor: pointer;
}

.speed-control input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #007bff;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.speed-control span {
    font-size: 14px;
    font-weight: bold;
    color: #007bff;
    min-width: 30px;
    text-align: center;
}

@media (max-width: 420px) {
    .game-container {
        padding: 15px;
    }
    
    h1 {
        font-size: 24px;
    }
    
    #snakeCanvas {
        width: 100%;
        height: auto;
    }
}