 @font-face {
    font-family: 'VegaSmallCaps';
    src: url('/VegaSmallCaps.ttf') format('truetype')
}


:root {
    --bg-color: #2a2a2e;
    --panel-bg: #1e1e1e;
    --border-color: #444;
    --text-color: #ccc;
    --text-color-strong: #fff;
    --highlight-color: #007acc;
    --highlight-color-light: hsl(from var(--highlight-color) h s calc(l + 15));
    --font-family: 'VegaSmallCaps';
    --input-bg: #333;
    --button-bg: #333;
    --button-hover-bg: #555;
    --header-bg: #333;
    --overlay-bg: rgba(0, 0, 0, 0.5);
    --scrollbar-thumb-border: #2c2f33;
    --hp-bar-empty-bg: #3c0e0e;
    --hp-bar-full-bg: #de3a3a;
    --sidebar-width: 300px;
    --bottom-panel-height: 200px;
}

html[data-theme='light'] {
    --bg-color: #f4f4f4;
    --panel-bg: #ffffff;
    --border-color: #d1d1d1;
    --text-color: #333;
    --text-color-strong: #000;
    --highlight-color-light: hsl(from var(--highlight-color) h s calc(l + 30));
    --input-bg: #eeeeee;
    --button-bg: #e0e0e0;
    --button-hover-bg: #cccccc;
    --header-bg: #f0f0f0;
    --overlay-bg: rgba(255, 255, 255, 0.7);
    --scrollbar-thumb-border: #e0e0e0;
    --hp-bar-empty-bg: #f5c0c0;
    --hp-bar-full-bg: #d9534f;
}

#editor {
    height: 0;
    flex-grow: 1;
    width: 100%;
}

body {
    margin: 0;
    height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: 1fr var(--bottom-panel-height);
    grid-template-areas:
        "sidebar main"
        "sidebar bottom-panel";
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
}

.toolbar-group.mode-toggle {
    border: 2px solid var(--highlight-color);
    background: rgba(0, 122, 204, 0.2);
}

.tool-btn[data-tool="draw"]:hover { background: #2d7546; }
.tool-btn[data-tool="erase"]:hover { background: #752d2d; }
.tool-btn[data-tool="box_select"]:hover { background: #2d5e75; }

body.mode-edit #main-view {
    outline: 3px dashed orange;
    outline-offset: -3px;
}

/* NEW: Container for Console + Admin */
#bottom-panel-container {
    grid-area: bottom-panel;
    display: flex;
    flex-direction: row;
    border-top: 1px solid var(--border-color);
    background-color: var(--panel-bg);
    overflow: hidden;
}

#_bottom-panel-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: row;
    border-top: 1px solid var(--border-color);
    background-color: var(--panel-bg);
    overflow: hidden;
}

/* Modified Console Panel to fit inside flex container */
#console-panel {
    flex: 2; /* Takes 66% width */
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    min-width: 0;
}

/* NEW: Admin Panel Styles */
#admin-commands-panel {
    flex: 1; /* Takes 33% width */
    display: flex;
    flex-direction: column;
    min-width: 300px;
    background-color: var(--panel-bg);
}

#admin-commands-header {
    padding: 5px 10px;
    background-color: var(--header-bg);
    font-weight: bold;
    color: var(--highlight-color);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9em;
    display: flex;
    justify-content: space-between;
}

#admin-commands-header button:first-of-type{
    margin-left: auto;
}

#admin-commands-header button {
    line-height: 0px;
    max-height: 0.5rem;
}

#admin-commands-content {
    flex: 1;
    padding: 5px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); /* Grid of buttons */
    grid-auto-rows: max-content;
    gap: 5px;
}

/* Style for admin buttons to make them smaller/compact */
#admin-commands-content button {
    font-size: 0.8em;
    padding: 5px;
    text-align: center;
    white-space: normal;
    display: flex;
    justify-content: center;   /* horizontal center */
    align-items: center;        /* vertical center */
    text-align: center;         /* center multi-line text */
    
    max-height: 1.5rem;           /* whatever your limit is */
    padding: 4px 8px;

    line-height: 1.2;           /* avoid extra spacing */
    overflow: hidden;           /* optional */
}

.panel {
    background-color: var(--panel-bg);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#sidebar {
    grid-area: sidebar;
}

#main-view {
    grid-area: main;
    position: relative;
}

#console-panel {
    grid-area: console;
}

#canvas-container {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    cursor: crosshair;
    padding: 2px;
    padding-right: 0px;
}

#canvas-container:focus {
    box-sizing: border-box;
    box-shadow: inset 0px 0px 5px 5px var(--highlight-color);
}

/* Sidebar styling */
.sidebar-section {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    /* Added for better internal layout */
    flex-direction: column;
    /* Added for better internal layout */
}

.sidebar-section .button-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    width: 100%;
}

.sidebar-section .button-grid button {
    width: 100%;
}

.sidebar-section h3 {
    margin: 0 0 10px 0;
    font-size: 1em;
    color: var(--highlight-color);
}

.sidebar-resize-handle, .bottom-panel-resize-handle {
    display: none;
}

input,
textarea {
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color-strong);
    border-radius: 4px;
}

#entity-tree {
    flex: 1;
    overflow-y: auto;
    padding: 5px;
}

.entity-item {
    padding: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.entity-item:hover {
    background-color: var(--button-hover-bg);
}

.entity-item.selected {
    background-color: var(--highlight-color);
    color: white;
}

#component-inspector {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.component-box {
    margin-bottom: 10px;
    border: 1px solid var(--input-bg);
    padding: 5px;
    max-height: 150px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.component-box * button {
    line-height: 0;
}

.component-box h4 {
    margin: 0 0 5px 0;
    font-size: 0.9em;
    background-color: var(--input-bg);
    padding: 3px;
}

/* Console styling */
#console-output {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    white-space: pre-wrap;
    display: flex;
    flex-direction: column-reverse;
    /* Newest logs at the bottom */
}

#console-input-area {
    display: flex;
    border-top: 1px solid var(--border-color);
}

#console-input {
    flex: 1;
    padding: 8px;
    border: none;
    outline: none;
    background-color: transparent;
    color: var(--text-color);
    font-family: var(--font-family);
    border-radius: 0;
}

/* Block Controls */
#block-controls {
    position: absolute;
    top: 10px;
    left: 10px;
    background: var(--overlay-bg);
    padding: 10px;
    border-radius: 5px;
    z-index: 10;
}

#block-position {
    display: none;
    gap: 10px;
}

#block-controls-bottom-right {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: var(--overlay-bg);
    padding: 10px;
    border-radius: 5px;
    z-index: 9;
}


#block-controls-right {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--overlay-bg);
    padding: 10px;
    border-radius: 5px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 10px;
}

#block-controls label,
#block-controls input,
#block-controls select {
    margin-right: 10px;
}

#block-controls-right button {
    max-height: 1.5em;
    line-height: 0.5em;
}

#chat {
    position: absolute;
    bottom: 10px;
    left: 10px;
    min-width: 25%;
    max-width: 25%;
    max-height: 20%;
    min-height: 20%;
    background: var(--overlay-bg);
    padding: 10px;
    border-radius: 5px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 5px
}

#chat-output {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    padding-bottom: 5px;
}

#chat-message-list {
    display: flex;
    flex-direction: column;
    margin-top: auto;
    /* THE MAGIC! Pushes this block to the bottom */
}

.chat-message-wrapper {
    display: flex;
}

.chat-name {
    font-weight: bolder;
    color: var(--highlight-color-light);
    padding-right: 12px;
}

.chat-message {
    flex: 1
}

#chat-input {
    flex: 0;
}

input[type=number] {
    width: 50px;
}

/* General UI Elements */
button {
    padding: 8px 15px;
    border: none;
    cursor: pointer;
    background-color: var(--button-bg);
    color: var(--text-color);
    font-family: var(--font-family);
}

button:hover {
    background: var(--button-hover-bg);
}

.tab-btn {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    border-bottom: solid 1px var(--border-color);
    padding: 5px;
    border: none;
    cursor: pointer;
    color: var(--text-color);
    font-family: var(--font-family);
    background-color: var(--border-color);
}

.tab-btn:hover {
    background: var(--button-hover-bg);
}

.tab-btn.active {
    border-bottom: none;
    color: var(--highlight-color);
    font-weight: bolder;
    background-color: var(--panel-bg) !important;
}

.tab-btn.active:hover {
    background: var(--button-hover-bg);
}

.tab {
    border-top: none;
}

#login-overlay {
    position: absolute;
    z-index: 999999;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(2px);
    display: flex;
    justify-content: center;
    align-items: center;
}
#login-overlay .panel {
    width: 100vw;
    height: 100vh;
    background-color: rgba(10, 10, 10, 0.85); /* Dark semi-transparent background */
    backdrop-filter: blur(3px); /* Optional: blurs the 3D scene behind it */
    z-index: 500;
    pointer-events: all; /* Blocks clicks to the canvas */
}


::-webkit-scrollbar {
    width: 8px;
    height: 8px;
    padding: 2px;
}

::-webkit-scrollbar-track {
    background: var(--border-color);
}

::-webkit-scrollbar-thumb {
    background-color: var(--text-color);
    border-radius: 20px;
    border: 2px solid var(--scrollbar-thumb-border);
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--highlight-color);
}

#choice-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(1px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.choice-modal-panel {
    min-width: 350px;
    max-width: 50%;
    background-color: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 3px 3px 15px 5px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.choice-modal-body {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px; /* Spacing between choice buttons */
}

.choice-option-btn {
    width: 100%;
    padding: 12px 15px;
    text-align: center;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

#item-studio-editor,
#item-studio-overlay,
#ai-modal-overlay,
#es-modal-overlay,
#command-modal-overlay,
.command-modal-overlay,
#item-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(1px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.command-modal-panel {
    min-width: 450px;
    max-width: 90%;
    max-height: 90%;
    background-color: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 3px 3px 15px 5px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.command-modal-header {
    padding: 15px;
    background-color: var(--header-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.command-modal-header h3 {
    margin: 0;
    color: var(--highlight-color);
}

.command-modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5em;
    color: var(--text-color);
    cursor: pointer;
    line-height: 1;
    padding: 0 5px;
}

.command-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.command-modal-form-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.command-modal-form-row label {
    padding-right: 20px;
}

.command-modal-form-row input[type="text"],
.command-modal-form-row input[type="number"],
.command-modal-form-row textarea {
    flex-grow: 1;
    padding: 8px;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color-strong);
}

.command-modal-form-row input[type="checkbox"] {
    width: 20px;
    height: 20px;
}

.command-modal-footer {
    padding: 15px;
    display: flex;
    justify-content: flex-end;
    border-top: 1px solid var(--border-color);
    background-color: var(--header-bg);
}

.command-modal-footer span {
    margin-right: auto;
}

/* ----- INVENTORY & EQUIPMENT STYLES ----- */
.inventory-container,
.equipment-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
    overflow-y: auto;
}

.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    row-gap: 4px;
    border-radius: 4px;
    min-height: 80px;
    overflow-y: auto;
    flex-grow: 1;
}

.equipment-slots {
    display: grid;
    grid-template-columns: repeat(5, 48px);
    grid-template-rows: repeat(3, 48px);
    gap: 5px;
    justify-content: center;
    align-content: center;
    border-radius: 4px;
}

.item-slot {
    width: 40px;
    height: 40px;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.7em;
    color: #888;
    overflow: hidden;
    position: relative;
    user-select: none;
    box-sizing: border-box;
    overflow: visible;
}

.item-slot:hover .tooltip {
  display: block;
  opacity: 1; /* Fade in */
}

.item-slot .tooltip {
  /* NEW */
  display: none;
  pointer-events: none;
}

.tooltip {
  display: none;
  /* NEW */
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  padding: 10px;
  position: fixed;
  z-index: 1000;
  width: 180px;
    top: 0; 
  left: 0;
  transition: opacity 0.1s ease-in-out;
  opacity: 0;
}

.tooltip span {
    background-color: var(--border-color);
    height: 1px;
    width: 100%;
    display: block;
    margin-top: 5px;
    margin-bottom: 5px;
}

.tooltip b {
    font-size: 14px;
}

.item-slot.has-item {
    cursor: pointer;
    border-color: #666;
}

.item-slot[draggable="true"] {
    cursor: grab;
}

.item-slot.has-item:hover {
    border-color: var(--highlight-color);
}

.item-slot.drag-over,
#main-view.drag-over {
    outline: 2px solid var(--highlight-color);
    box-shadow: 0 0 5px var(--highlight-color);
}

/* --- Base Rarity Colors (For Common and undefined, default styles apply) --- */
.item-slot.has-item.rarity-common {
    /* Subtle blue border and glow */
    border-color: #3d9123;
}

.tooltip.rarity-common,
.item-slot.has-item.rarity-common:hover {
    border-color: #45a827; /* Deep Sky Blue on hover */
    box-shadow: 0 0 3px #45a827;
}

/* RARE ITEMS */
.item-slot.has-item.rarity-rare {
    /* Subtle blue border and glow */
    border-color: #0088FF; /* Medium Blue */
    box-shadow: 0 0 5px rgba(0, 136, 255, 0.5);
}

.tooltip.rarity-rare,
.item-slot.has-item.rarity-rare:hover {
    border-color: #00BFFF; /* Deep Sky Blue on hover */
    box-shadow: 0 0 7px #00BFFF;
}

/* EPIC ITEMS */
.item-slot.has-item.rarity-epic {
    /* Purple border and glow */
    border-color: #AA00FF; /* Medium Purple */
    box-shadow: 0 0 5px rgba(170, 0, 255, 0.6);
}

.tooltip.rarity-epic,
.item-slot.has-item.rarity-epic:hover {
    border-color: #BF00FF; /* Electric Purple on hover */
    box-shadow: 0 0 8px #BF00FF;
}

/* LEGENDARY ITEMS */
.item-slot.has-item.rarity-legendary {
    /* Gold/Amber border and glow, maybe a slight gradient for extra effect */
    border-color: #FFB300; /* Amber/Gold */
    background: linear-gradient(135deg, rgba(30, 30, 30, 1) 0%, rgba(45, 40, 30, 1) 100%); /* Slight gold gradient background */
    box-shadow: 0 0 8px rgba(255, 179, 0, 0.7);
}

.item-slot.has-item.rarity-deus {
    /* Gold/Amber rgb(189, 39, 39)and glow, maybe a slight gradient for extra effect */
    border-color: #bf2525; 
    background: linear-gradient(135deg, rgba(30, 30, 30, 1) 0%, rgba(45, 40, 30, 1) 100%); /* Slight gold gradient background */
    box-shadow: 0 0 8px #bf2525c3;
}

.tooltip.rarity-legendary,
.item-slot.has-item.rarity-legendary:hover {
    border-color: #FFD700; /* Pure Gold on hover */
    box-shadow: 0 0 12px #FFD700;
}

.tooltip.rarity-deus,
.item-slot.has-item.rarity-deus:hover {
    border-color: #ee2d2d;
    box-shadow: 0 0 12px #ee2d2d;
}

/* --- Optional: Adjust Item Text Color to Match Rarity for better contrast/visibility --- */
.item-slot.has-item.rarity-rare .item-name {
    color: #00BFFF;
}
.item-slot.has-item.rarity-epic .item-name {
    color: #BF00FF;
}
.item-slot.has-item.rarity-legendary .item-name {
    color: #FFB300;
}

/* Ensure the drag-over visual remains consistent and overrides rarity borders */
.item-slot.drag-over,
#main-view.drag-over {
    /* Uses the existing highlight color from your base styles */
    outline: 2px solid var(--highlight-color); 
    box-shadow: 0 0 5px var(--highlight-color);
}

.item-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1px;
    font-size: 10px;
    line-height: 1.2;
    color: white;
    background: rgba(0, 0, 0, 0.6);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

.item-stack-count {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 10px;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px black;
    pointer-events: none;
}

/* Specific equipment slot placement */
.eq-slot {
    width: 100%;
    height: 100%;
}

/* --- ROW 1 --- */
.eq-slot-HEAD {        grid-area: 1 / 1; }
.eq-slot-BODY {        grid-area: 1 / 2; }
.eq-slot-HANDS {        grid-area: 1 / 3; }
.eq-slot-LEGS {        grid-area: 1 / 4; }
.eq-slot-FEET {        grid-area: 1 / 5; }

/* --- ROW 2 (blank in col 1) --- */
.eq-slot-ACCESSORY_1 { grid-area: 2 / 4; }
.eq-slot-ACCESSORY_2 { grid-area: 2 / 5; }
.eq-slot-ACCESSORY_3 { grid-area: 3 / 4; }
.eq-slot-ACCESSORY_4 { grid-area: 3 / 5; }

/* --- ROW 3 (blank in col 3) --- */
.eq-slot-WEAPON_1 {   grid-area: 3 / 1; }
.eq-slot-WEAPON_2 {   grid-area: 3 / 2; }
.eq-slot-SPECIAL_1 {   grid-area: 2 / 1; }
.eq-slot-SPECIAL_2 {   grid-area: 2 / 2; }

#item-context-menu {
    position: absolute;
    display: none;
    background-color: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 5px 0;
    z-index: 1000;
    min-width: 150px;
    box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
}

#item-context-menu h3 {
    text-align: center;
    color: var(--border-color);
    list-style: none;
    margin: 0;
    padding: 0;
}

#item-context-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

#item-context-menu li {
    padding: 8px 12px;
    cursor: pointer;
    user-select: none;
}

#item-context-menu li:hover {
    background-color: var(--highlight-color);
    color: white;
}

#entity-context-menu {
    position: absolute;
    display: none;
    background-color: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 5px 0;
    z-index: 1000;
    min-width: 150px;
    box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
}

#entity-context-menu h3 {
    text-align: center;
    list-style: none;
    margin: 0;
    padding: 0;
}

#entity-context-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

#entity-context-menu li {
    padding: 8px 12px;
    cursor: pointer;
    user-select: none;
}

#entity-context-menu li:hover {
    background-color: var(--highlight-color);
    color: white;
}

.stats-container {
    display: flex;
    flex-direction: row;
    gap: 50px;
}

.stats-container div {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.stats-container div div {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: stretch;
}

/* HP Bar Wrapper */
.hp-wrapper {
    margin-bottom: 10px;
    position: relative;
}

.hp-wrapper label {
    position: absolute;
    left: 5px;
    top: 0;
    z-index: 4;
    font-weight: bold;
    color: white;
    mix-blend-mode: difference;
}

.hp-label {
    text-align: center;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    line-height: 16px;
    /* same as bar height */
    font-weight: bold;
    color: white;
    mix-blend-mode: difference;
    /* <-- makes text invert against bg */
    z-index: 2;
    pointer-events: none;
}

.hp-bar-outer {
    border: 1px solid var(--text-color-strong);
    height: 16px;
    width: 100%;
    background: var(--bg-color);
    position: relative;
    overflow: hidden;
    z-index: -1;
}

.hp-bar-inner {
    background: var(--text-color-strong);
    height: 100%;
    width: 0%;
}

/* Inventory Modal specific styles */
.entity-inventory-modal {
    position: absolute;
    display: none;
    /* Hidden by default */
    background-color: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 3px 3px 15px 5px rgba(0, 0, 0, 0.5);
    z-index: 10001;
    /* Above other modals/context menus */
    min-width: 400px;
    max-width: 600px;
    max-height: 80vh;
    /* For inner scrolling content */
    flex-direction: column;
    /* To stack header, body */
}

.entity-inventory-modal .modal-header {
    padding: 10px 15px;
    background-color: var(--header-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.entity-inventory-modal .modal-header h3 {
    margin: 0;
    color: var(--highlight-color);
}

.entity-inventory-modal .modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5em;
    color: var(--text-color);
    cursor: pointer;
    line-height: 1;
    padding: 0 5px;
}

.entity-inventory-modal .modal-body {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    /* Allows the body to scroll if content is too tall */
    flex: 1;
    /* Allows it to grow and take available space */
}

.entity-inventory-modal .modal-section {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 5px;
    flex: 1;
    /* Allows sections to grow equally */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* For inner scrolling item grids */
}

#player-inventory-modal-section {
    display: none;
}

#player-equipment-modal-section {
    display: none;
}

.entity-inventory-modal .modal-section h4 {
    margin: 0 0 5px 0;
    padding-bottom: 5px;
    border-bottom: 1px dashed var(--border-color);
    color: var(--text-color-strong);
    font-size: 1em;
}

/* Adjust item grid for modal to allow it to scroll independently */
.entity-inventory-modal .item-grid {
    min-height: 100px;
    /* Ensure a minimum height for scrolling */
}

#player-buffs-container {
    display: flex;
    flex-direction: column-reverse;
    flex-wrap: wrap;
    min-height: 30px;
    position: absolute;
    bottom: 12px;
    left: calc(50% + 175px + 10px);
    border-radius: 5px;
    z-index: 10;
    align-items: start;
    justify-content: flex-start;
    gap: 4px;
}

.buff-item-old {
    position: relative;
    /* Needed for tooltip positioning */
    min-width: 24px;
    min-height: 24px;
    max-height: 24px;
    background-color: #555;
    border: 1px solid #888;
    border-radius: 5px;
    cursor: help;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    overflow: hidden;
    white-space: nowrap;
    padding: 5px;
}

.buff-item {
    position: relative;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  padding: 2px;
  font-size: 10px;
  min-width: 16px;
  min-height: 16px;
  max-height: 16px;
  cursor: help;
    display: flex;
    align-items: center;
    justify-content: center;
}
s 
.buff-name {
    color: white;
}

.buff-item:hover .buff-tooltip {
    display: block;
    /* Show tooltip on hover */
}

.buff-tooltip {
    display: none;
    position: absolute;
    bottom: 100%;
    /* Position above the buff item */
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #333;
    width: max-content;
    /* Adjust width to content */
    z-index: 100;
    font-size: 15px;
    pointer-events: none;
    /* Prevent the tooltip from interfering with mouse events */
    margin-bottom: 5px;
    /* Space between buff and tooltip */
}

/* ========================= */
/* RESPONSIVE ADJUSTMENTS    */
/* ========================= */

@media (max-width: 1024px) {
    body {
        grid-template-columns: 220px 1fr;
        grid-template-rows: 1fr 120px;
    }

    #chat {
        min-width: 35%;
        max-width: 35%;
    }
}

.social-list {
    background: var(--input-bg);
    border-radius: 4px;
    padding: 5px;
    overflow-y: auto;
}

.social-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px;
    border-bottom: 1px solid var(--border-color);
}

.social-item:last-child {
    border-bottom: none;
}

.social-item .btn-group {
    display: flex;
    gap: 5px;
}

.social-item button {
    padding: 2px 6px;
    font-size: 1.2em;
}

.social-item button:last-of-type {
    padding: 2px 6px;
    margin-top: 3px;
    font-size: 0.6em;
}

.social-item * small {
    color: #888;
}

/* --- Editor Toolbar (Top Left) --- */
#editor-toolbar {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    flex-wrap: wrap;
    row-gap: 3px;
    column-gap: 10px;
    z-index: 10;
}

.flex-break {
    flex-basis: 100%;
    height: 0;
}

.toolbar-group {
    display: flex;
    background: rgba(30, 30, 30, 0.9);
    border: 1px solid #444;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.tool-btn {
    background: transparent;
    border: none;
    border-right: 1px solid #444;
    color: #ccc;
    padding: 4px 10px;
    margin-top: -1px;
    width: 34px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
/* .tool-btn.deactivated {
    max-width: 0;
    padding: 0;
    content: '';
    font-size: 0;
} */

.tool-btn:last-child { border-right: none; }
.tool-btn:hover { background: #444; color: #fff; }
.tool-btn.active {
    background: var(--highlight-color, #008acc);
    color: #fff;
    font-weight: bold;
}

/* --- Bottom Right Panel --- */
#editor-bottom-panel {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    z-index: 10;
    pointer-events: none; /* Let clicks pass through gaps */
}

/* Enable pointer events on children */
#editor-bottom-panel > * { pointer-events: auto; }

.cam-mode-container {
    background: rgba(30, 30, 30, 0.9);
    border: 0px solid #444;
    border-radius: 6px;
    padding: 0px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.cam-btn-group { display: flex; gap: 1px; }

.cam-btn {
    flex: 1;
    background: #333;
    border: 1px solid #555;
    color: #bbb;
    padding: 5px 10px;
    font-size: 12px;
    cursor: pointer;
}
.cam-btn:first-child { border-radius: 4px 0 0 4px; }
.cam-btn:last-child { border-radius: 0 4px 4px 0; }
.cam-btn:hover { background: #444; color: #fff; }
.cam-btn.active {
    background: var(--highlight-color, #008acc);
    border-color: var(--highlight-color, #008acc);
    color: #fff;
}

.cam-options {
    display: flex;
    justify-content: center;
    padding-top: 2px;
    margin-top: -1px;
}

.cam-checkbox {
    font-size: 11px;
    color: #ccc;
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.info-overlay {
    background: rgba(0, 0, 0, 0.6);
    color: #eee;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
    display: flex;
    gap: 10px;
}

#block-position {
    position: absolute;
    top: 10px;
    display: flex;
    left: 50%;
    transform: translateX(-50%);
}

.system-controls {
    display: flex;
    align-items: center;
    position: fixed;
    right: 10px;
    top: 10px;
    display: flex;
    background: rgba(30, 30, 30, 0.9);
    border: 1px solid #444;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.system-controls button:nth-of-type(2) {
    border-left: 1px solid #444;
}

.system-controls span {
    width: 80px;
    padding: 4px 10px;
}

.system-controls button {
    background: transparent;
    border: none;
    border-right: 1px solid #444;
    color: #ccc;
    padding: 4px 10px;
    margin-top: -1px;
    width: 34px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.system-controls button:hover { background: #444; color: #fff; }

#disconnected-overlay,#died-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(10, 10, 10, 0.85); /* Dark semi-transparent background */
    backdrop-filter: blur(3px); /* Optional: blurs the 3D scene behind it */
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    z-index: 50; /* Above toolbars (z-index 10) */
    pointer-events: all; /* Blocks clicks to the canvas */
}

#disconnected-overlay,#died-overlay .overlay-content {
    text-align: center;
    color: #888;
    user-select: none;
}

#disconnected-overlay,#died-overlay h2 {
    margin: 0 0 10px 0;
    color: #ccc;
    font-family: sans-serif;
    font-weight: normal;
}


#hp-toolbar {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    width: 350px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    z-index: 10;
}

#quick-use-container {
    position: absolute;
    bottom: 12px; 
    left: calc(50% - 175px - 10px);
    transform: translateX(-100%);
    display: flex;
    gap: 10px;
    z-index: 10;
    pointer-events: none; /* Crucial: lets mouse clicks pass through to canvas */
}

.quick-slot-wrapper {
    /* Mimics item-slot style but wider/taller for quick-use visibility */
    width: 50px; 
    height: 50px;
    background-color: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    overflow: visible;
    position: relative;
    box-sizing: border-box;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    opacity: 0.95;
    transition: all 0.2s;
}

.quick-slot-wrapper.has-item {
    border-color: #666; /* Base color for non-rarity item */
}

/* Base rarity color overrides for the quick-use border - Use standard item-slot rarity colors */
.quick-slot-wrapper.rarity-rare { border-color: #00BFFF; }
.quick-slot-wrapper.rarity-epic { border-color: #BF00FF; }
.quick-slot-wrapper.rarity-legendary { border-color: #FFD700; }
.quick-slot-wrapper.rarity-deus { border-color: #ee2d2d; }
.quick-slot-wrapper.rarity-common { border-color: #45a827; }


.quick-slot-hotkey {
    background: var(--highlight-color);
    color: var(--text-color-strong);
    font-size: 14px;
    font-weight: bold;
    width: 0;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    position: absolute;
    left: 0;
    top: 0;
}

.quick-slot-cycle-hint {
    font-size: 10px;
    color: #999;
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
}

.item-visual {
    padding-left: 0; /* Offset for hotkey button */
    padding-right: 5px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
}

.item-visual .item-name {
    font-size: 12px;
    color: var(--text-color-strong);
    font-weight: bold;
    line-height: 1.2;
    /* Rarity name color overrides */
}
.quick-slot-wrapper.rarity-rare .item-visual .item-name { color: #00BFFF; }
.quick-slot-wrapper.rarity-epic .item-visual .item-name { color: #BF00FF; }
.quick-slot-wrapper.rarity-legendary .item-visual .item-name { color: #FFD700; }

.item-visual .item-stack-count {
    right: 2px;
    font-size: 10px;
    color: #ccc;
    text-shadow: 1px 1px 1px #000;
}

.quick-slot-wrapper.empty-slot {
    background-color: #333;
    border-style: dashed;
}

.quick-slot-wrapper .empty-text {
    margin-left: 50%;
    transform: translateX(-50%);
    color: #666;
    font-size: 16px;
    font-style: italic;
}

#prefab-list-modal-overlay .entity-item {
    font-size: 0.8em;
    padding: 3px;
}

#prefab-list-modal-overlay .entity-item.selected {
    background-color: var(--highlight-color);
    color: white;
}

fieldset {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin: 10px 0;
    padding: 10px;
    background: rgba(0, 0, 0, 0.15); /* Slightly darker than panel bg */
}

/* The label for the fieldset (e.g., "BODY LAYER") */
legend {
    padding: 0 8px;
    color: var(--highlight-color);
    font-weight: bold;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Ensure nested rows are compact */
.command-modal-form-row {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.command-modal-form-row label {
    font-size: 0.85rem;
    min-width: 100px;
}

select {
    flex: 1;
    padding: 8px;
    background: var(--input-bg);
    color: var(--text-color-strong);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: var(--font-family);
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: var(--highlight-color);
}

/* Specific styling for the 'Unknown' data warning */
option[value^="!!"] {
    color: #ff9800; /* Orange warning */
    font-weight: bold;
}

/* Styling for the "None (undefined)" option */
option[value="__UNDEFINED__"] {
    color: #888;
    font-style: italic;
}

.command-modal-form-row > div[style*="display: flex"] {
    flex: 2;
    display: flex;
    gap: 4px !important;
}

.command-modal-form-row input[type="number"] {
    min-width: 0; /* Allows shrinking in flex container */
    padding: 6px;
    text-align: center;
}

.tab-btn {
    transition: background 0.2s, color 0.2s;
    border-bottom: 2px solid transparent;
}

.tab-btn.active {
    border-bottom: 2px solid var(--highlight-color);
    background-color: rgba(0, 122, 204, 0.1);
}

/* Style for generic components in the list (italics) */
.tab-btn[style*="font-style: italic"] {
    opacity: 0.8;
}