@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

:root {
    --primary-color: #4CAF50;
    --secondary-color: #2196F3;
    --accent-color: #FF4081;
    --background-color: #1a1a1a;
    --board-color: #2d2d2d;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--background-color), #000);
    font-family: 'Press Start 2P', cursive;
    color: white;
}

.game-container {
    text-align: center;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
}

.game-title {
    font-size: 2em;
    margin-bottom: 10px;
    color: var(--accent-color);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    animation: glow 2s ease-in-out infinite alternate;
}

.controls-info {
    font-size: 0.8em;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 20px;
    font-family: Arial, sans-serif;
}

.score-container {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    font-size: 1.2em;
}

.current-score, .high-score {
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    min-width: 200px;
}

.history-container {
    margin: 20px 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 15px;
    max-width: 400px;
    margin: 20px auto;
}

.history-container h3 {
    margin-bottom: 10px;
    color: var(--accent-color);
    text-align: center;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-height: 200px;
    overflow-y: auto;
    padding: 5px;
}

.history-score-item {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    font-size: 0.8em;
}

.history-score-item .rank {
    font-weight: bold;
    color: var(--secondary-color);
    min-width: 30px;
}

.history-score-item .score {
    font-weight: bold;
    min-width: 50px;
    text-align: right;
}

.history-score-item .date {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.7em;
    flex: 1;
    text-align: right;
    margin-left: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
}

#game-board {
    width: 400px;
    height: 400px;
    border: 3px solid var(--accent-color);
    background-color: var(--board-color);
    position: relative;
    margin: 0 auto;
    border-radius: 10px;
    box-shadow: 0 0 30px rgba(255, 64, 129, 0.3);
}

.snake-segment {
    width: 20px;
    height: 20px;
    position: absolute;
    border-radius: 4px;
    transition: all 0.1s;
}

.snake-segment:first-child {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.snake-segment:not(:first-child) {
    background-color: var(--primary-color);
    opacity: 0.9;
}

.food {
    width: 20px;
    height: 20px;
    background: radial-gradient(circle, var(--accent-color), #ff1744);
    position: absolute;
    border-radius: 50%;
    box-shadow: 0 0 15px rgba(255, 64, 129, 0.7);
    animation: pulse 1s infinite;
}

.controls {
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.main-controls {
    display: flex;
    gap: 15px;
}

button {
    padding: 12px 24px;
    font-size: 14px;
    font-family: 'Press Start 2P', cursive;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

button:active {
    transform: translateY(0);
}

.mobile-controls {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}

.horizontal-controls {
    display: flex;
    gap: 10px;
}

.direction-btn {
    width: 60px;
    height: 60px;
    padding: 0;
    font-size: 24px;
}

.overlay {
    position: fixed;
    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: 1000;
}

.overlay-content {
    background: rgba(45, 45, 45, 0.95);
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 0 30px rgba(255, 64, 129, 0.5);
}

.overlay-content h2 {
    color: var(--accent-color);
    margin-bottom: 20px;
}

.hidden {
    display: none;
}

@keyframes glow {
    from {
        text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 15px var(--accent-color);
    }
    to {
        text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px var(--accent-color);
    }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@media (max-width: 600px) {
    .mobile-controls {
        display: flex;
    }
    
    #game-board {
        width: 300px;
        height: 300px;
    }
    
    .score-container {
        flex-direction: column;
        gap: 10px;
    }
}