/* Snake — Game Styles */

.game-area {
    max-width: 600px;
}

/* Info Bar */
.game-info-bar {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: stretch;
}

.info-item {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 8px 16px;
    text-align: center;
    min-width: 70px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.info-label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    font-weight: 700;
}

.info-value {
    display: block;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-heading);
    font-family: 'Oswald', sans-serif;
}

/* Controls */
.game-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
}

/* Board */
.board-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.board-container {
    position: relative;
    background: #0a0c14;
    border: 2px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 4px;
    line-height: 0;
    touch-action: none;
}

#game-board {
    display: block;
    background: linear-gradient(135deg, #0e1220 0%, #131929 100%);
    border-radius: 4px;
    width: 500px;
    height: 500px;
    max-width: 100%;
    image-rendering: pixelated;
}

/* Game Over Overlay */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    border-radius: var(--radius-md);
}

.overlay.hidden {
    display: none !important;
}

.result-content {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    padding: 28px;
    border-radius: var(--radius-lg);
    text-align: center;
    width: 90%;
    max-width: 280px;
    box-shadow: var(--shadow-card);
    line-height: 1.4;
}

.result-content h2 {
    color: var(--text-heading);
    margin-bottom: 12px;
    font-family: 'Oswald', sans-serif;
}

.result-content p {
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-size: 16px;
}

.result-content .btn-primary {
    margin-top: 16px;
}

/* Touch Controls — D-pad layout */
.touch-controls {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    touch-action: manipulation;
}

.touch-row {
    display: flex;
    gap: 14px;
    justify-content: center;
    align-items: center;
}

.touch-btn {
    background: var(--bg-surface);
    border: 2px solid var(--border-subtle);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.05s ease, background 0.08s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    font-weight: 700;
}

.touch-btn.pressed {
    background: #4ade80;
    border-color: #4ade80;
    color: #0a0c14;
    transform: scale(0.92);
}

.touch-btn-dir {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    font-size: 28px;
}

/* Floating pause button — only on mobile during play */
.play-pause-btn {
    display: none;
    position: fixed;
    top: 8px;
    right: 8px;
    z-index: 50;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 6px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.play-pause-btn:active {
    background: #4ade80;
    color: #0a0c14;
}

/* ────────── FULLSCREEN PLAY MODE for mobile/tablet ────────── */
@media (max-width: 1024px) {
    .touch-controls {
        display: flex;
    }

    body.playing {
        overflow: hidden;
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
    }

    body.playing header,
    body.playing .hamburger-menu,
    body.playing footer,
    body.playing .how-to-play,
    body.playing .game-stats-section,
    body.playing .game-header,
    body.playing .game-controls {
        display: none !important;
    }

    body.playing main {
        padding: 0 !important;
        margin: 0 !important;
    }

    body.playing .game-area {
        max-width: 100%;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        padding: 0 !important;
        margin: 0 !important;
        border-radius: 0;
        border: none;
        background: var(--bg-page, #0a0c12);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    body.playing .play-pause-btn {
        display: flex;
    }

    body.playing .game-info-bar {
        margin: 0;
        padding: 6px 8px;
        gap: 6px;
        flex-wrap: nowrap;
        background: var(--bg-card);
        border-bottom: 1px solid var(--border-subtle);
        flex-shrink: 0;
    }

    body.playing .info-item {
        padding: 4px 6px;
        min-width: 0;
        flex: 1;
        background: transparent;
        border: none;
    }

    body.playing .info-label {
        font-size: 9px;
        margin-bottom: 1px;
    }

    body.playing .info-value {
        font-size: 16px;
        line-height: 1;
    }

    body.playing .board-wrapper {
        flex: 1;
        margin: 0;
        padding: 8px 4px;
        align-items: center;
        justify-content: center;
        min-height: 0;
    }

    body.playing .board-container {
        padding: 3px;
        border-radius: 6px;
        max-width: 100%;
        max-height: 100%;
    }

    /* Board sizes to whichever fits the smaller dimension. Reserve ~225px
       for top info strip and bottom controls. */
    body.playing #game-board {
        width: min(calc(100vw - 16px), calc(100dvh - 260px));
        height: min(calc(100vw - 16px), calc(100dvh - 260px));
    }

    body.playing .touch-controls {
        flex-shrink: 0;
        padding: 10px 8px 14px;
        margin-top: 0;
        background: var(--bg-card);
        border-top: 1px solid var(--border-subtle);
        gap: 8px;
    }

    body.playing .touch-row {
        gap: 14px;
    }
}

@media (max-width: 480px) {
    body.playing .touch-btn-dir {
        width: 62px;
        height: 62px;
        font-size: 24px;
    }

    body.playing .touch-row {
        gap: 12px;
    }

    body.playing #game-board {
        width: min(calc(100vw - 16px), calc(100dvh - 230px));
        height: min(calc(100vw - 16px), calc(100dvh - 230px));
    }
}

@media (max-width: 360px) {
    body.playing .touch-btn-dir {
        width: 54px;
        height: 54px;
        font-size: 22px;
    }

    body.playing .touch-row {
        gap: 10px;
    }
}

/* When NOT playing on small screens, scale board down naturally */
@media (max-width: 768px) {
    body:not(.playing) #game-board {
        width: 100%;
        height: auto;
        aspect-ratio: 1 / 1;
    }
}
