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

:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --success-color: #2ecc71;
    --danger-color: #e74c3c;
    --bg-color: #1a1a2e;
    --game-bg: #16213e;
    --text-color: #ffffff;
    --border-color: #4a69bd;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-color) 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.game-container {
    width: 100%;
    max-width: 900px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

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

.game-title {
    color: var(--text-color);
    font-size: 2.5rem;
    margin-bottom: 15px;
    text-shadow: 0 2px 10px rgba(52, 152, 219, 0.5);
}

.score-panel {
    display: flex;
    justify-content: center;
    gap: 40px;
}

.score-item {
    text-align: center;
}

.score-item .label {
    display: block;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.score-item .value {
    display: block;
    color: var(--success-color);
    font-size: 2rem;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(46, 204, 113, 0.5);
}

.game-main {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
}

.game-area {
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(52, 152, 219, 0.3);
    border: 2px solid var(--border-color);
}

#gameCanvas {
    display: block;
    background: var(--game-bg);
}

.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.overlay-content {
    text-align: center;
}

#overlayText {
    color: var(--text-color);
    font-size: 1.5rem;
    margin-bottom: 20px;
    animation: pulse 1.5s infinite;
}

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

.control-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 200px;
}

.section-title {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.95rem;
    margin-bottom: 10px;
    display: block;
}

.difficulty-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.diff-btn {
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    border: 1px solid transparent;
}

.diff-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.diff-btn.active {
    background: var(--secondary-color);
    border-color: var(--secondary-color);
    box-shadow: 0 0 10px rgba(52, 152, 219, 0.5);
}

.control-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--secondary-color) 0%, #2980b9 100%);
    color: var(--text-color);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.6);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-color);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.25);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color) 0%, #c0392b 100%);
    color: var(--text-color);
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.6);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.info-section {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 10px;
}

.info-list {
    list-style: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
}

.info-list li {
    padding: 5px 0;
    padding-left: 20px;
    position: relative;
}

.info-list li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--secondary-color);
}

.game-footer {
    text-align: center;
    margin-top: 20px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
}

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

@keyframes foodPop {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.score-popup {
    position: absolute;
    color: var(--success-color);
    font-size: 1.2rem;
    font-weight: bold;
    animation: scoreFloat 0.8s ease-out forwards;
    pointer-events: none;
    z-index: 20;
}

@keyframes scoreFloat {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-30px); }
}

@media (max-width: 768px) {
    .game-main {
        flex-direction: column;
        align-items: center;
    }

    .game-title {
        font-size: 1.8rem;
    }

    .score-panel {
        gap: 20px;
    }

    .score-item .value {
        font-size: 1.5rem;
    }

    .control-panel {
        width: 100%;
        max-width: 300px;
    }

    .difficulty-buttons,
    .control-buttons {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px;
    }

    .diff-btn,
    .btn {
        flex: 1;
        min-width: calc(50% - 5px);
    }
}

@media (max-width: 480px) {
    .game-container {
        padding: 15px;
    }

    .game-title {
        font-size: 1.5rem;
    }

    .score-panel {
        flex-direction: column;
        gap: 10px;
    }

    .btn {
        padding: 10px 15px;
        font-size: 0.85rem;
    }
}