:root {
            --bg-dark: #121214;
            --panel-bg: #1e1e24;
            --border-color: #3a3a42;
            --accent-gold: #dfb15b;
            --text-main: #e2e8f0;
            --text-muted: #a0aec0;
            --success-green: #48bb78;
            --combat-red: #e53e3e;
        }

        * { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
        body { 
            background-color: var(--bg-dark); 
            color: var(--text-main); 
            height: 100vh; 
            overflow: hidden; 
        }
        /* Center the entire screen overlay and give it a dark/atmospheric backdrop */
            #setup-screen {
                position: fixed;
                top: 0;
                left: 0;
                width: 100vw;
                height: 100vh;
                background: rgba(10, 12, 16, 0.85); /* Semi-transparent dark overlay */
                display: flex;
                justify-content: center; /* Horizontally centers the box */
                align-items: center;     /* Vertically centers the box */
                z-index: 9999;
                padding: 20px;
                box-sizing: border-box;
            }
        #levelup-screen { display: none; z-index: 101; background: rgba(18, 18, 20, 0.9); }
        #game-view {
            display: flex;
            flex-direction: row; /* This puts sidebar and game-container side-by-side */
            height: 100vh;       /* This ensures it fills the screen height */
            width: 100vw;
            overflow: hidden; /* Added this to ensure no scrollbars appear */
        } 
        .setup-box {
            background: #151922; /* Rich dark fantasy panel background */
            border: 2px solid var(--accent-gold, #c5a059); /* Fallback gold border */
            border-radius: 8px;
            padding: 30px;
            width: 100%;
            max-width: 550px; /* Keeps it from stretching too wide on large monitors */
            max-height: 90vh; /* Prevents overflow on smaller screens */
            overflow-y: auto; /* Adds a clean scrollbar if content is taller than the screen */
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
            color: #e0e0e0;
        }

        .form-section { margin-bottom: 16px; }
        label { display: block; margin-bottom: 6px; font-weight: 600; color: var(--accent-gold); text-transform: uppercase; font-size: 0.85rem; letter-spacing: 0.5px; }
        .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
        select, input[type="text"], input[type="password"] { width: 100%; background-color: var(--bg-dark); border: 1px solid var(--border-color); color: var(--text-main); padding: 10px 14px; border-radius: 6px; font-size: 1rem; outline: none; }
        select:focus, input[type="text"]:focus, input[type="password"]:focus { border-color: var(--accent-gold); }

        .points-header { display: flex; justify-content: space-between; background: rgba(255,255,255,0.02); padding: 10px; border-radius: 6px; margin-bottom: 12px; border: 1px solid rgba(255,255,255,0.05); }
        .stat-allocator-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
        .stat-allocator-row { display: flex; justify-content: space-between; align-items: center; background: rgba(0,0,0,0.2); padding: 8px 12px; border-radius: 6px; }
        .stat-label-desc { display: flex; flex-direction: column; }
        .stat-desc { font-size: 0.75rem; color: var(--text-muted); }
        .allocator-controls { display: flex; align-items: center; gap: 8px; }
        .btn-circle { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border-color); background: #2d3748; color: white; font-weight: bold; cursor: pointer; display: flex; justify-content: center; align-items: center; }
        .btn-circle:hover { background: #4a5568; }
        .stat-display-val { font-size: 1.1rem; font-weight: bold; width: 22px; text-align: center; }

        /* Full-screen login overlay with a background image */
        #login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    /* Updated path assuming your file is saved as static/images/backgrounds/background.png */
    background: url('/images/backgrounds/background.png') no-repeat center center fixed;
    background-size: cover;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px; /* Restores space between your intro box and updates box */
    padding: 20px;
    box-sizing: border-box;
    z-index: 9999;
    color: white; 
}

        /* Semi-transparent frosted glass containers for readability */
        .login-panel {
            background: rgba(15, 23, 42, 0.85); /* Dark slate with high opacity */
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 12px;
            padding: 30px;
            max-width: 450px;
            width: 100%;
            color: #f8fafc;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
            backdrop-filter: blur(8px);
        }

        .login-panel h2 {
            margin-top: 0;
            color: #38bdf8; /* Bright accent color for headers */
            font-size: 1.5rem;
            margin-bottom: 15px;
        }

        .login-panel p, .login-panel ul {
            font-size: 0.95rem;
            line-height: 1.5;
            color: #cbd5e1;
        }

        .login-panel ul {
            padding-left: 20px;
            margin-bottom: 0;
        }

        /* Sidebar UI Panel */
        .sidebar { 
            width: 280px; /* Made slightly smaller to fit 3 columns */
            background-color: var(--panel-bg); 
            border-right: 2px solid var(--border-color);
            display: flex; flex-direction: column; padding: 20px; gap: 12px; overflow-y: auto; 
        }   
        .sidebar-right { 
            width: 280px; 
            background-color: var(--panel-bg); 
            border-left: 2px solid var(--border-color);
            display: flex; flex-direction: column; padding: 20px; gap: 12px; overflow-y: auto; 
        }     
        .avatar-box { width: 100%; height: 90px; background: #121214; border: 1px solid var(--border-color); border-radius: 8px; display: flex; justify-content: center; align-items: center; font-size: 2.5rem; }
        .panel-title { font-size: 1rem; text-transform: uppercase; letter-spacing: 1px; color: var(--accent-gold); border-bottom: 1px solid var(--border-color); padding-bottom: 4px; margin-bottom: 6px; }
        .stat-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; background: rgba(255,255,255,0.02); padding: 5px 10px; border-radius: 6px; }
        .stat-name { font-weight: 600; font-size: 0.9rem; }
        .stat-val { font-size: 0.95rem; color: var(--accent-gold); font-weight: bold; }
        .stat-mod { font-size: 0.8rem; color: var(--text-muted); }
        .status-pill { display: inline-block; padding: 4px 10px; border-radius: 20px; background: #2d3748; font-size: 0.8rem; margin-right: 4px; margin-bottom: 4px; }

        /* Visual Dice Roller */
        .dice-tray { display: flex; align-items: center; justify-content: center; gap: 20px; background: #121214; border: 1px solid var(--border-color); padding: 15px; border-radius: 8px; margin-bottom: 5px; }
        .d20-graphic { width: 50px; height: 50px; background: #742a2a; border: 2px solid var(--accent-gold); transform: rotate(45deg); display: flex; align-items: center; justify-content: center; border-radius: 6px; transition: transform 0.5s ease-out; box-shadow: 0 0 10px rgba(223,177,91,0.2); }
        .d20-number { transform: rotate(-45deg); font-weight: bold; font-size: 1.3rem; color: white; }
        .rolling { animation: spin 0.6s linear infinite; }

        /* Combat HUD Dashboard */
        #combat-hud { display: none; background: rgba(229, 62, 62, 0.1); border: 1px solid var(--combat-red); padding: 12px; border-radius: 8px; margin-bottom: 5px; }

        /* Main Console Panel */
        .game-container { flex: 1; display: flex; flex-direction: column; height: 100%; }
        .game-log { flex: 1; padding: 25px; overflow-y: auto; display: flex; flex-direction: column; gap: 20px; }
        .log-entry { line-height: 1.6; animation: fadeIn 0.3s ease-out; }
        .entry-dm { border-left: 3px solid var(--accent-gold); padding-left: 15px; }
        .entry-player { border-left: 3px solid var(--text-muted); padding-left: 15px; color: #cbd5e1; font-style: italic; }
        .entry-system { background: rgba(223, 177, 91, 0.1); border: 1px solid rgba(223, 177, 91, 0.3); padding: 10px 15px; border-radius: 6px; font-size: 0.9rem; color: var(--accent-gold); }
        
        /* Width of the scrollbar */
        #game-log::-webkit-scrollbar {
            width: 8px;
        }

        /* The track (the background the bar slides on) */
        #game-log::-webkit-scrollbar-track {
            background: transparent;
        }

        /* The handle (the part you drag) */
        #game-log::-webkit-scrollbar-thumb {
            background: rgba(255, 255, 255, 0.1); /* Very faint white */
            border-radius: 4px;
        }

        /* The handle when you hover over it */
        #game-log::-webkit-scrollbar-thumb:hover {
            background: rgba(255, 255, 255, 0.3); /* Slightly more visible on hover */
        }

        .input-area { background-color: var(--panel-bg); border-top: 2px solid var(--border-color); padding: 20px; display: flex; gap: 15px; align-items: center; }
        .text-input { flex: 1; background-color: var(--bg-dark); border: 1px solid var(--border-color); color: var(--text-main); padding: 12px 16px; border-radius: 6px; font-size: 1rem; outline: none; }
        
        .btn { background-color: var(--accent-gold); color: #121214; border: none; padding: 12px 24px; border-radius: 6px; font-weight: bold; cursor: pointer; font-size: 1rem; }
        .btn:hover { background-color: #cf9f48; }
        .btn-dice { background-color: #2d3748; color: var(--text-main); border: 1px solid var(--border-color); padding: 12px 16px; }
        .btn-save { background-color: #2b6cb0; color: white; padding: 8px 12px; font-size: 0.85rem; margin-top: auto; }
        
        .sidebar-tabs {
            display: flex;
            gap: 5px;
            margin-bottom: 15px;
            border-bottom: 2px solid #444;
            padding-bottom: 5px;
        }
        .tab-btn {
            background: none;
            border: none;
            color: #888;
            font-size: 1rem;
            font-weight: bold;
            cursor: pointer;
            padding: 5px 10px;
            transition: color 0.2s;
        }
        .tab-btn:hover {
            color: #fff;
        }
        .tab-btn.active {
            color: #ff9f43; /* Or your preferred theme accent color */
            border-bottom: 2px solid #ff9f43;
        }
        .equipment-list {
            display: flex;
            flex-direction: column;
            gap: 8px;
            font-size: 0.95rem;
        }
        .equip-slot {
            padding: 6px;
            background: rgba(255, 255, 255, 0.05);
            border-radius: 4px;
        }

        .inventory-item {
            cursor: pointer;
            padding: 4px 6px;
            border-radius: 4px;
            transition: background 0.2s;
        }
        .inventory-item:hover {
            background: rgba(255, 255, 255, 0.1);
            color: #ff9f43;
        }

        @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
        @keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
        /* Default styles for desktop keep your side-by-side layout */

        #mobile-menu-btn {
    display: none;
}

@media screen and (max-width: 768px) {
    
    #mobile-nav-bar {
        display: flex !important;
        justify-content: space-around;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        background: #111 !important;
        padding: 8px !important;
        z-index: 1100 !important;
        box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    }

    #mobile-nav-bar button {
        background: #ffb03a !important;
        color: #000 !important;
        border: none !important;
        padding: 6px 12px !important;
        font-weight: bold !important;
        border-radius: 4px !important;
        cursor: pointer !important;
        font-size: 0.8rem !important;
    }

    .game-container {
        padding-top: 45px !important;
        height: calc(100vh - 45px) !important;
        box-sizing: border-box !important;
    }

    /* --- SIDEBAR MOBILE DRAWER FIXES --- */
    .sidebar, .sidebar-right {
        position: fixed !important;
        top: 0 !important;
        width: 85% !important;
        max-width: 320px !important;
        height: 100vh !important;
        max-height: 100vh !important;
        background: #1a1a1a !important;
        z-index: 1200 !important;
        transition: transform 0.3s ease-in-out !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box !important;
        box-shadow: 0 0 20px rgba(0,0,0,0.8) !important;
        /* Reset top padding back to normal since close button is sticky */
        padding: 15px 15px 90px 15px !important; 
    }

    /* Pinned Sticky Close Button */
    .mobile-close-btn {
        display: block !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 10 !important;
        width: 100%;
        background: #222 !important;
        color: #ffb03a !important;
        border: 1px solid #ffb03a !important;
        padding: 12px !important;
        font-weight: bold !important;
        border-radius: 4px !important;
        margin-bottom: 15px !important;
        cursor: pointer !important;
        text-align: center;
        box-shadow: 0 4px 6px rgba(0,0,0,0.4);
    }
}

    /* Left Sidebar Off-Screen Position & Slide */
    .sidebar {
        left: 0 !important;
        transform: translateX(-100%) !important;
    }
    .sidebar.sidebar-open {
        transform: translateX(0) !important;
    }

    /* Right Sidebar Off-Screen Position & Slide */
    .sidebar-right {
        right: 0 !important;
        transform: translateX(100%) !important;
    }
    .sidebar-right.sidebar-open {
        transform: translateX(0) !important;
    }

    /* Styling for the close button pinned inside the sidebars */
    .mobile-close-btn {
        display: block !important;
        width: 100%;
        background: #333 !important;
        color: #ffb03a !important;
        border: 1px solid #ffb03a !important;
        padding: 10px !important;
        font-weight: bold !important;
        border-radius: 4px !important;
        margin-bottom: 15px !important;
        cursor: pointer !important;
        text-align: center;
    }


/* Hide mobile close buttons on desktop */
@media screen and (min-width: 769px) {
    .mobile-close-btn {
        display: none !important;
    }
    #mobile-nav-bar {
        display: none !important;
    }
    .sidebar, .sidebar-right {
        position: relative !important;
        transform: none !important;
        height: auto !important;
        display: flex !important;
    }
    .game-container {
        padding-top: 0 !important;
        height: auto !important;
    }
}
/* Tabbed Info Box (Right Side) */
.info-tab-box {
    flex: 1;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 9px;
    padding: 25px;
    max-width: 450px;
    width: 100%;
    color: #f8fafc;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
}

.tab-header {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    padding-bottom: 8px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: #a0aec0;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    padding: 4px 8px;
}

.tab-btn.active {
    color: var(--accent-gold);
    border-bottom: 2px solid var(--accent-gold);
}