/* SEAS OF LEGENDS — interface.
   Escrita primeiro para a tela pequena: alvos de toque de 48px, HUD nas
   bordas seguras e nada que dependa de passar o mouse. O layout de
   computador é o mesmo com mais espaço. */

:root {
  --fundo: #04101f;
  --painel: rgba(8, 24, 38, .92);
  --painelBorda: rgba(120, 190, 225, .22);
  --texto: #e8f4fb;
  --textoFraco: #9ab6c9;
  --azul: #4a92c4;
  --ouro: #ffd166;
  --vida: linear-gradient(90deg, #58d67f, #8ef27a);
  --vidaBaixa: linear-gradient(90deg, #ff5a5a, #ff9a6a);
  --energia: linear-gradient(90deg, #3f9fd6, #8fd8ff);
  --exp: linear-gradient(90deg, #b38dff, #e2c9ff);
  --seguro-t: env(safe-area-inset-top, 0px);
  --seguro-b: env(safe-area-inset-bottom, 0px);
  --seguro-l: env(safe-area-inset-left, 0px);
  --seguro-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: var(--fundo); color: var(--texto);
  font-family: system-ui, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: none;
}

#gameShell { position: fixed; inset: 0; }
#gameCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
/* Camada 2D por cima do WebGL: número de dano, barra de inimigo e minimapa.
   Texto em 2D fica nítido e custa muito menos que texto em textura 3D. */
#hudCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; z-index: 2; }

.hud-layer { position: absolute; pointer-events: none; z-index: 5; }
.hud-layer button, .hud-layer select, .hud-layer input { pointer-events: auto; }

/* ------------------------------------------------------------------ carga */
#loadingScreen {
  position: absolute; inset: 0; z-index: 60;
  display: grid; place-items: center;
  background: #04101f;
  transition: opacity .6s ease, visibility .6s;
}
#loadingScreen img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: .45; filter: saturate(1.1);
}
.loadingCopy { position: relative; text-align: center; padding: 0 22px; max-width: 640px; }
.loadingCopy span { letter-spacing: .22em; font-size: 11px; color: #8fd8ff; }
.loadingCopy h1 { font-size: clamp(34px, 9vw, 68px); margin: 8px 0 10px; letter-spacing: .04em; text-shadow: 0 6px 30px rgba(0, 0, 0, .7); }
.loadingCopy p { color: var(--textoFraco); margin: 0 0 20px; }
.loadingBar { height: 4px; background: rgba(255, 255, 255, .12); border-radius: 3px; overflow: hidden; }
.loadingBar i { display: block; height: 100%; width: 36%; background: linear-gradient(90deg, #4a92c4, #8fd8ff); border-radius: 3px; animation: carregando 1.3s ease-in-out infinite; }
@keyframes carregando { 0% { transform: translateX(-100%); } 100% { transform: translateX(320%); } }
body.game-ready #loadingScreen { opacity: 0; visibility: hidden; }

/* -------------------------------------------------------------- HUD topo */
#hudTopo {
  top: calc(10px + var(--seguro-t)); left: calc(10px + var(--seguro-l));
  right: calc(10px + var(--seguro-r));
  display: flex; align-items: flex-start; gap: 12px; justify-content: space-between;
}

#hudBarras { display: flex; flex-direction: column; gap: 5px; width: min(38vw, 300px); }
.barraBloco { position: relative; }
.barraExterna {
  height: 15px; border-radius: 9px; overflow: hidden;
  background: rgba(4, 16, 26, .78);
  border: 1px solid rgba(140, 200, 230, .2);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, .5);
}
.barraExterna.fina { height: 8px; }
.barraDentro { height: 100%; width: 100%; border-radius: 8px; transition: width .18s ease; }
.barraDentro.hp { background: var(--vida); }
.barraDentro.hp.critico { background: var(--vidaBaixa); animation: pulsaVida .7s ease-in-out infinite; }
.barraDentro.energy { background: var(--energia); }
.barraDentro.xp { background: var(--exp); }
@keyframes pulsaVida { 50% { filter: brightness(1.5); } }
.barraTexto {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 10px; font-weight: 700; letter-spacing: .04em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .9); pointer-events: none;
}
.barraBloco.xp .barraTexto { position: static; display: block; text-align: left; color: var(--textoFraco); font-weight: 600; margin-top: 2px; }

#hudLugar { text-align: center; flex: 1; min-width: 0; }
#hudLugar b { display: block; font-size: 12px; letter-spacing: .2em; color: #8fd8ff; opacity: .85; }
#hudLugar span { display: block; font-size: 13px; color: var(--textoFraco); }

/* O botão de tela cheia do portal (44 px, canto de cima à direita) cobria as
   fichas de moeda e o botão Conta — capturas da Fase 1 da v2. */
#hudDireita { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; justify-content: flex-end; margin-right: 48px; }
.fichaHud {
  display: flex; align-items: center; gap: 5px;
  background: rgba(6, 22, 36, .82); border: 1px solid var(--painelBorda);
  border-radius: 999px; padding: 5px 11px; font-weight: 700; font-size: 13px;
}
.fichaIcone { color: var(--ouro); }
#fichaPontos.temPontos { border-color: var(--ouro); box-shadow: 0 0 14px rgba(255, 209, 102, .45); animation: pulsaFicha 1.6s ease-in-out infinite; }
@keyframes pulsaFicha { 50% { box-shadow: 0 0 22px rgba(255, 209, 102, .8); } }
.botaoHud {
  background: rgba(6, 22, 36, .82); border: 1px solid var(--painelBorda); color: var(--texto);
  border-radius: 999px; padding: 7px 13px; font-size: 12px; cursor: pointer; min-height: 34px;
}

/* --------------------------------------------------------------- missões */
#questTracker {
  top: calc(88px + var(--seguro-t)); right: calc(10px + var(--seguro-r));
  width: min(70vw, 268px);
  background: rgba(6, 22, 36, .8); border: 1px solid var(--painelBorda);
  border-radius: 13px; padding: 10px 12px;
  backdrop-filter: blur(7px);
}
#questTracker h3 { margin: 0 0 7px; font-size: 10px; letter-spacing: .2em; color: #8fd8ff; opacity: .8; }
.questItem b { display: block; font-size: 14px; margin-bottom: 3px; }
.questItem span { display: block; font-size: 12px; color: var(--textoFraco); line-height: 1.35; }
.questItem em { display: block; font-size: 11px; color: var(--ouro); font-style: normal; margin-top: 5px; }
.questBarra { height: 4px; background: rgba(255, 255, 255, .12); border-radius: 3px; margin-top: 7px; overflow: hidden; }
.questBarra i { display: block; height: 100%; background: linear-gradient(90deg, var(--ouro), #ffe9b0); transition: width .3s ease; }
.questContagem { margin-top: 8px; font-size: 10px; color: var(--textoFraco); opacity: .8; }

/* ----------------------------------------------------------------- chefe */
#bossBanner {
  top: calc(14px + var(--seguro-t)); left: 50%; transform: translateX(-50%) translateY(-24px);
  width: min(86vw, 540px); opacity: 0; transition: opacity .4s ease, transform .4s ease;
}
#bossBanner.visivel { opacity: 1; transform: translateX(-50%) translateY(0); }
.bossTopo { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; }
.bossTopo b { font-size: 16px; letter-spacing: .12em; text-shadow: 0 2px 10px rgba(0, 0, 0, .8); }
.bossTopo span { font-size: 11px; color: var(--ouro); }
.bossBarra {
  height: 13px; border-radius: 7px; overflow: hidden;
  background: rgba(4, 10, 18, .85); border: 1px solid rgba(255, 130, 130, .35);
}
.bossBarra i { display: block; height: 100%; width: 100%; background: #ff4f7a; transition: width .22s ease; }

/* ---------------------------------------------------------------- avisos */
#toastWrap {
  left: 50%; bottom: calc(160px + var(--seguro-b)); transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 7px; align-items: center; width: min(90vw, 460px);
}
.toast {
  background: rgba(6, 22, 36, .93); border: 1px solid var(--cor, var(--painelBorda));
  border-left: 3px solid var(--cor, var(--azul));
  color: var(--texto); padding: 9px 15px; border-radius: 10px;
  font-size: 13px; line-height: 1.35; text-align: center;
  animation: entraToast .28s ease; box-shadow: 0 8px 26px rgba(0, 0, 0, .45);
}
.toast.saindo { animation: saiToast .38s ease forwards; }
@keyframes entraToast { from { opacity: 0; transform: translateY(12px); } }
@keyframes saiToast { to { opacity: 0; transform: translateY(-10px); } }

/* --------------------------------------------------------------- prêmios */
#rewardBanner {
  left: 50%; top: 26%; transform: translateX(-50%) scale(.85);
  display: flex; align-items: center; gap: 14px;
  background: rgba(6, 20, 34, .95); border: 2px solid var(--rar, var(--ouro));
  border-radius: 15px; padding: 14px 22px;
  opacity: 0; visibility: hidden; transition: all .38s cubic-bezier(.2, 1.4, .4, 1);
  box-shadow: 0 0 40px color-mix(in srgb, var(--rar, #ffd166) 45%, transparent);
}
#rewardBanner.visivel { opacity: 1; visibility: visible; transform: translateX(-50%) scale(1); }
.premioIcone { font-size: 40px; }
#rewardBanner b { display: block; font-size: 12px; letter-spacing: .18em; }
#rewardBanner span { display: block; font-size: 17px; font-weight: 700; }
#rewardBanner em { display: block; font-size: 10px; letter-spacing: .16em; color: var(--ouro); font-style: normal; margin-top: 3px; }

/* -------------------------------------------------------------- diálogo */
#dialogBox {
  left: 50%; bottom: calc(150px + var(--seguro-b)); transform: translateX(-50%) translateY(14px);
  width: min(92vw, 620px); pointer-events: auto; cursor: pointer;
  background: rgba(6, 22, 36, .96); border: 1px solid var(--painelBorda);
  border-radius: 14px; padding: 15px 19px;
  opacity: 0; visibility: hidden; transition: all .26s ease;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .5);
}
#dialogBox.visivel { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
#dialogBox b { color: var(--ouro); font-size: 14px; letter-spacing: .06em; }
#dialogBox p { margin: 7px 0 10px; font-size: 15px; line-height: 1.5; }
#dialogBox span { font-size: 11px; color: var(--textoFraco); }

/* --------------------------------------------------------------- atalhos */
#skillDock {
  position: absolute; left: 50%; bottom: calc(12px + var(--seguro-b)); transform: translateX(-50%);
  display: flex; gap: 7px; z-index: 5; pointer-events: none;
  width: max-content; max-width: calc(100% - 24px - var(--seguro-l) - var(--seguro-r));
  flex-wrap: wrap; justify-content: center;
}
.skillKey {
  background: rgba(6, 22, 36, .8); border: 1px solid var(--painelBorda);
  border-radius: 9px; padding: 5px 10px; text-align: center; min-width: 58px;
}
.skillKey b { display: block; font-size: 11px; color: var(--ouro); }
.skillKey span { display: block; font-size: 9px; color: var(--textoFraco); letter-spacing: .05em; }
.skillKey.power b { color: #8fd8ff; }
.skillKey.ultimate b { color: #ffa45c; }
.skillKey.pesado { border-color: rgba(255, 209, 102, .5); }

#barraBotoes {
  position: absolute; left: calc(10px + var(--seguro-l)); bottom: calc(12px + var(--seguro-b));
  display: flex; gap: 7px; z-index: 6; flex-wrap: wrap; max-width: 44vw;
}
.pillButton {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(6, 22, 36, .86); border: 1px solid var(--painelBorda);
  color: var(--texto); border-radius: 999px; padding: 9px 15px;
  font-size: 13px; cursor: pointer; min-height: 44px;
  transition: border-color .2s, transform .12s;
}
.pillButton:hover { border-color: var(--azul); }
.pillButton:active { transform: scale(.96); }
.pillButton.pulsando { border-color: var(--ouro); box-shadow: 0 0 16px rgba(255, 209, 102, .5); animation: pulsaFicha 1.5s ease-in-out infinite; }

/* -------------------------------------------------------------- painéis */
.panel {
  position: absolute; inset: 0; z-index: 20;
  display: none; flex-direction: column;
  background: rgba(3, 12, 22, .96);
  backdrop-filter: blur(11px);
  padding: calc(12px + var(--seguro-t)) calc(12px + var(--seguro-r)) calc(12px + var(--seguro-b)) calc(12px + var(--seguro-l));
}
.panel.visivel { display: flex; animation: abrePainel .2s ease; }
@keyframes abrePainel { from { opacity: 0; transform: scale(.985); } }
.panelHead { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.panelHead h2 { margin: 0; font-size: 19px; letter-spacing: .05em; flex: 1; }
.lojaMoedas { font-weight: 700; color: var(--ouro); font-size: 15px; }
.fecharX {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  background: rgba(255, 255, 255, .08); border: 1px solid var(--painelBorda);
  color: var(--texto); font-size: 17px; cursor: pointer;
}
.fecharX:hover { background: rgba(255, 90, 90, .22); }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.aba {
  background: rgba(255, 255, 255, .05); border: 1px solid transparent; color: var(--textoFraco);
  border-radius: 999px; padding: 9px 15px; font-size: 13px; cursor: pointer;
  white-space: nowrap; min-height: 40px;
}
.aba.ativa { background: rgba(74, 146, 196, .26); border-color: var(--azul); color: var(--texto); }
.lojaSep { width: 1px; background: var(--painelBorda); margin: 4px 6px; flex: none; }

.painelCorpo { display: flex; gap: 14px; flex: 1; min-height: 0; }
.invGrid { flex: 1; overflow-y: auto; display: grid; gap: 9px; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); align-content: start; padding: 3px; }
.invDetails {
  width: min(42vw, 330px); overflow-y: auto; flex: none;
  background: rgba(255, 255, 255, .04); border: 1px solid var(--painelBorda);
  border-radius: 13px; padding: 14px;
}

.cartao {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid color-mix(in srgb, var(--rar, #9ca3af) 48%, transparent);
  border-radius: 12px; padding: 12px 8px 10px; cursor: pointer; color: var(--texto);
  min-height: 106px; text-align: center; transition: transform .12s, border-color .2s, background .2s;
}
.cartao:hover { background: rgba(255, 255, 255, .09); transform: translateY(-2px); }
.cartao:active { transform: scale(.97); }
.cartao.marcado { border-color: var(--ouro); background: rgba(255, 209, 102, .12); }
.cartao.bloqueado { opacity: .5; }
.cartao.desconhecido { border-style: dashed; border-color: rgba(150, 175, 195, .3); color: var(--textoFraco); cursor: default; }
.cartaoIcone { font-size: 27px; line-height: 1; }
.cartaoNome { font-size: 11.5px; font-weight: 600; line-height: 1.25; }
.cartaoRar { font-size: 9.5px; letter-spacing: .1em; color: var(--rar, #9ca3af); text-transform: uppercase; }
.cartaoFonte { font-size: 9px; color: var(--textoFraco); }
.cartaoQtd { position: absolute; top: 5px; right: 7px; font-size: 10px; font-weight: 700; background: rgba(0, 0, 0, .55); border-radius: 6px; padding: 1px 5px; }
.cartaoFav { position: absolute; top: 5px; left: 7px; font-size: 12px; color: var(--ouro); }
.cartaoPreco { font-size: 12px; font-weight: 700; color: var(--ouro); margin-top: 3px; }
.cartaoBloqueio { font-size: 9px; color: #ff8a8a; letter-spacing: .06em; }
.cartaoEquipado { position: absolute; bottom: 4px; font-size: 8px; letter-spacing: .1em; color: var(--ouro); }
/* Raridade alta ganha um brilho contínuo: dá para bater o olho e reconhecer. */
.cartao.rar-legendary, .cartao.rar-mythic, .cartao.rar-ancient, .cartao.rar-secret {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--rar) 35%, transparent), 0 0 20px color-mix(in srgb, var(--rar) 28%, transparent);
}

.detCabeca { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.detIcone { font-size: 36px; }
.detCabeca h4 { margin: 0; font-size: 16px; }
.detRar { font-size: 10.5px; letter-spacing: .1em; color: var(--rar, #9ca3af); text-transform: uppercase; }
.detDesc { font-size: 13px; color: var(--textoFraco); line-height: 1.45; margin: 0 0 10px; }
.detPassivo { font-size: 12.5px; color: #8fd8ff; background: rgba(74, 146, 196, .12); border-left: 2px solid var(--azul); padding: 7px 10px; border-radius: 0 8px 8px 0; margin: 0 0 10px; }
.detStatus { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 4px; }
.detStatus li { display: flex; justify-content: space-between; font-size: 12.5px; padding: 4px 0; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.detStatus span { color: var(--textoFraco); }
.detAviso { font-size: 12px; color: #ff9a6a; }
.comparacao { background: rgba(255, 255, 255, .04); border-radius: 9px; padding: 9px 11px; margin-bottom: 12px; }
.comparacao h5 { margin: 0 0 6px; font-size: 10.5px; letter-spacing: .08em; color: var(--textoFraco); text-transform: uppercase; }
.comparacao ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.comparacao li { font-size: 12px; }
.comparacao .sobe { color: #8ef27a; }
.comparacao .desce { color: #ff8a8a; }
.detAcoes { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.detFonte { font-size: 10.5px; color: var(--textoFraco); opacity: .75; margin: 0; }

.botao {
  background: rgba(255, 255, 255, .08); border: 1px solid var(--painelBorda); color: var(--texto);
  border-radius: 9px; padding: 10px 15px; font-size: 13px; cursor: pointer; min-height: 44px;
}
.botao:hover:not(:disabled) { background: rgba(255, 255, 255, .14); }
.botao:disabled { opacity: .4; cursor: not-allowed; }
.botao.primario { background: linear-gradient(180deg, #4a92c4, #2f6f9e); border-color: #6fb6dd; font-weight: 700; }
.botao.perigo { border-color: rgba(255, 120, 120, .4); color: #ff9a9a; }
.botao.fantasma { background: transparent; }
.vazio { color: var(--textoFraco); font-size: 13px; padding: 22px; text-align: center; }

/* ------------------------------------------------------------ atributos */
.attrList { overflow-y: auto; max-width: 620px; width: 100%; margin: 0 auto; }
.atrTopo { display: flex; gap: 12px; margin-bottom: 16px; }
.atrTopo div { flex: 1; background: rgba(255, 255, 255, .05); border-radius: 11px; padding: 11px; text-align: center; }
.atrTopo span { display: block; font-size: 10px; letter-spacing: .1em; color: var(--textoFraco); text-transform: uppercase; }
.atrTopo b { display: block; font-size: 23px; margin-top: 3px; }
.atrTopo b.destaque { color: var(--ouro); }
.atrLinha {
  display: flex; align-items: center; gap: 12px; padding: 13px;
  background: rgba(255, 255, 255, .04); border: 1px solid var(--painelBorda);
  border-radius: 13px; margin-bottom: 9px;
}
.atrIcone { font-size: 25px; width: 34px; text-align: center; }
.atrTexto { flex: 1; min-width: 0; }
.atrTexto b { display: block; font-size: 13.5px; letter-spacing: .1em; }
.atrTexto span { display: block; font-size: 12px; color: var(--textoFraco); }
.atrTexto small { display: block; font-size: 10.5px; color: #8fd8ff; opacity: .85; margin-top: 3px; }
.atrValor { font-size: 22px; font-weight: 700; min-width: 34px; text-align: center; }
.atrMais {
  width: 46px; height: 46px; border-radius: 50%; flex: none;
  background: linear-gradient(180deg, #4a92c4, #2f6f9e); border: 1px solid #6fb6dd;
  color: #fff; font-size: 22px; cursor: pointer;
}
.atrMais:disabled { opacity: .3; cursor: not-allowed; }
.atrDica { font-size: 12px; color: var(--textoFraco); text-align: center; margin-top: 14px; }

/* ----------------------------------------------------------------- loja */
.lojaSaudacao { font-size: 13px; color: var(--ouro); font-style: italic; margin: 0 0 12px; grid-column: 1 / -1; }
.lojaTrilho { grid-column: 1 / -1; margin-bottom: 16px; }
.lojaTrilho header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.lojaTrilho h5 { margin: 0; font-size: 11px; letter-spacing: .16em; color: #8fd8ff; text-transform: uppercase; }
.lojaRelogio { font-size: 11px; color: var(--textoFraco); font-variant-numeric: tabular-nums; }
.lojaItens { display: grid; gap: 9px; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }

/* -------------------------------------------------------------- coleção */
.colecaoCorpo { flex: 1; overflow-y: auto; }
.colProgresso { font-size: 13px; color: var(--ouro); margin: 0 0 12px; }
.colGrade { display: grid; gap: 9px; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }

/* ---------------------------------------------------------------- ajuda */
.ajudaCorpo { overflow-y: auto; max-width: 620px; width: 100%; margin: 0 auto; }
.ajudaCorpo section { margin-bottom: 20px; }
.ajudaCorpo h4 { margin: 0 0 9px; font-size: 11px; letter-spacing: .16em; color: #8fd8ff; text-transform: uppercase; }
.listaTeclas { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.listaTeclas li { font-size: 13px; color: var(--textoFraco); }
.listaTeclas b { color: var(--texto); background: rgba(255, 255, 255, .08); border-radius: 5px; padding: 2px 7px; margin-right: 6px; font-size: 12px; }
.ajuste { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.ajuste label { font-size: 13.5px; }
.ajustePesado label { display: flex; align-items: center; flex: 1; min-height: 44px; cursor: pointer; }
.ajustePesado input { flex: none; }
.ajuste select, .ajuste input[type="range"] { min-height: 40px; }
.ajuste select { background: rgba(255, 255, 255, .08); border: 1px solid var(--painelBorda); color: var(--texto); border-radius: 8px; padding: 8px 11px; }
.ajuste input[type="checkbox"] { width: 26px; height: 26px; accent-color: var(--azul); }
.ajuste input[type="range"] { width: 148px; accent-color: var(--azul); }
.ajudaNota { font-size: 11.5px; color: var(--textoFraco); margin: 10px 0 0; }

/* ------------------------------------------------------ toque (celular) */
#mobileControls { position: absolute; inset: 0; z-index: 7; pointer-events: none; display: none; }
#joystickBase {
  position: absolute; left: calc(22px + var(--seguro-l)); bottom: calc(28px + var(--seguro-b));
  width: 132px; height: 132px; border-radius: 50%; pointer-events: auto;
  background: radial-gradient(circle, rgba(140, 200, 230, .13), rgba(6, 22, 36, .5));
  border: 2px solid rgba(140, 200, 230, .28);
  display: grid; place-items: center; touch-action: none;
}
#joystickBase.ativo { border-color: rgba(140, 200, 230, .6); }
#joystickDot {
  width: 54px; height: 54px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #9fd8f2, #3f7d9c);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .5); transition: transform .05s linear;
}
#botoesToque {
  position: absolute; right: calc(18px + var(--seguro-r)); bottom: calc(22px + var(--seguro-b));
  display: grid; gap: 9px; pointer-events: none;
  grid-template-columns: repeat(3, auto); justify-items: center; align-items: end;
}
#botoesToqueEsq {
  position: absolute; left: calc(22px + var(--seguro-l)); bottom: calc(176px + var(--seguro-b));
  display: flex; gap: 9px; pointer-events: auto;
}
.botaoToque {
  border-radius: 50%; border: 2px solid rgba(140, 200, 230, .32);
  background: rgba(8, 28, 44, .72); color: var(--texto);
  display: grid; place-items: center; cursor: pointer; touch-action: none; pointer-events: auto;
  font-size: 17px; font-weight: 700; user-select: none;
  transition: transform .08s, background .12s;
}
.botaoToque.grande { width: 84px; height: 84px; font-size: 30px; grid-column: 3; grid-row: 3; background: rgba(74, 146, 196, .34); }
.botaoToque.pesado {
  width: 62px; height: 62px; grid-column: 3; grid-row: 2;
  border-color: rgba(255, 209, 102, .6); background: rgba(116, 78, 24, .74);
  color: #ffe7ad; font-size: 12px; padding: 0;
}
.botaoToque:focus-visible { outline: 3px solid var(--texto); outline-offset: 3px; }
.botaoToque.medio { width: 62px; height: 62px; font-size: 22px; grid-column: 2; grid-row: 2; }
.botaoToque.pequeno { width: 52px; height: 52px; }
/* Pulo colado ao ataque, na altura do polegar; alvo logo ao lado. */
.botaoToque.pulo { grid-column: 2; grid-row: 3; background: rgba(83, 241, 222, .16); border-color: rgba(83, 241, 222, .45); }
.botaoToque.alvo { grid-column: 1; grid-row: 3; color: #53f1de; }
.botaoToque.ult { border-color: rgba(255, 164, 92, .5); color: #ffa45c; }
.botaoToque.pressionado { transform: scale(.9); background: rgba(140, 200, 230, .4); }
#mobileActionHint {
  left: 50%; bottom: calc(178px + var(--seguro-b)); transform: translateX(-50%);
  font-size: 11px; color: var(--textoFraco); opacity: 0; transition: opacity .4s;
}

/* Separa os atalhos do menu inferior no desktop, mantendo as bordas seguras. */
@media (pointer: fine) {
  #skillDock { bottom: calc(66px + var(--seguro-b)); }
}

/* Só mostra o toque onde há toque de verdade. */
@media (pointer: coarse) {
  #mobileControls { display: block; }
  #skillDock { display: none; }
  /* No celular os botões de menu sobem para o topo: embaixo eles disputavam
     espaço com o direcional e com os botões de ação, e se sobrepunham. */
  /* 84 px: em pé as fichas de moeda quebram em duas linhas e a caixa delas
     chegava a 80 px (capturas da Fase 1 da v2). */
  #barraBotoes {
    top: calc(84px + var(--seguro-t)); bottom: auto;
    left: calc(10px + var(--seguro-l)); max-width: 60vw;
    gap: 6px;
  }
  .pillButton span { display: none; }
  .pillButton { padding: 0; width: 44px; height: 44px; justify-content: center; font-size: 17px; }
  #toastWrap { bottom: calc(232px + var(--seguro-b)); }
  #dialogBox { bottom: calc(226px + var(--seguro-b)); }
  .invDetails { width: min(50vw, 300px); }
  #hudLugar b { display: none; }      /* o título não cabe e não ajuda em jogo */
  #hudLugar { flex: 0 1 auto; }
  #questTracker {
    top: calc(136px + var(--seguro-t)); width: min(58vw, 214px);
    padding: 8px 10px; font-size: 12px;
  }
  .questItem b { font-size: 13px; }
  .questItem span { font-size: 11px; }
}

/* Celular em pé: o direcional e a grade de ação disputavam a mesma faixa
   (Defesa e Alvo entravam no direcional; o Inventário cobria o "3" — capturas
   da Fase 1 da v2). Botões um pouco menores e o grupo da esquerda empilhado
   acima do direcional. */
@media (pointer: coarse) and (max-width: 480px) {
  #joystickBase { width: 116px; height: 116px; left: calc(14px + var(--seguro-l)); }
  #botoesToque { right: calc(12px + var(--seguro-r)); gap: 6px; }
  .botaoToque.grande { width: 70px; height: 70px; font-size: 26px; }
  .botaoToque.medio { width: 54px; height: 54px; font-size: 20px; }
  .botaoToque.pesado { width: 54px; height: 54px; }
  .botaoToque.pequeno { width: 46px; height: 46px; font-size: 15px; }
  #botoesToqueEsq { flex-direction: column; left: calc(14px + var(--seguro-l)); bottom: calc(156px + var(--seguro-b)); gap: 6px; }
}

/* Em 320 px o pesado continua com 54 px e ha espaco entre os dois polegares. */
@media (pointer: coarse) and (max-width: 360px) {
  #joystickBase { width: 108px; height: 108px; }
  .botaoToque.grande { width: 64px; height: 64px; }
}

/* Retrato estreito: os detalhes vão para baixo em vez de espremer a grade. */
@media (max-width: 720px) {
  #hudBarras { width: 46vw; }
  #questTracker { width: min(52vw, 230px); font-size: 12px; }
  .painelCorpo { flex-direction: column; }
  .invDetails { width: 100%; max-height: 42vh; }
  .invGrid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .colGrade, .lojaItens { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  #hudLugar b { font-size: 10px; }
  #hudLugar span { font-size: 11px; }
}

/* Paisagem baixa (celular deitado): o essencial é ver o chão. */
@media (max-height: 460px) {
  #questTracker { display: none; }
  /* Em 58 px os botões de menu cobriam a linha de XP (celular deitado). */
  #barraBotoes { top: calc(76px + var(--seguro-t)); }
  #joystickBase { width: 108px; height: 108px; }
  .botaoToque.grande { width: 68px; height: 68px; font-size: 25px; }
  .botaoToque.medio { width: 52px; height: 52px; font-size: 19px; }
  .botaoToque.pesado { width: 54px; height: 54px; }
  .botaoToque.pequeno { width: 44px; height: 44px; font-size: 15px; }
  #botoesToque { gap: 7px; bottom: calc(12px + var(--seguro-b)); }
}

/* --------------------------------------------------- reações da tela */
body.levouDano #gameShell::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 8;
  box-shadow: inset 0 0 130px rgba(255, 60, 60, .55);
  animation: piscaDano .22s ease-out;
}
@keyframes piscaDano { to { opacity: 0; } }
body.subiuNivel #gameShell::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 8;
  box-shadow: inset 0 0 160px rgba(255, 209, 102, .5);
  animation: piscaNivel .9s ease-out;
}
@keyframes piscaNivel { to { opacity: 0; } }
body.painelAberto #skillDock, body.painelAberto #mobileControls, body.painelAberto #barraBotoes { opacity: 0; pointer-events: none; }

/* ------------------------------------- painel de desenvolvimento (F3) */
#devHud {
  position: absolute; z-index: 40; pointer-events: none;
  top: calc(96px + var(--seguro-t)); left: calc(10px + var(--seguro-l));
  margin: 0; padding: 8px 11px; max-width: min(94vw, 600px);
  font: 11px/1.45 ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  white-space: pre; overflow: hidden;
  color: #d8f3f7; background: rgba(4, 18, 30, .86);
  border: 1px solid rgba(83, 241, 222, .4); border-left: 3px solid #53f1de; border-radius: 8px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .8);
}
#devHud[hidden] { display: none; }
#devHud.alerta { border-color: rgba(255, 211, 106, .6); border-left-color: #ffd36a; }
#devHud.critico { border-color: rgba(255, 102, 95, .7); border-left-color: #ff665f; }
@media (pointer: coarse) { #devHud { top: calc(180px + var(--seguro-t)); font-size: 10px; } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .05ms !important; }
}
