:root {
  --fundo: #141a26; --painel: rgba(14, 18, 28, .82); --borda: rgba(255, 255, 255, .12);
  --texto: #eef2f8; --suave: #9fb0c6; --ouro: #ffd36a; --vida: #e5484d; --xp: #6ab8ff; --ok: #5fd38d;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--fundo); color: var(--texto);
  font: 14px/1.4 "Segoe UI", system-ui, sans-serif; touch-action: none; user-select: none; -webkit-user-select: none; }
canvas { display: block; }
[hidden] { display: none !important; }
#rotulos, #numeros { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }

/* ---------- entrada ---------- */
.tela { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(circle at 50% 20%, rgba(60, 90, 150, .55), rgba(10, 14, 22, .92)); z-index: 10; overflow: auto; }
.caixa { width: min(980px, 100%); background: var(--painel); border: 1px solid var(--borda); border-radius: 18px; padding: 24px; text-align: center; }
h1 { margin: 0; font-size: clamp(28px, 5vw, 44px); letter-spacing: .5px; color: #ffe7a8; text-shadow: 0 3px 0 #6a3d10, 0 0 24px rgba(255, 200, 90, .35); }
.sub { margin: 4px 0 16px; color: var(--suave); }
.nome { display: inline-flex; flex-direction: column; gap: 6px; text-align: left; color: var(--suave); }
.nome input, #chatTexto { background: rgba(0, 0, 0, .35); border: 1px solid var(--borda); color: var(--texto); border-radius: 10px; padding: 10px 12px; font-size: 16px; }
#classes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 18px 0; }
.classe { background: rgba(255, 255, 255, .04); border: 2px solid transparent; border-radius: 14px; padding: 10px; cursor: pointer; text-align: left; color: var(--texto); font: inherit; }
.classe:hover { background: rgba(255, 255, 255, .08); }
.classe.sel { border-color: var(--ouro); background: rgba(255, 211, 106, .1); }
.classe .img { height: 170px; border-radius: 10px; background: #fff center/contain no-repeat; }
.classe b { display: block; margin-top: 8px; font-size: 16px; }
.classe .papel { color: var(--ouro); font-size: 12px; }
.classe p { margin: 4px 0 0; color: var(--suave); font-size: 12px; }
.botao { background: linear-gradient(#ffd36a, #e0a030); color: #2a1a05; font-weight: 700; border: 0; border-radius: 12px; padding: 12px 28px; font-size: 16px; cursor: pointer; }
.botao:disabled { opacity: .5; }
.erro { color: #ff8a8a; min-height: 1em; }
.dica { color: var(--suave); font-size: 12px; }
@media (max-width: 760px) { #classes { grid-template-columns: repeat(2, 1fr); } .classe .img { height: 110px; } }

/* ---------- hud ---------- */
#hud > * { position: fixed; }
#ficha { left: 12px; top: 12px; display: flex; gap: 10px; background: var(--painel); border: 1px solid var(--borda); border-radius: 14px; padding: 8px 12px 8px 8px; width: 290px; }
#retrato { width: 58px; height: 58px; border-radius: 10px; object-fit: cover; object-position: 50% 8%; background: #fff; }
.dados { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.nivel { color: var(--ouro); font-size: 12px; }
.barra { position: relative; height: 12px; background: rgba(255, 255, 255, .1); border-radius: 6px; overflow: hidden; }
.barra i { position: absolute; inset: 0 auto 0 0; width: 100%; transition: width .15s; }
.barra.vida i { background: linear-gradient(#ff6b6b, #c22f35); }
.barra.xp { height: 6px; } .barra.xp i { background: var(--xp); }
.barra span { position: absolute; inset: 0; font-size: 10px; text-align: center; line-height: 12px; }
.ouro { font-size: 12px; color: var(--ouro); }
#local { top: 12px; left: 50%; transform: translateX(-50%); text-align: center; text-shadow: 0 2px 4px #000; }
#btnSair { margin-top: 4px; background: var(--painel); color: var(--suave); border: 1px solid var(--borda); border-radius: 8px; padding: 3px 10px; font-size: 11px; cursor: pointer; pointer-events: auto; }
#lNome { font-weight: 700; font-size: 18px; } #lZona { color: var(--suave); font-size: 12px; }
#chefeBarra { top: 92px; left: 50%; transform: translateX(-50%); width: min(560px, 80vw); text-align: center; }
#chefeNome { font-weight: 700; color: #ffb0a0; text-shadow: 0 2px 4px #000; }
.barra.chefe { height: 14px; border: 1px solid rgba(0, 0, 0, .5); } .barra.chefe i { background: linear-gradient(#ff8a3a, #b8261a); }
#habilidades { right: 12px; bottom: 12px; display: flex; gap: 8px; }
.hab { position: relative; width: 74px; height: 64px; background: var(--painel); border: 1px solid var(--borda); border-radius: 12px; overflow: hidden; padding: 6px; font-size: 11px; text-align: center; }
.hab .tecla { display: block; font-weight: 700; color: var(--ouro); }
.hab .recarga { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(0, 0, 0, .6); }
#grupo { left: 12px; top: 92px; display: flex; flex-direction: column; gap: 4px; }
.membro { background: var(--painel); border-radius: 8px; padding: 4px 8px; width: 170px; font-size: 12px; }
.membro .barra { height: 5px; margin-top: 2px; }
#chat { left: 12px; bottom: 12px; width: min(360px, 45vw); }
#chatLinhas { max-height: 140px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; font-size: 13px; text-shadow: 0 1px 2px #000; }
#chatLinhas div { padding: 1px 0; } #chatLinhas b { color: var(--ouro); } #chatLinhas .sis { color: #9fe0b0; }
#chatTexto { width: 100%; margin-top: 4px; padding: 6px 10px; font-size: 13px; opacity: .6; }
#chatTexto:focus { opacity: 1; outline: none; border-color: var(--ouro); }
#ajuda { bottom: 84px; right: 12px; color: var(--suave); font-size: 11px; text-shadow: 0 1px 2px #000; max-width: 360px; text-align: right; }
#faixa { top: 32%; left: 50%; transform: translate(-50%, -50%); font-size: clamp(28px, 6vw, 56px); font-weight: 800; color: #ffe7a8;
  text-shadow: 0 4px 0 #6a3d10, 0 0 30px rgba(255, 190, 80, .6); opacity: 0; transition: opacity .3s; text-align: center; pointer-events: none; }
#faixa.on { opacity: 1; } #faixa small { display: block; font-size: 16px; color: var(--texto); text-shadow: 0 2px 4px #000; font-weight: 600; }
#dicaPortal { left: 50%; bottom: 22%; transform: translateX(-50%); background: var(--painel); border: 1px solid var(--ouro); border-radius: 10px; padding: 8px 14px; }

/* energia dos especiais: 3 barras */
.energia { display: flex; gap: 3px; height: 7px; }
.energia i { flex: 1; background: rgba(255, 255, 255, .1); border-radius: 3px; overflow: hidden; position: relative; }
.energia i::after { content: ''; position: absolute; inset: 0 auto 0 0; width: var(--p, 0%); background: linear-gradient(#ffe27a, #e09a20); }
.energia i.cheia::after { box-shadow: 0 0 6px #ffd36a; }
/* medidor de carga sobre o heroi */
#carga { position: fixed; transform: translate(-50%, -100%); text-align: center; pointer-events: none; }
#carga .nomeEsp { font-weight: 800; font-size: 15px; color: #ffe7a8; text-shadow: 0 2px 3px #000; white-space: nowrap; min-height: 18px; }
#carga .pips { display: flex; gap: 4px; justify-content: center; margin-top: 3px; }
#carga .pips i { width: 30px; height: 9px; border-radius: 5px; background: rgba(0, 0, 0, .5); border: 1px solid rgba(255, 255, 255, .3); overflow: hidden; position: relative; }
#carga .pips i::after { content: ''; position: absolute; inset: 0 auto 0 0; width: var(--p, 0%); background: var(--c, #ffd36a); }
#carga .pips i.trancada { opacity: .25; }
/* mochila */
#btnMochila { right: 12px; top: 12px; width: 46px; height: 46px; border-radius: 12px; background: var(--painel); border: 1px solid var(--borda); font-size: 22px; cursor: pointer; }
#mochila { right: 12px; top: 66px; width: min(380px, calc(100vw - 24px)); max-height: calc(100vh - 90px); overflow: auto; background: var(--painel); border: 1px solid var(--borda); border-radius: 14px; padding: 10px 12px; z-index: 5; }
#mochila .topo { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
#mochila .topo button { background: none; border: 0; color: var(--texto); font-size: 18px; cursor: pointer; }
#mochila .sub { color: var(--suave); font-size: 11px; margin: 6px 0; }
#equipados { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
#equipados .lugar { background: rgba(255, 255, 255, .05); border-radius: 10px; padding: 6px; font-size: 11px; text-align: center; min-height: 52px; }
#equipados .lugar small { display: block; color: var(--suave); }
#itens { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.item { background: rgba(255, 255, 255, .05); border: 2px solid transparent; border-radius: 10px; padding: 6px 8px; text-align: left; color: var(--texto); font: inherit; font-size: 12px; cursor: pointer; }
.item.usando { border-color: var(--ouro); background: rgba(255, 211, 106, .1); }
.item small { display: block; color: var(--suave); font-size: 11px; }
.item:disabled { opacity: .4; cursor: default; }
#toque button.grande { position: relative; }
#toque button.grande::after { content: attr(data-barras); position: absolute; left: 0; right: 0; bottom: 6px; font-size: 13px; color: #ffe27a; text-shadow: 0 0 4px #000; }
body.toque #btnMochila { top: auto; bottom: 170px; right: 14px; }

/* rotulos sobre as cabecas */
.rotulo { position: absolute; transform: translate(-50%, -100%); text-align: center; font-size: 12px; font-weight: 600; text-shadow: 0 1px 3px #000; white-space: nowrap; }
.rotulo .barra { width: 60px; height: 5px; margin: 2px auto 0; }
.rotulo.inimigo .barra i { background: #ff5a4a; } .rotulo.aliado .barra i { background: var(--ok); }
.rotulo.portal { color: #bfe3ff; font-size: 14px; } .rotulo.portal small { display: block; color: var(--suave); font-weight: 400; }
.rotulo.portal.trancado { color: #8a95a6; }
.numero { position: absolute; font-weight: 800; font-size: 20px; color: #fff; text-shadow: 0 2px 0 #000, 0 0 6px #000; animation: sobe .9s ease-out forwards; transform: translate(-50%, 0); }
.numero.crit { color: var(--ouro); font-size: 26px; } .numero.meu { color: #ff6b6b; } .numero.xp { color: var(--xp); font-size: 15px; }
.numero.alerta { color: #ffdd44; font-size: 30px; } .numero.aviso { color: #c9d6e8; font-size: 14px; }
#faixa .esp { display: inline-block; animation: pulo .35s ease-out; }
#faixa .esp.n1 { color: #ffe7a8; } #faixa .esp.n2 { color: #a8e8ff; text-shadow: 0 4px 0 #10466a, 0 0 30px rgba(100, 200, 255, .7); }
#faixa .esp.n3 { color: #ffb0a0; font-size: 1.2em; text-shadow: 0 4px 0 #6a1010, 0 0 40px rgba(255, 120, 90, .9); }
@keyframes pulo { from { transform: scale(1.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes sobe { to { transform: translate(-50%, -60px); opacity: 0; } }

/* ---------- toque ---------- */
#toque { display: none; }
#toque.ativo { display: block; }
#toque .lado { position: fixed; bottom: max(14px, env(safe-area-inset-bottom)); display: flex; gap: 10px; align-items: flex-end; }
#toque .esq { left: max(14px, env(safe-area-inset-left)); }
#toque .dir { right: max(14px, env(safe-area-inset-right)); flex-wrap: wrap; width: 250px; justify-content: flex-end; }
#toque button { width: 64px; height: 64px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35); background: rgba(20, 26, 38, .55); color: #fff; font-size: 24px; touch-action: none; }
#toque button.peq { width: 50px; height: 50px; font-size: 17px; }
#toque button.grande { width: 84px; height: 84px; font-size: 32px; background: rgba(200, 120, 40, .55); }
#toque button.apertado { background: rgba(255, 211, 106, .55); }
body.toque #habilidades, body.toque #ajuda, body.toque #chatTexto { display: none; }
body.toque #chat { bottom: auto; top: 90px; right: 12px; left: auto; width: 240px; pointer-events: none; }
body.toque #ficha { transform: scale(.8); transform-origin: top left; }
body.toque #toque button.recarregando { opacity: .4; }
