/* Snake Game Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #2c3e50;
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 50%, #16a085 100%);
    min-height: 100vh;
    position: relative;
}

/* Animated snake pattern background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: repeating-linear-gradient(
        45deg,
        rgba(255,255,255,0.05) 0px,
        rgba(255,255,255,0.05) 10px,
        transparent 10px,
        transparent 20px
    );
    pointer-events: none;
    z-index: -1;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 3.5rem;
    color: #fff;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.3);
    margin-bottom: 10px;
    font-weight: bold;
    letter-spacing: 2px;
}

.subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.3rem;
    margin-bottom: 20px;
    font-style: italic;
}

.back-btn {
    display: inline-block;
    margin-top: 15px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    text-decoration: none;
    border-radius: 20px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* Game Area */
.game-area {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-info {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 400px;
    margin-bottom: 20px;
    gap: 20px;
}

.score-display, .high-score-display, .speed-display {
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: white;
    padding: 10px 15px;
    border-radius: 15px;
    text-align: center;
    flex: 1;
    box-shadow: 0 3px 10px rgba(52, 152, 219, 0.3);
}

.game-info .label {
    display: block;
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 2px;
}

.game-info .value {
    display: block;
    font-size: 1.4rem;
    font-weight: bold;
}

/* Game Board */
.game-board-container {
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    margin-bottom: 30px;
}

#gameCanvas {
    display: block;
    background: #2c3e50;
    border: 3px solid #34495e;
}

.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(44, 62, 80, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.overlay-content {
    text-align: center;
    color: white;
    padding: 30px;
}

.overlay-content h2 {
    font-size: 2rem;
    margin-bottom: 15px;
    color: #ecf0f1;
}

.overlay-content p {
    font-size: 1.1rem;
    margin-bottom: 25px;
    color: #bdc3c7;
    line-height: 1.5;
}

.game-btn {
    background: linear-gradient(45deg, #e74c3c, #c0392b);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.game-btn:hover {
    background: linear-gradient(45deg, #c0392b, #a93226);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(231, 76, 60, 0.4);
}

/* Controls Info */
.controls-info {
    text-align: center;
    margin-bottom: 20px;
}

.controls-info h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.control-keys {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 15px;
}

.key-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
}

.key-group:first-child {
    grid-template-areas: 
        ". up"
        "left down"
        ". right";
}

.key-group:first-child .key:nth-child(1) { grid-area: up; }
.key-group:first-child .key:nth-child(2) { grid-area: left; }
.key-group:first-child .key:nth-child(3) { grid-area: down; }
.key-group:first-child .key:nth-child(4) { grid-area: right; }

.key {
    background: #34495e;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.9rem;
    min-width: 35px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.or {
    color: #7f8c8d;
    font-weight: bold;
    font-size: 1.1rem;
}

.tip {
    color: #27ae60;
    font-weight: 500;
    font-style: italic;
}

/* Game Settings */
.game-settings {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.game-settings h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    text-align: center;
}

.setting {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.setting:last-child {
    margin-bottom: 0;
}

.setting label {
    color: #2c3e50;
    font-weight: 500;
}

select {
    padding: 8px 12px;
    border: 2px solid #bdc3c7;
    border-radius: 8px;
    background: white;
    color: #2c3e50;
    font-size: 1rem;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

select:focus {
    outline: none;
    border-color: #3498db;
}

.toggle-btn {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
}

.toggle-btn.active {
    background: #27ae60;
}

.toggle-btn:hover {
    transform: scale(1.05);
}

/* Footer */
footer {
    text-align: center;
    margin-top: auto;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2.5rem;
    }
    
    #gameCanvas {
        width: 300px;
        height: 300px;
    }
    
    .game-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .control-keys {
        flex-direction: column;
        gap: 15px;
    }
    
    .game-area {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 2rem;
    }
    
    #gameCanvas {
        width: 250px;
        height: 250px;
    }
    
    .game-settings {
        padding: 15px;
    }
    
    .setting {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}

/* Game animations */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.pulse {
    animation: pulse 0.5s ease-in-out;
}
