/* 赛博朋克贪吃蛇游戏样式 */

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

body {
    font-family: 'Courier New', monospace;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #16213e 100%);
    color: #00ffff;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* 背景动画效果 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(120, 219, 255, 0.1) 0%, transparent 50%);
    animation: backgroundPulse 4s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: -1;
}

@keyframes backgroundPulse {
    0% { opacity: 0.3; }
    100% { opacity: 0.7; }
}

.game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 主标题 */
.game-title {
    text-align: center;
    font-size: 48px;
    font-weight: bold;
    background: linear-gradient(45deg, #00ffff, #ff00ff, #ffff00, #00ff00);
    background-size: 400% 400%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 3s ease-in-out infinite;
    text-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
    margin-bottom: 30px;
    letter-spacing: 4px;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* 主游戏区域布局 */
.game-main {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

/* 游戏画布区域 */
.game-area {
    flex: 1;
    position: relative;
    border: 2px solid #00ffff;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.8);
    box-shadow: 
        0 0 20px rgba(0, 255, 255, 0.3),
        inset 0 0 20px rgba(0, 255, 255, 0.1);
    overflow: hidden;
}

#gameCanvas {
    display: block;
    background: #000011;
    width: 100%;
    height: auto;
}

/* 开始界面蛇图案 */
.start-snake-pattern {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    gap: 2px;
    z-index: 10;
}

/* 蛇图案显示时的背景模糊效果 */
.game-area:has(.start-snake-pattern:not(.hidden))::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    z-index: 5;
}

/* 为不支持:has()的浏览器提供备用方案 */
.game-area.blur-background::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    z-index: 5;
}

.snake-block {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.6);
    animation: snakeGlow 2s ease-in-out infinite alternate;
}

.snake-block.head {
    background: #00ffff;
    position: relative;
}

.snake-block.head::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: 3px;
    height: 3px;
    background: #000;
    border-radius: 50%;
}

.snake-block.head::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 3px;
    height: 3px;
    background: #000;
    border-radius: 50%;
}

.snake-block.body {
    background: #00ff80;
}

.snake-block.tail {
    background: #0080ff;
}

@keyframes snakeGlow {
    0% { box-shadow: 0 0 10px rgba(0, 255, 255, 0.6); }
    100% { box-shadow: 0 0 20px rgba(0, 255, 255, 1); }
}

.start-snake-pattern.hidden {
    display: none;
}

/* 分数面板 */
.score-panel {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid #00ffff;
    border-radius: 8px;
    padding: 10px 15px;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.4);
}

.score-label {
    font-size: 12px;
    color: #00ffff;
    text-align: center;
    margin-bottom: 5px;
    letter-spacing: 1px;
}

.score-value {
    font-size: 24px;
    font-weight: bold;
    color: #00ff00;
    text-align: center;
    text-shadow: 0 0 10px rgba(0, 255, 0, 0.6);
}

.score-emoji {
    font-size: 20px;
    text-align: center;
    margin-top: 5px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.score-emoji.show {
    opacity: 1;
    animation: emojiPulse 0.6s ease-in-out;
}

@keyframes emojiPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* 游戏覆盖层 */
.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.game-overlay.show {
    display: flex;
}

.overlay-content {
    text-align: center;
    padding: 40px;
    border: 2px solid #ff0080;
    border-radius: 15px;
    background: rgba(0, 0, 0, 0.8);
    box-shadow: 0 0 30px rgba(255, 0, 128, 0.5);
}

.game-over-text {
    font-size: 36px;
    color: #ff0080;
    margin-bottom: 20px;
    text-shadow: 0 0 20px rgba(255, 0, 128, 0.8);
    animation: pulse 2s ease-in-out infinite;
}

.final-score {
    font-size: 24px;
    color: #00ffff;
    text-shadow: 0 0 15px rgba(0, 255, 255, 0.6);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* 控制面板 */
.control-panel {
    width: 280px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.control-section {
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid #00ffff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.2);
}

.section-title {
    font-size: 16px;
    color: #00ffff;
    margin-bottom: 15px;
    text-align: center;
    font-weight: bold;
    letter-spacing: 1px;
}

/* 控制按钮 */
.control-btn {
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.start-btn {
    background: linear-gradient(45deg, #00ff00, #00cc00);
    color: #000;
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.3);
}

.start-btn:hover {
    box-shadow: 0 0 25px rgba(0, 255, 0, 0.6);
    transform: translateY(-2px);
}

.pause-btn {
    background: linear-gradient(45deg, #ffaa00, #ff8800);
    color: #000;
    box-shadow: 0 0 15px rgba(255, 170, 0, 0.3);
}

.pause-btn:hover {
    box-shadow: 0 0 25px rgba(255, 170, 0, 0.6);
    transform: translateY(-2px);
}

.restart-btn {
    background: linear-gradient(45deg, #ff0080, #cc0066);
    color: #fff;
    box-shadow: 0 0 15px rgba(255, 0, 128, 0.3);
}

.restart-btn:hover {
    box-shadow: 0 0 25px rgba(255, 0, 128, 0.6);
    transform: translateY(-2px);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* 按键说明 */
.key-instruction {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.key-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(0, 255, 255, 0.2);
}

.key-row:last-child {
    border-bottom: none;
}

.key-label {
    color: #00ffff;
    font-size: 14px;
}

.key-symbol {
    color: #00ff00;
    font-weight: bold;
    font-size: 14px;
    text-shadow: 0 0 8px rgba(0, 255, 0, 0.5);
}

/* 底部背景面板 */
.background-panel {
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid #ff00ff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 0 20px rgba(255, 0, 255, 0.2);
}

.panel-title {
    font-size: 18px;
    color: #ff00ff;
    margin-bottom: 15px;
    text-align: center;
    font-weight: bold;
    letter-spacing: 1px;
}

.background-text {
    line-height: 1.6;
    color: #cccccc;
}

.background-text p {
    margin-bottom: 12px;
}

.background-text strong {
    color: #ffff00;
    text-shadow: 0 0 8px rgba(255, 255, 0, 0.4);
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .game-main {
        flex-direction: column;
    }
    
    .control-panel {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
    }
    
    .control-section {
        flex: 1;
        margin: 0 10px;
    }
}

@media (max-width: 768px) {
    .game-title {
        font-size: 32px;
    }
    
    .control-panel {
        flex-direction: column;
    }
    
    .control-section {
        margin: 0;
    }
    
    #gameCanvas {
        width: 100%;
        height: auto;
    }
}

/* 粒子效果动画 */
@keyframes particleFloat {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) rotate(360deg);
        opacity: 0;
    }
}

/* 霓虹灯闪烁效果 */
@keyframes neonFlicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.neon-flicker {
    animation: neonFlicker 2s ease-in-out infinite;
}