* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700&display=swap');

:root {
    --primary-color: #3498db;
    --primary-dark: #2980b9;
    --secondary-color: #2ecc71;
    --secondary-dark: #27ae60;
    --danger-color: #e74c3c;
    --danger-dark: #c0392b;
    --dark-color: #2c3e50;
    --light-color: #ecf0f1;
    --gradient-bg: linear-gradient(135deg, #1a2a3a 0%, #2c3e50 100%);
    --box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    --text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

body {
    font-family: 'Noto Sans SC', 'Microsoft YaHei', Arial, sans-serif;
    background: var(--gradient-bg);
    color: var(--light-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M54.627 0l.83.828-1.415 1.415L51.8 0h2.827zM5.373 0l-.83.828L5.96 2.243 8.2 0H5.374zM48.97 0l3.657 3.657-1.414 1.414L46.143 0h2.828zM11.03 0L7.372 3.657 8.787 5.07 13.857 0H11.03zm32.284 0L49.8 6.485 48.384 7.9l-7.9-7.9h2.83zM16.686 0L10.2 6.485 11.616 7.9l7.9-7.9h-2.83zm20.97 0l9.315 9.314-1.414 1.414L34.828 0h2.83zM22.344 0L13.03 9.314l1.414 1.414L25.172 0h-2.83zM32 0l12.142 12.142-1.414 1.414L30 .828 17.272 13.556l-1.414-1.414L28 0h4zM.284 0l28 28-1.414 1.414L0 2.544V0h.284zM0 5.373l25.456 25.455-1.414 1.415L0 8.2V5.374zm0 5.656l22.627 22.627-1.414 1.414L0 13.86v-2.83zm0 5.656l19.8 19.8-1.415 1.413L0 19.514v-2.83zm0 5.657l16.97 16.97-1.414 1.415L0 25.172v-2.83zM0 28l14.142 14.142-1.414 1.414L0 30.828V28zm0 5.657L11.314 44.97 9.9 46.386l-9.9-9.9v-2.828zm0 5.657L8.485 47.8 7.07 49.212 0 42.143v-2.83zm0 5.657l5.657 5.657-1.414 1.415L0 47.8v-2.83zm0 5.657l2.828 2.83-1.414 1.413L0 53.456v-2.83zM54.627 60L30 35.373 5.373 60H8.2L30 38.2 51.8 60h2.827zm-5.656 0L30 41.03 11.03 60h2.828L30 43.858 46.142 60h2.83zm-5.656 0L30 46.686 16.686 60h2.83L30 49.515 40.485 60h2.83zm-5.657 0L30 52.343 22.344 60h2.83L30 55.172 34.828 60h2.83zM32 60l-2-2-2 2h4zM59.716 0l-28 28 1.414 1.414L60 2.544V0h-.284zM60 5.373L34.544 30.828l1.414 1.415L60 8.2V5.374zm0 5.656L37.373 33.656l1.414 1.414L60 13.86v-2.83zm0 5.656l-19.8 19.8 1.415 1.413L60 19.514v-2.83zm0 5.657l-16.97 16.97 1.414 1.415L60 25.172v-2.83zM60 28L45.858 42.142l1.414 1.414L60 30.828V28zm0 5.657L48.686 44.97l1.415 1.415 9.9-9.9v-2.828zm0 5.657L51.515 47.8l1.414 1.413 7.07-7.07v-2.83zm0 5.657l-5.657 5.657 1.414 1.415L60 47.8v-2.83zm0 5.657l-2.828 2.83 1.414 1.413L60 53.456v-2.83zM39.9 16.385l1.414-1.414L30 3.658 18.686 14.97l1.415 1.415 9.9-9.9 9.9 9.9zm-2.83 2.828l1.415-1.414L30 9.313 21.515 17.8l1.414 1.413L30 11.8l7.07 7.414v-.002zm-2.827 2.83l1.414-1.416L30 14.97l-5.657 5.657 1.414 1.415L30 17.8l4.243 4.242zm-2.83 2.827l1.415-1.414L30 20.626l-2.828 2.83 1.414 1.414L30 23.456l1.414 1.414zM56.87 59.414L58.284 58 30 29.716 1.716 58l1.414 1.414L30 32.544l26.87 26.87z' fill='%2327415c' fill-opacity='0.08' fill-rule='evenodd'/%3E%3C/svg%3E"),
        radial-gradient(circle at 10% 20%, rgba(30, 55, 80, 0.08) 0%, transparent 40%);
    pointer-events: none;
    z-index: -1;
    opacity: 0.8;
}

body::after {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(52, 152, 219, 0.02) 0%, transparent 40%);
    animation: rotateBackground 60s linear infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes rotateBackground {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.game-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    backdrop-filter: blur(10px);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px;
    flex: 1;
    position: relative;
    z-index: 1;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

header::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    height: 2px;
    width: 100%;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(52, 152, 219, 0.2) 25%, 
        rgba(52, 152, 219, 0.5) 50%, 
        rgba(52, 152, 219, 0.2) 75%, 
        transparent 100%);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -100% 0;
    }
    100% {
        background-position: 100% 0;
    }
}

.title-container {
    position: relative;
}

header h1 {
    font-size: 2.8rem;
    color: var(--light-color);
    text-shadow: var(--text-shadow);
    position: relative;
    display: inline-block;
    letter-spacing: 1px;
}

.title-icon {
    display: inline-flex;
    margin-left: 15px;
    font-size: 0.7em;
    color: var(--secondary-color);
    animation: pulse 2s infinite;
    position: relative;
}

.title-icon::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: rgba(46, 204, 113, 0.2);
    border-radius: 50%;
    filter: blur(10px);
    animation: glowPulse 2s infinite alternate;
}

@keyframes glowPulse {
    0% {
        transform: scale(0.8);
        opacity: 0.3;
    }
    100% {
        transform: scale(1.5);
        opacity: 0.6;
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.score-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    padding: 15px 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    backdrop-filter: blur(10px);
    overflow: hidden;
}

.score-container::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        to bottom right,
        rgba(255, 255, 255, 0),
        rgba(255, 255, 255, 0),
        rgba(255, 255, 255, 0.1),
        rgba(255, 255, 255, 0)
    );
    transform: rotate(30deg);
    animation: shine 6s linear infinite;
}

@keyframes shine {
    0% {
        transform: rotate(30deg) translate(-100%, -100%);
    }
    100% {
        transform: rotate(30deg) translate(100%, 100%);
    }
}

.score-label {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 5px;
}

#score {
    font-size: 2.8rem;
    font-weight: bold;
    color: var(--primary-color);
    text-shadow: 0 0 10px rgba(52, 152, 219, 0.5);
    transition: var(--transition);
}

.main-content {
    display: flex;
    justify-content: space-between;
    gap: 30px;
    margin-bottom: 30px;
}

.game-container {
    flex: 1;
    display: flex;
    justify-content: center;
}

.game-board {
    position: relative;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--box-shadow), 0 0 20px rgba(52, 152, 219, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    background-color: rgba(0, 0, 0, 0.4);
    transition: var(--transition);
    transform-style: preserve-3d;
    perspective: 1000px;
}

.game-board::after {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border-radius: calc(var(--border-radius) + 5px);
    background: transparent;
    border: 2px solid transparent;
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: -1;
}

.game-board:hover::after {
    opacity: 1;
}

.game-board:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25), 0 0 30px rgba(52, 152, 219, 0.3);
}

#game-canvas {
    background-color: rgba(14, 27, 40, 0.9);
    display: block;
    transition: var(--transition);
    border: 1px solid rgba(52, 152, 219, 0.3);
}

.canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.5s ease;
}

.canvas-overlay[style*="flex"] {
    opacity: 1;
}

.sidebar {
    width: 350px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.controls-panel, .instructions {
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--border-radius);
    padding: 25px;
    box-shadow: var(--box-shadow);
    border: 1px solid rgba(52, 152, 219, 0.1);
    backdrop-filter: blur(10px);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.controls-panel::before, .instructions::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: var(--border-radius);
    background: linear-gradient(45deg, 
        rgba(52, 152, 219, 0.05), 
        rgba(52, 152, 219, 0), 
        rgba(52, 152, 219, 0.05), 
        rgba(52, 152, 219, 0));
    background-size: 400% 400%;
    animation: gradientBorder 8s ease infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes gradientBorder {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.controls-panel:hover, .instructions:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25);
    border-color: rgba(52, 152, 219, 0.3);
}

.sidebar h3 {
    color: var(--light-color);
    margin-bottom: 20px;
    font-size: 1.3rem;
    font-weight: 500;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar h3 i {
    color: var(--primary-color);
    text-shadow: 0 0 10px rgba(52, 152, 219, 0.5);
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

button {
    padding: 15px 20px;
    font-size: 1rem;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    font-weight: bold;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: white;
}

button i {
    font-size: 1.1rem;
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: 0.5s;
}

button:hover::before {
    left: 100%;
}

button:active {
    transform: scale(0.95);
}

#start-btn {
    background: linear-gradient(135deg, var(--secondary-color), var(--secondary-dark));
}

#start-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(46, 204, 113, 0.3);
}

#pause-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
}

#pause-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(52, 152, 219, 0.3);
}

.difficulty {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.difficulty label {
    color: var(--light-color);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.difficulty label i {
    color: var(--secondary-color);
}

select {
    padding: 10px 20px;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background-color: rgba(0, 0, 0, 0.3);
    color: var(--light-color);
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: var(--transition);
    flex: 1;
}

select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.instructions p {
    margin-bottom: 20px;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.8);
}

/* 方向键样式 */
.key-controls {
    margin-top: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.key-tip {
    margin-bottom: 15px;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.8);
}

.arrow-keys {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.key-row {
    display: flex;
    gap: 8px;
}

.key {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #2c3e50, #1a2530);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: var(--transition);
    user-select: none;
    color: var(--light-color);
}

.key i {
    font-size: 1.2rem;
    transition: var(--transition);
}

.key:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.3);
    background: linear-gradient(135deg, #34495e, #2c3e50);
}

.key:hover i {
    color: var(--primary-color);
    transform: scale(1.2);
}

.up-key:hover i, .down-key:hover i, .left-key:hover i, .right-key:hover i {
    color: var(--primary-color);
    text-shadow: 0 0 10px rgba(52, 152, 219, 0.5);
}

/* 游戏消息样式 */
#game-message {
    background: rgba(0, 0, 0, 0.85);
    color: white;
    text-align: center;
    flex-direction: column;
    border-radius: var(--border-radius);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(52, 152, 219, 0.2);
    transform: scale(0.9);
    opacity: 0;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.5s ease;
    box-shadow: 0 0 30px rgba(52, 152, 219, 0.2);
}

#game-message[style*="flex"] {
    transform: scale(1);
    opacity: 1;
}

.welcome-screen, .pause-screen, .game-over-screen {
    padding: 40px;
    max-width: 80%;
    animation: fadeIn 0.5s forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.welcome-screen h2, .pause-screen h2, .game-over-screen h2 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: var(--primary-color);
    text-shadow: 0 0 15px rgba(52, 152, 219, 0.5);
    letter-spacing: 2px;
    animation: glow 2s infinite alternate;
}

@keyframes glow {
    from {
        text-shadow: 0 0 5px rgba(52, 152, 219, 0.5);
    }
    to {
        text-shadow: 0 0 20px rgba(52, 152, 219, 0.8);
    }
}

.game-over-screen h2 {
    color: var(--danger-color);
    text-shadow: 0 0 15px rgba(231, 76, 60, 0.5);
    animation: shakeText 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shakeText {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.welcome-screen p, .pause-screen p, .game-over-screen p {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.6;
}

.welcome-screen .small {
    font-size: 1rem;
    opacity: 0.8;
    margin-top: 15px;
}

.final-score {
    font-size: 2.5rem !important;
    font-weight: bold;
    color: var(--secondary-color) !important;
    margin: 15px 0 20px !important;
    text-shadow: 0 0 15px rgba(46, 204, 113, 0.5);
    animation: pulseText 1s infinite alternate;
}

@keyframes pulseText {
    from {
        transform: scale(1);
    }
    to {
        transform: scale(1.05);
    }
}

.arrow-hint {
    font-size: 1.5rem;
    letter-spacing: 10px;
    margin-top: 20px;
    color: var(--primary-color);
    animation: bounceArrows 1s infinite alternate;
}

@keyframes bounceArrows {
    to {
        transform: translateY(-5px);
    }
}

/* 吃食物动画 */
.score-popup {
    position: absolute;
    color: var(--secondary-color);
    font-weight: bold;
    font-size: 1.5rem;
    pointer-events: none;
    animation: floatUp 1s ease-out;
    z-index: 100;
    text-shadow: 0 0 10px rgba(46, 204, 113, 0.8);
}

@keyframes floatUp {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-80px) scale(1.8);
        opacity: 0;
    }
}

.fade-out {
    animation: fadeOut 0.5s forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
    }
}

/* 添加新的炫酷动画效果 */
@keyframes snakeMovement {
    0% {
        transform: rotate(0deg) translateX(2px);
    }
    50% {
        transform: rotate(0deg) translateX(-2px);
    }
    100% {
        transform: rotate(0deg) translateX(2px);
    }
}

footer {
    background-color: rgba(0, 0, 0, 0.5);
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    padding: 20px 0;
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.beian-info {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.beian-info span {
    opacity: 0.8;
}

.beian-info a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
    position: relative;
    padding-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.beian-info a i {
    font-size: 0.9rem;
}

.beian-info a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 1px;
    bottom: 0;
    left: 0;
    background-color: var(--primary-color);
    transition: width 0.3s;
}

.beian-info a:hover {
    color: var(--primary-color);
    text-shadow: 0 0 8px rgba(52, 152, 219, 0.5);
}

.beian-info a:hover::after {
    width: 100%;
}

@media (max-width: 1200px) {
    .main-content {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
    }
    
    .container {
        padding: 15px;
    }
    
    #game-canvas {
        width: 100%;
        height: auto;
    }
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 20px;
    }
    
    .score-container {
        width: 100%;
    }
    
    .controls {
        flex-direction: column;
        align-items: center;
    }
}

/* 添加游戏启动和分数脉冲动画 */
.pulse-animation {
    animation: pulse-effect 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}

@keyframes pulse-effect {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.game-start-animation {
    animation: gameStart 1s ease-out;
}

@keyframes gameStart {
    0% {
        transform: scale(0.9);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
} 