/* Layout 2D: a área visível cresce; o canvas interno continua em 720 × 528. */
:root { --ui-gold: #d6b770; --ui-parchment: #e8dcc0; --ui-edge: #6c542b; --ui-world-reserve: 280px; }
body.chat-expanded { --ui-world-reserve: 428px; }
body { justify-content: flex-start; padding: 8px 12px 12px; color: var(--ui-parchment); }
#title { font-size: 17px; margin: 0; }
#connStatus { margin-bottom: 3px; font-size: 11px; }
#displayControls {
    display: flex; justify-content: center; flex-wrap: wrap; gap: 5px;
    width: 100%; margin: 1px 0 7px;
}
#displayControls button, #firstSteps button {
    min-height: 30px; padding: 4px 10px; border: 1px solid var(--ui-edge);
    border-radius: 3px; background: #211b13; color: var(--ui-parchment);
    font: 12px 'Segoe UI', system-ui, sans-serif; cursor: pointer;
}
#displayControls button:hover, #displayControls button[aria-expanded="true"],
#displayControls button[aria-pressed="false"] { background: #41301a; color: #ffdfa0; }
#gameWrapper { max-width: 100%; gap: 7px; padding: 5px; align-items: flex-start; }
body.layout-focus #gameContainer {
    width: min(calc((100dvh - var(--ui-world-reserve)) * 15 / 11), calc(100vw - 225px), 1200px);
    min-width: 0;
}
#gameContainer canvas#canvas { width: 100%; height: auto; aspect-ratio: 15 / 11; }
#gameContainer { flex: 0 1 auto; }
.sidebar { width: 174px; flex: none; font-size: 12px; line-height: 1.35; }
#leftSidebar { max-height: none; overflow: visible; }
body:not(.touch) #leftSidebar { overflow-y:auto; overscroll-behavior-y:contain; scrollbar-width:thin; scrollbar-color:#8c6b32 #0a0805; }
/* A lista encolhe dentro da coluna; a quantidade de itens não define a altura do jogo. */
#inventory { min-height: 0; overscroll-behavior-y: contain; scrollbar-width: thin; scrollbar-color: #8c6b32 #0a0805; }
/* Mantém os atributos à vista nas janelas com barras do navegador abertas. */
body:not(.touch) #leftSidebar { padding: 8px 11px; }
body:not(.touch) #leftSidebar .s-section { margin-bottom: 6px; }
body:not(.touch) #leftSidebar .s-section + .s-section { padding-top: 6px; }
body:not(.touch) #leftSidebar .s-label { margin-bottom: 3px; }
body:not(.touch) #leftSidebar #minimap { width: 116px; height: 116px; }
@media (max-height: 800px) {
    body:not(.touch) #leftSidebar { line-height: 1.25; }
    body:not(.touch) #leftSidebar .s-section { margin-bottom: 2px; }
    body:not(.touch) #leftSidebar .s-section + .s-section { padding-top: 4px; }
    body:not(.touch) #leftSidebar .s-label { margin-bottom: 2px; }
    body:not(.touch) #leftSidebar #minimap { width: 96px; height: 96px; }
}
.s-label { color: #c2a46a; font-size: 11px; letter-spacing: 1px; }
.s-value, .skill-name, #spellList, #inventory, #equipment,
#targetWidget, #players-online, #pvpWidget, #bossesWidget { font-size: 12px !important; }
/* Nome em uma linha própria; vida e efeitos cabem mesmo na coluna clássica. */
#targetWidget, #players-online {
    min-width: 0; overflow-x: hidden; overscroll-behavior-y: contain;
    scrollbar-width: thin; scrollbar-color: #8c6b32 #0a0805;
}
#targetWidget .bl-row {
    display: grid; grid-template-columns: 8px minmax(0, 1fr) auto auto auto;
    gap: 4px; padding: 5px 4px; min-width: 0; flex-shrink: 0;
}
#targetWidget .bl-dot { grid-row: 1; grid-column: 1; }
#targetWidget .bl-name {
    grid-row: 1; grid-column: 2 / -1; white-space: normal;
    overflow-wrap: anywhere; line-height: 1.25;
}
#targetWidget .bl-row > span:not(.bl-dot):not(.bl-name) { grid-row: 2; }
#targetWidget .bl-hp { grid-column: 1 / 3; width: 100%; min-width: 0; height: 13px; }
#targetWidget .bl-hp-txt { font-size: 8px; }
#targetWidget .bl-auto { justify-self: end; }
#rightSidebar .split-half:has(> #targetWidget) { flex-grow: 2; }
body.layout-focus #targetWidget { max-height: min(300px, 35dvh); }
#floorBadge {
    position: absolute; top: 10px; left: 10px; z-index: 30; pointer-events: none;
    background: rgba(18, 8, 22, .85); border: 1px solid #5a2a6a; color: #e6c8f5;
    font: 700 13px monospace; letter-spacing: 1px; padding: 4px 14px;
    border-radius: 7px; box-shadow: 0 2px 12px rgba(80, 20, 90, .4); text-shadow: 0 1px 2px #000;
}
#leftSidebar .bar-wrap { height: 13px; }
#chatPanel { width: 0; min-width: 100%; }
#chatMessages, #log { font-size: 12px; line-height: 1.4; }
#chatInput { font-size: 12px; padding: 6px 9px; }
.chat-tab, .log-filter { font-size: 11px; letter-spacing: 1px; }
#controls { width: min(100%, 1400px); margin-top: 7px; text-align: center; line-height: 1.55; font-size: 11px; letter-spacing: 0; }
#controls kbd { font-size: 10px; }
body.layout-focus #rightSidebar, body.layout-focus #invSidebar {
    display: none; position: fixed; top: 55px; right: 10px; bottom: 10px;
    width: min(310px, calc(100vw - 20px)); height: auto !important;
    overflow-y: auto; z-index: 90; box-shadow: 0 12px 36px #000c;
}
body.layout-focus.panel-equipment #rightSidebar,
body.layout-focus.panel-inventory #invSidebar { display: flex; }
body.layout-focus #rightSidebar .split-half { flex: none; min-height: 82px; }
body.layout-focus #inventory { min-height: 0; }
body.layout-classic #gameContainer {
    width: min(calc((100dvh - var(--ui-world-reserve)) * 15 / 11), calc(100vw - 625px), 950px);
    min-width: 360px;
}
body.layout-classic #invSidebar { width: 205px; }
body.layout-classic #equipmentPanelBtn, body.layout-classic #inventoryPanelBtn { display: none; }
#firstSteps:not([hidden]) {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    position: absolute; left: 12px; right: 12px; top: 12px; z-index: 35;
    padding: 9px 12px; border: 1px solid #9c7840; border-radius: 4px;
    background: rgba(19, 16, 12, .94); box-shadow: 0 4px 16px #000a;
    color: var(--ui-parchment); font-size: 13px; line-height: 1.4;
}
#firstSteps strong { color: #f4d495; }
#firstSteps span { flex: 1; min-width: 170px; }
#firstSteps button { margin-left: auto; }
#login { z-index: 500; overflow-y: auto; height: 100dvh; padding: 12px; }
#login .box { width: min(440px, 96vw); max-height: calc(100dvh - 24px); overflow-y: auto; padding: 22px 28px; }
#login h2 { font-size: 22px; margin-bottom: 8px; letter-spacing: 4px; }
#login .login-intro { max-width: 360px; margin: 0 auto 16px; color: #d3c3a3; font-size: 13px; line-height: 1.4; }
#login input { width: 100%; margin-bottom: 9px; text-align: left; }
#login #serverInput { width: 100% !important; }
#login .opt { letter-spacing: .3px; }
/* Login e teclado continuam acessíveis em retrato; o aviso de rotação só vale no jogo. */
body.touch:not(.game-active) #mobileTopBar,
body.touch:not(.game-active) #touchControls,
body.touch:not(.game-active) #mobileHotbar,
body.touch:not(.game-active) #mobileMenu,
body.touch:not(.game-active) #orientationLock { display: none !important; }
@media (orientation: portrait) and (max-width: 900px) {
    body.touch:not(.game-active) #orientationLock { display: none !important; }
}
@media (max-width: 900px) {
    #targetWidget { max-height: min(300px, 35dvh); }
    body { padding: 0 0 env(safe-area-inset-bottom); }
    body.touch #displayControls { display: none; }
    #gameWrapper { width: 100%; padding: 0; flex-direction: column; }
    body.layout-focus #gameContainer, body.layout-classic #gameContainer {
        width: min(100vw, calc((100dvh - 56px) * 15 / 11)); min-width: 0;
        align-self: center;
    }
    #gameContainer canvas#canvas { width: 100% !important; height: auto !important; max-height: none; }
    #chatPanel { width: 100% !important; max-width: none; }
    body.touch.menu-open #leftSidebar, body.touch.menu-open #rightSidebar,
    body.touch.menu-open #invSidebar { position: static; width: 100%; max-height: none; height: auto !important; }
    body.touch.menu-open #gameWrapper { align-items: center; }
    #firstSteps:not([hidden]) { top: 45px; }
    /* Narrow desktop windows keep a keyboard/mouse layout and reachable drawers. */
    body:not(.touch) #gameWrapper { width: auto; flex-direction: row; gap: 7px; }
    body:not(.touch) #gameContainer { width: min(calc(100vw - 200px), calc((100dvh - var(--ui-world-reserve)) * 15 / 11)); }
    body:not(.touch) #rightSidebar, body:not(.touch) #invSidebar {
        display: none; position: fixed; top: 90px; right: 10px; bottom: 10px;
        width: min(310px, calc(100vw - 20px)); height: auto !important;
        overflow-y: auto; z-index: 90; box-shadow: 0 12px 36px #000c;
    }
    body:not(.touch).panel-equipment #rightSidebar,
    body:not(.touch).panel-inventory #invSidebar { display: flex; }
    body:not(.touch) #equipmentPanelBtn, body:not(.touch) #inventoryPanelBtn { display: inline-block; }
}
@media (max-width: 900px) and (max-height: 440px) {
    #login { align-items: flex-start; padding: 4px; }
    #login .box { max-height: calc(100dvh - 8px); margin: auto; padding: 10px 16px; }
    #login h2 { font-size: 17px; margin-bottom: 3px; }
    #login .login-intro { margin-bottom: 7px; font-size: 12px; }
    #login input { padding: 7px 10px; margin-bottom: 6px; font-size: 13px; }
    #login .opt { margin-top: 6px !important; }
    #login .lang-toggle { margin-top: 6px !important; }
    #login button { padding: 6px 12px; }
}
