:root {
    /* Theme Variables - Dark (Default) */
    --bg-color: #0f0f12;
    --text-color: #fff;
    --accent-cyan: #00ffe1;
    --accent-magenta: #ff00de;
    --glass: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --card-bg: rgba(40, 40, 50, 0.6);
    --hud-bg: rgba(0, 0, 0, 0.6);
    --sidebar-bg: rgba(0, 0, 0, 0.8);
    --sidebar-width: 80px;
    --icon-bg: linear-gradient(145deg, #333, #222);
    --icon-border: #444;
    --lobby-gradient: linear-gradient(135deg, rgba(26,26,46,0.95) 0%, rgba(22,33,62,0.95) 100%);
}

/* Light Mode Overrides */
[data-theme="light"] {
    --bg-color: #f0f0f5;
    --text-color: #333;
    --glass: rgba(0, 0, 0, 0.05);
    --glass-border: rgba(0, 0, 0, 0.1);
    --card-bg: rgba(255, 255, 255, 0.8);
    --hud-bg: rgba(255, 255, 255, 0.8);
    --sidebar-bg: rgba(255, 255, 255, 0.85);
    --icon-bg: linear-gradient(145deg, #fff, #e6e6e6);
    --icon-border: #ccc;
    --lobby-gradient: linear-gradient(135deg, rgba(240,240,255,0.95) 0%, rgba(255,255,255,0.95) 100%);
}

body {
    margin: 0;
    overflow: hidden;
    background: var(--bg-color);
    color: var(--text-color);
    font-family: 'Fredoka', sans-serif;
    display: flex;
    height: 100vh;
    user-select: none;
    transition: background 0.3s, color 0.3s;
}

/* --- SIDEBAR (Glassmorphism) --- */
#sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 20px;
    z-index: 100;
    border-right: 1px solid var(--glass-border);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s;
    box-shadow: 5px 0 15px rgba(0,0,0,0.1);
}

.hidden-sidebar {
    transform: translateX(-100%);
    position: absolute; 
}

.game-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    margin-bottom: 20px;
    background: var(--icon-bg);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    border: 1px solid var(--icon-border);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    color: var(--text-color);
}

.game-icon:hover, .game-icon.active {
    background: var(--accent-cyan);
    color: #000;
    transform: scale(1.15) rotate(5deg);
    border-color: #fff;
    box-shadow: 0 0 15px var(--accent-cyan);
}

.tooltip {
    position: absolute;
    left: 70px;
    background: var(--accent-cyan);
    color: #000;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
    transition: opacity 0.2s, transform 0.2s;
    transform: translateX(-10px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    z-index: 200;
}

.game-icon:hover .tooltip { opacity: 1; transform: translateX(0); }

/* --- MAIN GAME CONTAINER --- */
#game-container {
    flex-grow: 1;
    position: relative;
    height: 100vh;
    background: var(--bg-color); 
    overflow: hidden;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* --- LOBBY SCREEN (Fancy Neon) --- */
#lobby-screen {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--lobby-gradient);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 50;
    backdrop-filter: blur(5px);
    transition: background 0.3s;
}

h1.game-title { 
    font-family: 'Orbitron', sans-serif;
    font-size: 5rem; 
    margin-bottom: 10px; 
    background: linear-gradient(to right, var(--accent-cyan), var(--accent-magenta));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px rgba(0, 255, 225, 0.3);
    letter-spacing: 5px;
    text-align: center;
}

p.subtitle { 
    font-size: 1.4rem; 
    color: var(--text-color); 
    opacity: 0.7;
    margin-bottom: 40px; 
    font-weight: 300; 
}

.feature-icons {
    display: flex;
    gap: 30px;
    margin-bottom: 40px;
}
.f-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-color);
    font-size: 1.5rem;
    opacity: 0.8;
    transition: transform 0.3s;
}
.f-item:hover {
    transform: translateY(-5px);
    opacity: 1;
    color: var(--accent-cyan);
}
.f-item span {
    font-size: 0.8rem;
    margin-top: 5px;
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 1px;
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 40px;
    max-width: 900px;
    width: 100%;
    padding: 0 20px;
    justify-items: center;
}

.glass-card {
    width: 220px;
    height: 280px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.4s ease;
    position: relative;
    overflow: hidden;
}

.glass-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 5px;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-magenta));
    opacity: 0;
    transition: opacity 0.3s;
}

.glass-card:hover {
    transform: translateY(-15px) scale(1.02);
    background: var(--glass-border);
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.glass-card:hover::before { opacity: 1; }

.glass-card .emoji-icon { 
    font-size: 64px; 
    margin-bottom: 25px; 
    filter: drop-shadow(0 5px 10px rgba(0,0,0,0.2)); 
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); 
    line-height: 1;
}
.glass-card:hover .emoji-icon { transform: scale(1.2) rotate(15deg); }

.glass-card h3 { 
    margin: 0; 
    color: var(--text-color); 
    font-family: 'Orbitron', sans-serif; 
    letter-spacing: 1px; 
    font-size: 1.2rem;
}
.glass-card span { font-size: 13px; color: var(--text-color); opacity: 0.6; margin-top: 8px; font-weight: 400; }

/* --- OVERLAY (Start / Game Over) --- */
#game-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(10, 10, 15, 0.85);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 60;
    backdrop-filter: blur(15px);
}
[data-theme="light"] #game-overlay {
    background: rgba(240, 240, 255, 0.85);
}

.overlay-card {
    background: var(--card-bg);
    padding: 50px;
    border-radius: 30px;
    text-align: center;
    border: 1px solid var(--glass-border);
    max-width: 550px;
    box-shadow: 0 0 50px rgba(0,255,225,0.1), inset 0 0 20px rgba(255,255,255,0.1);
    animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
    from { transform: scale(0.9) translateY(20px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.ov-title { 
    font-family: 'Orbitron', sans-serif;
    font-size: 3.5rem; 
    margin: 0 0 20px 0; 
    background: linear-gradient(to bottom, #fff, #aaa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 10px rgba(0,0,0,0.5);
}
[data-theme="light"] .ov-title {
    background: linear-gradient(to bottom, #333, #666);
    -webkit-background-clip: text;
    text-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.ov-desc { font-size: 1.3rem; color: var(--text-color); margin-bottom: 40px; line-height: 1.6; }

.ov-score { 
    font-family: 'Orbitron', sans-serif;
    font-size: 3rem; 
    font-weight: bold; 
    margin-bottom: 40px; 
    color: var(--accent-cyan);
    text-shadow: 0 0 20px rgba(0, 255, 225, 0.5);
}

.btn-group { display: flex; gap: 20px; justify-content: center; }

.btn {
    padding: 16px 36px;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    overflow: hidden;
}
.btn:hover { transform: translateY(-3px); box-shadow: 0 10px 20px rgba(0,0,0,0.2); }
.btn:active { transform: translateY(-1px); }

.btn-primary { 
    background: linear-gradient(135deg, var(--accent-cyan), #00b894); 
    color: #000; 
    box-shadow: 0 4px 15px rgba(0, 255, 225, 0.4);
}
.btn-secondary { 
    background: #3e3e4e; 
    color: #fff; 
    border: 1px solid #555;
}
[data-theme="light"] .btn-secondary {
    background: #e0e0e5;
    color: #333;
    border: 1px solid #ccc;
}

/* --- HUD & MESSAGES --- */
#hud {
    position: absolute;
    top: 30px;
    left: 30px;
    pointer-events: none;
    display: none;
    z-index: 10;
}
.hud-text { 
    font-family: 'Orbitron', sans-serif;
    font-size: 24px; 
    font-weight: 700; 
    color: var(--text-color); 
    text-shadow: 0 0 10px var(--accent-cyan);
    background: var(--hud-bg);
    padding: 10px 20px;
    border-radius: 12px;
    margin-bottom: 10px;
    backdrop-filter: blur(5px);
    border: 1px solid var(--glass-border);
    display: inline-block;
    min-width: 150px;
}

.io-msg {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Orbitron', sans-serif;
    font-size: 80px;
    font-weight: 900;
    color: var(--accent-magenta);
    text-shadow: 0 0 20px rgba(255,0,222,0.8);
    opacity: 0;
    transition: opacity 0.5s, transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    z-index: 20;
    white-space: nowrap;
    letter-spacing: 2px;
}

#theme-toggle {
    position: absolute;
    top: 20px; right: 20px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--accent-cyan);
    width: 40px; height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    transition: all 0.3s;
}
#theme-toggle:hover { background: var(--glass-border); transform: rotate(15deg); }
[data-theme="light"] #theme-toggle { color: #f39c12; }

.asset-credit {
    position: absolute;
    bottom: 20px; width: 100%; text-align: center;
    font-size: 0.8rem; color: var(--text-color); opacity: 0.5; pointer-events: none;
}

.feedback-msg {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Orbitron', sans-serif;
    font-size: 50px;
    font-weight: 900;
    text-shadow: 0 0 15px rgba(255,255,255,0.8);
    opacity: 0;
    transition: opacity 0.5s, transform 0.5s;
    pointer-events: none;
    z-index: 20;
}

/* --- SNAKE IO UI ELEMENTS --- */
#snake-ui {
    display: none; 
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 15;
}

.mini-map {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 150px;
    height: 150px;
    background: rgba(0,0,0,0.5);
    border: 2px solid var(--accent-cyan);
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 255, 225, 0.2);
}
#minimap-canvas {
    width: 100%;
    height: 100%;
}

#commentary-box {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    text-align: center;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.comment-bubble {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--accent-cyan);
    border-radius: 20px;
    padding: 10px 20px;
    margin-bottom: 5px;
    color: #fff;
    font-style: italic;
    font-size: 16px;
    text-shadow: 0 0 5px var(--accent-cyan);
    animation: fadeIn 0.3s ease-out;
    max-width: 100%;
    backdrop-filter: blur(3px);
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

#ai-roast-box {
    margin: 20px auto;
    padding: 15px;
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
    border: 1px dashed var(--glass-border);
    max-width: 90%;
    min-height: 80px;
    display: none; 
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.ai-loading { font-size: 14px; color: #aaa; animation: pulse 1s infinite; }
@keyframes pulse { 0% { opacity: 0.5; } 50% { opacity: 1; } 100% { opacity: 0.5; } }

/* --- NEW MODAL & UI ADDITIONS --- */
.modal-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    backdrop-filter: blur(5px);
}

.neon-input {
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    background: rgba(0,0,0,0.5);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: #fff;
    font-family: 'Fredoka', sans-serif;
    box-sizing: border-box;
    transition: all 0.3s;
}
.neon-input:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(0, 255, 225, 0.3);
}

.lb-row {
    display: flex; justify-content: space-between;
    padding: 8px 10px; border-bottom: 1px solid var(--glass-border);
    font-family: 'Orbitron', sans-serif;
    font-size: 14px; color: var(--text-color);
}
.lb-row:nth-child(1) { color: #f1c40f; font-weight: bold; font-size: 16px; }
.lb-row:nth-child(2) { color: #bdc3c7; font-weight: bold; }
.lb-row:nth-child(3) { color: #cd7f32; font-weight: bold; }

/* --- NEW: User HUD (Top Right) --- */
.user-hud {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    padding: 5px 15px 5px 5px;
    gap: 10px;
    box-shadow: 0 0 15px rgba(0, 255, 225, 0.1);
    transition: all 0.3s;
}
.user-hud.hidden { display: none !important; }

.hud-avatar {
    width: 35px; height: 35px;
    background: var(--icon-bg);
    border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    font-size: 20px; border: 1px solid var(--accent-cyan);
}

.hud-info { display: flex; flex-direction: column; width: 120px; }

.hud-top { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 2px; }
#player-name { color: #fff; font-weight: bold; }
.hud-lvl { color: var(--accent-cyan); font-family: 'Orbitron'; }

.xp-bar-container {
    width: 100%; height: 4px; background: #333; border-radius: 2px; overflow: hidden;
}
.xp-fill {
    height: 100%; background: linear-gradient(90deg, var(--accent-cyan), var(--accent-magenta));
    box-shadow: 0 0 5px var(--accent-cyan);
    transition: width 0.5s ease;
}

.btn-icon {
    background: none; border: none; color: #ff3838; font-size: 16px; cursor: pointer;
    padding: 5px; border-radius: 50%;
}
.btn-icon:hover { background: rgba(255, 56, 56, 0.2); }

/* --- NEW: Leaderboard Styles --- */
.lb-card { width: 500px; padding: 20px; }
.neon-title { margin-top: 0; color: var(--accent-cyan); text-shadow: 0 0 10px var(--accent-cyan); }

.lb-tabs { display: flex; justify-content: center; gap: 10px; margin-bottom: 15px; }
.lb-tab {
    background: transparent; border: 1px solid var(--glass-border); color: #888;
    padding: 5px 15px; border-radius: 15px; cursor: pointer; font-family: 'Orbitron';
    transition: 0.3s;
}
.lb-tab.active, .lb-tab:hover {
    border-color: var(--accent-magenta); color: #fff; box-shadow: 0 0 10px rgba(255, 0, 222, 0.3);
}

.lb-header {
    display: grid; grid-template-columns: 1fr 3fr 1fr;
    padding: 10px; border-bottom: 2px solid var(--glass-border);
    color: var(--accent-cyan); font-family: 'Orbitron'; font-size: 14px;
}

.lb-list { max-height: 300px; overflow-y: auto; margin-bottom: 20px; }

.lb-row {
    display: grid; grid-template-columns: 1fr 3fr 1fr;
    padding: 10px; border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 14px; align-items: center;
}
.lb-row:hover { background: rgba(255,255,255,0.05); }

.rank-1 { color: #ffd700; text-shadow: 0 0 10px #ffd700; font-weight: bold; font-size: 1.1em; }
.rank-2 { color: #c0c0c0; text-shadow: 0 0 5px #c0c0c0; font-weight: bold; }
.rank-3 { color: #cd7f32; text-shadow: 0 0 5px #cd7f32; font-weight: bold; }

.loading-text { text-align: center; padding: 20px; color: #888; }
.close-btn { margin-top: 10px; }

/* ===== MOBILE RESPONSIVE DESIGN ===== */

/* iPhone & Mobile Devices (320px - 600px) */
@media (max-width: 800px) {
    body {
        flex-direction: column;
        height: 100dvh; /* Dynamic viewport height for phones with notch */
    }

    /* Hide sidebar on mobile, show hamburger menu */
    #sidebar {
        width: 100%;
        height: 60px;
        flex-direction: row;
        padding: 0 10px;
        padding-top: 8px;
        bottom: 0;
        top: auto;
        border-right: none;
        border-top: 1px solid var(--glass-border);
        z-index: 100;
    }

    #sidebar.hidden-sidebar {
        transform: none;
    }

    .game-icon {
        width: 45px;
        height: 45px;
        margin: 0 8px;
        font-size: 20px;
        flex-shrink: 0;
    }

    .game-icon:hover .tooltip { 
        display: none; /* Hide tooltips on mobile */
    }

    /* Game container full width */
    #game-container {
        flex-grow: 1;
        width: 100%;
        height: calc(100dvh - 60px);
        padding-bottom: 60px; /* Reserve space for bottom navbar */
    }

    canvas {
        width: 100%;
        height: 100%;
        display: block;
    }

    /* Responsive lobby screen */
    #lobby-screen {
        padding: 20px;
        padding-bottom: 80px; /* Extra space above bottom nav */
    }

    h1.game-title {
        font-size: 2.5rem;
        margin-bottom: 5px;
        letter-spacing: 2px;
    }

    p.subtitle {
        font-size: 1rem;
        margin-bottom: 20px;
    }

    .feature-icons {
        gap: 15px;
        margin-bottom: 20px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .f-item {
        font-size: 1.2rem;
    }

    .f-item span {
        font-size: 0.7rem;
    }

    /* Mobile game grid */
    .game-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 15px;
        max-width: 100%;
        padding: 0 10px;
    }

    .glass-card {
        width: 100%;
        height: 200px;
        font-size: 14px;
    }

    .emoji-icon {
        font-size: 32px;
    }

    .glass-card h3 {
        font-size: 1rem;
        margin: 8px 0 4px 0;
    }

    .glass-card span {
        font-size: 0.75rem;
    }

    .asset-credit {
        font-size: 0.85rem;
        margin-top: 20px;
    }

    /* Responsive modals */
    .modal-overlay {
        justify-content: center;
        align-items: flex-end;
        padding: 20px;
    }

    .overlay-card {
        width: 90% !important;
        max-width: 100% !important;
        max-height: 90vh;
        overflow-y: auto;
        border-radius: 20px 20px 0 0;
        animation: slideUp 0.3s ease-out;
    }

    @keyframes slideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    /* Leaderboard mobile */
    .lb-card {
        width: 100%;
        padding: 15px;
    }

    .lb-tabs {
        gap: 5px;
        overflow-x: auto;
        padding: 5px 0;
    }

    .lb-tab {
        padding: 4px 10px;
        font-size: 0.85rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .lb-list {
        max-height: 400px;
    }

    .lb-header, .lb-row {
        grid-template-columns: 0.5fr 1fr 1fr;
        padding: 8px;
        font-size: 12px;
    }

    /* Auth modal mobile */
    .overlay-card[style*="350px"] {
        width: 100% !important;
        padding: 20px !important;
    }

    .neon-input {
        padding: 10px;
        font-size: 16px; /* Prevent auto-zoom on iOS */
    }

    .btn {
        padding: 10px 15px;
        font-size: 14px;
    }

    /* User badge HUD - repositioned for mobile */
    .user-hud {
        position: fixed;
        top: 10px;
        right: 10px;
        z-index: 90;
        padding: 8px 12px;
        gap: 8px;
    }

    .hud-info {
        display: none; /* Hide info on very small screens */
    }

    .hud-avatar {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }

    #btn-show-login {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    #theme-toggle {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    /* Game HUD - adjust for mobile */
    #hud {
        flex-direction: column;
        bottom: 70px;
        left: 10px;
        gap: 5px;
    }

    .hud-text {
        font-size: 1rem;
    }

    /* Game overlay adjustments */
    #game-overlay {
        padding: 20px;
    }

    .overlay-card {
        max-height: 80vh;
    }

    .ov-title {
        font-size: 1.5rem;
    }

    .ov-desc {
        font-size: 0.9rem;
    }

    .btn-group {
        flex-direction: column;
        gap: 8px;
    }

    /* Snake UI mobile */
    #snake-ui {
        display: none; /* Hide on small screens, show on tablet */
    }

    .mini-map {
        width: 120px;
        height: 120px;
    }

    #commentary-box {
        font-size: 0.85rem;
        padding: 8px;
    }
}

/* Tablets (601px - 1024px) */
@media (min-width: 601px) and (max-width: 1024px) {
    body {
        flex-direction: column;
    }

    #sidebar {
        width: 100%;
        height: 70px;
        flex-direction: row;
        padding: 0 15px;
        border-top: 1px solid var(--glass-border);
        border-right: none;
        order: 2;
    }

    #sidebar.hidden-sidebar {
        transform: none;
    }

    .game-icon {
        width: 50px;
        height: 50px;
        margin: 0 12px;
    }

    #game-container {
        order: 1;
        width: 100%;
        height: calc(100vh - 70px);
        padding-bottom: 70px;
    }

    /* Larger lobby for tablet */
    h1.game-title {
        font-size: 4rem;
    }

    p.subtitle {
        font-size: 1.2rem;
    }

    .game-grid {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
        gap: 25px;
        max-width: 600px;
    }

    .glass-card {
        width: 100%;
        height: 240px;
    }

    /* Show HUD info on tablet */
    .user-hud {
        top: 15px;
        right: 15px;
    }

    .hud-info {
        display: flex;
    }

    /* Leaderboard on tablet */
    .lb-card {
        width: 600px;
    }

    #hud {
        bottom: 80px;
        left: 15px;
    }
}

/* Large tablets & iPads (1025px+) */
@media (min-width: 1025px) {
    body {
        flex-direction: row;
        height: 100vh;
    }

    #sidebar {
        position: fixed;
        left: 0;
        width: var(--sidebar-width);
        height: 100vh;
        flex-direction: column;
        padding-top: 20px;
        border-right: 1px solid var(--glass-border);
        border-top: none;
    }

    #sidebar.hidden-sidebar {
        transform: translateX(-100%);
    }

    .game-icon {
        margin-bottom: 20px;
    }

    #game-container {
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
        height: 100vh;
        padding-bottom: 0;
    }

    .game-grid {
        grid-template-columns: repeat(3, minmax(200px, 1fr));
    }

    #hud {
        left: calc(var(--sidebar-width) + 20px);
        bottom: 20px;
    }
}

/* iOS Safari optimizations */
@supports (-webkit-touch-callout: none) {
    body {
        height: 100dvh; /* Safe area on iPhone notch */
    }

    #game-container {
        height: 100dvh;
    }

    input, textarea, select {
        font-size: 16px; /* Prevent auto-zoom */
    }
}

/* Landscape mode adjustments */
@media (orientation: landscape) and (max-height: 600px) {
    #sidebar {
        height: 100vh;
        width: 100%;
        flex-direction: row;
        order: 2;
    }

    #game-container {
        order: 1;
        height: calc(100vh - 60px);
    }

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

    .feature-icons {
        display: none;
    }

    .game-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 10px;
    }

    .glass-card {
        height: 150px;
    }
}
