* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100%;
}

body {
    background: #0d0d0d;
    font-family: monospace;
    color: #9bbc0f;

    min-height: 100vh;

    display: flex;
    justify-content: center;
    align-items: center;

    overflow: hidden;

    user-select: none;
}

.game-wrapper {
    width: 100%;

    display: flex;
    justify-content: center;
    align-items: center;
}

.phone {
    width: min(92vw, 480px);

    padding: 24px;

    background: #181818;

    border: 1px solid #292929;

    border-radius: 26px;

    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.65),
        0 0 0 1px rgba(255, 255, 255, 0.02);
}


/* -------------------------
   TOP / BOTTOM BAR
------------------------- */

.top-bar,
.bottom-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 2px 4px 12px;

    font-size: 13px;
    font-weight: bold;

    letter-spacing: 2px;

    color: #9bbc0f;
}

.bottom-bar {
    padding: 14px 4px 0;
}


/* -------------------------
   GAME SCREEN
------------------------- */

.screen-container {
    position: relative;

    width: 100%;

    aspect-ratio: 1 / 1;

    background: #9bbc0f;

    border: 7px solid #0a0a0a;

    border-radius: 8px;

    overflow: hidden;

    box-shadow:
        inset 0 0 18px rgba(0, 0, 0, 0.35),
        0 3px 10px rgba(0, 0, 0, 0.45);
}

canvas {
    display: block;

    width: 100%;
    height: 100%;

    touch-action: none;
}


/* -------------------------
   OVERLAYS
------------------------- */

.overlay {
    position: absolute;

    inset: 0;

    display: flex;
    flex-direction: column;

    justify-content: center;
    align-items: center;

    background: rgba(155, 188, 15, 0.88);

    color: #0f380f;

    text-align: center;
}

.hidden {
    display: none !important;
}

.snake-title {
    font-size: clamp(34px, 9vw, 56px);

    font-weight: bold;

    letter-spacing: 7px;

    margin-bottom: 30px;
}

.press-start {
    font-size: 14px;

    letter-spacing: 2px;

    animation: blink 1s infinite;
}

.game-over-title {
    font-size: 26px;

    font-weight: bold;

    letter-spacing: 3px;

    margin-bottom: 18px;
}

.final-score {
    font-size: 16px;

    margin-bottom: 25px;
}


/* -------------------------
   RESTART BUTTON
------------------------- */

#restart {
    border: 1px solid #0f380f;

    background: rgba(15, 56, 15, 0.08);

    color: #0f380f;

    padding: 10px 20px;

    border-radius: 6px;

    font-family: monospace;
    font-weight: bold;

    cursor: pointer;

    transition:
        background 0.15s,
        transform 0.1s;
}

#restart:hover {
    background: rgba(15, 56, 15, 0.15);
}

#restart:active {
    transform: scale(0.96);
}


/* -------------------------
   DIRECTION CONTROLS
------------------------- */

.controls {
    display: grid;

    grid-template-columns: repeat(3, 58px);

    grid-template-rows: repeat(3, 58px);

    gap: 8px;

    width: max-content;

    margin: 20px auto 8px;
}

.control {
    width: 58px;
    height: 58px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 1px solid #353535;

    border-radius: 14px;

    background: linear-gradient(
        145deg,
        #292929,
        #171717
    );

    color: #b4d51a;

    font-size: 21px;

    font-family: monospace;

    cursor: pointer;

    box-shadow:
        0 5px 0 #0a0a0a,
        0 7px 12px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);

    transition:
        transform 0.08s ease,
        box-shadow 0.08s ease,
        background 0.08s ease;

    touch-action: manipulation;
}

.control:hover {
    background: linear-gradient(
        145deg,
        #303030,
        #1b1b1b
    );

    color: #c4e529;
}

.control:active {
    transform: translateY(4px);

    box-shadow:
        0 1px 0 #0a0a0a,
        0 3px 6px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
}


/* Button positions */

.up {
    grid-column: 2;
    grid-row: 1;
}

.left {
    grid-column: 1;
    grid-row: 2;
}

.center {
    grid-column: 2;
    grid-row: 2;
}

.right {
    grid-column: 3;
    grid-row: 2;
}

.down {
    grid-column: 2;
    grid-row: 3;
}


/* -------------------------
   CENTER START BUTTON
------------------------- */

.center {
    border-radius: 50%;

    background: radial-gradient(
        circle at 40% 35%,
        #333333,
        #181818
    );

    color: #9bbc0f;

    font-size: 16px;

    box-shadow:
        0 5px 0 #090909,
        0 7px 12px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.07);
}


/* -------------------------
   ANIMATION
------------------------- */

@keyframes blink {
    0%,
    45% {
        opacity: 1;
    }

    46%,
    100% {
        opacity: 0;
    }
}


/* -------------------------
   MOBILE
------------------------- */

@media (max-width: 500px) {

    .phone {
        width: 94vw;

        padding: 16px;

        border-radius: 22px;
    }

    .controls {
        margin-top: 17px;

        grid-template-columns: repeat(3, 52px);
        grid-template-rows: repeat(3, 52px);

        gap: 7px;
    }

    .control {
        width: 52px;
        height: 52px;

        border-radius: 13px;

        font-size: 19px;
    }

    .top-bar,
    .bottom-bar {
        font-size: 12px;
    }
}

.message {
    text-align: center;
    color: #f1f1f1;
    margin-bottom: 25px;
}

.message h1 {
    font-size: 24px;
    margin: 0 0 8px;
}

.message p {
    font-size: 15px;
    color: #999;
    margin: 0;
}

body {
    margin: 0;
    padding: 0;

    width: 100%;
    min-height: 100vh;

    background: #0d0d0d;

    font-family: monospace;

    color: #f1f1f1;

    overflow-x: hidden;
}

.page {
    min-height: 100vh;

    display: flex;
    flex-direction: column;

    align-items: center;

    justify-content: center;

    padding: 30px 20px;
}


/* Message above the game */

.message {
    width: 100%;
    max-width: 600px;

    text-align: center;

    margin-bottom: 28px;
}

.message h1 {
    margin: 0 0 10px;

    font-size: 24px;

    font-weight: 600;

    color: #f1f1f1;
}

.message p {
    margin: 0;

    font-size: 15px;

    color: #888;
}


/* Game */

.game-wrapper {
    width: 100%;

    display: flex;

    justify-content: center;

    align-items: center;
}