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

body {
    background: #0e0e1f;
    font-family: 'Courier New', monospace;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    cursor: pointer;
}

/* ========== Login ========== */

#login-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 30, 0.95);
    z-index: 110;
}

#login-box {
    width: 340px;
    max-width: 90vw;
    background: rgba(18, 18, 40, 0.98);
    border: 1px solid #3a3a6a;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
}

#login-title {
    color: #ccccff;
    font-size: 28px;
    margin-bottom: 4px;
    letter-spacing: 2px;
}

#online-count {
    color: #66ee66;
    font-size: 11px;
    text-align: center;
    margin-bottom: 12px;
}

#login-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    justify-content: center;
}

#login-tabs button {
    padding: 6px 20px;
    background: #1a1a3a;
    border: 1px solid #4a4a7a;
    border-radius: 4px;
    color: #8888aa;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    cursor: pointer;
}

#login-tabs button.active {
    background: #2a2a5a;
    color: #ffffff;
    border-color: #8a8aff;
}

#login-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#login-form input {
    padding: 8px 12px;
    background: #1a1a3a;
    border: 1px solid #4a4a7a;
    border-radius: 4px;
    color: #ffffff;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    outline: none;
}

#login-form input:focus {
    border-color: #6a6aaa;
}

#btn-auth {
    padding: 8px;
    background: #2a2a5a;
    border: 1px solid #4a4a8a;
    border-radius: 4px;
    color: #aaaaff;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    cursor: pointer;
}

#btn-auth:hover {
    background: #3a3a7a;
    color: #ffffff;
}

#auth-error {
    color: #e74c3c;
    font-size: 12px;
    margin-top: 4px;
}

/* ========== Avatar Editor ========== */

#avatar-editor {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 30, 0.95);
    z-index: 105;
}

#avatar-editor-box {
    width: 400px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
    background: rgba(18, 18, 40, 0.98);
    border: 1px solid #3a3a6a;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

#avatar-editor-box h2 {
    color: #ccccff;
    font-size: 18px;
    margin-bottom: 12px;
}

#avatar-preview {
    display: block;
    margin: 0 auto 12px;
    width: 160px;
    height: 210px;
    border: 1px solid #3a3a6a;
    border-radius: 8px;
    background: #1a2a3a;
    image-rendering: pixelated;
}

#avatar-options {
    text-align: left;
}

.ae-section {
    margin-bottom: 10px;
}

.ae-label {
    color: #8888aa;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.ae-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.ae-btn {
    padding: 4px 10px;
    background: #1a1a3a;
    border: 1px solid #3a3a5a;
    border-radius: 3px;
    color: #9999bb;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    cursor: pointer;
}

.ae-btn:hover { border-color: #6a6aaa; color: #ccccee; }
.ae-btn.active { border-color: #8a8aff; background: #2a2a5a; color: #ffffff; }

.ae-swatch {
    width: 24px;
    height: 24px;
    border: 2px solid #3a3a5a;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
}

.ae-swatch:hover { border-color: #8a8aff; }
.ae-swatch.active { border-color: #ffffff; box-shadow: 0 0 6px rgba(255,255,255,0.4); }

#avatar-outfits-section { margin-top: 10px; border-top: 1px solid #3a3a6a; padding-top: 8px; }
#avatar-outfits { max-height: 120px; overflow-y: auto; margin-bottom: 6px; }
.ae-outfit-empty { color: #6a6a9a; font-size: 11px; text-align: center; padding: 8px; }
.ae-outfit-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid #2a2a4a; }
.ae-outfit-name { color: #ccccee; font-size: 12px; }
.ae-outfit-btns { display: flex; gap: 4px; }
.ae-outfit-save-row { display: flex; gap: 4px; }

#outfit-name-input {
    flex: 1; padding: 4px 8px; background: #1a1a3a; border: 1px solid #4a4a7a; border-radius: 3px;
    color: #ffffff; font-family: 'Courier New', monospace; font-size: 11px; outline: none;
}

#btn-save-avatar {
    margin-top: 12px;
    padding: 8px 24px;
    background: #2a2a5a;
    border: 1px solid #4a4a8a;
    border-radius: 4px;
    color: #aaaaff;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    cursor: pointer;
}

#btn-save-avatar:hover { background: #3a3a7a; color: #ffffff; }

/* ========== Lobby ========== */

.check-label {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #9999bb;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
}

.check-label input[type="checkbox"] {
    accent-color: #6a6aaa;
}

.lock-icon {
    font-size: 11px;
}

/* ========== Lobby ========== */

#lobby-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 30, 0.92);
    z-index: 100;
}

#lobby-box {
    width: 700px;
    max-width: 95vw;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    background: rgba(18, 18, 40, 0.98);
    border: 1px solid #3a3a6a;
    border-radius: 12px;
    overflow: hidden;
}

#lobby-header {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 16px 20px 8px;
}

#lobby-title {
    color: #ccccff;
    font-size: 24px;
    font-weight: bold;
    letter-spacing: 2px;
}

#lobby-close {
    position: absolute;
    right: 16px;
    background: none;
    border: none;
    color: #8888aa;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

#lobby-close:hover { color: #ffffff; }

#lobby-tabs {
    display: flex;
    gap: 4px;
    padding: 0 16px 8px;
    justify-content: center;
}

.lobby-tab {
    padding: 5px 16px;
    background: #1a1a3a;
    border: 1px solid #3a3a5a;
    border-radius: 4px;
    color: #8888aa;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.lobby-tab:hover { border-color: #6a6aaa; color: #ccccee; }
.lobby-tab.active { background: #2a2a5a; color: #ffffff; border-color: #8a8aff; }

#lobby-search-bar {
    padding: 0 16px 8px;
}

#lobby-search {
    width: 100%;
    padding: 7px 10px;
    background: #1a1a3a;
    border: 1px solid #4a4a7a;
    border-radius: 4px;
    color: #ffffff;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    outline: none;
}

#lobby-search:focus { border-color: #6a6aaa; }
#lobby-search::placeholder { color: #6a6a9a; }

#room-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 12px;
    min-height: 120px;
    max-height: 480px;
}

.room-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    margin-bottom: 6px;
    background: #1a1a3a;
    border: 1px solid #2a2a5a;
    border-radius: 8px;
    transition: border-color 0.15s;
}

.room-card:hover {
    border-color: #4a4a8a;
}

.room-card-info {
    flex: 1;
    min-width: 0;
}

.room-card-name {
    color: #ddddff;
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.room-card-meta {
    color: #6a6a9a;
    font-size: 11px;
    margin-top: 2px;
}

.room-card-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-left: 10px;
}

.room-card-fav {
    padding: 4px 8px;
    background: transparent;
    border: 1px solid #3a3a5a;
    border-radius: 4px;
    color: #6a6a9a;
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
    transition: color 0.15s;
}

.room-card-fav:hover { color: #ffcc00; border-color: #6a6aaa; }
.room-card-fav.active { color: #ffcc00; }

.room-card-delete {
    padding: 4px 8px;
    background: transparent;
    border: 1px solid #3a3a5a;
    border-radius: 4px;
    color: #6a6a9a;
    font-size: 14px;
    cursor: pointer;
    line-height: 1;
}

.room-card-delete:hover { color: #e74c3c; border-color: #8a3a3a; }

.official-badge {
    display: inline-block;
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: #fff;
    font-size: 9px;
    font-weight: bold;
    padding: 1px 6px;
    border-radius: 3px;
    letter-spacing: 0.5px;
    vertical-align: middle;
    margin-right: 4px;
}
.private-icon { font-size: 11px; }
.lock-icon { font-size: 11px; }

.room-card-join {
    padding: 5px 14px;
    background: #2a2a5a;
    border: 1px solid #4a4a8a;
    border-radius: 4px;
    color: #aaaaff;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    cursor: pointer;
    margin-left: 10px;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
}

.room-card-join:hover {
    background: #3a3a7a;
    border-color: #6a6aaa;
    color: #ffffff;
}

.room-empty {
    text-align: center;
    color: #6a6a9a;
    padding: 24px;
    font-size: 13px;
}

#create-room-section {
    padding: 12px 16px 16px;
    border-top: 1px solid #2a2a5a;
}

#create-room-header {
    color: #8888aa;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

#create-room-form {
    display: flex;
    gap: 6px;
}

#room-password-input {
    padding: 7px 10px;
    background: #1a1a3a;
    border: 1px solid #4a4a7a;
    border-radius: 4px;
    color: #ffffff;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    outline: none;
    width: 100px;
}

#room-password-input:focus { border-color: #6a6aaa; }

#room-name-input {
    flex: 1;
    padding: 7px 10px;
    background: #1a1a3a;
    border: 1px solid #4a4a7a;
    border-radius: 4px;
    color: #ffffff;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    outline: none;
    min-width: 0;
}

#room-name-input:focus {
    border-color: #6a6aaa;
}

#room-name-input::placeholder {
    color: #6a6a9a;
}

#room-template-select {
    padding: 7px 8px;
    background: #1a1a3a;
    border: 1px solid #4a4a7a;
    border-radius: 4px;
    color: #ccccee;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    cursor: pointer;
    outline: none;
}

#btn-create-room {
    padding: 7px 16px;
    background: #2a2a5a;
    border: 1px solid #4a4a8a;
    border-radius: 4px;
    color: #aaaaff;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}

#btn-create-room:hover {
    background: #3a3a7a;
    color: #ffffff;
}

#lobby-error {
    color: #e74c3c;
    font-size: 11px;
    margin-top: 6px;
    padding: 4px 0;
}

/* ========== Action bar ========== */

#action-bar {
    position: fixed;
    bottom: 52px;
    right: 10px;
    display: flex;
    gap: 4px;
    padding: 6px 8px;
    background: rgba(10, 10, 30, 0.9);
    border: 1px solid #3a3a6a;
    border-radius: 8px;
    z-index: 15;
}

.action-btn {
    padding: 5px 10px;
    background: #1a1a3a;
    border: 1px solid #4a4a7a;
    border-radius: 4px;
    color: #ccccee;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    white-space: nowrap;
}

.action-btn:hover {
    border-color: #6a6aaa;
    background: #252550;
}

.action-btn.active {
    border-color: #8a8aff;
    box-shadow: 0 0 6px rgba(120, 120, 255, 0.4);
    background: #2a2a5a;
    color: #ffffff;
}

.action-stop {
    color: #aa8888;
    border-color: #5a3a3a;
}

.action-stop:hover {
    border-color: #8a5a5a;
    background: #302020;
}

/* ========== Toolbar ========== */

#toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: rgba(10, 10, 30, 0.9);
    border-bottom: 1px solid #3a3a6a;
    z-index: 20;
}

#toolbar-left {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    flex: 1;
    min-width: 0;
}

#toolbar-right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin-left: 8px;
}

.menu-level {
    display: flex;
    align-items: center;
    gap: 4px;
}

.menu-level.hidden { display: none; }

#category-tabs {
    display: flex;
    gap: 4px;
}

#submenu-bar {
    position: fixed;
    top: 40px;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: rgba(14, 14, 34, 0.95);
    border-bottom: 1px solid #3a3a6a;
    z-index: 19;
    overflow-x: auto;
}

#submenu-items {
    display: flex;
    gap: 6px;
}

.tool-btn {
    padding: 5px 12px;
    background: #1a1a3a;
    border: 1px solid #4a4a7a;
    border-radius: 4px;
    color: #ccccee;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    white-space: nowrap;
}

.tool-btn:hover {
    border-color: #6a6aaa;
    background: #252550;
}

.tool-btn.active {
    border-color: #8a8aff;
    box-shadow: 0 0 6px rgba(120, 120, 255, 0.4);
    background: #2a2a5a;
    color: #ffffff;
}

.menu-back {
    color: #8888cc;
    border-color: #3a3a6a;
}

.menu-back:hover {
    color: #ccccff;
}

.furni-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 8px;
    background: #1a1a3a;
    border: 1px solid #3a3a5a;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    min-width: 64px;
}

.furni-item canvas {
    display: block;
    width: 48px;
    height: 48px;
    image-rendering: pixelated;
}

.furni-item span {
    font-family: 'Courier New', monospace;
    font-size: 10px;
    color: #9999bb;
    white-space: nowrap;
}

.furni-size {
    font-family: 'Courier New', monospace;
    font-size: 9px;
    color: #6a6a9a;
    background: #1a1a2a;
    padding: 1px 4px;
    border-radius: 2px;
}

.furni-item:hover {
    border-color: #6a6aaa;
    background: #252550;
}

.furni-item:hover span {
    color: #ccccee;
}

.furni-item.active {
    border-color: #66ee66;
    box-shadow: 0 0 8px rgba(100, 255, 100, 0.35);
    background: #1a2a1a;
}

.furni-item.active span {
    color: #aaffaa;
}

/* ========== Settings Panel ========== */

#settings-panel {
    position: fixed;
    top: 44px;
    left: 10px;
    width: 220px;
    background: rgba(14, 14, 34, 0.95);
    border: 1px solid #3a3a6a;
    border-radius: 8px;
    z-index: 25;
    padding: 0;
    overflow: hidden;
}

#settings-panel.hidden {
    display: none;
}

#settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(30, 30, 60, 0.8);
    border-bottom: 1px solid #3a3a6a;
    color: #ccccee;
    font-size: 13px;
    font-weight: bold;
}

#settings-close {
    background: none;
    border: none;
    color: #8888aa;
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

#settings-close:hover {
    color: #ffffff;
}

.settings-section {
    padding: 10px 12px;
    border-bottom: 1px solid #2a2a4a;
}

.settings-section:last-child {
    border-bottom: none;
}

.settings-section label {
    display: block;
    font-size: 11px;
    color: #8888aa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.color-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-row input[type="color"] {
    width: 40px;
    height: 28px;
    border: 1px solid #4a4a7a;
    border-radius: 4px;
    background: #1a1a3a;
    cursor: pointer;
    padding: 2px;
}

.color-reset {
    padding: 3px 8px;
    background: #1a1a3a;
    border: 1px solid #3a3a5a;
    border-radius: 3px;
    color: #8888aa;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    cursor: pointer;
}

.color-reset:hover {
    border-color: #6a6aaa;
    color: #ccccee;
}

/* ========== Chat bar ========== */

#chat-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px;
    background: rgba(10, 10, 30, 0.85);
    border-top: 1px solid #3a3a6a;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 8px;
}

#chat-input {
    flex: 1;
    padding: 8px 12px;
    background: #1a1a3a;
    border: 1px solid #4a4a7a;
    border-radius: 4px;
    color: #ffffff;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    outline: none;
}

#chat-input:focus {
    border-color: #6a6aaa;
    box-shadow: 0 0 8px rgba(100, 100, 200, 0.3);
}

#chat-input::placeholder {
    color: #6a6a9a;
}

/* ========== Modals ========== */

.modal-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
}

.modal-box {
    width: 340px;
    max-width: 90vw;
    background: rgba(18, 18, 40, 0.98);
    border: 1px solid #3a3a6a;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    color: #ccccee;
    font-family: 'Courier New', monospace;
}

.modal-box h3 { font-size: 16px; margin-bottom: 8px; color: #ddddff; }
.modal-box p { font-size: 12px; margin-bottom: 8px; color: #9999bb; }

.modal-box input {
    width: 100%;
    padding: 7px 10px;
    background: #1a1a3a;
    border: 1px solid #4a4a7a;
    border-radius: 4px;
    color: #ffffff;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    outline: none;
    margin-bottom: 10px;
}

.modal-buttons { display: flex; gap: 8px; justify-content: center; }

.modal-btn {
    padding: 6px 16px;
    background: #1a1a3a;
    border: 1px solid #4a4a7a;
    border-radius: 4px;
    color: #ccccee;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    cursor: pointer;
}

.modal-btn:hover { background: #252550; border-color: #6a6aaa; }
.modal-btn-primary { background: #2a2a5a; border-color: #6a6aaa; color: #aaaaff; }
.modal-btn-primary:hover { background: #3a3a7a; color: #ffffff; }
.modal-btn-danger { background: #3a1a1a; border-color: #8a3a3a; color: #ff8888; }
.modal-btn-danger:hover { background: #5a2020; color: #ffffff; }

.confirm-code { color: #ffcc00; font-size: 16px; letter-spacing: 2px; }

/* ========== Room Info Panel ========== */

/* ========== Chat Log ========== */

#chat-log {
    position: fixed;
    bottom: 52px;
    left: 10px;
    width: 340px;
    max-height: 220px;
    background: rgba(10, 10, 30, 0.85);
    border: 1px solid #3a3a6a;
    border-radius: 8px;
    z-index: 15;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#chat-log-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    line-height: 1.5;
}

.chat-msg { margin-bottom: 2px; word-wrap: break-word; }
.chat-msg-role { color: #6a6a9a; font-size: 10px; }
.chat-msg-name { font-weight: bold; color: #aaaaff; }
.chat-msg-text { color: #ccccee; }
.chat-msg-event { color: #6a9a6a; font-style: italic; }
.chat-msg-command { color: #9a8a6a; font-style: italic; }
.chat-msg-system { color: #e8a040; font-style: italic; }

/* ========== Room Info Panel ========== */

#room-info {
    position: fixed;
    bottom: 95px;
    right: 10px;
    padding: 10px 14px;
    background: rgba(10, 10, 30, 0.9);
    border: 1px solid #3a3a6a;
    border-radius: 8px;
    z-index: 15;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: #aaaacc;
    line-height: 1.6;
}

#info-room-name { font-weight: bold; font-size: 13px; color: #ddddff; margin-bottom: 2px; }
#info-room-type { color: #8888aa; margin-bottom: 4px; }
.info-label { color: #6a6a9a; }

/* ========== Help Panel ========== */

#help-panel {
    position: fixed;
    bottom: 52px;
    left: 50px;
    width: 340px;
    max-height: 300px;
    overflow-y: auto;
    background: rgba(14, 14, 34, 0.95);
    border: 1px solid #3a3a6a;
    border-radius: 8px;
    z-index: 25;
}

#help-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(30, 30, 60, 0.8);
    border-bottom: 1px solid #3a3a6a;
    color: #ccccee;
    font-size: 13px;
    font-weight: bold;
}

#help-close {
    background: none; border: none; color: #8888aa; font-size: 18px; cursor: pointer; padding: 0 4px; line-height: 1;
}

#help-close:hover { color: #ffffff; }

#help-content { padding: 8px 12px; }

.help-cmd {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    color: #ccccee;
    font-size: 12px;
    border-bottom: 1px solid #2a2a4a;
}

.help-cmd:last-child { border-bottom: none; }
.help-cmd code { color: #aaaaff; font-size: 11px; }
.help-role { color: #8888aa; font-size: 10px; margin-left: 8px; }
.help-empty { color: #6a6a9a; font-size: 12px; text-align: center; padding: 12px; }

.help-btn {
    width: 32px;
    height: 32px;
    background: #1a1a3a;
    border: 1px solid #4a4a7a;
    border-radius: 50%;
    color: #ccccee;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-btn:hover { border-color: #6a6aaa; background: #252550; }

/* ========== Danger Button ========== */

.danger-btn {
    width: 100%;
    padding: 8px;
    background: #3a1a1a;
    border: 1px solid #6a3a3a;
    border-radius: 4px;
    color: #ff8888;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    cursor: pointer;
}

.danger-btn:hover { background: #5a2020; border-color: #8a4a4a; color: #ffffff; }

/* ========== Friends Overlay ========== */

#friends-overlay, #messages-overlay {
    position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
    background: rgba(10, 10, 30, 0.92); z-index: 100;
}

#friends-box {
    width: 600px; max-width: 95vw; max-height: 90vh;
    display: flex; flex-direction: column;
    background: rgba(18, 18, 40, 0.98); border: 1px solid #3a3a6a; border-radius: 12px; overflow: hidden;
}

.overlay-header {
    display: flex; align-items: center; justify-content: center; position: relative;
    padding: 14px 20px 8px;
}

.overlay-header h2 { color: #ccccff; font-size: 20px; letter-spacing: 1px; }

.overlay-close {
    position: absolute; right: 16px;
    background: none; border: none; color: #8888aa; font-size: 22px; cursor: pointer; padding: 0 4px; line-height: 1;
}

.overlay-close:hover { color: #ffffff; }

#friends-tabs { display: flex; gap: 4px; padding: 0 16px 8px; justify-content: center; }

.friends-tab {
    padding: 5px 16px; background: #1a1a3a; border: 1px solid #3a3a5a; border-radius: 4px;
    color: #8888aa; font-family: 'Courier New', monospace; font-size: 12px; cursor: pointer;
}

.friends-tab:hover { border-color: #6a6aaa; color: #ccccee; }
.friends-tab.active { background: #2a2a5a; color: #ffffff; border-color: #8a8aff; }
.friends-tab.pulsing { animation: toolbar-pulse 1.5s ease-in-out infinite; border-color: #ff6666; }

#friends-search-bar { padding: 0 16px 8px; }

#friends-search {
    width: 100%; padding: 7px 10px; background: #1a1a3a; border: 1px solid #4a4a7a; border-radius: 4px;
    color: #ffffff; font-family: 'Courier New', monospace; font-size: 12px; outline: none;
}

#friends-search:focus { border-color: #6a6aaa; }

#friends-list { flex: 1; overflow-y: auto; padding: 0 16px 12px; max-height: 400px; }

.fl-card {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px; margin-bottom: 4px; background: #1a1a3a; border: 1px solid #2a2a5a; border-radius: 6px;
}

.fl-info { flex: 1; min-width: 0; }
.fl-name { color: #ddddff; font-size: 13px; font-weight: bold; }
.fl-pending { color: #8888aa; font-size: 10px; }
.fl-actions { display: flex; gap: 4px; margin-left: 8px; }
.fl-empty { text-align: center; color: #6a6a9a; padding: 20px; font-size: 12px; }
.fl-section-header { color: #8888aa; font-size: 10px; text-transform: uppercase; padding: 8px 0 4px; letter-spacing: 0.5px; }

.fl-btn {
    padding: 4px 10px; background: #2a2a5a; border: 1px solid #4a4a8a; border-radius: 4px;
    color: #aaaaff; font-family: 'Courier New', monospace; font-size: 11px; cursor: pointer; white-space: nowrap;
}

.fl-btn:hover { background: #3a3a7a; color: #ffffff; }
.fl-btn-danger { color: #ff8888; border-color: #6a3a3a; background: #2a1a1a; }
.fl-btn-danger:hover { background: #3a2020; color: #ffffff; }
.fl-btn-accept { color: #88ff88; border-color: #3a6a3a; background: #1a2a1a; }
.fl-btn-accept:hover { background: #203a20; color: #ffffff; }
.fl-btn-muted { color: #aaaaaa; border-color: #4a4a5a; }

.badge-online { color: #2ecc71; font-size: 10px; margin-left: 6px; }
.badge-online::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #2ecc71; margin-right: 3px; vertical-align: middle; }
.badge-offline { color: #6a6a9a; font-size: 10px; margin-left: 6px; }
.badge-offline::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #6a6a9a; margin-right: 3px; vertical-align: middle; }

/* ========== Messages Overlay ========== */

#messages-box {
    width: 700px; max-width: 95vw; max-height: 90vh; height: 500px;
    display: flex; flex-direction: column;
    background: rgba(18, 18, 40, 0.98); border: 1px solid #3a3a6a; border-radius: 12px; overflow: hidden;
}

#messages-content { flex: 1; display: flex; overflow: hidden; }

#msg-left {
    width: 35%; border-right: 1px solid #3a3a6a; display: flex; flex-direction: column; overflow: hidden;
}

#msg-convo-search {
    padding: 8px 10px; background: #12122a; border: none; border-bottom: 1px solid #3a3a6a;
    color: #ffffff; font-family: 'Courier New', monospace; font-size: 12px; outline: none;
}

#msg-convo-list { flex: 1; overflow-y: auto; }

.msg-convo {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; cursor: pointer; border-bottom: 1px solid #1a1a3a;
    transition: background 0.15s;
}

.msg-convo:hover { background: #1a1a3a; }
.msg-convo.active { background: #2a2a5a; }
.msg-head-icon {
    width: 32px; height: 32px; border-radius: 50%;
    background: #2a2a5a; border: 1px solid #4a4a8a;
    flex-shrink: 0; margin-right: 8px;
    image-rendering: pixelated;
}

.msg-friend-badge { color: #ffcc00; font-size: 10px; margin-left: 4px; }

.msg-convo-info { flex: 1; min-width: 0; }
.msg-convo-name { color: #ddddff; font-size: 12px; font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-convo-preview { color: #6a6a9a; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

.msg-unread-badge {
    background: #e74c3c; color: #ffffff; font-size: 10px; font-weight: bold;
    min-width: 18px; height: 18px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 5px; margin-left: 8px; flex-shrink: 0;
}

#msg-right { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

#msg-header {
    padding: 10px 14px; border-bottom: 1px solid #3a3a6a; background: rgba(20, 20, 45, 0.8);
}

#msg-header-name { color: #ddddff; font-size: 14px; font-weight: bold; }

#msg-placeholder { flex: 1; display: flex; align-items: center; justify-content: center; color: #6a6a9a; font-size: 13px; }

#msg-messages {
    flex: 1; overflow-y: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px;
}

.msg-bubble { max-width: 75%; padding: 8px 12px; border-radius: 10px; font-size: 12px; word-wrap: break-word; }
.msg-left { align-self: flex-start; background: #1a1a3a; border: 1px solid #2a2a5a; color: #ccccee; }
.msg-right { align-self: flex-end; background: #2a2a6a; border: 1px solid #4a4a8a; color: #ddddff; }
.msg-text { margin-bottom: 2px; }
.msg-time { font-size: 9px; color: #6a6a9a; text-align: right; }
.msg-empty { text-align: center; color: #6a6a9a; padding: 20px; font-size: 12px; }
.msg-loading { text-align: center; color: #6a6a9a; padding: 20px; font-size: 12px; }

#msg-input-bar {
    display: flex; gap: 6px; padding: 8px 10px; border-top: 1px solid #3a3a6a; background: rgba(20, 20, 45, 0.8);
}

#msg-input {
    flex: 1; padding: 7px 10px; background: #1a1a3a; border: 1px solid #4a4a7a; border-radius: 4px;
    color: #ffffff; font-family: 'Courier New', monospace; font-size: 12px; outline: none;
}

#msg-input:focus { border-color: #6a6aaa; }

/* ========== Toolbar Pulse Animation ========== */

@keyframes toolbar-pulse {
    0%, 100% { box-shadow: 0 0 4px rgba(255, 100, 100, 0.3); }
    50% { box-shadow: 0 0 12px rgba(255, 100, 100, 0.7); }
}

.tool-btn.pulsing {
    animation: toolbar-pulse 1.5s ease-in-out infinite;
    border-color: #ff6666;
}

/* ========== Admin Console ========== */

#admin-popup {
    position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, 0.7); z-index: 250;
}

#admin-popup-box {
    width: 600px; max-width: 95vw; height: 400px;
    display: flex; flex-direction: column;
    background: rgba(10, 10, 25, 0.98); border: 1px solid #4a4a8a; border-radius: 8px; overflow: hidden;
}

#admin-output {
    flex: 1; overflow-y: auto; padding: 10px; font-family: 'Courier New', monospace; font-size: 11px;
    color: #88ff88; background: #0a0a1a; white-space: pre-wrap; word-break: break-all;
}

.admin-cmd { color: #88aaff; }
.admin-err { color: #ff8888; }
.admin-res { color: #88ff88; }

#admin-input-bar { display: flex; gap: 6px; padding: 8px; border-top: 1px solid #3a3a6a; }

#admin-input {
    flex: 1; padding: 7px 10px; background: #0a0a1a; border: 1px solid #4a4a7a; border-radius: 4px;
    color: #88ff88; font-family: 'Courier New', monospace; font-size: 12px; outline: none;
}

/* ========== Context Menu ========== */

#context-menu {
    position: fixed;
    z-index: 250;
    background: rgba(18, 18, 40, 0.98);
    border: 1px solid #4a4a8a;
    border-radius: 6px;
    padding: 4px 0;
    min-width: 140px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.ctx-item {
    display: block; width: 100%;
    padding: 6px 14px;
    background: none; border: none;
    color: #ccccee; font-family: 'Courier New', monospace; font-size: 12px;
    text-align: left; cursor: pointer;
    white-space: nowrap;
}

.ctx-item:hover { background: #2a2a5a; color: #ffffff; }
.ctx-item-danger { color: #ff8888; }
.ctx-item-danger:hover { background: #3a1a1a; }
.ctx-sep { height: 1px; background: #3a3a6a; margin: 3px 0; }

/* ========== Notifications ========== */

#notifications {
    position: fixed;
    top: 50px;
    right: 10px;
    width: 280px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: none;
}

.notification {
    background: rgba(18, 18, 50, 0.95);
    border: 1px solid #4a4a8a;
    border-radius: 8px;
    padding: 10px 14px;
    color: #ccccee;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    cursor: pointer;
    pointer-events: auto;
    animation: notif-in 0.3s ease-out;
    transition: opacity 0.3s;
}

.notification:hover { border-color: #8a8aff; }
.notif-content { display: flex; align-items: center; gap: 8px; }
.notif-head { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; image-rendering: pixelated; background: #2a2a5a; }
.notification .notif-title { font-weight: bold; color: #ddddff; font-size: 11px; margin-bottom: 2px; }
.notification .notif-text { color: #9999bb; font-size: 11px; }

@keyframes notif-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ========== Utility ========== */

.hidden {
    display: none !important;
}
