/* 贪食蛇游戏样式 */

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    color: #fff;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden; /* 禁止页面滚动 */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    height: 100vh; /* 100% 视窗高度 */
    overflow: hidden; /* 容器也禁止滚动 */
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

h1 {
    font-size: 2.8rem;
    margin-bottom: 10px;
    color: #00ffcc;
    text-shadow: 0 0 10px rgba(0, 255, 204, 0.5);
}

.subtitle {
    font-size: 1.2rem;
    color: #aaa;
}

.game-area {
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: rgba(20, 20, 40, 0.7);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    height: calc(100vh - 120px); /* 适应屏幕高度 */
    overflow: hidden; /* 禁止滚动 */
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
}

.score-display, .level-display {
    display: flex;
    align-items: center;
    gap: 10px;
}

.score-label, .level-label {
    font-size: 1.1rem;
    color: #bbb;
}

.score-value, .level-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: #ffcc00;
}

.status {
    font-size: 1.2rem;
    padding: 8px 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.game-board {
    display: flex;
    justify-content: center;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    margin-bottom: 10px;
}

#gameCanvas {
    border: 3px solid #333;
    border-radius: 10px;
    background-color: #0a0a1a;
    box-shadow: 0 0 20px rgba(0, 255, 204, 0.3);
}

.controls {
    padding: 20px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 10px;
}

.controls h3 {
    margin-bottom: 15px;
    color: #00ffcc;
    font-size: 1.5rem;
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.control-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    transition: transform 0.2s;
}

.control-item:hover {
    transform: translateY(-3px);
    background: rgba(255, 255, 255, 0.15);
}

.key {
    font-size: 1.8rem;
    font-weight: bold;
    color: #ffcc00;
    padding: 8px 12px;
    background: rgba(255, 204, 0, 0.2);
    border-radius: 5px;
    border: 1px solid rgba(255, 204, 0, 0.3);
}

.description {
    font-size: 0.9rem;
    color: #aaa;
}

.buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 15px;
    margin-bottom: 10px;
}

.btn {
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.start-btn {
    background: linear-gradient(135deg, #00cc66, #00aa55);
    color: white;
}

.start-btn:hover {
    background: linear-gradient(135deg, #00dd77, #00bb66);
    box-shadow: 0 5px 15px rgba(0, 204, 102, 0.4);
}

.pause-btn {
    background: linear-gradient(135deg, #ff9900, #cc7700);
    color: white;
}

.pause-btn:hover {
    background: linear-gradient(135deg, #ffaa33, #dd8800);
    box-shadow: 0 5px 15px rgba(255, 153, 0, 0.4);
}

.restart-btn {
    background: linear-gradient(135deg, #ff3366, #cc0044);
    color: white;
}

.restart-btn:hover {
    background: linear-gradient(135deg, #ff5588, #dd0055);
    box-shadow: 0 5px 15px rgba(255, 51, 102, 0.4);
}

.instructions {
    background: rgba(20, 20, 40, 0.7);
    padding: 15px;
    border-radius: 15px;
    margin-bottom: 15px;
}

.instructions h2 {
    margin-bottom: 15px;
    color: #00ffcc;
}

.instructions ul {
    list-style-type: none;
    padding-left: 15px;
}

.instructions li {
    margin-bottom: 12px;
    padding-left: 20px;
    position: relative;
}

.instructions li::before {
    content: "•";
    color: #00ffcc;
    position: absolute;
    left: 0;
    font-size: 1.2rem;
}

footer {
    text-align: center;
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    color: #aaa;
    margin-top: 10px;
}

footer p {
    margin-bottom: 15px;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.footer-links a {
    color: #00ffcc;
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: #ffcc00;
    text-decoration: underline;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .game-info {
        flex-direction: column;
        gap: 15px;
    }
    
    .control-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    #gameCanvas {
        width: 100%;
        max-width: 500px;
        max-height: 350px;
    }
    
    .buttons {
        flex-direction: row;
        gap: 10px;
    }
    
    .btn {
        width: auto;
        justify-content: center;
        padding: 10px 15px;
    }
}

@media (max-width: 480px) {
    .control-grid {
        grid-template-columns: 1fr;
    }
}

/* Canvas 聚焦提示 */
.canvas-tip {
    margin-top: 10px;
    font-size: 0.9rem;
    color: #ffcc00;
    text-align: center;
    padding: 8px 12px;
    background: rgba(255, 204, 0, 0.1);
    border-radius: 5px;
    border: 1px solid rgba(255, 204, 0, 0.2);
}

.canvas-tip i {
    margin-right: 5px;
}

/* Canvas 焦点状态 */
#gameCanvas:focus {
    border-color: #00ffcc;
    box-shadow: 0 0 25px rgba(0, 255, 204, 0.5);
}

/* 减少Canvas大小以适应一个页面 */
#gameCanvas {
    width: 500px;
    height: 350px;
}

/* 更紧密的布局 */
.game-info {
    margin-bottom: 10px;
    padding: 10px 15px;
}

    padding: 12px 24px;
    font-size: 1rem;
}

/* 去掉页面滚动 */
body {
    overflow-y: hidden;

.container {
    overflow-y: hidden;
    max-height: 100vh;
}