:root {
    --bg-darker: #0a1120;
    --bg-dark: #0f172a;
    --bg-light: #1e293b;
    --bg-lighter: #334155;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --brand: #f29358;
    --brand-hover: #e67e3a;
    --danger: #fa777c;
}

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

body {
    font-family: 'gg sans', 'Noto Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* Auth Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-dark);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal {
    background-color: var(--bg-light);
    padding: 32px;
    border-radius: 8px;
    width: 400px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.modal h2 {
    margin-bottom: 8px;
}

.modal p {
    color: var(--text-muted);
    margin-bottom: 20px;
}

.modal input {
    width: 100%;
    padding: 10px;
    background-color: var(--bg-darker);
    border: none;
    border-radius: 4px;
    color: var(--text-main);
    margin-bottom: 16px;
}

.modal button {
    width: 100%;
    padding: 12px;
    background-color: var(--brand);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.error {
    color: var(--danger);
    margin-top: 10px;
    font-size: 14px;
}

/* App Layout */
#app {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 240px;
    background-color: var(--bg-dark);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.sidebar-header {
    height: 48px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 0 rgba(0,0,0,0.2);
}

.channels-list {
    flex: 1;
    padding: 8px;
    overflow-y: auto;
}

.channel-item {
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.channel-item:hover {
    background-color: var(--bg-lighter);
    color: var(--text-main);
}

.channel-item.active {
    background-color: var(--bg-lighter);
    color: white;
}

.channel-item .edit-btn {
    display: none;
    float: right;
    font-size: 10px;
    padding: 2px 4px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 2px;
    color: var(--text-muted);
}

.channel-item:hover .edit-btn {
    display: block;
}

/* Message Actions */
.message {
    position: relative;
    margin-bottom: 16px;
}

.message .delete-btn {
    display: none;
    position: absolute;
    right: 0;
    top: 0;
    background: var(--bg-lighter);
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    color: var(--danger);
    cursor: pointer;
}

.message:hover .delete-btn {
    display: block;
}

/* User Actions */
.user-item {
    position: relative;
    padding: 8px;
    border-radius: 4px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.user-item .user-actions {
    display: none;
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    gap: 4px;
}

.user-item:hover .user-actions {
    display: flex;
}

.user-item button {
    background: var(--bg-darker);
    border: 1px solid #444;
    color: var(--text-muted);
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 2px;
    cursor: pointer;
}

.user-item button:hover {
    color: white;
    border-color: white;
}


.user-info {
    height: 52px;
    background-color: #232428;
    padding: 0 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logout-btn {
    background-color: transparent;
    color: var(--text-muted);
    border: 1px solid var(--text-muted);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
}

.logout-btn:hover {
    color: white;
    border-color: white;
    background-color: rgba(255,255,255,0.1);
}


.chat-area {
    flex: 1;
    background-color: var(--bg-light);
    display: flex;
    flex-direction: column;
}

.chat-header {
    height: 48px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 0 rgba(0,0,0,0.2);
}

.messages-container {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background-color: #000;
}

.message {
    margin-bottom: 2px;
    line-height: 1.2;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px;
}

.message-header {
    display: contents;
}

.message-username {
    font-weight: 600;
}

.message-time {
    font-size: 11px;
}

.message-content {
    word-break: break-word;
}

.message-input-container {
    padding: 0 16px 24px 16px;
    background-color: #000;
}

#message-input {
    width: 100%;
    padding: 11px;
    background-color: var(--bg-lighter);
    border: none;
    border-radius: 8px;
    color: var(--text-main);
}

.users-sidebar {
    width: 240px;
    background-color: var(--bg-dark);
    display: flex;
    flex-direction: column;
    border-left: 1px solid rgba(0,0,0,0.2);
}

.users-list {
    flex: 1;
    padding: 8px;
    overflow-y: auto;
}

.user-item {
    padding: 8px;
    border-radius: 4px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.user-item:hover {
    background-color: var(--bg-lighter);
    color: var(--text-main);
}



/* User Status */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
    flex-shrink: 0;
}
.status-online {
    background-color: #23a559;
}
.status-idle {
    background-color: #f0b232;
}
.status-offline {
    background-color: #80848e;
}


/* Game World UI */
/* Game World UI - Refined from Screenshot */





/* Reverted 12x12 Odyssey UI */
#game-layout {
    display: flex;
    flex-direction: row;
    background: var(--bg-light);
    padding: 12px;
    gap: 12px;
    justify-content: center;
    align-items: flex-start; /* Ensure vertical alignment */
    border: 3px ridge var(--bg-lighter);
    width: fit-content;
    margin: 10px auto;
    box-sizing: border-box;
}

#game-canvas-wrapper {
    border: 4px inset #222;
    background: #000;
    width: 584px; /* 576 + 8 for border */
    height: 584px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}

#game-canvas {
    width: 576px;
    height: 576px;
    display: block;
    image-rendering: pixelated;
}

#game-sidebar {
    display: flex;
    flex-direction: row;
    gap: 8px;
    height: 392px;
    box-sizing: border-box;
}

#game-sidebar-left {
    display: flex;
    flex-direction: column;
    width: 250px;
    gap: 4px;
    height: 100%;
}

.game-box {
    background: var(--bg-dark);
    border: 3px inset var(--bg-lighter);
    padding: 4px;
    box-sizing: border-box;
}

.stats-box {
    width: 250px;
    height: 68px;
}

.inventory-box {
    width: 250px;
    height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.item-info-box {
    width: 250px;
    height: 88px;
    overflow: hidden;
}

#game-map-title {
    height: 24px;
    background: #111;
    color: #ffd700;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 12px;
    text-align: center;
    border: 3px inset var(--bg-lighter);
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    box-sizing: border-box;
}

#game-sidebar-right {
    width: 85px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.game-buttons {
    display: flex;
    flex-direction: column;
    gap: 3px;
    height: 100%;
}

.game-buttons button {
    flex-grow: 1; /* Make buttons fill the height evenly */
    background: var(--bg-lighter);
    border: 2px outset var(--text-muted);
    color: #fff;
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    text-transform: uppercase;
}


/* Inner Stats and Inventory Styles */
.stat-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.stat-label {
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    text-shadow: 1px 1px #000;
}

.stat-bar {
    flex-grow: 1;
    height: 12px;
    background: #000;
    border: 1px solid #555;
    position: relative;
    box-shadow: inset 1px 1px 2px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.stat-fill {
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
    transition: width 0.1s ease;
}

.stat-text {
    font-size: 10px;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 1px black;
    pointer-events: none;
    white-space: nowrap;
    z-index: 10;
    position: relative;
    line-height: 12px; /* Matches bar height to force exact vertical centering */
    margin-top: 1px; /* Slight optical adjustment for pixel fonts */
}
.stat-fill.hp { background: #d63031; }
.stat-fill.energy { background: #27ae60; }
.stat-fill.mana { background: #0984e3; }
.stat-fill.exp { background: #fdcb6e; }

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(5, 36px);
    grid-template-rows: repeat(5, 36px);
    gap: 3px;
}

.inv-slot {
    width: 32px;
    height: 32px;
    background: #000;
    border: 1px inset var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #ffd700;
    box-sizing: border-box;
}

.inv-slot.eq {
    background: #222;
    border: 1px inset #555;
    font-weight: bold;
}

.inv-slot.selected {
    border: 1px solid #fff !important;
    box-shadow: inset 0 0 4px rgba(255,255,255,0.5);
}


/* Gameplay UX and Dynamic Chat Theme */
.no-select {
    user-select: none !important;
    -webkit-user-select: none !important;
}

.messages-container.in-world-theme {
    background-color: #000 !important;
    font-size: 11px !important;
    color: #ccc !important;
}

.messages-container.in-world-theme .message {
    padding: 1px 8px !important;
    border-bottom: none !important;
}

.messages-container.in-world-theme .message-username {
    font-size: 11px !important;
}

.messages-container.in-world-theme .message-time {
    font-size: 9px !important;
}


/* Aligned Chat Input and Theme Colors */
.user-info {
    height: 60px !important; /* Standardized height */
    border-top: 1px solid rgba(0,0,0,0.2);
}

.message-input-container {
    height: 60px !important;
    padding: 0 16px !important;
    display: flex;
    align-items: center;
    background-color: #2b2d31; /* Default Discord-like gray */
    border-top: 1px solid rgba(0,0,0,0.2);
    box-sizing: border-box;
    gap: 8px;
}

#chat-mode-select {
    background-color: var(--bg-lighter);
    border: none;
    border-radius: 4px;
    color: var(--text-main);
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    min-width: 80px;
}

#tell-target-container {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

#tell-target-input {
    background-color: var(--bg-lighter);
    border: none;
    border-radius: 4px;
    color: var(--text-main);
    padding: 4px 8px;
    font-size: 12px;
    width: 100px;
}

#message-input {
    flex: 1;
    padding: 11px;
    background-color: var(--bg-lighter);
    border: none;
    border-radius: 8px;
    color: var(--text-main);
}

.message-input-container.in-world-theme {
    background-color: #000 !important;
    border-top: 1px solid #111 !important;
}

.message-input-container.in-world-theme #chat-mode-select,
.message-input-container.in-world-theme #tell-target-input,
.message-input-container.in-world-theme #message-input {
    background-color: #111 !important;
    border: 1px solid #222 !important;
    color: #ffd700 !important; /* Gold text in game chat */
    font-family: 'Courier New', monospace;
}

.message-input-container.in-world-theme #message-input {
    font-size: 12px;
}

.character-list {
    margin-top: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.character-item {
    background: #2f3136;
    margin-bottom: 8px;
    padding: 10px;
    border-radius: 4px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

.char-info {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.char-info strong {
    font-size: 16px;
    color: #fff;
}

.char-info span {
    font-size: 12px;
    color: #b9bbbe;
}

.btn.small {
    padding: 4px 12px;
    font-size: 12px;
}
