:root {
    --bg-color: #0f172a;
    --game-bg: #1e293b;
    --snake-color: #10b981;
    --food-color: #f43f5e;
    --text-color: #f1f5f9;
    --accent-color: #10b981;
    /* Green */
    --accent-color-glow-strong: rgba(16, 185, 129, 0.4);
    --accent-color-glow-medium: rgba(16, 185, 129, 0.2);
    --accent-color-glow-weak: rgba(16, 185, 129, 0.1);
    --overlay-bg: rgba(15, 23, 42, 0.85);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    margin: 0 auto;
    max-width: 1200px;
    /* padding-top removed */
}

/* .top-bar styles moved to global style.css */

/* Header Icon Containers */
.header-icon-container {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid #334155;
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

.header-icon-btn {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    text-decoration: none;
    transition: all 0.3s ease;
    border-radius: 6px;
}

.header-icon-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-color);
}

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

/* Header Stats Area */
.header-stats-area {
    flex: 1;
    display: contents;
    align-items: center;
    justify-content: center;
    padding: 0 1rem;
}

.stats-display {
    display: contents;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.25rem;
}

.username-row {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-color);
}

#username-display {
    color: var(--accent-color) !important;
}

.stats-row {
    display: flex;
    gap: 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.stat-item {
    color: #94a3b8;
}

.stat-item span {
    color: #fff;
    font-weight: 700;
}

/* Game-specific styles below - button styles and controls legend are now global */

.game-container {
    /* Styles now inherited from global .game-container */
    position: relative;
    margin-top: 20px;
    width: 576px;
    height: 576px;
    max-width: 90vw;
    max-height: 90vh;
    aspect-ratio: 1;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

canvas {
    background-color: var(--game-bg);
    display: block;
    width: 576px;
    height: 576px;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

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

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

h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-shadow: 0 0 10px var(--accent-color);
    letter-spacing: 2px;
}

p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    color: #cbd5e1;
}

/* Game button styles moved to global style.css as .game-button */
button {
    padding: 12px 32px;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--bg-color);
    background-color: var(--accent-color);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 20px var(--accent-color);
}

button:active {
    transform: translateY(0);
}

.score-board {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 1.2rem;
    font-weight: 600;
    z-index: 5;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

#countdown-text {
    font-size: 8rem;
    color: var(--snake-color);
    text-shadow: 0 0 30px var(--snake-color);
    animation: pulse 0.5s infinite alternate;
}

@keyframes pulse {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.1);
    }
}

.difficulty-selector {
    margin-bottom: 2rem;
    text-align: center;
}

.difficulty-selector label {
    display: block;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: #cbd5e1;
}

.difficulty-options,
.countdown-options,
.snake-size-options,
.snake-skin-options,
.basic-color-options {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.difficulty-btn,
.countdown-btn,
.snake-size-btn,
.snake-skin-btn,
.basic-color-btn {
    padding: 8px 16px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    background-color: transparent;
    border: 2px solid var(--accent-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    min-width: 45px;
}

.difficulty-btn:hover,
.countdown-btn:hover,
.snake-size-btn:hover,
.snake-skin-btn:hover,
.basic-color-btn:hover {
    background-color: rgba(59, 130, 246, 0.2);
    transform: translateY(-2px);
}

.difficulty-btn.active,
.countdown-btn.active,
.snake-size-btn.active,
.snake-skin-btn.active,
.basic-color-btn.active {
    background-color: var(--accent-color);
    color: var(--bg-color);
    box-shadow: 0 0 15px var(--accent-color);
}

/* Color-specific button styling */
.basic-color-btn[data-color="green"].active {
    background-color: #10b981;
    box-shadow: 0 0 15px #10b981;
}

.basic-color-btn[data-color="purple"].active {
    background-color: #8b5cf6;
    box-shadow: 0 0 15px #8b5cf6;
}

.basic-color-btn[data-color="pink"].active {
    background-color: #ec4899;
    box-shadow: 0 0 15px #ec4899;
}

.basic-color-btn[data-color="blue"].active {
    background-color: #3b82f6;
    box-shadow: 0 0 15px #3b82f6;
}

.settings-content {
    width: 100%;
    max-width: 450px;
    max-height: 70vh;
    overflow-y: scroll;
    padding-right: 10px;
}

.setting-group {
    margin-bottom: 1.5rem;
}

.setting-group label {
    display: block;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: #cbd5e1;
}

.setting-group input[type="text"] {
    width: 100%;
    padding: 10px 15px;
    font-size: 1rem;
    font-family: inherit;
    background-color: rgba(30, 41, 59, 0.5);
    border: 2px solid var(--accent-color);
    border-radius: 8px;
    color: var(--text-color);
    outline: none;
    transition: all 0.2s;
}

.setting-group input[type="text"]:focus {
    background-color: rgba(30, 41, 59, 0.8);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
}

.setting-group input[type="range"] {
    width: 100%;
    height: 6px;
    background: linear-gradient(to right, var(--accent-color), var(--snake-color));
    border-radius: 5px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.setting-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent-color);
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-color);
}

.setting-group input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--accent-color);
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-color);
    border: none;
}

/* ============================================
 * MOBILE RESPONSIVE STYLES
 * ============================================ */

/* Mobile-specific layout adjustments */
@media (max-width: 768px) {
    body {
        height: 100vh;
        height: 100dvh;
        /* Dynamic viewport height for mobile */
        overflow: hidden;
    }

    .game-container {
        margin-top: 10px;
        width: 90vw;
        /* Responsive width */
        /* max-width: 400px;*/
        /* Maximum size on mobile */
        height: 90vw;
        /* Match width for 1:1 ratio */
        /*max-height: 400px;*/
        /* Maximum height on mobile */
        border-radius: 8px;
        /* Smaller border radius */
    }

    /* Canvas fills container responsively */
    canvas {
        border-radius: 8px;
        box-shadow: 0 0 30px rgba(16, 185, 129, 0.2);
    }

    /* Mobile header adjustments */
    .header-icon-container {
        width: 45px;
        height: 45px;
        border-radius: 6px;
    }

    .header-icon-btn svg {
        width: 20px;
        height: 20px;
    }

    /* Adjust stats display for mobile */
    .stats-display {
        gap: 0.15rem;
    }

    .username-row {
        font-size: 0.95rem;
    }

    .stats-row {
        gap: 1rem;
        font-size: 0.8rem;
    }

    /* Add gap between header and game */
    .game-container {
        margin-top: 15px;
    }

    /* Controls legend hidden on mobile via global CSS */

    /* Mobile-friendly overlays */
    h1 {
        font-size: 2.5rem;
        margin-bottom: 1rem;
    }

    p {
        font-size: 1rem;
        margin-bottom: 1.5rem;
        text-align: center;
        padding: 0 1rem;
    }

    /* Mobile-friendly buttons */
    button {
        padding: 10px 24px;
        font-size: 1.1rem;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    /* Adjust countdown for mobile */
    #countdown-text {
        font-size: 6rem;
    }

    /* Mobile-friendly settings */
    .settings-content {
        max-width: 90vw;
        max-height: 60vh;
        padding: 0 1rem;
        padding-right: 20px;
        overflow-y: scroll;
    }

    .difficulty-options,
    .countdown-options,
    .snake-size-options,
    .snake-skin-options,
    .basic-color-options {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .difficulty-btn,
    .countdown-btn,
    .snake-size-btn,
    .snake-skin-btn,
    .basic-color-btn {
        min-width: 50px;
        padding: 10px 18px;
    }

    /* Adjust setting groups for mobile */
    .setting-group {
        margin-bottom: 0.5rem;
    }

    .setting-group label {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
        text-align: center;
    }

    /* Score board adjustment for mobile */
    .score-board {
        top: 10px;
        left: 10px;
        right: 10px;
        font-size: 1rem;
        text-align: center;
    }

    /* Add some padding for better touch targets */
    .ui-overlay {
        padding: 0rem 0rem;
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    body {
        padding-top: 0px;
    }

    /*   .game-container {*/
    /*max-width: 350px;*/
    /*max-height: 350px;*/
    /*}*/

    .stats-display {
        font-size: 0.8rem;
        gap: 0.25rem;
    }

    .stats-display #username-display {
        font-size: 0.9rem;
    }

    h1 {
        font-size: 2rem;
        margin-top: 0.5rem;
    }

    p {
        font-size: 0.9rem;
    }

    button {
        padding: 8px 20px;
        font-size: 1rem;
    }

    #countdown-text {
        font-size: 4.5rem;
    }

    .difficulty-btn,
    .countdown-btn,
    .snake-size-btn,
    .snake-skin-btn,
    .basic-color-btn {
        min-width: 45px;
        padding: 8px 16px;
        font-size: 0.9rem;
    }
}

/* Landscape mobile orientation */
@media (max-width: 768px) and (orientation: landscape) {
    body {
        padding-top: 40px;
    }

    .game-container {
        margin-top: 5px;
    }

    .game-container {
        max-width: 60vh;
        /* Use viewport height for landscape */
        max-height: 60vh;
    }

    .stats-display {
        flex-direction: row;
        gap: 1rem;
        font-size: 0.8rem;
    }

    h1 {
        font-size: 2rem;
        margin-bottom: 0.5rem;
    }

    p {
        font-size: 0.9rem;
        margin-bottom: 1rem;
    }

    .ui-overlay {
        padding: 1rem;
    }
}

/* Touch-friendly improvements */
@media (pointer: coarse) {

    /* Ensure all interactive elements are touch-friendly */
    button,
    .difficulty-btn,
    .countdown-btn,
    .snake-size-btn,
    .snake-skin-btn,
    .basic-color-btn {
        min-height: 44px;
        /* Apple's recommended touch target size */
        min-width: 44px;
    }

    /* Remove hover effects on touch devices */
    button:hover,
    .difficulty-btn:hover,
    .countdown-btn:hover,
    .snake-size-btn:hover,
    .snake-skin-btn:hover,
    .basic-color-btn:hover {
        transform: none;
        box-shadow: none;
    }

    /* Add pressed state for better feedback */
    button:active,
    .difficulty-btn:active,
    .countdown-btn:active,
    .snake-size-btn:active,
    .snake-skin-btn:active,
    .basic-color-btn:active {
        transform: scale(0.95);
    }
}

/* High DPI display support */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
    canvas {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* ============================================
 * INSTRUCTION TEXT VISIBILITY
 * ============================================ */

/* Show desktop instructions by default */
.desktop-instruction {
    display: block;
}

.mobile-instruction {
    display: none;
}

/* On mobile, show mobile instructions */
@media (max-width: 768px) {
    .desktop-instruction {
        display: none;
    }

    .mobile-instruction {
        display: block;
    }
}

/* Countdown hint */
.countdown-hint {
    margin-top: 2rem;
    text-align: center;
    font-size: 0.9rem;
    color: #94a3b8;
    opacity: 0.8;
}