@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
    --bg-color: #0a0a1a;
    --grid-color: #1a1a3a;
    --snake-color: #00ff66;
    --food-color: #ff3366;
    --powerup-color: #ffcc00;
    --text-color: #33ccff;
    --score-color: #ff9900;
    --modal-bg: rgba(0, 0, 0, 0.9);
    --button-hover: #ff6600;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Press Start 2P', cursive;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    position: relative;
}

.score-container {
    display: flex;
    justify-content: space-between;
    width: 100%;
    font-size: 16px;
    padding: 10px;
}

.score, .high-score {
    text-shadow: 0 0 5px var(--text-color);
}

.score span, .high-score span {
    color: var(--score-color);
}

canvas {
    border: 4px solid var(--text-color);
    box-shadow: 0 0 20px var(--text-color);
    background-color: var(--bg-color);
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 10px;
    gap: 10px;
}

button {
    font-family: 'Press Start 2P', cursive;
    background-color: var(--text-color);
    color: var(--bg-color);
    border: none;
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
}

button:hover {
    background-color: var(--button-hover);
    transform: scale(1.05);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.toggle-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-container input {
    width: 20px;
    height: 20px;
}

/* Pause Screen Styles */
.pause-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 15;
    display: none;
}

.pause-content {
    background-color: var(--bg-color);
    border: 4px solid var(--text-color);
    box-shadow: 0 0 30px var(--text-color);
    padding: 40px;
    text-align: center;
    animation: modalAppear 0.3s ease-out;
}

.pause-content h2 {
    color: var(--text-color);
    font-size: 32px;
    margin-bottom: 20px;
    text-shadow: 0 0 10px var(--text-color);
}

.pause-content p {
    color: var(--score-color);
    font-size: 16px;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    display: none;
}

.modal-content {
    background-color: var(--bg-color);
    border: 4px solid var(--text-color);
    box-shadow: 0 0 30px var(--text-color);
    padding: 40px;
    text-align: center;
    animation: modalAppear 0.3s ease-out;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal h2 {
    color: var(--text-color);
    font-size: 24px;
    margin-bottom: 30px;
    text-shadow: 0 0 10px var(--text-color);
}

.modal input {
    font-family: 'Press Start 2P', cursive;
    background-color: var(--bg-color);
    border: 2px solid var(--text-color);
    color: var(--text-color);
    padding: 15px;
    font-size: 18px;
    text-align: center;
    width: 100%;
    max-width: 300px;
    margin-bottom: 30px;
}

.modal input:focus {
    outline: none;
    box-shadow: 0 0 10px var(--text-color);
}

.modal-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.modal-buttons button {
    font-size: 14px;
    padding: 10px 20px;
}

/* Game Over Modal Specific */
.game-over {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    display: none;
}

.game-over-content {
    background-color: var(--bg-color);
    border: 4px solid var(--text-color);
    box-shadow: 0 0 20px var(--text-color);
    padding: 40px;
    text-align: center;
    animation: pulse 2s infinite;
}

.game-over h2 {
    color: var(--food-color);
    font-size: 32px;
    margin-bottom: 20px;
    text-shadow: 0 0 10px var(--food-color);
}

.game-over p {
    font-size: 20px;
    margin-bottom: 20px;
}

.rank-message {
    font-size: 14px;
    color: var(--powerup-color);
    margin-bottom: 30px;
    min-height: 30px;
}

.game-over-content button {
    margin: 10px;
    font-size: 14px;
    padding: 10px 20px;
}

/* Scoreboard Modal Specific */
.scoreboard-content {
    width: 90vw;
    max-width: 1200px;
    max-height: 90vh;
    padding: 30px;
    overflow-y: auto;
}

.scoreboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 30px;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 20px;
    right: 20px;
}

.close-btn:hover {
    color: var(--food-color);
    transform: scale(1.2);
}

.scoreboards-container {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.scoreboard-section {
    flex: 1;
    min-width: 0;
}

.scoreboard-section h3 {
    font-size: 18px;
    color: var(--text-color);
    text-align: center;
    margin-bottom: 20px;
    padding: 10px;
    border: 2px solid var(--text-color);
    background-color: var(--grid-color);
}

.scoreboard-section h3.today {
    color: var(--powerup-color);
    border-color: var(--powerup-color);
}

.scoreboard-section h3.alltime {
    color: var(--snake-color);
    border-color: var(--snake-color);
}

.scoreboard-list {
    max-height: 500px;
    overflow-y: auto;
    border: 2px solid var(--grid-color);
    padding: 10px;
}

.score-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    margin-bottom: 10px;
    border: 2px solid var(--grid-color);
    background-color: var(--bg-color);
    transition: all 0.3s;
}

.score-entry:hover {
    border-color: var(--text-color);
    box-shadow: 0 0 10px var(--text-color);
}

.score-entry.current-player {
    border-color: var(--powerup-color);
    background-color: rgba(255, 204, 0, 0.1);
}

.score-rank {
    color: var(--score-color);
    font-weight: bold;
    min-width: 50px;
}

.score-name {
    flex: 1;
    text-align: left;
    margin-left: 20px;
    color: var(--text-color);
}

.score-value {
    color: var(--snake-color);
    font-weight: bold;
}

.score-date {
    font-size: 10px;
    color: var(--grid-color);
    margin-left: 20px;
    min-width: 100px;
    text-align: right;
}

.loading {
    text-align: center;
    color: var(--text-color);
    font-size: 16px;
}

.no-scores {
    text-align: center;
    color: var(--grid-color);
    font-size: 14px;
    font-style: italic;
}

@keyframes pulse {
    0% { box-shadow: 0 0 20px var(--text-color); }
    50% { box-shadow: 0 0 40px var(--text-color); }
    100% { box-shadow: 0 0 20px var(--text-color); }
}

.flicker {
    animation: flicker 0.2s;
}

@keyframes flicker {
    0% { opacity: 1; }
    25% { opacity: 0.5; }
    50% { opacity: 1; }
    75% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Media queries for responsiveness */
@media (max-width: 768px) {
    .score-container {
        font-size: 12px;
    }
    
    button {
        font-size: 12px;
        padding: 8px 16px;
    }
    
    .modal h2 {
        font-size: 20px;
    }
    
    .modal input {
        font-size: 16px;
    }
    
    .scoreboard-content {
        width: 95vw;
        padding: 20px;
        max-height: 85vh;
    }
    
    .scoreboards-container {
        flex-direction: column;
        gap: 20px;
    }
    
    .scoreboard-section h3 {
        font-size: 16px;
    }
    
    .score-entry {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .score-name {
        margin-left: 0;
    }
    
    .score-date {
        margin-left: 0;
        font-size: 10px;
    }
    
    .controls {
        flex-wrap: wrap;
    }
    
    .scoreboard-list {
        max-height: 300px;
    }
    
    .pause-content h2 {
        font-size: 24px;
    }
    
    .pause-content p {
        font-size: 14px;
    }
}