:root {
    --bg-color: #0f172a;
    /* slate-900 */
    --text-color: #f1f5f9;
    /* slate-100 */
    --accent-primary: #34d399;
    /* emerald-400 */
    --accent-secondary: #5eead4;
    /* teal-300 */
    --snake-body: rgba(5, 150, 105, 0.9);
    /* emerald-600 */
    --snake-head: #34d399;
    --food-color: #f43f5e;
    /* rose-500 */
    --grid-bg: rgba(30, 41, 59, 0.8);
    /* slate-800 */
    --glass-bg: rgba(15, 23, 42, 0.6);
    --glass-border: rgba(51, 65, 85, 0.5);

    --font-heading: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'Courier New', Courier, monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-heading);
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

/* Background Decor */
.background-decor {
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.2;
    animation: pulse 4s infinite ease-in-out;
}

.blob-1 {
    top: 5%;
    left: 5%;
    width: 300px;
    height: 300px;
    background: var(--accent-primary);
}

.blob-2 {
    bottom: 5%;
    right: 5%;
    width: 350px;
    height: 350px;
    background: var(--food-color);
    animation-delay: 2s;
}

/* Container */
.game-container {
    z-index: 10;
    width: 100%;
    max-width: 500px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

/* Header */
header {
    width: 100%;
    text-align: center;
}

.title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 15px;
    background: linear-gradient(to right, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    letter-spacing: -1px;
}

.score-board {
    display: flex;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.score-item {
    display: flex;
    flex-direction: column;
}

.score-item.right {
    align-items: flex-end;
}

.label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    /* slate-400 */
    font-weight: 600;
}

.value {
    font-size: 1.875rem;
    font-family: var(--font-mono);
    font-weight: 700;
    line-height: 1;
}

.score-highlight {
    color: var(--accent-primary);
}

/* Game Board */
.game-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1/1;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(20, 1fr);
    grid-template-rows: repeat(20, 1fr);
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 4px solid rgba(51, 65, 85, 0.5);
}

.cell {
    width: 100%;
    height: 100%;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

/* Entities */
.snake-body {
    background-color: var(--snake-body);
    border-radius: 2px;
    transform: scale(0.92);
}

.snake-head {
    background-color: var(--snake-head);
    border-radius: 4px;
    position: relative;
    transform: scale(1.05);
    z-index: 2;
    box-shadow: 0 0 15px rgba(52, 211, 153, 0.5);
}

.eye {
    position: absolute;
    width: 18%;
    height: 18%;
    background: #0f172a;
    border-radius: 50%;
}

.food-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.food {
    width: 70%;
    height: 70%;
    background-color: var(--food-color);
    border-radius: 50%;
    box-shadow: 0 0 15px rgba(244, 63, 94, 0.6);
    animation: bounce-pulse 1s infinite;
}

/* Overlays */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(4px);
    border-radius: 12px;
    z-index: 20;
    transition: opacity 0.3s ease;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.game-over-title {
    font-size: 2rem;
    color: var(--food-color);
    margin-bottom: 1rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.commentary-box {
    background: rgba(30, 41, 59, 0.6);
    padding: 1.5rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(51, 65, 85, 0.5);
    margin-bottom: 2rem;
    width: 85%;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#commentary-text {
    font-size: 1.1rem;
    font-style: italic;
    color: #ccfbf1;
    text-align: center;
    line-height: 1.4;
}

.primary-btn {
    padding: 12px 32px;
    background: linear-gradient(to right, #10b981, #14b8a6);
    color: white;
    font-weight: bold;
    font-size: 1.1rem;
    border: none;
    border-radius: 9999px;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.primary-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.6);
}

.primary-btn:active {
    transform: scale(0.95);
}

/* Hints & Controls */
.controls-hint {
    display: flex;
    justify-content: center;
    gap: 20px;
    color: #64748b;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    margin-top: 10px;
}

.hint-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.key-badge {
    background: rgba(30, 41, 59, 0.8);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid #334155;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.mobile-controls {
    display: none;
    /* Hidden on desktop by default */
    margin-top: 1rem;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.dpad-row {
    display: flex;
    gap: 0.5rem;
}

.dpad-center {
    width: 64px;
    height: 64px;
    background: rgba(30, 41, 59, 0.3);
    border-radius: 50%;
    margin: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dpad-center::after {
    content: '';
    width: 8px;
    height: 8px;
    background: rgba(52, 211, 153, 0.3);
    border-radius: 50%;
}

.dpad-btn {
    width: 64px;
    height: 64px;
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(71, 85, 105, 0.5);
    border-radius: 16px;
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.1s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.dpad-btn:active {
    background: rgba(52, 211, 153, 0.2);
    transform: scale(0.95);
    color: white;
}

/* Footer */
footer {
    position: absolute;
    bottom: 10px;
    font-size: 0.75rem;
    color: #475569;
}

/* Animations */
@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.2;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.3;
    }
}

@keyframes bounce-pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(0.9);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .desktop-only {
        display: none;
    }

    .mobile-controls {
        display: flex;
    }

    .title {
        font-size: 2rem;
    }
}