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

body {
    font-family: 'Microsoft YaHei', sans-serif;
    line-height: 1.6;
    background: transparent;
    color: #333;
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
    padding-top: 5px;
}

/* 游戏容器样式 */
.game-container {
    max-width: 500px;  /* 从800px改为500px */
    margin: 5px auto;
    padding: 2rem;
    background: rgba(25, 25, 35, 0.2);
    backdrop-filter: blur(8px);
    border-radius: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

h1 {
    color: white;
    margin-bottom: 2rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    font-size: 2.5em;
    font-weight: bold;
    letter-spacing: 2px;
    text-align: center;
}

/* 游戏区域样式 */
.game-board {
    width: 400px;
    height: 400px;
    margin: 0 auto;
    background: rgba(35, 35, 45, 0.3);
    backdrop-filter: blur(8px);
    border-radius: 10px;
    position: relative;
    border: 2px solid rgba(255, 255, 255, 0.1);
    display: grid;
    grid-template-columns: repeat(20, 1fr);
    grid-template-rows: repeat(20, 1fr);
    background-image: linear-gradient(to right, rgba(0,0,0,0.05) 1px, transparent 1px),
                      linear-gradient(to bottom, rgba(0,0,0,0.05) 1px, transparent 1px);
    background-size: 5% 5%;
}

.start-guide {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.start-guide p {
    margin-bottom: 15px;
}

/* 游戏信息样式 */
.game-info {
    margin-top: 2rem;
    color: white;
}

.score-board {
    font-size: 1.5em;
    margin-bottom: 1rem;
    text-align: center;
}

.high-score {
    font-size: 0.8em;
    margin-top: 0.5rem;
    color: #f0f0f0;
}

/* 控制按钮样式 */
.controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 1rem 0;
}

.controls button {
    padding: 10px 20px;
    margin: 0 10px;
    border: none;
    border-radius: 5px;
    background: rgba(25, 25, 35, 0.4);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.controls button:hover {
    background: rgba(45, 45, 55, 0.6);
    transform: translateY(-2px);
}

.controls button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    opacity: 0.5;
}

/* 移动端控制按钮样式 */
.mobile-controls {
    display: block;
    margin-top: 2rem;
}

.mobile-control-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 5px 0;
}

.mobile-btn {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 5px;
    background: rgba(25, 25, 35, 0.4);
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mobile-btn:hover {
    background: rgba(45, 45, 55, 0.6);
}

/* 游戏消息样式 */
.game-message {
    margin-top: 1rem;
    color: white;
    text-align: center;
    padding: 10px;
}

/* 蛇和食物样式 */
.snake {
    background-color: #4CAF50;
    border: 1px solid #388E3C;
    border-radius: 2px;
    z-index: 2;
    animation: snakeMove 0.3s infinite alternate;
}

.snake-head {
    background-color: #388E3C;
    border-radius: 4px;
}

.food {
    background-color: #F44336;
    border-radius: 50%;
    z-index: 1;
    animation: foodBlink 1s infinite;
}

/* 方向指示样式 */
.snake-head.head-up {
    border-radius: 4px 4px 0 0;
}

.snake-head.head-down {
    border-radius: 0 0 4px 4px;
}

.snake-head.head-left {
    border-radius: 4px 0 0 4px;
}

.snake-head.head-right {
    border-radius: 0 4px 4px 0;
}

/* 游戏状态样式 */
.paused .game-board {
    opacity: 0.7;
    filter: grayscale(50%);
}

.game-over .game-board {
    opacity: 0.7;
}

.game-over {
    animation: gameOver 1s infinite;
}

/* 动画定义 */
@keyframes snakeMove {
    0% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

@keyframes foodBlink {
    0% { opacity: 0.8; }
    50% { opacity: 1; }
    100% { opacity: 0.8; }
}

@keyframes gameOver {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* 响应式设计 */
@media screen and (max-width: 768px) {
    .game-container {
        margin-top: 60px;
        padding: 1.5rem;
        max-width: 85%;
    }

    .game-board {
        width: 300px;
        height: 300px;
    }

    .controls {
        flex-wrap: wrap;
    }

    .controls button {
        margin: 5px;
        padding: 8px 16px;
    }
}

@media screen and (max-width: 480px) {
    .game-container {
        margin-top: 50px;
        padding: 1rem;
    }

    .game-board {
        width: 250px;
        height: 250px;
    }

    .mobile-controls {
        margin-top: 1rem;
    }

    .mobile-btn {
        width: 40px;
        height: 40px;
        font-size: 1.2em;
    }

    h1 {
        font-size: 2rem;
    }
}