.snake-tool-wrapper { --p-bg: #ffffff; --p-border: #e2e8f0; --p-primary: #10b981; --p-text: #0f172a; width: 100%; max-width: 1000px; margin: 0 auto; background: var(--p-bg); border-radius: 24px; padding: 32px; border: 1px solid var(--p-border); box-shadow: 0 10px 25px -5px rgba(0,0,0,0.05); transition: 0.3s; display: flex; flex-direction: column; align-items: center; }
.snake-header-main { font-size: 1.5rem; font-weight: 900; background: linear-gradient(45deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; text-shadow: 0 0 30px rgba(255, 107, 107, 0.2); margin-bottom: 8px; display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; animation: snakeBounce 1s ease infinite; }
.snake-badge { background: #d1fae5; color: #047857; padding: 4px 12px; border-radius: 30px; font-size: 0.8rem; font-weight: 500; -webkit-text-fill-color: #047857; }
.snake-subtitle { color: #f59e0b; font-size: 1.1rem; padding-bottom: 16px; margin-bottom: 24px; text-align: center; width: 100%; font-weight: bold; }

@keyframes snakeBounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

/* 游戏运行环境隔离沙盒 */
.snake-game-env {
    position: relative;
    width: 100%;
    min-height: 550px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 10px;
    outline: none;
    user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
    box-shadow: inset 0 0 40px rgba(0,0,0,0.5);
}

.snake-bg-decoration {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 0;
}

.snake-star {
    position: absolute;
    background: white;
    border-radius: 50%;
    animation: snakeTwinkle 2s infinite;
}

@keyframes snakeTwinkle { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }

.snake-game-wrapper {
    position: relative;
    z-index: 10;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.snake-game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 600px;
    margin-bottom: 15px;
    padding: 0 10px;
}

.snake-score-display {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 10px 25px;
    border-radius: 50px;
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}
.snake-score-display span { font-size: 1.3rem; }

.snake-high-score {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    padding: 10px 20px;
    border-radius: 50px;
    color: white;
    font-weight: 700;
    font-size: 0.95rem;
    box-shadow: 0 5px 20px rgba(245, 87, 108, 0.4);
}

.snake-game-container {
    position: relative;
    background: linear-gradient(145deg, #1e3a5f 0%, #0d1b2a 100%);
    border-radius: 20px;
    padding: 15px;
    width: 100%;
    max-width: 630px;
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.1), 0 20px 60px rgba(0, 0, 0, 0.5);
}

#snakeGameCanvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 600 / 450;
    border-radius: 12px;
    background: linear-gradient(180deg, #0a1628 0%, #1a2f4a 100%);
}

.snake-shake { animation: snakeShake 0.3s ease-in-out; }
@keyframes snakeShake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-10px) rotate(-1deg); } 75% { transform: translateX(10px) rotate(1deg); } }

/* 遮罩层UI */
.snake-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(5px);
}
.snake-overlay.hidden { display: none; }

.snake-overlay-title { font-size: 2rem; font-weight: 900; margin-bottom: 20px; text-align: center; }
.snake-start-title { background: linear-gradient(45deg, #ff6b6b, #feca57); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.snake-gameover-title { background: linear-gradient(45deg, #ff4757, #ff6b81); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; animation: snakePulse 0.5s ease infinite; }

@keyframes snakePulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

.snake-final-score { font-size: 1.3rem; color: #feca57; margin-bottom: 10px; font-weight: bold; }
.snake-death-message { font-size: 1.1rem; color: #ff6b6b; margin-bottom: 20px; font-weight: 700; text-align: center; padding: 0 10px; }

.snake-start-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    padding: 12px 40px;
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
    font-family: inherit;
}
.snake-start-btn:hover { transform: translateY(-3px) scale(1.05); box-shadow: 0 15px 40px rgba(102, 126, 234, 0.6); }
.snake-start-btn:active { transform: translateY(0) scale(0.98); }

.snake-instructions { color: #a0a0a0; font-size: 0.85rem; margin-top: 20px; text-align: center; line-height: 1.6; }
.snake-instructions kbd, .snake-control-key kbd { background: #333; padding: 3px 8px; border-radius: 5px; font-family: monospace; color: white; border: 1px solid #555; }

.snake-emoji-bubble { position: fixed; font-size: 2.5rem; pointer-events: none; animation: snakeFloatUp 1s ease-out forwards; z-index: 1000; }
@keyframes snakeFloatUp { 0% { opacity: 1; transform: translateY(0) scale(1); } 100% { opacity: 0; transform: translateY(-80px) scale(1.5); } }

.snake-combo-popup { position: absolute; font-size: 1.8rem; font-weight: 900; color: #feca57; text-shadow: 0 0 20px rgba(254, 202, 87, 0.8); pointer-events: none; animation: snakeComboAnim 0.8s ease-out forwards; z-index: 50; }
@keyframes snakeComboAnim { 0% { opacity: 1; transform: scale(0.5); } 50% { transform: scale(1.2); } 100% { opacity: 0; transform: scale(1) translateY(-50px); } }

.snake-speed-indicator { position: absolute; top: -15px; right: 20px; background: linear-gradient(135deg, #ff6b6b, #ee5a24); padding: 5px 15px; border-radius: 20px; color: white; font-size: 0.8rem; font-weight: 700; opacity: 0; transition: opacity 0.3s; z-index: 20; box-shadow: 0 4px 10px rgba(238, 90, 36, 0.5); }
.snake-speed-indicator.visible { opacity: 1; }

.snake-controls-hint { display: flex; gap: 15px; margin-top: 15px; flex-wrap: wrap; justify-content: center; z-index: 10; width: 100%; max-width: 600px; }
.snake-control-key { background: rgba(255, 255, 255, 0.1); padding: 8px 15px; border-radius: 10px; color: #cbd5e1; font-size: 0.85rem; display: flex; align-items: center; gap: 8px; border: 1px solid rgba(255,255,255,0.1); }

@media (max-width: 650px) {
    .snake-game-env { padding: 10px 5px; min-height: 400px; }
    .snake-score-display { padding: 8px 15px; font-size: 0.95rem; }
    .snake-high-score { padding: 8px 12px; font-size: 0.85rem; }
    .snake-game-container { padding: 8px; border-radius: 12px; }
    .snake-controls-hint { display: none; }
}

[data-theme="dark"] .snake-tool-wrapper { background: #1e293b !important; border-color: #334155 !important; }
[data-theme="dark"] .snake-subtitle { border-bottom-color: #334155; }