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

body {
    background: #0f0f1a;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    font-family: 'Courier New', monospace;
    color: #c0c0d0;
    overflow: hidden;
    padding: 8px 0;
}
body.in-iframe { justify-content: flex-start; padding-top: 16px; min-height: 0; background: transparent; }

.game-wrap {
    display: flex;
    gap: 8px;
    align-items: stretch;
    position: relative;
}

.canvas-wrap {
    position: relative;
    border: 2px solid #2a2a4a;
    border-radius: 6px;
    overflow: hidden;
}
#gameCanvas {
    display: block;
    border: none;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    cursor: default;
}

#console-panel {
    width: 200px;
    max-height: 80vh;
    background: #14142a;
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 500;
    border: 2px solid #4a4a8a;
    border-radius: 8px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    overflow-x: visible;
    scrollbar-width: thin;
    scrollbar-color: #2a2a4a #14142a;
    box-shadow: 0 4px 30px rgba(0,0,0,0.7);
}
#console-panel.hidden { display: none; }

#chat-log-panel {
    width: 240px;
    max-height: 644px;
    background: #12122a;
    border: 2px solid #2a2a4a;
    border-radius: 6px;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}
/* ── Voice/Cam bar: pixel RPG HUD ── */
#voice-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    background: linear-gradient(180deg, #181830 0%, #12122a 100%);
    border-bottom: 2px solid #2a2a4a;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
    flex-wrap: wrap;
    position: relative;
}
#voice-bar::after {
    content: '';
    position: absolute;
    bottom: 0; left: 10px; right: 10px;
    height: 1px;
    background: linear-gradient(90deg, transparent, #4a4a7a, transparent);
}

#voiceStatus, #camStatus {
    font-size: 9px;
    font-weight: 700;
    color: #4a4a6a;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: color 0.2s, text-shadow 0.2s;
}
#voiceStatus.on {
    color: #22c55e;
    text-shadow: 0 0 6px rgba(34,197,94,0.4);
}

/* Toggle switches — pixel feel */
.voice-toggle {
    position: relative;
    width: 32px;
    height: 16px;
    flex-shrink: 0;
}
.voice-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.voice-slider {
    position: absolute;
    inset: 0;
    background: #1a1a2e;
    border: 1.5px solid #3a3a5a;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}
.voice-slider::before {
    content: '';
    position: absolute;
    width: 10px; height: 10px;
    left: 2px; top: 50%; transform: translateY(-50%);
    background: #4a4a6a;
    border-radius: 50%;
    transition: all 0.2s;
    box-shadow: 0 0 2px rgba(0,0,0,0.4);
}
.voice-toggle input:checked + .voice-slider {
    background: rgba(34,197,94,0.15);
    border-color: #22c55e;
}
.voice-toggle input:checked + .voice-slider::before {
    left: 18px;
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34,197,94,0.5);
}
.voice-toggle input:checked + .cam-slider {
    background: rgba(99,102,241,0.15);
    border-color: #6366f1;
}
.voice-toggle input:checked + .cam-slider::before {
    left: 18px;
    background: #6366f1;
    box-shadow: 0 0 6px rgba(99,102,241,0.5);
}
.voice-toggle input:checked + .screen-slider {
    background: rgba(6,182,212,0.15);
    border-color: #06b6d4;
}
.voice-toggle input:checked + .screen-slider::before {
    left: 18px;
    background: #06b6d4;
    box-shadow: 0 0 6px rgba(6,182,212,0.5);
}

/* Settings button */
#voiceSettingsBtn {
    font-size: 9px;
    font-weight: 700;
    color: #4a4a6a;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    transition: color 0.15s;
}
#voiceSettingsBtn:hover { color: #8a8abe; }

/* Settings panel */
#voice-settings {
    display: none;
    width: 100%;
    margin-top: 6px;
    padding: 8px;
    background: #0e0e1e;
    border: 1px solid #2a2a4a;
    border-radius: 4px;
}
#voice-settings.active { display: block; }
#voice-settings select {
    width: 100%;
    background: #14142a;
    color: #8a8abe;
    border: 1px solid #2a2a4a;
    border-radius: 3px;
    padding: 4px 6px;
    font-size: 9px;
    font-family: 'Courier New', monospace;
    margin-bottom: 6px;
    outline: none;
    transition: border-color 0.15s;
}
#voice-settings select:focus { border-color: #6366f1; }
#voice-settings label {
    font-size: 8px;
    font-weight: 700;
    color: #4a4a6a;
    letter-spacing: 1px;
    text-transform: uppercase;
    display: block;
    margin-bottom: 3px;
}

/* Volume meter — LED bar style */
.voice-meter {
    width: 100%;
    height: 4px;
    background: #0a0a18;
    border: 1px solid #1a1a2e;
    border-radius: 0;
    overflow: hidden;
    margin: 4px 0 6px;
}
.voice-meter-fill {
    height: 100%;
    background: linear-gradient(90deg, #22c55e 0%, #22c55e 60%, #f59e0b 80%, #ef4444 100%);
    width: 0%;
    transition: width 0.05s;
    box-shadow: 0 0 4px rgba(34,197,94,0.3);
}

/* ── Screen share ── */
/* 시작 버튼은 voice-bar의 토글(.screen-slider). 아래는 원격 공유자 목록/뷰어 */
#screen-list { display: flex; flex-direction: column; gap: 5px; }
#screen-list:not(:empty) { padding: 7px 10px; background: #10101f; border-bottom: 2px solid #2a2a4a; }
.screen-item-btn {
    width: 100%;
    text-align: left;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    font-weight: 600;
    color: #cfcfee;
    background: linear-gradient(180deg, #1c1c3a, #16162e);
    border: 1.5px solid #4a4a7a;
    border-radius: 4px;
    padding: 6px 9px;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.screen-item-btn::before {
    content: '●';
    color: #22c55e;
    font-size: 8px;
    animation: ss-pulse 1.6s infinite;
}
@keyframes ss-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }
.screen-item-btn:hover { border-color: #6366f1; background: #20204a; }
.screen-player {
    margin-top: 4px;
    border: 1.5px solid #3a3a5a;
    border-radius: 4px;
    background: #000;
    overflow: hidden;
}
.screen-player.hidden, .screen-item-btn.hidden { display: none; }
.screen-video {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
}
.screen-video video {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
}
.screen-player-bar {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: #14142a;
}
.screen-mini-btn {
    flex: 1;
    font-family: 'Courier New', monospace;
    font-size: 9px;
    font-weight: 700;
    color: #8a8abe;
    background: #1a1a30;
    border: 1px solid #3a3a5a;
    border-radius: 3px;
    padding: 4px;
    cursor: pointer;
    transition: all 0.15s;
}
.screen-mini-btn:hover { border-color: #6366f1; color: #aab; }

/* 화면 공유 최대화 오버레이 */
#screen-max {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(8,8,18,0.93);
    display: flex;
    flex-direction: column;
    padding: 20px;
}
#screen-max.hidden { display: none; }
#screen-max-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    color: #cfcfee;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    font-weight: 700;
}
#screen-max-close {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    font-weight: 700;
    color: #f87171;
    background: #1a1a30;
    border: 1.5px solid #ef4444;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
}
#screen-max-close:hover { background: rgba(239,68,68,0.2); }
.screen-max-btns { display: flex; gap: 8px; }
#screen-max-full {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    font-weight: 700;
    color: #22d3ee;
    background: #1a1a30;
    border: 1.5px solid #06b6d4;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
}
#screen-max-full:hover { background: rgba(6,182,212,0.2); }
#screen-max-video {
    flex: 1;
    background: #000;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
#screen-max-video video {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
}

/* ── 화면공유 최대화: 영상 + 우측 사이드바(참여자/채팅) ── */
#screen-max-body {
    flex: 1;
    display: flex;
    gap: 14px;
    min-height: 0;
}
#screen-max-side {
    width: 300px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: #12122a;
    border: 1px solid #2a2a4a;
    border-radius: 6px;
    overflow: hidden;
    font-family: 'Courier New', monospace;
}
#screen-max-viewers-head, #screen-max-chat-head {
    font-size: 10px;
    font-weight: 700;
    color: #8a8abe;
    letter-spacing: 2px;
    padding: 8px 10px;
    background: linear-gradient(180deg, #14142e 0%, #12122a 100%);
    border-bottom: 1px solid #2a2a4a;
    text-transform: uppercase;
}
#screen-max-viewer-count { color: #06b6d4; font-weight: 700; }
#screen-max-viewers {
    max-height: 28%;
    overflow-y: auto;
    padding: 6px 10px;
    border-bottom: 1px solid #2a2a4a;
    scrollbar-width: thin;
    scrollbar-color: #2a2a4a #14142a;
}
.smx-viewer {
    font-size: 11px;
    color: #b0b0c8;
    padding: 2px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}
.smx-viewer::before { content: '●'; color: #34d399; font-size: 8px; }
.smx-viewer.smx-self { color: #cfcfee; font-weight: 600; }
#screen-max-chat {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px;
    scrollbar-width: thin;
    scrollbar-color: #2a2a4a #14142a;
}
#screen-max-chat::-webkit-scrollbar, #screen-max-viewers::-webkit-scrollbar { width: 5px; }
#screen-max-chat::-webkit-scrollbar-track, #screen-max-viewers::-webkit-scrollbar-track { background: #14142a; }
#screen-max-chat::-webkit-scrollbar-thumb, #screen-max-viewers::-webkit-scrollbar-thumb { background: #2a2a4a; border-radius: 3px; }
#screen-max-chat-row {
    display: flex;
    gap: 6px;
    padding: 8px;
    border-top: 1px solid #2a2a4a;
    background: #14142a;
}
#screen-max-chat-input {
    flex: 1;
    min-width: 0;
    background: #0e0e1e;
    border: 1px solid #2a2a4a;
    border-radius: 4px;
    color: #cfcfee;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    padding: 6px 8px;
    outline: none;
}
#screen-max-chat-input:focus { border-color: #06b6d4; }
#screen-max-chat-send {
    background: #1a1a30;
    border: 1.5px solid #06b6d4;
    border-radius: 4px;
    color: #22d3ee;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    font-weight: 700;
    padding: 6px 10px;
    cursor: pointer;
    flex-shrink: 0;
}
#screen-max-chat-send:hover { background: rgba(6,182,212,0.2); }
@media (max-width: 720px) {
    #screen-max-body { flex-direction: column; }
    #screen-max-side { width: auto; height: 42%; }
}

/* ── CHAT title — pixel terminal header ── */
#chat-log-panel h2 {
    font-size: 10px;
    font-weight: 700;
    color: #4a4a7a;
    letter-spacing: 4px;
    text-align: center;
    padding: 8px 0 7px;
    margin: 0;
    background: linear-gradient(180deg, #14142e 0%, #12122a 100%);
    border-bottom: 1px solid #2a2a4a;
    position: relative;
    text-transform: uppercase;
}
#chat-log-panel h2::before,
#chat-log-panel h2::after {
    content: '―';
    color: #2a2a4a;
    font-weight: 400;
    letter-spacing: 0;
    margin: 0 6px;
}
#chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px;
    scrollbar-width: thin;
    scrollbar-color: #2a2a4a #14142a;
}
#chat-log::-webkit-scrollbar { width: 5px; }
#chat-log::-webkit-scrollbar-track { background: #14142a; }
#chat-log::-webkit-scrollbar-thumb { background: #2a2a4a; border-radius: 3px; }
.chat-log-msg {
    margin-bottom: 6px;
    font-size: 11px;
    line-height: 1.5;
    word-break: break-word;
}
.chat-log-name {
    font-weight: 600;
    color: #8a8abe;
    font-size: 10px;
}
.chat-log-text {
    color: #b0b0c8;
}
.chat-log-time {
    color: #4a4a6a;
    font-size: 9px;
    margin-left: 4px;
}
#console-panel::-webkit-scrollbar { width: 6px; }
#console-panel::-webkit-scrollbar-track { background: #14142a; }
#console-panel::-webkit-scrollbar-thumb { background: #2a2a4a; border-radius: 3px; }
#console-panel::-webkit-scrollbar-thumb:hover { background: #3a3a5a; }

#console-panel h2 {
    font-size: 12px;
    font-weight: 700;
    color: #6a6a8a;
    letter-spacing: 3px;
    text-align: center;
    padding-bottom: 8px;
    border-bottom: 1px solid #2a2a4a;
}

.panel-section h3 {
    font-size: 11px;
    font-weight: 600;
    color: #8888aa;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.char-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.char-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: #1a1a30;
    border: 1px solid #2a2a4a;
    border-radius: 4px;
    cursor: pointer;
    color: #b0b0c8;
    font-family: inherit;
    font-size: 12px;
    transition: border-color 0.15s, background 0.15s;
}

.char-btn:hover {
    background: #22223a;
    border-color: #4a4a6a;
}

.char-btn.active {
    background: #1e1e3a;
    border-color: #6666aa;
    color: #d0d0ee;
}

.char-btn canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    border-radius: 2px;
    background: #12122a;
}

.tab-bar {
    display: flex;
    gap: 4px;
}
.tab {
    flex: 1;
    padding: 5px 0;
    background: #1a1a30;
    border: 1px solid #2a2a4a;
    border-radius: 4px;
    color: #6a6a8a;
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
}
.tab.active {
    background: #22223a;
    border-color: #6666aa;
    color: #d0d0ee;
}
.tab-content { display: none; }
.tab-content.active { display: block; }

.gen-preview-wrap {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 6px;
    padding: 8px 0 6px;
    background: #12122a;
    border-radius: 4px;
    margin-bottom: 8px;
}
.rot-btn { flex-shrink: 0; margin-bottom: 4px; width: 16px; height: 16px; font-size: 8px; }
#gen-preview {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}
.gen-controls {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}
.gen-row {
    display: flex;
    align-items: center;
    gap: 4px;
}
.gen-label {
    font-size: 10px;
    color: #6a6a8a;
    width: 36px;
    flex-shrink: 0;
}
.gen-val {
    flex: 1;
    text-align: center;
    font-size: 10px;
    color: #b0b0c8;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.arr {
    width: 22px;
    height: 22px;
    padding: 0;
    background: #1a1a30;
    border: 1px solid #2a2a4a;
    border-radius: 3px;
    color: #8888aa;
    font-size: 10px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.arr:hover { background: #22223a; border-color: #4a4a6a; color: #d0d0ee; }

.palette-row { flex-wrap: wrap; }
.palette {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    flex: 1;
}
.pal-swatch {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    transition: border-color 0.1s;
}
.pal-swatch:hover { border-color: rgba(255,255,255,0.5); }
.pal-swatch.active { border-color: #fff; }
.gen-picker-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 2px;
}
.gen-thumb {
    padding: 2px;
    background: #12122a;
    border: 2px solid #2a2a4a;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gen-thumb:hover { border-color: #4a4a6a; }
.gen-thumb canvas {
    width: 24px;
    height: 48px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}
.gen-popup {
    position: fixed;
    width: 180px;
    max-height: 400px;
    background: #14142a;
    border: 2px solid #4a4a6a;
    border-radius: 6px;
    padding: 6px;
    overflow-y: auto;
    z-index: 600;
    box-shadow: 0 4px 20px rgba(0,0,0,0.6);
    scrollbar-width: thin;
    scrollbar-color: #2a2a4a #14142a;
}
.gen-popup.hidden { display: none; }
.gen-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 11px;
    color: #8888aa;
    font-weight: 600;
}
.gen-popup-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 3px;
}
.gen-popup-item {
    padding: 2px;
    background: #1a1a30;
    border: 2px solid #2a2a4a;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gen-popup-item:hover { border-color: #6a6aaa; }
.gen-popup-item.active { border-color: #8888dd; }
.gen-popup-item canvas {
    width: 28px;
    height: 56px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.gen-btn {
    width: 100%;
    padding: 6px;
    background: #1a1a30;
    border: 1px solid #2a2a4a;
    border-radius: 4px;
    color: #b0b0c8;
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
    margin-bottom: 4px;
}
.gen-btn:hover { background: #22223a; border-color: #4a4a6a; }
.gen-btn.primary { background: #2a2a5a; border-color: #6666aa; color: #d0d0ee; }
.gen-btn.primary:hover { background: #3a3a6a; }

.room-preview-wrap {
    margin-top: 6px;
    background: #12122a;
    border-radius: 4px;
    padding: 4px;
    display: flex;
    justify-content: center;
}
#room-preview {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    width: 100%;
    height: auto;
    border-radius: 2px;
}

.hint {
    font-size: 11px;
    color: #5a5a7a;
    line-height: 1.6;
}

.hint kbd {
    display: inline-block;
    background: #1a1a2e;
    border: 1px solid #3a3a5a;
    border-radius: 3px;
    padding: 1px 5px;
    margin: 0 1px;
    font-size: 11px;
    color: #9a9abc;
}


/* ============================================================
   EDITOR STYLES
   ============================================================ */
#editor-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #14142a;
    border: 2px solid #2a2a4a;
    border-radius: 4px;
    margin-bottom: 8px;
    flex-wrap: wrap;
    width: calc(960px + 240px + 12px);
}

#editor-tools {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.editor-btn {
    padding: 4px 10px;
    background: #1a1a30;
    border: 1px solid #2a2a4a;
    border-radius: 3px;
    color: #b0b0c8;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.1s, border-color 0.1s;
}
.editor-btn:hover { background: #22223a; border-color: #4a4a6a; color: #d0d0ee; }
.editor-btn.active { background: #2a2a5a; border-color: #6666aa; color: #d0d0ee; }
.editor-btn.small { padding: 3px 7px; font-size: 10px; }
.editor-btn.primary { background: #2a3a5a; border-color: #4488bb; }
.editor-btn.primary:hover { background: #3a4a6a; }
.editor-btn.danger { color: #dd6666; }
.editor-btn.danger:hover { background: #3a2020; border-color: #884444; }

.editor-sep {
    color: #2a2a4a;
    font-size: 14px;
    margin: 0 2px;
}

.editor-size-label {
    font-size: 10px;
    color: #6a6a8a;
    display: flex;
    align-items: center;
    gap: 3px;
}

.editor-size-input {
    width: 40px;
    padding: 2px 4px;
    background: #1a1a30;
    border: 1px solid #2a2a4a;
    border-radius: 3px;
    color: #b0b0c8;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    text-align: center;
}
.editor-size-input:focus { border-color: #4a4a6a; outline: none; }

/* Floor/Wall/Furniture panel (left side) */
#editor-left-panel {
    width: 140px;
    background: #14142a;
    border: 2px solid #2a2a4a;
    border-radius: 4px;
    padding: 8px 6px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    flex-shrink: 0;
    scrollbar-width: thin;
    scrollbar-color: #2a2a4a #14142a;
}
#editor-left-panel::-webkit-scrollbar { width: 5px; }
#editor-left-panel::-webkit-scrollbar-track { background: #14142a; }
#editor-left-panel::-webkit-scrollbar-thumb { background: #2a2a4a; border-radius: 3px; }
#editor-left-panel::-webkit-scrollbar-thumb:hover { background: #3a3a5a; }
#editor-left-panel h3 {
    font-size: 10px;
    color: #6a6a8a;
    letter-spacing: 1px;
    text-align: center;
    margin-bottom: 6px;
}
#floor-palette {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
}
.floor-swatch {
    width: 54px;
    height: 54px;
    padding: 2px;
    background: #12122a;
    border: 2px solid #2a2a4a;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.1s;
}
.floor-swatch:hover { border-color: #4a4a6a; }
.floor-swatch.active { border-color: #6666cc; box-shadow: 0 0 6px rgba(100,100,200,0.3); }
.floor-swatch canvas {
    width: 48px;
    height: 48px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}
.void-swatch {
    background: #0a0a16;
}

/* Furniture section in console panel */
#editor-furn-section {
    border-top: 1px solid #2a2a4a;
    padding-top: 8px;
}
#furn-cats {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-bottom: 6px;
}
.furn-cat-btn {
    padding: 2px 6px;
    background: #1a1a30;
    border: 1px solid #2a2a4a;
    border-radius: 3px;
    color: #8888aa;
    font-size: 9px;
    font-family: 'Courier New', monospace;
    cursor: pointer;
}
.furn-cat-btn:hover { background: #22223a; border-color: #4a4a6a; }
.furn-cat-btn.active { background: #2a2a5a; border-color: #6666aa; color: #d0d0ee; }

#wall-cats {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-bottom: 6px;
}
#wall-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 3px;
    max-height: calc(100vh - 280px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #2a2a4a #14142a;
}
#wall-grid::-webkit-scrollbar { width: 5px; }
#wall-grid::-webkit-scrollbar-track { background: #14142a; }
#wall-grid::-webkit-scrollbar-thumb { background: #2a2a4a; border-radius: 3px; }
#wall-grid .furn-item {
    background: #1a1a30;
}
#wall-grid .furn-item.active { border-color: #aa88dd; box-shadow: 0 0 6px rgba(170,136,220,0.3); }

#furn-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 3px;
    max-height: calc(100vh - 280px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #2a2a4a #14142a;
}
#furn-grid::-webkit-scrollbar { width: 5px; }
#furn-grid::-webkit-scrollbar-track { background: #14142a; }
#furn-grid::-webkit-scrollbar-thumb { background: #2a2a4a; border-radius: 3px; }
.furn-item {
    width: 100%;
    min-height: 48px;
    padding: 2px;
    background: #12122a;
    border: 2px solid #2a2a4a;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.1s;
}
.furn-item:hover { border-color: #4a4a6a; }
.furn-item.active { border-color: #66cc66; box-shadow: 0 0 6px rgba(100,200,100,0.3); }
.furn-item canvas {
    width: 100%;
    height: auto;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* Toast notification */
#editor-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(60px);
    background: #2a3a5a;
    color: #d0d0ee;
    padding: 8px 20px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    border: 1px solid #4488bb;
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    pointer-events: none;
    z-index: 100;
}
#editor-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* NPC grid in editor left panel */
#npc-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
    max-height: 300px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #2a2a4a #14142a;
}
#npc-grid::-webkit-scrollbar { width: 5px; }
#npc-grid::-webkit-scrollbar-track { background: #14142a; }
#npc-grid::-webkit-scrollbar-thumb { background: #2a2a4a; border-radius: 3px; }
.npc-item {
    padding: 2px;
    background: #1a1a30;
    border: 2px solid #2a2a4a;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.npc-item:hover { border-color: #6a6aaa; }
.npc-item.active { border-color: #88dd88; }
.npc-item canvas {
    width: 24px;
    height: 48px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}
.npc-item span {
    font-size: 8px;
    color: #6a6a8a;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 50px;
}

/* Edit mode canvas cursor */
#gameCanvas.editing {
    cursor: crosshair;
}

/* ============================================================
   DIALOGUE OVERLAY
   ============================================================ */
#dialogue-overlay {
    position: absolute;
    bottom: 14px; left: 0; right: 0;
    z-index: 50;
    pointer-events: none;
    display: flex;
    justify-content: center;
}
#dialogue-overlay.hidden { display: none; }
#dialogue-box {
    pointer-events: all;
    background: #12122aee;
    border: 2px solid #5a5a8a;
    border-radius: 6px;
    padding: 8px 10px;
    font-family: 'Courier New', monospace;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,0.6), inset 0 0 30px rgba(80,80,140,0.08);
    max-width: 500px;
}
#dialogue-portrait-wrap {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    border: 2px solid #4a4a7a;
    border-radius: 3px;
    background: #0e0e20;
    padding: 2px;
}
#dialogue-portrait {
    width: 24px;
    height: 48px;
    image-rendering: pixelated;
}
#dialogue-npc-name {
    font-size: 8px;
    font-weight: bold;
    color: #8a8abe;
    white-space: nowrap;
}
#dialogue-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 40px;
}
#dialogue-text {
    color: #c8c8e0;
    font-size: 12px;
    line-height: 1.5;
    word-break: break-word;
    overflow-wrap: break-word;
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #3a3a5a transparent;
}
.loading-dots {
    color: #8a8abe;
    font-size: 13px;
}
.loading-dots span {
    animation: dotFade 1.4s infinite;
    opacity: 0;
}
.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.3s; }
.loading-dots span:nth-child(3) { animation-delay: 0.6s; }
@keyframes dotFade {
    0%, 20% { opacity: 0; }
    40%, 60% { opacity: 1; }
    80%, 100% { opacity: 0; }
}
#dialogue-text .typing-cursor {
    display: inline-block;
    width: 7px;
    height: 13px;
    background: #7a7aaa;
    animation: blink 0.5s infinite;
    vertical-align: text-bottom;
    margin-left: 1px;
}
@keyframes blink { 0%,49% { opacity: 1; } 50%,100% { opacity: 0; } }
#dialogue-close {
    display: none;
}
#dialogue-input-row {
    display: flex;
    gap: 5px;
    margin-top: 6px;
}
#dialogue-input-row.hidden { display: none; }
#dialogue-input {
    flex: 1;
    padding: 5px 8px;
    background: #1a1a30;
    border: 1px solid #3a3a5a;
    border-radius: 3px;
    color: #c0c0d0;
    font-family: inherit;
    font-size: 12px;
    outline: none;
}
#dialogue-input::placeholder { color: #4a4a6a; }
#dialogue-input:focus { border-color: #6a6aaa; }
#dialogue-send {
    padding: 5px 12px;
    background: #2a2a5a;
    border: 1px solid #5a5a8a;
    border-radius: 3px;
    color: #c0c0e0;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
}
#dialogue-send:hover { background: #3a3a6a; }
#dialogue-attach {
    padding: 4px 8px;
    background: #2a2a4a;
    border: 1px solid #4a4a6a;
    border-radius: 3px;
    color: #8a8abe;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}
#dialogue-attach:hover { background: #3a3a5a; }
#dialogue-attach.hidden { display: none; }
.file-preview {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    margin-bottom: 4px;
    background: #1a1a30;
    border: 1px solid #3a3a5a;
    border-radius: 3px;
    font-size: 10px;
    color: #8a8abe;
}
.file-preview .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-preview .fremove { cursor: pointer; color: #6a6a8a; }
.file-preview .fremove:hover { color: #ff6666; }

/* ============================================================
   NPC CONFIG MODAL (editor)
   ============================================================ */
#npc-config-modal {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 400;
    background: #14142a;
    border: 2px solid #4a4a8a;
    border-radius: 8px;
    padding: 16px;
    width: 380px;
    font-family: 'Courier New', monospace;
    color: #c0c0d0;
    box-shadow: 0 4px 30px rgba(0,0,0,0.7);
}
#npc-config-modal.hidden { display: none; }
#npc-config-modal h3 {
    font-size: 14px;
    color: #aabbee;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #2a2a4a;
}
.npc-cfg-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
}
.npc-cfg-row label {
    font-size: 11px;
    color: #6a6a8a;
    width: 70px;
    flex-shrink: 0;
    padding-top: 4px;
}
.npc-cfg-row input, .npc-cfg-row select, .npc-cfg-row textarea {
    flex: 1;
    padding: 4px 8px;
    background: #1a1a30;
    border: 1px solid #3a3a5a;
    border-radius: 4px;
    color: #c0c0d0;
    font-family: inherit;
    font-size: 12px;
    outline: none;
}
.npc-cfg-row textarea {
    height: 60px;
    resize: vertical;
}
.npc-cfg-row input:focus, .npc-cfg-row textarea:focus { border-color: #6a6aaa; }
.npc-cfg-btns {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 12px;
}
.npc-cfg-btns button {
    padding: 6px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
}
#npc-cfg-save {
    background: #2a2a5a;
    border: 1px solid #6666aa;
    color: #d0d0ee;
}
#npc-cfg-save:hover { background: #3a3a6a; }
#npc-cfg-close {
    background: #1a1a30;
    border: 1px solid #3a3a5a;
    color: #8888aa;
}
#npc-cfg-close:hover { background: #22223a; border-color: #4a4a6a; }


/* Wandering toggle */
.npc-cfg-row label.npc-toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    min-width: 40px;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
}
.npc-toggle input { display: none; }
.npc-toggle-slider {
    position: absolute;
    inset: 0;
    background: #2a2a4a;
    border: 1px solid #3a3a5a;
    border-radius: 11px;
    transition: background 0.2s, border-color 0.2s;
}
.npc-toggle-slider::before {
    content: '';
    position: absolute;
    left: 3px; top: 3px;
    width: 14px; height: 14px;
    background: #6a6a8a;
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}
.npc-toggle input:checked + .npc-toggle-slider { background: #2a4a6a; border-color: #4a88cc; }
.npc-toggle input:checked + .npc-toggle-slider::before { transform: translateX(18px); background: #6ab0ff; }

/* ============================================================
   NPC APPEARANCE MODAL
   ============================================================ */
#npc-appearance-modal {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 500;
    background: #14142a;
    border: 2px solid #4a4a8a;
    border-radius: 8px;
    padding: 12px;
    width: 340px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    font-family: 'Courier New', monospace;
    color: #c0c0d0;
    box-shadow: 0 4px 30px rgba(0,0,0,0.7);
}
#npc-appearance-modal.hidden { display: none; }
.npc-appear-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #aabbee;
}
.npc-appear-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}
.npc-appear-tab {
    flex: 1;
    padding: 4px 0;
    background: #1a1a30;
    border: 1px solid #2a2a4a;
    border-radius: 4px;
    color: #6a6a8a;
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
}
.npc-appear-tab.active { background: #22223a; border-color: #6666aa; color: #d0d0ee; }
.npc-appear-preview-wrap {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 6px;
    padding: 6px 0;
    background: #12122a;
    border-radius: 4px;
    margin-bottom: 8px;
}
#npc-appear-preview {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}
.npc-appear-body {
    max-height: 280px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #2a2a4a #14142a;
}
.npc-appear-body::-webkit-scrollbar { width: 5px; }
.npc-appear-body::-webkit-scrollbar-track { background: #14142a; }
.npc-appear-body::-webkit-scrollbar-thumb { background: #2a2a4a; border-radius: 3px; }
#npc-appear-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 3px;
}
.npc-appear-item {
    padding: 2px;
    background: #1a1a30;
    border: 2px solid #2a2a4a;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}
.npc-appear-item:hover { border-color: #6a6aaa; }
.npc-appear-item.active { border-color: #88dd88; box-shadow: 0 0 6px rgba(100,200,100,0.3); }
.npc-appear-item canvas {
    width: 24px; height: 48px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}
.npc-appear-item span {
    font-size: 7px;
    color: #6a6a8a;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 50px;
}
.npc-gen-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 3px;
}
.npc-gen-thumb {
    padding: 2px;
    background: #12122a;
    border: 2px solid #2a2a4a;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.npc-gen-thumb:hover { border-color: #4a4a6a; }
.npc-gen-thumb canvas {
    width: 24px; height: 48px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}
#npc-gen-popup {
    position: absolute;
    bottom: 60px; left: 12px; right: 12px;
    background: #14142a;
    border: 2px solid #4a4a6a;
    border-radius: 6px;
    padding: 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 510;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.6);
}
#npc-gen-popup.hidden { display: none; }
.npc-gen-popup-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 3px;
}
