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

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background: linear-gradient(135deg, #0f4c75, #3282b8, #bbe1fa);
    min-height: 100vh;
    color: #fff;
    padding: 20px;
    user-select: none;
}

.game-container {
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 25px;
    backdrop-filter: blur(10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.game-header {
    text-align: center;
    margin-bottom: 25px;
}

.game-header h1 {
    font-size: 2.5em;
    margin-bottom: 20px;
    color: #3282b8;
    text-shadow: 0 0 20px rgba(50, 130, 184, 0.5);
    font-weight: bold;
}

.game-stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 12px;
    border: 2px solid rgba(50, 130, 184, 0.3);
}

.stat {
    text-align: center;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 80px;
}

.stat-label {
    font-size: 0.9em;
    color: #bbb;
    margin-bottom: 5px;
    font-weight: 600;
}

.stat-value {
    font-size: 1.4em;
    font-weight: bold;
    color: #3282b8;
    text-shadow: 0 0 10px rgba(50, 130, 184, 0.3);
}

.mode-selector, .difficulty-selector {
    margin-bottom: 25px;
    text-align: center;
}

.mode-selector h3, .difficulty-selector h3 {
    color: #fff;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.mode-buttons, .difficulty-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.mode-btn, .difficulty-btn {
    padding: 12px 18px;
    border: 3px solid rgba(50, 130, 184, 0.3);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    min-width: 120px;
}

.mode-btn:hover, .difficulty-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(50, 130, 184, 0.3);
    border-color: #3282b8;
}

.mode-btn.active, .difficulty-btn.active {
    border-color: #3282b8;
    background: linear-gradient(135deg, #3282b8, #0f4c75);
    color: white;
    box-shadow: 0 0 20px rgba(50, 130, 184, 0.4);
}

.mode-btn span, .difficulty-btn span {
    font-size: 1.5em;
    display: block;
    margin-bottom: 5px;
}

.mode-btn div, .difficulty-btn div {
    font-weight: bold;
    margin-bottom: 3px;
    font-size: 0.95em;
}

.mode-btn small, .difficulty-btn small {
    font-size: 0.8em;
    opacity: 0.8;
}

.game-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(45deg, #3282b8, #0f4c75);
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9em;
    min-width: 110px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(50, 130, 184, 0.4);
    background: linear-gradient(45deg, #0f4c75, #2c5282);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    background: #666;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn.secondary {
    background: linear-gradient(45deg, #666, #555);
}

.btn.secondary:hover {
    background: linear-gradient(45deg, #777, #666);
    box-shadow: 0 5px 15px rgba(102, 102, 102, 0.4);
}

.game-board-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 25px;
}

#gameCanvas {
    border: 3px solid #3282b8;
    border-radius: 12px;
    background: #000;
    box-shadow: 
        0 0 30px rgba(50, 130, 184, 0.3),
        inset 0 0 50px rgba(0, 0, 0, 0.5);
}

.power-ups-display {
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid rgba(50, 130, 184, 0.5);
    border-radius: 12px;
    padding: 15px;
    min-width: 200px;
    max-width: 250px;
}

.power-ups-display h4 {
    color: #3282b8;
    margin-bottom: 12px;
    font-size: 1em;
    text-align: center;
}

.active-powers {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.active-power {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.power-icon-small {
    font-size: 1.2em;
    width: 24px;
    text-align: center;
}

.power-details {
    flex: 1;
}

.power-name-small {
    color: #fff;
    font-size: 0.8em;
    font-weight: bold;
}

.power-timer {
    color: #3282b8;
    font-size: 0.7em;
}

.controls-hint {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 25px;
    flex-wrap: wrap;
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 12px;
    border: 2px solid rgba(50, 130, 184, 0.3);
}

.control-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #ccc;
    font-size: 0.9em;
}

.key {
    background: #3282b8;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.8em;
    min-width: 50px;
    text-align: center;
}

.desc {
    font-weight: 600;
}

.game-features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-bottom: 25px;
}

.food-types-section, .power-ups-section {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 20px;
    border: 2px solid rgba(50, 130, 184, 0.3);
}

.food-types-section h3, .power-ups-section h3 {
    color: #3282b8;
    margin-bottom: 20px;
    font-size: 1.2em;
    text-align: center;
}

.food-grid, .power-ups-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.food-item, .power-up-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.food-icon, .power-icon {
    font-size: 1.8em;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.food-icon.apple {
    background: rgba(255, 59, 48, 0.2);
}

.food-icon.golden {
    background: rgba(255, 204, 0, 0.2);
}

.food-icon.bonus {
    background: rgba(88, 86, 214, 0.2);
}

.food-info, .power-info {
    flex: 1;
}

.food-name, .power-name {
    color: #fff;
    font-weight: bold;
    font-size: 1em;
    margin-bottom: 4px;
}

.food-desc, .power-desc {
    color: #ccc;
    font-size: 0.85em;
    line-height: 1.3;
}

/* 弹窗样式 */
.game-over-popup, .help-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.game-over-popup.show, .help-modal.show {
    display: flex;
}

.popup-content, .modal-content {
    background: linear-gradient(135deg, #0f4c75, #3282b8);
    color: white;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(50, 130, 184, 0.6);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: popupSlideIn 0.5s ease-out;
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.popup-content h2 {
    color: #fff;
    margin-bottom: 20px;
    font-size: 2em;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.game-over-message {
    font-size: 1.1em;
    color: #ccc;
    margin-bottom: 20px;
    font-weight: 600;
}

.final-stats {
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    text-align: left;
}

.final-stats p {
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    color: #ccc;
}

.final-stats span {
    font-weight: bold;
    color: #3282b8;
}

.new-record {
    color: #ffcc00 !important;
    text-align: center;
    font-weight: bold;
    font-size: 1.1em;
    text-shadow: 0 0 10px rgba(255, 204, 0, 0.5);
}

.popup-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* 帮助模态框 */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(50, 130, 184, 0.3);
}

.modal-header h2 {
    color: #fff;
    font-size: 1.5em;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5em;
    color: #ccc;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #3282b8;
}

.modal-body {
    text-align: left;
}

.help-section {
    margin-bottom: 25px;
}

.help-section h3 {
    color: #3282b8;
    margin-bottom: 12px;
    font-size: 1.1em;
    border-left: 4px solid #3282b8;
    padding-left: 12px;
}

.help-section p {
    color: #ccc;
    line-height: 1.6;
    margin-bottom: 10px;
}

.help-section ul {
    color: #ccc;
    line-height: 1.6;
    margin-left: 20px;
}

.help-section li {
    margin-bottom: 8px;
}

.help-section strong {
    color: #fff;
    font-weight: 600;
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .game-features {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .game-board-container {
        flex-direction: column;
        align-items: center;
    }
    
    .power-ups-display {
        max-width: 100%;
        order: -1;
    }
}

@media (max-width: 768px) {
    .game-container {
        padding: 20px;
        margin: 10px;
    }
    
    .game-header h1 {
        font-size: 2em;
    }
    
    .game-stats {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }
    
    .stat {
        min-width: 120px;
    }
    
    .mode-buttons, .difficulty-buttons {
        flex-direction: column;
        align-items: center;
        max-width: 250px;
        margin: 0 auto;
    }
    
    .mode-btn, .difficulty-btn {
        width: 100%;
        min-width: auto;
    }
    
    #gameCanvas {
        width: 100%;
        height: auto;
        max-width: 400px;
        max-height: 400px;
    }
    
    .controls-hint {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .control-item {
        justify-content: center;
    }
    
    .game-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        min-width: 200px;
    }
    
    .popup-content, .modal-content {
        padding: 25px;
        margin: 20px;
    }
    
    .popup-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .popup-actions .btn {
        width: 100%;
        margin-bottom: 10px;
    }
}

@media (max-width: 480px) {
    .controls-hint {
        padding: 10px;
    }
    
    .control-item {
        font-size: 0.8em;
    }
    
    .key {
        min-width: 40px;
        padding: 3px 6px;
        font-size: 0.7em;
    }
    
    #gameCanvas {
        max-width: 300px;
        max-height: 300px;
    }
    
    .food-grid, .power-ups-grid {
        gap: 8px;
    }
    
    .food-item, .power-up-item {
        padding: 8px;
    }
    
    .food-icon, .power-icon {
        font-size: 1.5em;
        width: 35px;
        height: 35px;
    }
}

/* 游戏特效 */
@keyframes snakeMove {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.snake-move {
    animation: snakeMove 0.2s ease-out;
}

@keyframes foodEaten {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.5);
        opacity: 0.8;
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

.food-eaten {
    animation: foodEaten 0.3s ease-out;
}

@keyframes powerUpGlow {
    0%, 100% {
        box-shadow: 0 0 10px rgba(50, 130, 184, 0.3);
    }
    50% {
        box-shadow: 0 0 20px rgba(50, 130, 184, 0.6);
    }
}

.power-up-glow {
    animation: powerUpGlow 1s ease-in-out infinite;
}

/* 特殊状态效果 */
.flame-mode {
    filter: hue-rotate(30deg) brightness(1.2);
}

.lightning-mode {
    filter: brightness(1.5) saturate(1.5);
    animation: powerUpGlow 0.5s ease-in-out infinite;
}

.shield-mode {
    filter: hue-rotate(120deg) brightness(1.1);
}

.double-score-mode {
    filter: hue-rotate(60deg) brightness(1.3);
}