/* --- FONTS & THEMES --- */
@font-face {
    font-family: 'VegaSmallCaps';
    src: url('/VegaSmallCaps.ttf') format('truetype');
}

/* --- SIDEBAR --- */
#sidebar {
    grid-area: sidebar;
    background-color: var(--panel-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: visible;
    z-index: 100;
}

.sidebar-section {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-section h3 {
    margin: 0 0 10px 0;
    font-size: 1em;
    color: var(--highlight-color);
}

.sidebar-section .button-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
}

#bottom-panel-container {
    grid-area: bottom-panel;
    display: flex;
    flex-direction: row-reverse;
    border-top: 1px solid var(--border-color);
    background-color: var(--panel-bg);
    overflow: visible;
    z-index: 90;
}

/* ============================================================
   RESPONSIVE / MOBILE SYSTEM
   ============================================================ */

@media (max-width: 768px) {
    body {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
        grid-template-areas: "main"; /* Canvas fills everything */
    }

    /* 1. SIDEBAR AS DRAWER (PULL FROM LEFT) */
    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        max-height: 90vh;
        transform: translateY(-95%); /* Hidden by default */
        transition: transform 0.3s ease-in-out;
        box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    }
    
    #sidebar.open {
        transform: translateY(0);
    }

    .sidebar-resize-handle {
        display: block;
        width: 20%;
        cursor: pointer;
        border: 1px solid var(--border-color);
        background-color: var(--panel-bg);
        position: absolute;
        left: 50%;
        top: 100%;
        height: 10px;
        z-index: 100;
        transform: translate(-50%, -50%);
    }

    .bottom-panel-resize-handle {
        display: block;
        width: 20%;
        cursor: pointer;
        border: 1px solid var(--border-color);
        background-color: var(--panel-bg);
        position: absolute;
        left: 50%;
        bottom: 100%;
        height: 10px;
        z-index: 100;
        transform: translate(-50%, 50%);
    }

    /* 2. BOTTOM PANEL AS DRAWER (PULL FROM BOTTOM) */
    #bottom-panel-container {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100vw;
        height: 50vh;
        flex-direction: column;
        transform: translateY(95%); /* Hidden by default */
        transition: transform 0.3s ease-in-out;
        box-shadow: 0 -5px 15px rgba(0,0,0,0.5);
    }

    #_bottom-panel-container {
        flex-direction: column;
    }

    #bottom-panel-container.open {
        transform: translateY(0);
    }

    #console-panel { border-right: none; border-bottom: 1px solid var(--border-color); }

    /* 3. MOBILE HUD ADJUSTMENTS */
    #editor-toolbar {
        top: 50px; /* Lowered to avoid system notches */
        flex-direction: row;
        width: calc(100% - 20px);
    }

    #chat {
        width: 60%;
        height: 15%;
        bottom: 130px; /* Moved up to clear HP bar */
        font-size: 0.8em;
    }

    #hp-toolbar {
        width: 90%;
        bottom: 20px;
    }

    #quick-use-container {
        left: 20px;
        bottom: 60px;
        transform: none;
        flex-direction: row;
    }

    .quick-slot-wrapper {
        width: 40px;
        height: 40px;
    }
    
    /* Stats and containers */
    .stats-container {
        flex-direction: column;
        gap: 10px;
    }

    /* Modal scaling for small screens */
    .command-modal-panel {
        width: 95%;
        max-height: 80%;
    }
}

/* Form row fixes for labels */
.command-modal-form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

.command-modal-form-row label {
    min-width: 100px;
}

input, select, textarea {
    padding: 8px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color-strong);
    font-family: inherit;
}