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

:root {
    --bg: #050505;
    --panel: #0d0d0d;
    --panel-2: #111111;
    --border: #242424;
    --text: #ffffff;
    --muted: #888888;
    --accent: #00ff88;
    --accent-dark: #00a85a;
    --danger: #ff3b3b;
    --food: #ff3b3b;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top, #101c16 0%, #050505 45%, #000000 100%);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-x: hidden;
}

.game-container {
    width: 100%;
    max-width: 520px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.game-header h1 {
    font-size: clamp(28px, 8vw, 42px);
    font-weight: 900;
    letter-spacing: 4px;
    color: var(--accent);
    text-shadow:
        0 0 8px rgba(0, 255, 136, 0.7),
        0 0 25px rgba(0, 255, 136, 0.25);
}

.game-header p {
    color: var(--muted);
    font-size: 13px;
    margin-top: 4px;
}

.score-box {
    min-width: 95px;
    padding: 10px 14px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    text-align: center;
}

.score-box span,
.stat span {
    display: block;
    font-size: 9px;
    letter-spacing: 1.5px;
    color: var(--muted);
}

.score-box strong {
    display: block;
    color: var(--accent);
    font-size: 25px;
    margin-top: 3px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}

.stat {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 10px;
    text-align: center;
}

.stat strong {
    display: block;
    font-size: 16px;
    margin-top: 4px;
}

.game-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #000;
    border: 2px solid #1d1d1d;
    border-radius: 14px;
    overflow: hidden;
    box-shadow:
        0 0 25px rgba(0, 255, 136, 0.08),
        inset 0 0 35px rgba(0, 0, 0, 0.8);
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
    background-color: #020202;
}

.overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.84);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 25px;
    z-index: 5;
}

.overlay-content {
    max-width: 330px;
}

.snake-icon,
.game-over-icon {
    font-size: 55px;
    margin-bottom: 12px;
}

.overlay h2 {
    font-size: 32px;
    letter-spacing: 4px;
    margin-bottom: 10px;
}

.overlay p {
    color: #999;
    line-height: 1.6;
    margin-bottom: 22px;
}

.overlay small {
    display: block;
    color: #666;
    margin-top: 15px;
}

.main-button {
    border: none;
    background: var(--accent);
    color: #00150b;
    font-weight: 900;
    letter-spacing: 1px;
    padding: 14px 28px;
    border-radius: 9px;
    cursor: pointer;
    font-size: 14px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.25);
}

.main-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.45);
}

.main-button:active {
    transform: scale(0.97);
}

.final-score {
    display: block;
    color: var(--accent);
    font-size: 48px;
    margin: 5px 0 20px;
}

.new-record {
    color: var(--accent) !important;
    font-weight: bold;
    margin-top: -8px;
}

.hidden {
    display: none !important;
}

.mobile-controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-width: 260px;
    margin: 18px auto 0;
}

.control {
    height: 58px;
    border: 1px solid #292929;
    background: #101010;
    color: #fff;
    border-radius: 10px;
    font-size: 21px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: background 0.1s, transform 0.1s;
}

.control:not(.empty):active {
    background: #1d3328;
    color: var(--accent);
    transform: scale(0.94);
}

.control.empty {
    visibility: hidden;
}

.instructions {
    margin-top: 20px;
    padding: 14px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.instructions p {
    color: #777;
    font-size: 12px;
    margin: 5px 0;
}

.instructions span {
    margin-right: 6px;
}

.instructions strong {
    color: #aaa;
}

footer {
    text-align: center;
    padding: 20px 0 5px;
    color: #444;
    font-size: 11px;
    letter-spacing: 1px;
}

@media (max-width: 480px) {
    body {
        padding: 12px;
        align-items: flex-start;
        padding-top: 25px;
    }

    .game-header {
        margin-bottom: 14px;
    }

    .score-box {
        min-width: 78px;
        padding: 8px 10px;
    }

    .score-box strong {
        font-size: 21px;
    }

    .stats {
        margin-bottom: 10px;
    }

    .mobile-controls {
        max-width: 240px;
        margin-top: 13px;
    }

    .control {
        height: 54px;
    }

    .instructions {
        margin-top: 14px;
    }
}

@media (min-width: 700px) {
    .mobile-controls {
        display: none;
    }
}
