:root {
  --fundo: #0d111a; --painel: #161d2b; --painel2: #1f2839; --linha: #2e3b54; --texto: #eaf0fb; --fraco: #93a1bb;
  --ambar: #ffb627; --ambar-esc: #a86d05; --ciano: #4cc9f0; --verde: #58d68d; --vermelho: #ef5350;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--fundo); color: var(--texto); font: 500 14px/1.4 system-ui, "Segoe UI", Roboto, sans-serif;
  display: grid; grid-template: auto 1fr auto / 1fr 320px; grid-template-areas: "topo topo" "palco equipe" "barra equipe";
  overflow: hidden; -webkit-tap-highlight-color: transparent; user-select: none; }
b { font-weight: 700; }
small { font-size: 12px; color: var(--fraco); }
p { margin: 0 0 10px; }
.fraco { color: var(--fraco); }
.centro { text-align: center; }

/* ---------- topo ---------- */
#topo { grid-area: topo; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--painel); border-bottom: 1px solid var(--linha); }
.marca { font-size: 17px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; white-space: nowrap; }
.marca span { color: var(--ambar); }
.placar { margin-left: auto; display: flex; gap: 10px; align-items: stretch; }
.cx { background: var(--painel2); border: 1px solid var(--linha); border-radius: 10px; padding: 6px 12px; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.cx .rot { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--fraco); }
.cx .val { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cx.moedas .val { color: var(--ambar); font-size: 19px; }
.cx small { white-space: nowrap; }
.moeda { width: 20px; height: 20px; object-fit: contain; display: inline-block; vertical-align: -4px; flex: none; }
i.moeda { background: var(--ambar); border-radius: 50%; border: 2px solid var(--ambar-esc); }
.btn .moeda { width: 16px; height: 16px; vertical-align: -3px; }

/* ---------- palco ---------- */
#palco { grid-area: palco; min-height: 0; min-width: 0; display: flex; align-items: center; justify-content: center; padding: 14px; position: relative; }
#tela { max-width: 100%; max-height: 100%; aspect-ratio: 17 / 11; border-radius: 10px; background: #0a0d14; box-shadow: 0 0 0 1px var(--linha), 0 12px 40px rgba(0, 0, 0, .5); }
#aviso { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(13, 17, 26, .94); border: 1px solid var(--ambar);
  border-radius: 12px; padding: 14px 24px; font-size: 20px; font-weight: 700; text-align: center; pointer-events: none; }
#aviso small { display: block; font-size: 13px; font-weight: 500; margin-top: 4px; }

/* ---------- barra de ações ---------- */
#barra { grid-area: barra; display: flex; gap: 8px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: var(--painel); border-top: 1px solid var(--linha); justify-content: center; }
.btn { font: inherit; font-weight: 600; color: var(--texto); background: var(--painel2); border: 1px solid var(--linha); border-radius: 9px; padding: 9px 16px; cursor: pointer; transition: filter .12s, transform .06s; white-space: nowrap; }
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--ciano); outline-offset: 2px; }
.btn.ambar { background: var(--ambar); border-color: var(--ambar-esc); color: #2a1a00; }
.btn.verde { background: var(--verde); border-color: #2c8a55; color: #06240f; }
.btn.claro { background: var(--ciano); border-color: #2386a8; color: #04222c; }
.btn.vermelho { background: var(--vermelho); border-color: #9c2a28; color: #fff; }
.btn.fantasma { background: transparent; color: var(--fraco); }
.btn:disabled { opacity: .4; cursor: default; filter: none; }
.btn.mini { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn.principal { padding: 9px 22px; }
.btn.principal small { color: inherit; opacity: .8; margin-left: 6px; font-weight: 700; }

/* ---------- equipe ---------- */
#equipe { grid-area: equipe; background: var(--painel); border-left: 1px solid var(--linha); display: flex; flex-direction: column; min-height: 0; }
#equipe h2 { margin: 0; padding: 12px 14px 8px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--fraco); font-weight: 700; }
#equipeLista { flex: 1; overflow-y: auto; padding: 0 10px 10px; display: flex; flex-direction: column; gap: 6px; scrollbar-width: thin; scrollbar-color: var(--linha) transparent; }
.vazio { color: var(--fraco); padding: 8px 4px; }
.membro { display: flex; align-items: center; gap: 8px; background: var(--painel2); border: 1px solid var(--linha); border-left: 3px solid var(--rar); border-radius: 8px; padding: 6px 8px; }
.membro.dorme { background: transparent; }
.membro.dorme img { opacity: .55; }
.membro img, .membro .sem-arte { width: 34px; height: 34px; object-fit: contain; flex: none; }
.sem-arte { border-radius: 50%; background: var(--rar); display: inline-block; }
.m-info { flex: 1; min-width: 0; }
.m-info b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-info small { display: block; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.barra { height: 5px; background: rgba(0, 0, 0, .45); border-radius: 3px; overflow: hidden; margin: 3px 0 2px; }
.barra i { display: block; height: 100%; width: 0; background: var(--verde); border-radius: 3px; }
.dorme .barra i { background: var(--ciano); }

/* ---------- avisos ---------- */
#toasts { position: fixed; top: 76px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; z-index: 30; }
.toast { background: var(--painel2); border: 1px solid var(--ambar); border-radius: 10px; padding: 8px 14px; display: flex; align-items: center; gap: 10px; animation: sobe .25s ease-out; max-width: 92vw; box-shadow: 0 6px 20px rgba(0, 0, 0, .45); }
.toast img { width: 36px; height: 36px; object-fit: contain; }
@keyframes sobe { from { opacity: 0; transform: translateY(8px); } }

/* ---------- janela ---------- */
#modalFundo { position: fixed; inset: 0; background: rgba(4, 6, 10, .7); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 14px; }
#modalFundo[hidden] { display: none; }
#modal { background: var(--painel); border: 1px solid var(--linha); border-radius: 14px; width: min(640px, 100%); max-height: 100%; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.modal-topo { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--linha); }
.modal-topo b { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }
#modalFechar { font: inherit; font-size: 13px; background: none; border: 0; color: var(--fraco); cursor: pointer; padding: 4px 6px; }
#modalFechar:hover { color: var(--texto); }
#modalCorpo { padding: 14px 16px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--linha) transparent; }

.resumo { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; flex-wrap: wrap; }
.lista-herois { display: flex; flex-direction: column; gap: 8px; }
.heroi { background: var(--painel2); border: 1px solid var(--linha); border-left: 4px solid var(--rar); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.heroi.fora { background: transparent; }
.h-topo { display: flex; gap: 12px; align-items: center; }
.h-topo img, .h-topo .sem-arte { width: 54px; height: 54px; object-fit: contain; flex: none; }
.h-nome { flex: 1; min-width: 0; }
.h-nome b { display: block; font-size: 15px; }
.h-nome span { color: var(--rar); font-size: 12px; font-weight: 600; }
.h-nome small { display: block; font-variant-numeric: tabular-nums; }
.atributos { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 6px; }
.atributos span { background: rgba(0, 0, 0, .25); border-radius: 7px; padding: 4px 8px; font-weight: 700; font-variant-numeric: tabular-nums; }
.atributos small { display: block; font-size: 10px; letter-spacing: .06em; text-transform: uppercase; font-weight: 500; }
.poderes { display: flex; flex-wrap: wrap; gap: 5px; }
.poderes span { border: 1px solid var(--ambar-esc); color: var(--ambar); border-radius: 6px; padding: 1px 8px; font-size: 12px; font-weight: 600; }
.poderes.completo { flex-direction: column; margin: 10px 0; }
.poderes.completo span { color: var(--texto); padding: 6px 10px; font-weight: 500; text-align: left; }
.poderes.completo b { color: var(--ambar); display: block; }
.acoes { display: flex; flex-wrap: wrap; gap: 6px; }
.acoes .fantasma { margin-left: auto; }

.novo-heroi { text-align: center; }
.novo-heroi img { width: 128px; height: 128px; object-fit: contain; }
.novo-heroi .rar { color: var(--rar); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; }
.novo-heroi h2 { margin: 2px 0 12px; font-size: 22px; }
.novo-heroi .atributos { text-align: left; margin-bottom: 10px; }
.grande { text-align: center; font-size: 28px; font-weight: 800; margin: 12px 0; color: var(--ambar); font-variant-numeric: tabular-nums; }
.grande .moeda { width: 28px; height: 28px; vertical-align: -5px; }

.grade-mapas { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.mapa { background: var(--painel2); border: 1px solid var(--linha); border-radius: 10px; padding: 8px; }
.mapa.atual { border-color: var(--ambar); }
.mapa canvas { width: 100%; height: auto; border-radius: 6px; display: block; margin-bottom: 6px; }
.mapa b { display: block; font-size: 13px; }
.mapa.atual small { color: var(--ambar); }

/* ---------- telas estreitas: a equipe vira uma faixa rolável embaixo do mapa ---------- */
@media (max-width: 900px) {
  body { grid-template: auto 1fr auto auto / 1fr; grid-template-areas: "topo" "palco" "equipe" "barra"; }
  #palco { padding: 8px; }
  #equipe { border-left: 0; border-top: 1px solid var(--linha); }
  #equipe h2 { padding: 8px 12px 4px; }
  #equipeLista { flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 0 8px 8px; }
  .membro { flex: 0 0 230px; }
  .marca { font-size: 14px; }
  .cx.blocos { display: none; }
}
@media (max-width: 560px) {
  #topo { padding: 8px 10px; gap: 8px; }
  .marca { display: none; }
  .placar { margin-left: 0; flex: 1; }
  .cx { flex: 1; padding: 5px 8px; }
  .btn { padding: 9px 12px; }
  #barra { gap: 6px; }
}

/* ---------- loja de baús ---------- */
.baus { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.bau { background: var(--painel2); border: 1px solid var(--linha); border-radius: 12px; padding: 12px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.bau:nth-child(3) { border-color: var(--ambar-esc); }
.bau img { width: 100%; max-width: 170px; aspect-ratio: 1; object-fit: contain; }
.bau-sem-arte { width: 110px; height: 110px; border-radius: 14px; background: rgba(0, 0, 0, .3); display: grid; place-items: center; font-size: 44px; font-weight: 800; color: var(--ambar); }
.bau b { font-size: 15px; margin-top: 6px; }
.bau span { font-weight: 700; color: var(--ambar); }
.bau small { min-height: 34px; }
.bau .btn { width: 100%; margin-top: 6px; }
.revelar { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin-bottom: 14px; }
.revelar.um { grid-template-columns: minmax(0, 220px); justify-content: center; }
.carta { background: var(--painel2); border: 1px solid var(--linha); border-top: 3px solid var(--rar); border-radius: 10px; padding: 8px 6px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 2px; animation: carta .35s ease-out backwards; }
.carta img, .carta .sem-arte { width: 64px; height: 64px; object-fit: contain; }
.revelar.um .carta img { width: 128px; height: 128px; }
.carta .rar { color: var(--rar); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; }
.carta b { font-size: 13px; }
.carta .poderes { justify-content: center; }
.carta .poderes span { font-size: 10px; padding: 0 5px; }
@keyframes carta { from { opacity: 0; transform: translateY(14px) scale(.9); } }
@media (max-width: 560px) { .baus { grid-template-columns: 1fr; } .bau img { max-width: 120px; } .bau small { min-height: 0; } }
@media (prefers-reduced-motion: reduce) { .carta, .toast { animation: none; } }

/* ---------- conta e ranking ---------- */
.form-conta { display: flex; flex-direction: column; gap: 8px; max-width: 340px; margin: 0 auto 6px; }
.campo { font: inherit; color: var(--texto); background: rgba(0, 0, 0, .3); border: 1px solid var(--linha); border-radius: 8px; padding: 9px 12px; user-select: text; }
.campo:focus { outline: 2px solid var(--ciano); outline-offset: 1px; }
.form-conta .acoes { justify-content: center; }
.sub { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--fraco); margin: 18px 0 8px; }
.linha-rank { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; }
.linha-rank:nth-child(odd) { background: var(--painel2); }
.linha-rank.eu { outline: 1px solid var(--ambar); }
.linha-rank b { width: 30px; }
.linha-rank span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.linha-rank .num { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ambar); }
#btnConta { max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
