/* Snake Game Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    background-color: #1a1a2e;
    color: #e0e0e0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Screen Management */
.screen {
    display: none;
    opacity: 0;
    transition: opacity 300ms ease-in-out;
    position: absolute;
    inset: 0;
    text-align: center;
    width: 100%;
    padding: 1rem;
    justify-content: center;
    align-items: center;
}

.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

/* Utility */
.hidden {
    display: none !important;
}

/* Buttons - Shared Styles */
button {
    min-width: 44px;
    min-height: 44px;
    padding: 12px 32px;
    font-size: 1.1rem;
    font-family: inherit;
    color: #e0e0e0;
    background-color: #16213e;
    border: 2px solid #0f3460;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 200ms ease, border-color 200ms ease;
}

button:hover {
    background-color: #0f3460;
    border-color: #e94560;
}

button:focus-visible {
    outline: 2px solid #e94560;
    outline-offset: 2px;
}

/* Game Over Screen */
#game-over-screen {
    gap: 1.5rem;
    max-width: 600px;
    margin: 0 auto;
}

#game-over-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #e0e0e0;
    margin-bottom: 0.5rem;
}

.final-score {
    font-size: 1.4rem;
    color: #e0e0e0;
}

#new-high-score-indicator {
    font-size: 1.2rem;
    font-weight: 700;
    color: #fbbf24;
    text-shadow: 0 0 8px rgba(251, 191, 36, 0.4);
    animation: pulse-glow 1.5s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        opacity: 1;
        text-shadow: 0 0 8px rgba(251, 191, 36, 0.4);
    }
    50% {
        opacity: 0.85;
        text-shadow: 0 0 16px rgba(251, 191, 36, 0.7);
    }
}

.game-over-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

#play-again-button {
    font-weight: 600;
    color: #1a1a2e;
    background-color: #4ecca3;
    border: none;
}

#play-again-button:hover {
    background-color: #3bb891;
}

#main-menu-button {
    font-weight: 600;
}

/* Start Screen */
#start-screen {
    max-width: 600px;
    margin: 0 auto;
}

.game-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: #e0e0e0;
}

.high-score-display {
    font-size: 1.125rem;
    margin-bottom: 1.5rem;
    color: #e0e0e0;
}

#start-button {
    min-width: 44px;
    min-height: 44px;
    padding: 0.75rem 2rem;
    font-size: 1.125rem;
    font-family: inherit;
    font-weight: 600;
    color: #1a1a2e;
    background-color: #4ecca3;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 1.5rem;
    transition: background-color 200ms ease;
}

#start-button:hover {
    background-color: #3bb891;
}

#start-button:focus-visible {
    outline: 2px solid #e0e0e0;
    outline-offset: 2px;
}

.controls-info {
    font-size: 1rem;
    color: #b0b0b0;
    line-height: 1.6;
}

.controls-info p {
    margin-bottom: 0.25rem;
}

/* ===========================================
   Game Screen
   =========================================== */

#game-screen {
    max-width: none;
    width: 100%;
    padding: 1rem;
}

/* HUD */
#hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: min(80vmin, 600px);
    margin: 0 auto 0.75rem auto;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: #e0e0e0;
    background-color: #0f1629;
    border-radius: 6px;
}

#hud span {
    white-space: nowrap;
}

/* Game Board */
#game-board {
    display: grid;
    grid-template-columns: repeat(20, 1fr);
    grid-template-rows: repeat(20, 1fr);
    width: min(80vmin, 600px);
    height: min(80vmin, 600px);
    min-width: 240px;
    min-height: 240px;
    margin: 0 auto;
    background-color: #16213e;
    border-radius: 4px;
    border: 2px solid #1b2a4a;
    overflow: hidden;
    position: relative;
}

/* Board cells */
.cell {
    position: relative;
    aspect-ratio: 1;
    min-width: 12px;
    min-height: 12px;
}

/* Alternating cell shading for grid visibility (1.5:1 contrast) */
.cell-light {
    background-color: #192640;
}

.cell-dark {
    background-color: #16213e;
}

/* Snake Head - bright green, rounded, distinct from body */
.snake-head {
    background-color: #4ade80;
    border-radius: 5px;
    box-shadow: 0 0 4px rgba(74, 222, 128, 0.5);
}

/* Snake Body - darker green shade */
.snake-body {
    background-color: #22c55e;
    border-radius: 3px;
}

/* Food - red with circular shape */
.food {
    background-color: #ef4444;
    border-radius: 50%;
    box-shadow: 0 0 4px rgba(239, 68, 68, 0.5);
}

/* Pause Overlay */
#pause-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.65);
    border-radius: 4px;
    z-index: 10;
}

#pause-overlay.hidden {
    display: none;
}

.pause-text {
    font-size: 2rem;
    font-weight: 700;
    color: #e0e0e0;
    margin-bottom: 1.5rem;
}

#resume-button {
    min-width: 44px;
    min-height: 44px;
    padding: 0.75rem 2rem;
    font-size: 1.125rem;
    font-family: inherit;
    font-weight: 600;
    color: #1a1a2e;
    background-color: #4ecca3;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 200ms ease;
}

#resume-button:hover {
    background-color: #3bb891;
}

#resume-button:focus-visible {
    outline: 2px solid #e0e0e0;
    outline-offset: 2px;
}

/* Game Screen layout when active */
#game-screen.active {
    position: relative;
}

/* Responsive scaling */
@media (max-width: 400px) {
    #game-board {
        width: calc(100vw - 2rem);
        height: calc(100vw - 2rem);
        min-width: 240px;
        min-height: 240px;
    }

    #hud {
        max-width: calc(100vw - 2rem);
        font-size: 0.875rem;
        padding: 0.375rem 0.75rem;
    }
}

@media (min-width: 1200px) {
    #game-board {
        width: min(80vmin, 700px);
        height: min(80vmin, 700px);
    }

    #hud {
        max-width: min(80vmin, 700px);
    }
}
