/* Mobile shell. The scene, status and controls occupy separate grid areas. */
:root {
  --safe-top: max(6px, env(safe-area-inset-top));
  --safe-right: max(6px, env(safe-area-inset-right));
  --safe-bottom: max(6px, env(safe-area-inset-bottom));
  --safe-left: max(6px, env(safe-area-inset-left));
  --hud-copy: calc(13px * var(--hud-zoom, 1));
  --touch: 44px;
}

button, summary { touch-action: manipulation; }
.chat-grip { display: none; }
#chat[style*="height"] { height: auto !important; }
button:focus-visible, summary:focus-visible, [role="button"]:focus-visible { outline: 2px solid var(--brass2); outline-offset: -2px; }
input, select { font-size: 16px; max-width: 100%; }
:is(.btn, .tab) { min-height: var(--touch); }
.mobile-only.dock-button, #menu button.mobile-only { display: flex; }
#hud :is(#playerCard, #profBadge, #skillBar, #buffBar, #menu, #chat, #lootFeed, #mapHud, #floorTitle, #btnGiveUp) { zoom: 1; }

#hud {
  inset: 0 0 auto;
  height: 100dvh;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  display: grid;
  grid-template: "player" auto "scene" auto "stage" minmax(0, 1fr) "loot" auto "controls" auto "dock" auto / minmax(0, 1fr);
  gap: 5px;
  background: radial-gradient(ellipse at 50% 0%, #2b1e21, #100b0e 62%);
  font-size: var(--hud-copy);
}
#stage { grid-area: stage; position: relative; border: 1px solid #725639; border-radius: 7px; box-shadow: 0 0 0 1px #080507; }
#stage canvas { touch-action: manipulation; }
#worldBossRoster { top: 5px; left: 5px; max-height: 55%; }
#vignette { display: none; }
#deathOverlay { font-size: clamp(22px, 7vw, 54px); text-align: center; }
#deathOverlay small { font-size: 15px; }

#playerCard {
  grid-area: player;
  justify-self: stretch;
  margin: 0;
  width: auto;
  min-width: 0;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 7px;
  border-width: 1px;
}
#playerCard::before, #playerCard::after { display: none; }
#portrait { width: 44px; height: 44px; flex: none; }
.pc-name { gap: 4px; font-size: 1.05em; align-items: baseline; }
#hName { min-width: 0; overflow-wrap: anywhere; }
.pc-name .lvl { font-size: .9em; white-space: nowrap; }
.pc-info .bar { margin-top: 3px; }
.pc-res { font-size: .95em; gap: 2px 5px; margin-top: 3px; }
.pc-res > span { padding: 0 4px; }
#hDps { margin-left: 0; font-size: .9em; }
#btnPot { min-width: 36px; min-height: 30px; font-size: 17px; }

#sceneHeader {
  grid-area: scene;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  border-top: 1px solid #483424;
  border-bottom: 1px solid #483424;
  padding: 1px 2px 1px 7px;
  background: linear-gradient(90deg, #291d1a, #160f12);
}
#sceneHeader :is(#floorTitle, #lobbyTitle, .house-head, .ghall-head, #btnGiveUp, #houseExit, #guildExit) {
  position: static;
  inset: auto;
  transform: none;
  text-align: left;
  white-space: normal;
}
#sceneHeader :is(#floorTitle, #lobbyTitle, .house-head, .ghall-head) { flex: 1; min-width: 0; overflow-wrap: anywhere; padding-block: 3px; }
#lobbyTitle b, .house-head b, .ghall-head b, .ft-floor { font-size: 1.08em; letter-spacing: .045em; }
#lobbyTitle small, .house-head small, .ghall-head small, .ft-name, .ft-boss { font-size: .86em; letter-spacing: .025em; }
#floorTitle { display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 6px; }
.ft-boss { flex-basis: 100%; margin: 0; }
.ft-boss:empty { display: none; }
#sceneHeader :is(#btnGiveUp, #houseExit, #guildExit) { max-width: 38%; font-size: 11px; padding: 4px 7px; }
#houseExitWrap, #guildExitWrap { display: contents; }
/* Título e botão Campo na 1ª linha; Boss Diário / Missões Globais / Guerra descem para a 2ª linha dividindo a largura.
   Na mesma linha eles espremiam o título a 0px (letras em coluna) e o palco sumia. */
#sceneHeader { flex-wrap: wrap; row-gap: 4px; }
#sceneHeader :is(#floorTitle, #lobbyTitle, .house-head, .ghall-head) { flex-basis: min(60%, 14em); }
#sceneHeader #mobileField { order: 1; }
/* quebra de linha forçada antes dos cartões (só quando algum está visível) */
#sceneHeader:has(.wb-card:not(.hidden))::after { content: ''; order: 1; flex-basis: 100%; height: 0; }
#sceneHeader :is(#worldBossOpen, #guildWarOpen, #globalQuestOpen, #bloodOpen) { order: 2; margin: 0; zoom: 1; min-width: 0; flex: 1 1 9em; padding: 4px 6px; gap: 1px 5px; }
/* Eventos recolhidos por padrão: botão "Eventos" ao lado do Campo abre/fecha a linha de cartões (ui.js, lembrado em localStorage). */
#sceneHeader #mobileEvents { order: 1; flex: 0 0 auto; min-width: max(49px, 4em); }
#sceneHeader:not(:has(.wb-card:not(.hidden))) #mobileEvents, body.ng-newbie #mobileEvents { display: none; }
#sceneHeader:not(.ev-open) .wb-card, #sceneHeader:not(.ev-open)::after { display: none; }
#mobileEvents i { position: relative; }
#mobileEventsN { position: absolute; top: -4px; right: -11px; font: 700 10px/1 system-ui, sans-serif; color: #e5c99d; }
#mobileEvents.hot { border-color: #d08b50; }
#mobileEvents.hot #mobileEventsN { color: #ffb677; }
body.in-world-boss #sceneHeader #floorTitle { inset: auto; text-align: left; transform: none; }
/* cartões dividem a linha: texto numa linha só (com reticências) e teto de fonte pela largura da tela */
#sceneHeader .wb-card { grid-template-columns: minmax(0, 1fr) auto; column-gap: 6px; }
#sceneHeader .wb-card :is(b, small) { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
:is(#worldBossOpen, #globalQuestOpen, #guildWarOpen, #bloodOpen) b { font-size: min(11px, 3.4vw); }
:is(#worldBossOpen, #globalQuestOpen, #guildWarOpen, #bloodOpen) small { font-size: min(10px, 3vw); }
#worldBossOpen [data-wb="timer"], #globalQuestOpen [data-gq="timer"], #guildWarOpen [data-gw="timer"] { font-size: min(11px, 3.4vw); }
.wb-detail .wb-timing { margin-left: auto; }

#sceneControls {
  grid-area: controls;
  min-width: 0;
  display: grid;
  gap: 3px;
}
#buffBar, #skillBar, #houseBar { position: static; inset: auto; transform: none; max-width: none; }
#buffBar { min-width: 0; overflow-x: auto; scrollbar-width: thin; align-items: center; gap: 4px; }
#buffBar:empty { display: none; }
.coach { position: static; transform: none; max-width: none; font-size: 13px; }
#buffBar > * { flex: none; white-space: nowrap; }
#buffBar .buff { font-size: .87em; }
/* stage.js move a barra para dentro do palco no mobile: sobreposta no rodapé, sem roubar altura do canvas */
#stage > #buffBar { position: absolute; left: 5px; right: 5px; bottom: 5px; z-index: 2; justify-content: flex-start; pointer-events: none; }
#stage > #buffBar > * { pointer-events: auto; }
#skillBar { display: flex; gap: 6px; justify-content: center; align-items: center; }
#skillBar .sk { width: clamp(44px, 13vw, 56px); height: clamp(44px, 13vw, 56px); }
#skillBar .pet-skill, #skillBar .sig-skill, #skillBar .pot-skill { margin: 0; }
/* com a Hora Treze são até 8 slots: encolhem para caber na largura */
#skillBar:has(.h13-skill) { gap: 3px; }
#skillBar:has(.h13-skill) .sk { flex: 1 1 0; min-width: 0; max-width: 56px; width: auto; height: auto; aspect-ratio: 1; }
body.in-lobby:not(.in-house):not(.in-guild) #lobbyEnter { justify-self: center; padding-inline: 16px; flex-direction: row; gap: 7px; }
body:not(.in-lobby) #lobbyEnter, body.in-house #lobbyEnter, body.in-guild #lobbyEnter, body.in-lobby #mobileField { display: none; }
#houseBar { width: auto; min-width: 0; overflow-x: auto; scrollbar-width: thin; flex-wrap: nowrap; justify-content: safe center; }
#houseBar .house-btn { flex: none; min-width: var(--touch); min-height: var(--touch); }
#houseBar .hbuff { width: 42px; height: 42px; }
#houseExit { position: static; transform: none; justify-self: center; }

#menu { grid-area: dock; position: static; display: block; min-width: 0; max-width: none; }
#menuPrimary { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; }
#menu button, .dock-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: auto;
  min-width: 0;
  min-height: var(--touch);
  height: auto;
  padding: 3px;
  border: 1px solid #705334;
  border-radius: 6px;
  background: linear-gradient(180deg, #302323, #1b1316);
  color: var(--brass2);
  box-shadow: 0 1px 0 #080507;
}
#menu button i, .dock-button i { font-style: normal; font-size: 19px; line-height: 1; }
#menu button span, .dock-button span {
  display: block;
  max-width: 100%;
  color: #e5c99d;
  /* fonte grande tem teto pela largura da tela: rótulo numa linha só, sem partir a palavra ("Personag/em") */
  font: 600 min(calc(clamp(9px, .82em, 13px) * var(--fs, 1)), 3vw)/1.15 system-ui, sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#menuPrimary button span { font-size: min(calc(clamp(9px, 2.5vw, 11px) * var(--fs, 1)), 2.9vw); }
.pvp-slot .x { min-width: 40px; min-height: 40px; }
.pvp-slot, .pvp-card { min-height: 44px; }
.pvp-doll { grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); }
.pvp-doll .slot { width: auto; aspect-ratio: 1; height: auto; }
.pvp-status .btn.secondary, .pvp-loadout .btn.secondary, .pvp-pick-h .btn.secondary { min-height: 40px; }
.pvp-loadout .pvp-preset { flex: 1 1 100%; }
.pvp-loadout .pvp-preset select { flex: 1; max-width: none; }
.pvp-mini-it, .pvp-mini-sk { width: 30px; height: 30px; }
.pvp-mini canvas { width: 26px; height: 26px; }
.pvp-cand { width: 58px; }
#mobileField { flex: 0 0 auto; min-width: max(49px, 4em); }
#menu button[aria-expanded="true"], .dock-button[aria-expanded="true"] { border-color: var(--brass2); background: #453022; }
body.no-chat #menu #mobileChat { display: none; }

#drawerScrim { position: fixed; inset: 0; z-index: 1; padding: 0; border: 0; background: #080507a8; }
#menuMore, #chat, #fieldDrawer {
  position: fixed;
  z-index: 2;
  inset: auto var(--safe-right) calc(var(--safe-bottom) + 50px) var(--safe-left);
  width: auto;
  height: auto;
  max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 56px);
  padding: 8px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #94704a;
  border-radius: 8px;
  background: linear-gradient(160deg, #2b1e22, #150f13);
  box-shadow: 0 14px 32px #000b;
}
#menuMore, #chat, #fieldDrawer { display: none; }
#hud[data-drawer="menu"] #menuMore, #hud[data-drawer="field"] #fieldDrawer { display: block; }
body:not(.no-chat) #hud[data-drawer="chat"] #chat { display: flex; }
#hud[data-drawer] #drawerScrim { display: block; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding-left: 5px; margin-bottom: 6px; border-bottom: 1px solid #63472e; }
.drawer-head h2 { margin: 0; font: 700 16px Cinzel, serif; color: var(--brass2); }
.drawer-head .x { width: var(--touch); height: var(--touch); }
.chat-shortcuts {
  inset: 14px calc(14px + var(--touch)) auto auto;
}
#chatVote { order: 1; }
.chat-shortcuts > :is(button, a) {
  width: 32px;
  height: 32px;
}
/* style.css encolhe o chat dentro de casa (desktop); aqui ele é gaveta e o ✕ não pode herdar o visual do dock */
body.in-house #chat { width: auto; height: auto; }
#menu .drawer-head .x { width: var(--touch); border: 0; background: none; box-shadow: none; }
.chat-shortcuts svg { width: 17px; height: 17px; }
#menuPages { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
#menuPages button { min-height: 54px; }
#chatTabs button { min-height: var(--touch); }
.chat-log { min-height: 0; height: min(29dvh, 250px); padding: 4px; }
#chatForm, #chatTradeForm { margin-top: 5px; flex: none; }
#chatIn, #chatTradeIn { margin: 0; min-height: var(--touch); }
#chatForm .btn, #chatTradeForm .btn { display: block; }
#hud[data-drawer="chat"]:has(#chatIn:focus) #chat { bottom: var(--safe-bottom); max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom)); }
#fieldDrawer #profBadge { width: auto; }
#fieldDrawer #mapHud { --map-control-size: 36px; position: static; width: min(100%, 250px); margin-inline: auto; }
#fieldDrawer #profBadge { margin: 0 0 6px; }
#fieldDrawer #profBadge .tq { float: none !important; }
/* barra do mapa (online, Sessão, bug, automação, sair) no topo da gaveta Menu; painéis abrem na própria linha */
#menuMore .map-toolbar { --map-control-size: var(--touch); grid-template-columns: minmax(0, 1fr) auto repeat(3, var(--map-control-size)); gap: 4px; margin: 0 0 8px; padding-bottom: 8px; border-bottom: 1px solid #63472e; }
#menuMore .map-toolbar :is(summary, button) { font-size: 14px; padding-inline: 10px; }
#menuMore .map-toolbar summary { display: grid; place-items: center; list-style: none; }
#menuMore .map-toolbar summary::-webkit-details-marker { display: none; }
#menuMore #sessionStats summary { display: flex; }
#menuMore #online { font-size: 13px; padding-left: 4px; }
#menuMore .map-toolbar .session-stats { inset: calc(100% - 4px) 0 auto; width: auto; z-index: 3; }
#menuMore .session-stats { grid-template-columns: minmax(0, 1fr) auto; }
#lootFeed {
  grid-area: loot;
  position: static;
  width: auto;
  height: 25px;
  flex-direction: column;
  overflow: auto;
  scrollbar-width: thin;
  pointer-events: auto;
}
#lootFeed .loot { flex: none; font-size: .88em; overflow-wrap: anywhere; }
/* Automação: tela cheia, alvos de toque maiores */
#automation { width: calc(100vw - 12px); height: calc(100dvh - 12px); padding: 10px 12px; }
#automation .dlg-head .x { width: var(--touch); height: 40px; }
.auto-tabs button { min-width: 0; min-height: var(--touch); padding: 0 3px; font-size: 12px; }
.automation-option { min-height: 50px; }
.auto-q { width: 26px; height: 26px; }
.loot-keep { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.automation-modes span { padding: 13px 3px; }
#automation .preset-rule select { min-height: var(--touch); }

#panel, #modal, #duelModal { overscroll-behavior: contain; }
#panel {
  inset: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  width: auto;
  max-height: none;
  border-radius: 8px;
}
.panel-head { flex: none; gap: 4px; padding: 2px 6px 2px 12px; }
.panel-head h2 { font-size: clamp(15px, 4.4vw, 22px); }
.panel-head .x { width: var(--touch); height: var(--touch); flex: none; }
#panelBody { padding: 10px; overflow: auto; overscroll-behavior: contain; }
#panelFoot { padding: 4px; }
#panelFoot button, .vault-pages button, .vault-filter .chips button { min-height: var(--touch); }
#panelBody :is(.toolbar, .ch-foot, .chips, .vault-actions, .pvp-build-h, .pvp-sk-h, .inv-row) { flex-wrap: wrap; }
#panelBody .toolbar > :is(select, input) { min-width: 0; min-height: var(--touch); flex: 1 1 135px; }
#panelBody .cols > div, .pvp-id { min-width: 0; }
#panelBody .tabs { overflow-x: auto; }
#panelBody .tabs .tab { min-width: max-content; font-size: 13px; }
#panelBody .btn { max-width: 100%; white-space: normal; }
#panelBody .inv-grid { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); }
#panelBody .cell { width: 100%; height: auto; aspect-ratio: 1; }
#panelBody .inv-detail { grid-template-columns: auto minmax(0, 1fr); padding: 10px; gap: 9px; }
#panelBody .inv-fav { right: 10px; width: 38px; height: 38px; }
#panelBody .inv-actions { grid-column: 1 / -1; }
#panelBody .inv-row > .btn { min-width: min(100%, 118px); }
#panelBody .inv-market { flex-wrap: nowrap; }
#panelBody .inv-market .btn { min-width: 0; }
#panelBody .boss-list { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.boss-card canvas { width: 66px; height: 76px; }
.ch-head { flex-wrap: wrap; gap: 8px; }
.ch-portrait { width: 54px; height: 54px; }
.ch-name { font-size: 17px; overflow-wrap: anywhere; }
.ch-kpis { display: flex; flex: 1 0 100%; gap: 4px; }
.ch-kpis div { flex: 1; min-width: 0; padding: 4px; }
.ch-kpis b { font-size: 14px; }
/* personagem: cabeçalho compacto, abas fixas e um assunto por vez */
.ch-head { padding: 8px 10px; }
.ch-head ~ .cols { margin-top: 0; }
.ch-kpis div:last-child { display: none; }
.char-tabs { position: sticky; top: -10px; z-index: 5; display: flex; margin: 8px -10px 6px; padding: 0 4px; background: #160f13; border-bottom: 1px solid #53402e; }
.char-tabs button { flex: 1 1 auto; min-width: 0; min-height: var(--touch); padding: 0 4px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font: 600 13px 'Cinzel', serif; cursor: pointer; }
.char-tabs button.on { color: var(--brass2); border-bottom-color: var(--brass2); }
.char-tabs b { margin-left: 4px; color: #8fe07a; font-size: 12px; }
#panelBody .attr-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); }
.attr-card { padding: 10px 12px; }
.attr-card .an { min-height: 20px; padding-right: 120px; }
.attr-card .ab { gap: 8px; right: 10px; top: 10px; }
.attr-card .ab .btn { min-width: 52px; min-height: var(--touch); }
.attr-card .aw { margin-top: 8px; gap: 4px; } .attr-card .aw span { width: 30px; height: 30px; } .attr-card .aw canvas { width: 28px !important; height: 28px !important; }
.attr-card .ag { font-size: 13px; gap: 2px 12px; margin-top: 4px; }
.attr-reset { width: 100%; min-height: var(--touch); margin-top: 8px; }
#panelBody .doll { grid-template-columns: repeat(3, minmax(0, 96px)); gap: 10px; }
#panelBody .doll .slot { width: 100%; height: auto; aspect-ratio: 1; }
#panelBody .doll .slot.sel { outline: 2px solid var(--brass2); }
.ch-slot-foot { grid-column: 1 / -1; display: flex; gap: 8px; } .ch-slot-foot .btn { flex: 1; min-height: var(--touch); }
.ch-skills { gap: 10px; padding: 10px 0; } .ch-sk { width: 52px; height: 52px; }
#panelBody .stat { padding: 7px 0; font-size: 15px; }
#panelBody .prof-row { padding: 7px 0; }
#panelBody .pz-quick { flex-wrap: wrap; }
#panelBody .pz-quick-list { order: 3; flex: 1 0 100%; min-width: 0; }
#panelBody .pz-quick-l { flex: 1; }
.mobile-only.vault-move { display: inline-block; }
.skm-loadout-h { flex-direction: column; gap: 2px; }
.skm-slots { gap: 5px; }
.skm-lslot { flex-direction: column; gap: 4px; padding: 5px 3px; text-align: center; }
.skm-lslot .sk { width: min(100%, calc(44 * var(--skm-px))); }
.skm-ltx .mt { display: none; }
#panelBody .skm-tabs { overflow: visible; }
#panelBody .skm-tabs .tab { flex: 1 1 0; min-width: 0; flex-direction: column; gap: 2px; padding: 6px 2px; font-size: 12px; }
.skm-tools > * { min-height: var(--touch); }
.skm-weapon { flex: 1 1 9em; }
.skm-detail .btn { min-height: max(var(--touch), calc(28 * var(--skm-px))); }
.skm-equip .btn { flex: 1; }
.skm-scrolls { grid-template-columns: minmax(0, 1fr); }
.skm-scroll { grid-template-columns: auto minmax(0, 1fr); }
.skm-scroll-act { grid-column: 1 / -1; flex-direction: row; }
.skm-scroll-act .btn { flex: 1; min-height: var(--touch); }
.chip, .floors button { min-height: var(--touch); }
.table-scroll { max-width: 100%; overflow-x: auto; }
.table-scroll table { min-width: 30rem; }
.vault-layout { display: grid; grid-template-columns: minmax(0, 1fr); }
.vault-inv { width: auto; }
.vault-invgrid { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); max-height: min(240px, 42dvh); }
.vault-invgrid .vc { width: 100%; height: auto; aspect-ratio: 1; }
.vault-grid { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); }
#panelBody .vault-filter .chips.rar button:not(:first-child) { width: 36px; }

dialog[open], .modal-box { max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom)); overflow: auto; overscroll-behavior: contain; }
.modal-box { min-width: 0; width: min(480px, calc(100% - var(--safe-left) - var(--safe-right))); padding: 14px; }
/* #modal: corpo rola e rodapé fixo já vêm do style.css; aqui só não deixa a caixa rolar inteira */
#modal .modal-box { overflow: hidden; padding: 14px; }
#houseShop .house-shop { max-height: none; overflow: visible; }
.house-shop-row { grid-template-columns: 44px minmax(0, 1fr) auto; gap: 5px; }
.house-shop-row > i img { width: 44px; height: 44px; }
#duelModal { padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left); }
.dm-box {
  width: min(900px, 100%);
  max-height: 100%;
  padding: 8px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  overflow: hidden;
}
.dm-head { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px; overflow-wrap: anywhere; }
.dm-side .tq { display: block; }
.dm-box canvas { width: 100%; height: auto; min-height: 0; object-fit: contain; }
.dm-foot { flex-wrap: wrap; }
.dm-sum { font-size: 11px; gap: 4px 8px; padding: 4px 6px; }
.dm-side { min-width: 0; }
.dm-sk, .dm-ch { gap: 3px; }
.dm-chip { height: 18px; padding: 0 4px; }
:is(#tooltip, #tooltip-eq) { max-width: min(320px, calc(100vw - 16px)); max-height: calc(100dvh - 16px); overflow: hidden; }
#toasts { top: var(--safe-top); width: min(330px, 86vw); }
body:has(#panel[data-view="presets"]:not(.hidden)) #toasts { bottom: calc(var(--safe-bottom) + 52px); }
.u-banner { width: min(92vw, 660px); white-space: normal; }
.u-banner .ub-t { font-size: clamp(18px, 5vw, 34px); }
.u-banner .ub-s { letter-spacing: 2px; }
#updateBar { top: var(--safe-top); width: max-content; }
#updateBar .x { width: 32px; min-height: var(--touch); flex: none; }

#login { padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left); }
#loginBg { position: fixed; }
.login-wrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; width: min(620px, 100%); max-width: none; }
.login-box, .login-side { width: 100%; }
.login-box { padding: 14px; }
.login-side { display: grid; gap: 6px; }
.logo { font-size: clamp(23px, 7.2vw, 43px); letter-spacing: 1px; }
.subtitle { letter-spacing: 3px; }
.login-box .tab { font-size: 13px; }
#heroPreview { width: min(160px, 27vw); height: auto; }
.create-form { min-width: 0; }
.create .row { flex-wrap: wrap; gap: 4px; }
.create .lbl { width: auto; min-width: 72px; }
.seg button { min-height: 36px; }
.swatches i { width: 28px; height: 28px; }
#accHero { width: 78px; height: auto; }
.acc-name { overflow-wrap: anywhere; font-size: 22px; }
.acc-actions { flex-wrap: wrap; gap: 6px; }
#googleBtn { overflow-x: auto; }

@media (max-width: 560px) {
  #panelBody > .cols { flex-direction: column; }
  .stat-grid { grid-template-columns: minmax(0, 1fr); }
  .biome-h { grid-template-columns: minmax(0, 1fr); gap: 5px; }
  .biome-description { justify-self: stretch; text-align: left; }
  .create { flex-direction: column-reverse; gap: 6px; }
  .create-form { width: 100%; }
  #heroPreview { align-self: center; width: 92px; }
}

@media (max-width: 360px) {
  #menuPrimary button { padding-inline: 1px; }
  #menuPrimary button span { font-size: 8.5px; }
}

/* ---- Paisagem: o palco ocupa a tela inteira e o HUD fica por cima, sempre nas bordas:
   topo = cartão · título · Eventos/Campo | direita = dock em trilho | rodapé = buffs · skills · saque.
   Quem desenha no canvas (barra do chefe, saguão, casa) desvia do HUD por Stage.pad (stage.js, mesma media query). min-width: celular em pé com o teclado
   aberto fica mais largo que alto e não pode trocar de layout no meio da digitação. */
@media (orientation: landscape) and (min-width: 520px) {
  :root {
    --safe-top: max(5px, env(safe-area-inset-top)); --safe-bottom: max(5px, env(safe-area-inset-bottom));
    --dock-w: 60px; --rail: calc(var(--dock-w) + env(safe-area-inset-right, 0px)); --land-sk: 44px;
    --chip: #150f12d9; --chip-line: #5f4830;
  }
  #hud {
    grid-template: "player scene dock" minmax(44px, auto) "mid mid dock" minmax(0, 1fr) / auto minmax(0, 1fr) var(--rail);
    gap: 5px; padding: 0 0 0 var(--safe-left); background: #100b0e;
  }
  /* z-index -1: atrás de todo o HUD sem criar contexto em #menu/#chat (as gavetas ficam acima do véu) */
  #stage { position: fixed; inset: 0; z-index: -1; border: 0; border-radius: 0; box-shadow: none; }

  /* ---- topo */
  #playerCard { margin-top: var(--safe-top); padding: 3px 7px 4px; border: 1px solid var(--chip-line); border-radius: 6px; background: var(--chip); box-shadow: none; }
  #portrait { display: none; }
  .pc-info { display: grid; grid-template: "name res" auto "hp res" auto "xp res" auto / minmax(118px, min(24vw, 205px)) auto; column-gap: 8px; align-items: center; }
  .pc-name { grid-area: name; align-items: center; line-height: 1.15; }
  .pc-who { display: flex; align-items: center; min-width: 0; }
  .pc-right { flex: none; gap: 5px; }
  .pc-name .pc-party { padding: 1px 4px; min-height: 0; height: 18px; position: relative; }
  .pc-name button.pc-party::after { content: ''; position: absolute; inset: -8px -6px; }
  #hName { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pc-info .bar { margin-top: 2px; }
  .bar.hp { grid-area: hp; }
  .bar.xp { grid-area: xp; }
  .pc-info .bar.hp { height: calc(13px * var(--fs, 1)); }
  .pc-info .bar.xp { height: calc(10px * var(--fs, 1)); }
  .pc-info .bar.hp span { font-size: 11px; }
  .pc-info .bar.xp span { font-size: 9px; }
  .pc-res { grid-area: res; display: grid; grid-auto-flow: column; grid-template-rows: repeat(2, auto); align-items: center; justify-items: start; gap: 2px 4px; margin: 0; }
  #btnPot { min-width: 30px; min-height: 18px; font-size: 14px; line-height: 1; }

  /* absoluto na própria célula: a 2ª linha (cartões de evento, treino) desce sobre o palco sem esticar o topo */
  #sceneHeader { position: absolute; grid-area: scene; inset: var(--safe-top) 5px auto 0; z-index: 1; min-height: 0; align-items: flex-start; justify-content: flex-end; gap: 5px; padding: 0; border: 0; background: none; pointer-events: none; }
  #sceneHeader > * { pointer-events: auto; }
  #sceneHeader :is(#floorTitle, #lobbyTitle, .house-head, .ghall-head) { flex: 1 1 0; min-width: 84px; max-width: max-content; margin-right: auto; padding: 4px 10px; min-height: 42px; border: 1px solid var(--chip-line); border-radius: 6px; background: var(--chip); line-height: 1.25; overflow: hidden; }
  #sceneHeader :is(.ft-floor, .ft-name, .ft-boss, #lobbyTitle b, #lobbyTitle small, .house-head b, .house-head small, .ghall-head b, .ghall-head small) { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #floorTitle { display: grid; grid-template-columns: auto minmax(0, auto); align-content: center; }
  .ft-boss { grid-column: 1 / -1; }
  #sceneHeader .ghall-head { display: grid; grid-template-columns: minmax(0, auto) auto; column-gap: 10px; align-items: center; padding-right: 4px; }
  #sceneHeader .ghall-head small { grid-row: 2; }
  #sceneHeader #guildExit { grid-area: 1 / 2 / 3 / 3; width: 112px; max-width: none; min-height: 34px; white-space: normal; }
  body:not(.in-guild) #sceneHeader .ghall-head { display: none; }
  #sceneHeader :is(#mobileEvents, #mobileField) { width: 50px; min-width: 0; min-height: 42px; padding: 1px; border-color: var(--chip-line); background: var(--chip); box-shadow: none; }
  #sceneHeader :is(#mobileEvents, #mobileField) i { font-size: 16px; }
  #sceneHeader :is(#mobileEvents, #mobileField) span { font-size: min(calc(10px * var(--fs, 1)), 11px); }
  #sceneHeader .wb-card { flex: 0 1 11em; border-radius: 6px; background: var(--chip); }
  #sceneHeader #btnGiveUp { min-height: 42px; max-width: 112px; line-height: 1.15; }
  #sceneHeader #trainBar { position: static; order: 3; flex-basis: 100%; align-items: flex-end; }

  /* ---- dock: trilho contínuo, colado na borda */
  #menu { grid-area: dock; }
  #menuPrimary { grid-auto-flow: row; grid-template-columns: minmax(0, 1fr); grid-auto-rows: minmax(40px, 1fr); gap: 0; height: 100dvh; min-height: 0; overflow: auto; scrollbar-width: none; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) 0; border-left: 1px solid var(--chip-line); background: var(--chip); }
  #menu #menuPrimary button { border: 0; border-bottom: 1px solid #3c2c1f; border-radius: 0; background: none; box-shadow: none; }
  #menu #menuPrimary button:last-child { border-bottom: 0; }
  #menu #menuPrimary button:is([aria-expanded="true"], :active) { background: #453022; }
  #menuPrimary button i { font-size: 21px; }
  #menuPrimary button span { font-size: min(calc(10px * var(--fs, 1)), calc(var(--dock-w) / 6.7)); }

  /* ---- rodapé */
  #sceneControls { grid-area: mid; align-self: end; justify-self: center; z-index: 1; max-width: 100%; margin-bottom: calc(var(--safe-bottom) + 2px); justify-items: center; pointer-events: none; }
  #sceneControls > * { pointer-events: auto; }
  #skillBar { flex-wrap: nowrap; gap: 5px; pointer-events: none; }
  #skillBar > * { pointer-events: auto; }
  #skillBar .sk { width: var(--land-sk); height: var(--land-sk); }
  .coach { max-width: min(480px, 60vw); }
  body.in-lobby #sceneControls { justify-self: end; margin: 0 10px calc(var(--safe-bottom) + 6px) 0; }
  #lobbyEnter.dock-button { min-height: 46px; }
  /* as skills (até 7 quadrados = 340px) ficam no centro; buffs e saque usam o que sobra de cada lado */
  #stage > #buffBar { left: var(--safe-left); right: auto; bottom: calc(var(--safe-bottom) + 2px); max-width: max(96px, calc(50vw - var(--rail) / 2 - 184px)); flex-wrap: wrap-reverse; overflow: visible; gap: 3px; }
  #stage > #buffBar .hbuff { width: 30px; height: 30px; }
  #lootFeed { grid-area: mid; align-self: end; justify-self: end; z-index: 1; width: max(104px, calc(50vw - var(--rail) / 2 - 190px)); max-width: 250px; height: auto; max-height: 96px; margin: 0 2px calc(var(--safe-bottom) + 2px) 0; overflow: hidden; pointer-events: none; }
  #lootFeed .loot { font-size: .82em; padding: 2px 6px; }

  /* ---- arena do Boss Diário e movimento manual */
  #worldBossRoster { top: calc(var(--safe-top) + 62px); left: var(--safe-left); max-height: 40%; }
  #manualPad { left: max(14px, var(--safe-left)); bottom: calc(var(--safe-bottom) + 10px); }
  #manualMove { right: calc(var(--rail) + 8px); bottom: 112px; }
  body.manual-move #sceneControls { justify-self: end; margin-right: 8px; }
  body.manual-move #stage > #buffBar { bottom: 136px; }
  body.manual-move #lootFeed { margin-bottom: 60px; }
  .wg-card { top: calc(var(--safe-top) + 64px); bottom: auto; right: calc(var(--rail) + 10px); padding: 5px 10px 5px 8px; }
  #toasts { top: calc(var(--safe-top) + 58px); left: calc(50% - var(--rail) / 2); width: min(300px, 50vw); }
  #toasts .toast { padding: 5px 12px; font-size: 13px; }

  /* ---- casa: móveis numa coluna à esquerda; a saída fica no topo, ao lado do título */
  body.in-house #sceneControls { display: contents; }
  #houseBar { grid-area: mid; align-self: stretch; justify-self: start; z-index: 1; width: 54px; display: flex; flex-direction: column; justify-content: flex-start; gap: 4px; padding-bottom: var(--safe-bottom); overflow: hidden auto; scrollbar-width: none; pointer-events: none; }
  #houseBar .house-btn { width: 100%; min-width: 0; padding: 3px; border-width: 1px; background: var(--chip); pointer-events: auto; }
  #houseBar .house-btn :is(span, small) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  #houseExit { grid-area: scene; z-index: 2; align-self: start; justify-self: end; width: 118px; min-height: 42px; margin: var(--safe-top) 5px 0 0; padding: 3px 6px; font-size: 11px; white-space: normal; pointer-events: auto; }
  body.in-house #sceneHeader { right: 128px; }

  /* ---- gavetas: encostadas no dock */
  #menuMore, #chat, #fieldDrawer { inset: var(--safe-top) calc(var(--rail) + 5px) auto auto; width: min(58vw, 460px); max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom)); }
  #menuMore { width: min(calc(100vw - var(--rail) - var(--safe-left) - 10px), 620px); }
  #menuPages { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
  #menuPages button { min-height: 52px; }
  #menuMore .map-toolbar { margin-bottom: 6px; padding-bottom: 6px; }
  #menuMore:has(#sessionStats[open]) { bottom: var(--safe-bottom); }
  .drawer-head { margin-bottom: 4px; }
  .drawer-head .x { height: 36px; }
  .chat-shortcuts { inset: 10px calc(14px + var(--touch)) auto auto; }
  #chat, body.in-house #chat { bottom: var(--safe-bottom); width: min(58vw, 460px); }
  .chat-log { height: auto; flex: 1; }
  #chatTabs button { min-height: 36px; }
  #fieldDrawer { width: min(46vw, 300px); }

  /* ---- painéis e duelo */
  #panel { inset-inline: max(var(--safe-left), calc((100vw - 980px) / 2)) max(var(--safe-right), calc((100vw - 980px) / 2)); }
  .panel-head { padding-block: 0; }
  .panel-head h2 { font-size: 17px; margin-block: 0; }
  .panel-head .x { height: 40px; }
  #panelBody { padding: 8px 10px; }
  .ch-head { flex-wrap: nowrap; padding-block: 6px; }
  .ch-kpis { flex: 1 1 46%; }
  .ch-kpis b { font-size: 13px; }
  .skm-loadout-h { flex-direction: row; align-items: baseline; gap: 10px; }
  .skm-lslot { flex-direction: row; gap: 7px; padding: 4px 6px; text-align: left; }
  .skm-lslot .sk { width: calc(36 * var(--skm-px)); height: calc(36 * var(--skm-px)); flex: none; }
  .skm-ltx { min-width: 0; }
  #panelBody .skm-tabs .tab { flex-direction: row; justify-content: center; gap: 7px; }
  /* inventário: grade à esquerda e o item aberto fixo à direita (texto | ações), sem rolar para longe da grade */
  #panel[data-view="inv"] #panelBody:has(> .inv-detail) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); column-gap: 10px; align-items: start; align-content: start; }
  #panel[data-view="inv"] #panelBody:has(> .inv-detail) > :not(.inv-grid, .inv-detail) { grid-column: 1 / -1; }
  #panelBody > .inv-detail.inv-detail { grid-column: 2; position: sticky; top: 0; margin: 0; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 64px); overflow: auto; overscroll-behavior: contain; font-size: 14px; }
  #panelBody > .inv-detail > .slot { display: none; }
  #panelBody > .inv-detail .inv-info { padding-right: 0; }
  #panelBody > .inv-detail .inv-actions { grid-column: 2; padding-top: 42px; gap: 6px; }
  #panelBody > .inv-detail .inv-row > .btn { min-width: 0; }
  #panelBody > .inv-detail .inv-actions .btn { padding: 6px 4px; font-size: 12px; min-height: 40px; }
  .vault-layout { grid-template-columns: minmax(135px, 1fr) minmax(0, 2fr); }
  .dm-box { height: 100%; }
  .dm-box canvas { height: 100%; aspect-ratio: auto; }
  .login-wrap { width: 100%; grid-template-columns: minmax(0, 2fr) minmax(155px, 1fr); }
}
/* paisagem em telas pequenas (568–680px) */
@media (orientation: landscape) and (min-width: 520px) and (max-width: 680px) {
  :root { --dock-w: 54px; --land-sk: 42px; }
  #playerCard { padding-inline: 5px; }
  .pc-info { grid-template-columns: minmax(112px, 22vw) auto; column-gap: 5px; }
  .pc-name { font-size: .95em; }
  #hCronal, .ft-name, .house-head small { display: none; }
  #sceneHeader :is(#floorTitle, #lobbyTitle, .house-head, .ghall-head) { padding-inline: 7px; }
  #sceneHeader :is(#mobileEvents, #mobileField) { width: 44px; }
  #skillBar { gap: 3px; }
}
@media (orientation: landscape) and (min-width: 520px) and (max-width: 600px) {
  .pc-info { grid-template-columns: 104px auto; }
  #hDps { display: none; }
  #sceneHeader :is(#mobileEvents, #mobileField) { width: 34px; }
  #sceneHeader :is(#mobileEvents, #mobileField) span { display: none; }
}
/* Arena PVP: cabeçalho em duas linhas (emblema + elo; Duelar embaixo, largura toda), atributos em duas colunas */
.pvp-head { gap: 10px 12px; flex-wrap: wrap; }
.pvp-emblem { width: 56px; height: 56px; }
.pvp-id { flex: 1 1 0; min-width: 0; }
.pvp-id .elo { font-size: 20px; }
.pvp-btns { flex: 1 1 100%; margin-left: 0; }
.pvp-btns .btn { flex: 1; width: 100%; }
.pvp-stats { grid-template-columns: 1fr 1fr; gap: 2px 10px; }
.pvp-stats .ps { font-size: 12px; }
.pvp-stats .ps i { min-width: 0; }
.pvp-season-end { flex-wrap: wrap; }
/* ranking PVP sem rolagem lateral: nível e "online" ficam só no desktop */
.pvp-rank th:nth-child(n+6), .pvp-rank td:nth-child(n+6) { display: none; }
.pvp-rank tr.gap td { display: table-cell; }
.table-scroll > .pvp-rank { min-width: 0; width: 100%; }
.pvp-rank th, .pvp-rank td { padding-left: 4px; padding-right: 4px; }
/* escada de elos no celular: só o nome do seu elo aparece (os outros pelo trilho e pelo toque) */
.pvp-ladder .pl:not(.cur) span { visibility: hidden; }
#menu #menuToggle { display: none; }

/* Mercado: no celular a linha vira 2 andares (ícone · nome · preço / detalhes · vendedor · ação) */
@media (max-width: 560px) {
  #panelBody .mk-head { display: none; }
  #panelBody .mk-card { grid-template-columns: 44px minmax(0, 1fr) auto; grid-template-areas: 'ic nm pr' 'ic dt bt' 'ic sd bt'; column-gap: 10px; row-gap: 2px; padding: 8px 2px; }
  #panelBody .mk-ico { grid-area: ic; align-self: start; }
  #panelBody .mk-name { grid-area: nm; }
  #panelBody .mk-name > span { white-space: normal; }
  #panelBody .mk-det { grid-area: dt; }
  #panelBody .mk-det:empty { display: none; }
  #panelBody .mk-side { grid-area: sd; font-size: 12px; color: var(--muted); }
  #panelBody .mk-price { grid-area: pr; }
  #panelBody .mk-card > .btn, #panelBody .mk-act { grid-area: bt; align-self: end; }
}
