:root {
    --bg-color: #f8f9fa;
    --game-bg: #1a1a1d;
    --snake-color: #00b894;
    --snake-head: #00cec9;
    --food-color: #ff4d6d;
    --text-color: #2d3436;
    --secondary-text: #636e72;
    --overlay-bg: rgba(0, 0, 0, 0.85);
    --btn-bg: #00b894;
    --btn-text: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    touch-action: none;
    /* Prevent default touch actions like clean zooming */
    user-select: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

.game-container {
    width: 100%;
    max-width: 420px;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    gap: 1rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.score-board {
    display: flex;
    gap: 0.8rem;
}

.score-card {
    background: #ffffff;
    padding: 0.5rem 1rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 90px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    border: 2px solid transparent;
}

/* Highlight Score */
.score-card:first-child {
    border-color: var(--snake-head);
    background: rgba(0, 206, 201, 0.1);
}

/* Highlight Best Score */
.score-card:last-child {
    border-color: #ff9f43;
    background: rgba(255, 159, 67, 0.1);
}

.label {
    font-size: 0.75rem;
    color: var(--secondary-text);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#score {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--snake-head);
}

#high-score {
    font-size: 1.8rem;
    font-weight: 800;
    color: #ff9f43;
}

.home-btn {
    text-decoration: none;
    background: #ffffff;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    transition: transform 0.2s, background-color 0.2s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    color: var(--text-color);
}

.home-btn:hover {
    background: #f1f2f6;
}

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

.home-btn svg {
    width: 24px;
    height: 24px;
}

.canvas-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
}

canvas {
    background-color: var(--game-bg);
    display: block;
    width: 100%;
    max-width: min(92vw, 450px);
    aspect-ratio: 1 / 1;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .game-container {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .score-card {
        min-width: 65px;
        padding: 0.35rem 0.5rem;
    }

    .label {
        font-size: 0.6rem;
    }

    #score,
    #high-score {
        font-size: 1.3rem;
    }

    .home-btn {
        width: 38px;
        height: 38px;
    }

    .home-btn svg {
        width: 18px;
        height: 18px;
    }

    canvas {
        max-width: 90vw;
        border-radius: 12px;
    }

    .controls-hint {
        font-size: 0.75rem;
    }

    h1 {
        font-size: 2rem;
    }

    .overlay p {
        font-size: 0.9rem;
        margin-bottom: 1.2rem;
    }

    .action-btn {
        padding: 0.7rem 1.8rem;
        font-size: 0.95rem;
    }
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: opacity 0.3s;
    backdrop-filter: blur(5px);
}

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

h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--snake-head), var(--snake-color));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

.overlay p {
    color: var(--secondary-text);
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

.action-btn {
    background: var(--btn-btn);
    background-color: var(--btn-bg);
    color: var(--btn-text);
    border: none;
    padding: 1rem 3rem;
    font-size: 1.2rem;
    font-weight: 700;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(0, 184, 148, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

.action-btn:active {
    transform: scale(0.95);
    box-shadow: 0 5px 10px rgba(0, 184, 148, 0.2);
}

.controls-hint {
    text-align: center;
    color: var(--secondary-text);
    margin-top: 1rem;
    font-size: 0.9rem;
    opacity: 0.7;
}