/* ============================================================
   TrayMon Web — style.css
   Contrato visual do GDD §5: paleta, bevel 3D retro, pixel-art
   ============================================================ */

@font-face {
  font-family: "Pixeloid Sans";
  src: url("../data/fonts/PixeloidSans.ttf") format("truetype");
  font-display: swap;
}

:root {
  --bg-outer: #030d08;
  --bg-main: #0a1f14;
  --painel: #0d2b1d;
  --card: #0a2e16;
  --inset: #051a0b;
  --verde-1: #2d6a4f;
  --verde-2: #3ba144;
  --verde-3: #4ade80;
  --ouro: #facc15;
  --ouro-2: #ca8a04;
  --vermelho: #b91c1c;
  --vermelho-2: #dc2626;
  --azul: #2563eb;
  --roxo: #8e44ad;
  --muted: #86efac;
  --muted-2: #6b9a78;
  --neon: #5cffb0;
  --falha: #fb923c;
  --spr: 148px;
  --fonte: "Pixeloid Sans", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }
img, canvas { image-rendering: pixelated; }

html, body {
  height: 100%;
  background: var(--bg-outer);
  font-family: var(--fonte);
  color: #e7f5ea;
  overflow: hidden;
}

#app {
  position: relative;
  width: min(100vw, 1100px);
  height: min(100vh, 620px);
  margin: auto;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-main);
  overflow: hidden;
}
#app.compacta { width: min(100vw, 360px); }

/* moldura .frame: anéis pretos + verde */
.frame {
  border: 3px solid #000;
  outline: 2px solid var(--verde-2);
  outline-offset: -6px;
  box-shadow: inset 0 0 0 3px #000, 0 0 0 2px #000;
}

/* ---------- telas ---------- */
.tela { position: absolute; inset: 0; display: none; flex-direction: column; }
.tela.ativa { display: flex; }

/* ---------- botões bevel ---------- */
.btn3d {
  font-family: var(--fonte);
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #eafff0;
  background: var(--verde-1);
  border: 2px solid #000;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,.28), inset -2px -2px 0 rgba(0,0,0,.5);
  padding: 8px 14px;
  cursor: pointer;
}
.btn3d:hover { filter: brightness(1.15); }
.btn3d:active { box-shadow: inset -2px -2px 0 rgba(255,255,255,.2), inset 2px 2px 0 rgba(0,0,0,.5); transform: translateY(1px); }
.btn3d:focus-visible { outline: 2px solid var(--ouro); outline-offset: 2px; }
.btn3d:disabled { filter: grayscale(.7) brightness(.7); cursor: not-allowed; }
.btn3d.ouro { background: var(--ouro-2); color: #1b1400; }
.btn3d.perigo { background: var(--vermelho); }
.btn3d.azul { background: var(--azul); }
.btn3d.mini { font-size: 10px; padding: 4px 8px; }

/* ---------- header/hud ---------- */
.header {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--painel);
  border-bottom: 2px solid #000;
}
.header .titulo { font-size: 14px; letter-spacing: 0.22em; color: var(--verde-3); }
.header .espaco { flex: 1; }
.hud-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--inset);
  border: 2px solid #000;
  padding: 3px 9px;
  font-size: 12px;
}
.hud-pill .ico { width: 14px; height: 14px; display: inline-block; }
.hud-moeda .ico { background: var(--ouro); border-radius: 50%; box-shadow: inset -2px -2px 0 var(--ouro-2); }
.hud-frag .ico { background: var(--neon); clip-path: polygon(50% 0, 100% 38%, 82% 100%, 18% 100%, 0 38%); }
.hud-ess .ico { background: var(--roxo); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.hud-moeda { color: var(--ouro); }
.hud-frag { color: var(--neon); }
.hud-ess { color: #c99ae0; }
.btn-fechar {
  background: var(--vermelho-2); color: #fff;
  border: 2px solid #000; width: 26px; height: 26px;
  font-family: var(--fonte); font-size: 13px; cursor: pointer;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,.3), inset -2px -2px 0 rgba(0,0,0,.5);
}

/* ---------- login ---------- */
.tela-login-corpo {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  gap: 14px; padding: 28px;
}
.logo-jogo { text-align: center; margin-bottom: 8px; }
.logo-jogo h1 {
  font-size: 30px; letter-spacing: 0.2em; color: var(--verde-3);
  text-shadow: 3px 3px 0 #000, 0 0 18px rgba(74,222,128,.35);
}
.logo-jogo p { font-size: 10px; color: var(--muted-2); letter-spacing: .3em; margin-top: 6px; }
.campo { display: flex; flex-direction: column; gap: 4px; }
.campo label { font-size: 10px; letter-spacing: .2em; color: var(--muted); }
.campo input {
  font-family: var(--fonte); font-size: 14px; color: #eafff0;
  background: var(--inset); border: 2px solid #000; padding: 9px 10px;
  box-shadow: inset 2px 2px 0 rgba(0,0,0,.6);
}
.campo input:focus { outline: 2px solid var(--verde-2); }
.msg-erro { color: var(--falha); font-size: 11px; min-height: 15px; }
.link-mini { background: none; border: none; color: var(--muted-2); font-family: var(--fonte); font-size: 10px; cursor: pointer; letter-spacing: .12em; }
.link-mini:hover { color: var(--verde-3); }

/* ---------- starter ---------- */
.starter-lista { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 18px; overflow-y: auto; }
.starter-card {
  display: flex; gap: 12px; align-items: center;
  background: var(--card); border: 2px solid #000; padding: 10px;
  cursor: pointer;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,.06);
}
.starter-card:hover, .starter-card.sel { outline: 2px solid var(--verde-3); }
.starter-card img { width: 64px; height: 64px; }
.starter-card h3 { font-size: 14px; color: var(--ouro); }
.starter-card p { font-size: 10px; color: var(--muted-2); margin-top: 4px; line-height: 1.5; }

/* ---------- lobby ---------- */
#lobby-mapa { position: absolute; inset: 0; }
#lobby-fundo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.distrito-hit {
  position: absolute;
  background: rgba(0,0,0,.28);
  border: 2px solid var(--verde-2);
  box-shadow: inset 2px 2px 0 rgba(255,255,255,.1), 0 4px 0 rgba(0,0,0,.5);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: #eafff0; font-family: var(--fonte); font-size: 11px; letter-spacing: .12em;
  text-shadow: 2px 2px 0 #000;
  transition: transform .12s;
}
.distrito-hit:hover { transform: translateY(-3px); background: rgba(45,106,79,.5); }
.distrito-hit .emoji { font-size: 26px; filter: drop-shadow(2px 2px 0 #000); }
.float-hud {
  position: absolute; top: 10px; right: 10px;
  display: flex; gap: 8px; align-items: center; z-index: 5;
}
.lobby-rodape {
  position: absolute; bottom: 8px; left: 10px; right: 10px;
  display: flex; gap: 8px; align-items: center; z-index: 5;
}
.lobby-lider {
  display: flex; align-items: center; gap: 8px;
  background: rgba(5,26,11,.85); border: 2px solid #000; padding: 5px 10px; font-size: 11px;
}
.lobby-lider img { width: 40px; height: 40px; }

/* ---------- modais de distrito ---------- */
.distrito {
  position: absolute; inset: 0;
  background: var(--bg-main);
  display: none; flex-direction: column;
  z-index: 10;
}
.distrito.aberto { display: flex; }
.distrito-corpo { flex: 1; overflow-y: auto; padding: 12px; }

/* abas */
.abas { display: flex; gap: 6px; padding: 8px 12px 0; flex-wrap: wrap; }
.aba {
  font-family: var(--fonte); font-size: 11px; letter-spacing: .12em;
  background: var(--inset); color: var(--muted-2);
  border: 2px solid #000; border-bottom: none;
  padding: 6px 12px; cursor: pointer;
}
.aba.ativa { background: var(--painel); color: var(--verde-3); }
.aba-painel { display: none; }
.aba-painel.ativa { display: block; }

/* ---------- arena ---------- */
#arena-palco {
  position: relative; flex: 1; overflow: hidden;
  background: #000;
}
.parallax-layer {
  position: absolute; inset: 0;
  background-repeat: repeat-x;
  background-size: auto 100%;
  will-change: background-position;
}
#arena-chao-info {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  background: rgba(5,26,11,.85); border: 2px solid #000;
  padding: 4px 14px; font-size: 11px; letter-spacing: .18em; color: var(--muted);
  z-index: 4; white-space: nowrap;
}
.lutador {
  position: absolute; bottom: 12%;
  width: var(--spr); height: var(--spr);
  z-index: 3;
}
#lutador-jogador { left: 12%; }
#lutador-inimigo { right: 12%; }
.sprite {
  width: var(--spr); height: var(--spr);
  background-size: 400% 100%;
  background-repeat: no-repeat;
  animation: idle-loop .6s steps(4) infinite;
}
#lutador-inimigo .sprite { transform: scaleX(-1); }
@keyframes idle-loop { from { background-position-x: 0%; } to { background-position-x: -400%; } }
.sprite.atacando { animation: attack-once .4s steps(4) 1; }
@keyframes attack-once { from { background-position-x: 0%; } to { background-position-x: -400%; } }

.lutador .placa {
  position: absolute; top: -44px; left: 50%; transform: translateX(-50%);
  width: 150px; text-align: center; font-size: 10px;
  background: rgba(5,26,11,.9); border: 2px solid #000; padding: 3px 4px;
}
.placa .nome { color: #eafff0; letter-spacing: .1em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra {
  height: 8px; margin-top: 3px;
  background: var(--inset); border: 1px solid #000;
  position: relative; overflow: hidden;
}
.barra > i {
  position: absolute; inset: 0; transform-origin: left;
  background: var(--verde-3);
  transition: transform .3s;
}
.barra > i.meio { background: var(--falha); }
.barra > i.baixo { background: var(--vermelho-2); }
.barra::after { /* scanlines pixel */
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 4px, rgba(0,0,0,.25) 4px 5px);
}
.barra-furia > i { background: linear-gradient(90deg, #ff7043, var(--ouro)); }

/* animações de combate */
.sacudir { animation: sacudir .3s steps(4) 1; }
@keyframes sacudir {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
#lutador-inimigo.sacudir .sprite { transform: scaleX(-1); }
.lunge-dir { animation: lunge-dir .45s ease-in-out 1; }
@keyframes lunge-dir { 0%,100% { transform: translateX(0); } 45% { transform: translateX(46vw) scale(1.05); } }
.lunge-esq { animation: lunge-esq .45s ease-in-out 1; }
@keyframes lunge-esq { 0%,100% { transform: translateX(0); } 45% { transform: translateX(-46vw) scale(1.05); } }
.recuo { animation: recuo .28s ease-out 1; }
@keyframes recuo { 0%,100% { transform: translateX(0); } 40% { transform: translateX(-14px); } }

.projetil {
  position: absolute; width: 18px; height: 18px; z-index: 4;
  border-radius: 50%;
  box-shadow: 0 0 10px 3px currentColor;
  background: currentColor;
  animation: projetil-voa .28s linear 1 forwards;
}
@keyframes projetil-voa { from { transform: translateX(0); opacity: 1; } to { transform: translateX(var(--dist)); opacity: 1; } }

.estoura {
  position: absolute; width: 40px; height: 40px; border-radius: 50%;
  background: #fff; z-index: 5;
  animation: estoura .35s ease-out 1 forwards;
}
@keyframes estoura { from { transform: scale(.2); opacity: .95; } to { transform: scale(1.8); opacity: 0; } }

.dano-flutuante {
  position: absolute; z-index: 6;
  font-size: 16px; color: #fff; text-shadow: 2px 2px 0 #000;
  animation: sobe 1s ease-out 1 forwards;
  pointer-events: none;
  white-space: nowrap;
}
.dano-flutuante.crit { font-size: 22px; color: var(--ouro); text-shadow: 2px 2px 0 var(--vermelho), 0 0 12px var(--ouro); }
.dano-flutuante.cura { color: var(--verde-3); }
.dano-flutuante.moeda { color: var(--ouro); font-size: 13px; }
.dano-flutuante.esquiva { color: #7fd4e8; }
@keyframes sobe { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-56px); opacity: 0; } }

.particula-moeda {
  position: absolute; width: 10px; height: 10px; border-radius: 50%;
  background: var(--ouro); box-shadow: inset -2px -2px 0 var(--ouro-2); z-index: 6;
  animation: moeda-pula .7s ease-out 1 forwards;
}
@keyframes moeda-pula {
  0% { transform: translate(0,0); opacity: 1; }
  60% { transform: translate(var(--mx), -34px); }
  100% { transform: translate(var(--mx), 6px); opacity: 0; }
}

.entrada-inimigo { animation: entrada-inimigo .6s ease-out 1; }
@keyframes entrada-inimigo { from { transform: translateX(280px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.morte-fade { animation: morte-fade .6s ease-in 1 forwards; }
@keyframes morte-fade { to { opacity: 0; transform: translateY(10px) scale(.9); } }

.furia-cheia .sprite { filter: drop-shadow(0 0 10px #ff7043); animation: idle-loop .6s steps(4) infinite, furia-pulsa .8s ease-in-out infinite; }
@keyframes furia-pulsa { 50% { filter: drop-shadow(0 0 18px #ff7043) brightness(1.3); } }

.flash-ultimate { animation: flash-ult .52s ease-out 1; }
@keyframes flash-ult { 20% { filter: brightness(2.2); } }
.shake-cena { animation: shake-cena .52s linear 1; }
@keyframes shake-cena {
  0%,100% { transform: translate(0,0); }
  20% { transform: translate(4px,-4px); }
  40% { transform: translate(-4px,4px); }
  60% { transform: translate(4px,4px); }
  80% { transform: translate(-4px,-4px); }
}
.scale-atacante { animation: scale-atk .52s ease-out 1; }
@keyframes scale-atk { 40% { transform: scale(1.12); } }

/* arena rodapé */
#arena-controles {
  display: flex; gap: 8px; align-items: center;
  padding: 8px 12px; background: var(--painel); border-top: 2px solid #000;
  flex-wrap: wrap;
}
#arena-log {
  height: 66px; overflow-y: auto;
  background: var(--inset); border: 2px solid #000;
  font-size: 10px; padding: 5px 8px; line-height: 1.6;
}
#arena-log .info { color: var(--azul); }
#arena-log .ganho { color: var(--ouro); }
#arena-log .perigo { color: var(--vermelho-2); }
#arena-log .neutro { color: var(--muted-2); }
.ganho-hud {
  position: absolute; right: 14px; top: 44px; z-index: 6;
  font-size: 13px; color: var(--verde-3); text-shadow: 2px 2px 0 #000;
  animation: ganho-some 2.5s ease-out 1 forwards;
}
.ganho-hud.crit { color: var(--ouro); }
@keyframes ganho-some { 0%,70% { opacity: 1; } 100% { opacity: 0; transform: translateY(-12px); } }

/* ---------- cards genéricos ---------- */
.grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 10px; }
.mcard {
  background: var(--card); border: 2px solid #000; padding: 8px;
  box-shadow: inset 2px 2px 0 rgba(255,255,255,.05);
  display: flex; flex-direction: column; gap: 6px; align-items: center;
  position: relative;
}
.mcard img.port { width: 72px; height: 72px; }
.mcard .mnome { font-size: 12px; color: #eafff0; letter-spacing: .08em; text-align: center; }
.mcard .mtag { font-size: 9px; letter-spacing: .1em; }
.mcard .estrelas { color: var(--ouro); font-size: 11px; letter-spacing: 2px; min-height: 13px; }
.mcard.lider-sel { outline: 2px solid var(--ouro); }
.mcard.na-equipe { outline: 2px solid var(--verde-3); }
.selo {
  position: absolute; top: 4px; left: 4px;
  font-size: 8px; padding: 2px 5px; border: 1px solid #000;
  background: var(--ouro-2); color: #1b1400; letter-spacing: .1em;
}
.selo.equipe { background: var(--verde-1); color: #eafff0; top: 4px; right: 4px; left: auto; }
.linha-botoes { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }

.pc-badge { font-size: 10px; color: var(--neon); }
.nivel-badge { font-size: 10px; color: var(--ouro); }

/* ---------- popups ---------- */
#overlay-popup {
  position: absolute; inset: 0; z-index: 50;
  background: rgba(0,0,0,.72);
  display: none; align-items: center; justify-content: center;
}
#overlay-popup.aberto { display: flex; }
.popup {
  width: min(92%, 420px);
  background: var(--painel);
  padding: 18px;
  display: flex; flex-direction: column; gap: 12px;
  max-height: 86%; overflow-y: auto;
}
.popup h2 {
  font-size: 15px; letter-spacing: .18em; color: var(--verde-3); text-align: center;
}
.popup h2::before, .popup h2::after { content: " ❦ "; color: var(--verde-1); }
.popup p { font-size: 11px; color: var(--muted); line-height: 1.7; text-align: center; }
.popup .destaque { color: var(--ouro); font-size: 13px; }
.popup .linha-botoes { justify-content: center; }

/* ---------- toasts ---------- */
#toasts {
  position: absolute; top: 12px; right: 12px; z-index: 90;
  display: flex; flex-direction: column; gap: 6px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  background: var(--painel); border: 2px solid #000;
  outline: 1px solid var(--verde-2);
  padding: 7px 12px; font-size: 11px; max-width: 300px;
  animation: toast-in .25s ease-out 1, toast-out .4s ease-in 1 forwards 3.4s;
}
.toast.ouro { outline-color: var(--ouro); color: var(--ouro); }
.toast.perigo { outline-color: var(--vermelho-2); color: #ffb4b4; }
@keyframes toast-in { from { transform: translateX(24px); opacity: 0; } }
@keyframes toast-out { to { transform: translateX(24px); opacity: 0; } }

/* ---------- gacha ---------- */
.gacha-palco { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 18px; }
.gacha-anel {
  width: 130px; height: 130px; border-radius: 50%;
  border: 4px dashed var(--neon);
  display: flex; align-items: center; justify-content: center;
}
.gacha-anel.girando { animation: gira 1s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
.gacha-anel img { width: 60px; height: 70px; animation: none; }
.egg-pop { animation: egg-pop .5s cubic-bezier(.2,1.6,.4,1) 1; }
@keyframes egg-pop { from { transform: scale(.2); } }
.glow-mitico { filter: drop-shadow(0 0 16px #d64550); }
.animate-tremer { animation: tremer 1.4s ease-in-out infinite; }
@keyframes tremer {
  0%,72%,100% { transform: rotate(0); }
  76% { transform: rotate(-7deg); }
  82% { transform: rotate(7deg); }
  88% { transform: rotate(-4deg); }
}

.incubadora-slots { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.ninho {
  width: 120px; min-height: 130px;
  background: var(--card); border: 2px solid #000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 8px; font-size: 10px; color: var(--muted-2); text-align: center;
}

/* ---------- listas ---------- */
.lista-linha {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 2px solid #000; padding: 8px 10px;
  margin-bottom: 8px; font-size: 11px;
}
.lista-linha .cresce { flex: 1; }
.lista-linha .sub { color: var(--muted-2); font-size: 9px; margin-top: 3px; line-height: 1.5; }
.lista-linha.destaque-voce { outline: 2px solid var(--ouro); }
.pos-rank { width: 30px; color: var(--ouro); font-size: 13px; text-align: center; }

.secao-titulo {
  font-size: 11px; letter-spacing: .22em; color: var(--verde-3);
  margin: 14px 0 8px; text-transform: uppercase;
  display: flex; align-items: center; gap: 8px;
}
.secao-titulo::before, .secao-titulo::after { content: ""; height: 2px; background: var(--verde-1); flex: 1; }

.aviso-risco { color: var(--vermelho-2); font-size: 10px; animation: pisca 1s steps(2) infinite; text-align: center; }
@keyframes pisca { 50% { opacity: .25; } }

.vazio { text-align: center; color: var(--muted-2); font-size: 11px; padding: 24px 10px; line-height: 1.8; }

/* ---------- barra XP líder ---------- */
.xp-wrap { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 120px; }
.xp-wrap .rotulo { font-size: 9px; color: var(--muted-2); letter-spacing: .14em; }

/* boot */
#tela-boot { align-items: center; justify-content: center; gap: 16px; }
.boot-barra { width: 200px; }

/* acessibilidade / motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* responsivo simples */
@media (max-width: 720px) {
  :root { --spr: 96px; }
  .grade { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  #lutador-jogador { left: 4%; }
  #lutador-inimigo { right: 4%; }
}
