/* Arena noturna: tinta azul-marinho, vermelho do P1, ciano do P2, amarelo de destaque */
:root {
  --ink: #0f1222;
  --panel: #191e35;
  --panel-2: #222849;
  --line: #2f3760;
  --text: #eef1ff;
  --muted: #9aa3c7;
  --p0: #ff5a5f;
  --p1: #4cc9f0;
  --hl: #ffd54a;
  --ok: #5bd46a;
  --display: 'Pixelify Sans', 'Courier New', monospace;
  --body: 'Rubik', system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(ellipse at 50% -10%, #232a52 0%, var(--ink) 60%) fixed, var(--ink);
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }

.screen { min-height: 100%; padding: 24px 16px; }

/* ---------- botões ---------- */
.btn {
  font: 600 15px var(--body);
  border: 2px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .08s, background .15s, border-color .15s;
}
.btn:hover:not(:disabled) { border-color: var(--hl); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible { outline: 3px solid var(--hl); outline-offset: 2px; }
.btn.primary { background: var(--p0); border-color: #ff8285; color: #1a0608; }
.btn.primary:hover:not(:disabled) { background: #ff6d72; border-color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.big { padding: 14px 32px; font-size: 17px; }
.btn.ready { background: var(--ok); border-color: #8be696; color: #06210b; }

input {
  font: 500 16px var(--body);
  background: var(--ink);
  color: var(--text);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
}

.status { min-height: 1.4em; color: var(--muted); text-align: center; margin: 12px 0 0; }
.status.error { color: #ff8a8d; }

/* ---------- início ---------- */
#home { display: grid; place-items: center; }
.home-box { width: min(640px, 100%); display: flex; flex-direction: column; gap: 20px; }
.logo {
  font-family: var(--display);
  font-size: clamp(44px, 9vw, 76px);
  line-height: .95;
  margin: 0;
  text-align: center;
  letter-spacing: 1px;
  color: var(--hl);
  text-shadow: 4px 4px 0 #b3412f, 8px 8px 0 rgba(0,0,0,.35);
}
.logo span { color: var(--text); text-shadow: 4px 4px 0 #3a4a8a, 8px 8px 0 rgba(0,0,0,.35); }
.tagline { text-align: center; color: var(--muted); margin: -6px 0 6px; }
.field { display: grid; gap: 6px; }
.field span { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.home-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 2px solid var(--line); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.card h2 { margin: 0; font: 700 22px var(--display); }
.card p { margin: 0; color: var(--muted); font-size: 14px; flex: 1; }
.join-row { display: flex; gap: 8px; }
#codeInput { text-transform: uppercase; letter-spacing: .3em; font-family: var(--display); font-size: 20px; text-align: center; }
#btnSolo { align-self: center; }

/* ---------- sala ---------- */
#lobby { max-width: 1100px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.lobby-head { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; justify-content: space-between; }
.room { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.room .label { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.room strong { font: 700 30px var(--display); letter-spacing: .2em; color: var(--hl); }
.players { display: flex; align-items: center; gap: 12px; font-weight: 600; }
.players .vs { font-family: var(--display); color: var(--muted); }
.pl { display: flex; flex-direction: column; align-items: center; padding: 6px 12px; border-radius: 10px; background: var(--panel); border: 2px solid var(--line); min-width: 120px; }
.pl.p0 { border-color: var(--p0); }
.pl.p1 { border-color: var(--p1); }
.pl em { font-style: normal; font-size: 12px; color: var(--muted); }
.pl em.on { color: var(--ok); }
.pick-hint { margin: 0; color: var(--muted); }

.mon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.mon-card {
  position: relative;
  text-align: left;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 4px 12px;
  color: var(--text);
  font-family: var(--body);
  cursor: pointer;
  transition: border-color .15s, transform .1s, background .15s;
}
.mon-card:hover { border-color: var(--hl); }
.mon-card.picked { border-color: var(--p0); background: #2a1f33; }
.mon-card .pic { grid-row: span 3; display: grid; place-items: center; height: 92px; background: var(--ink); border-radius: 10px; overflow: hidden; }
.mon-card .pic img { max-width: 88px; max-height: 88px; image-rendering: pixelated; }
.mon-card h3 { margin: 0; font: 700 21px var(--display); }
.mon-card .role { font-size: 13px; color: var(--muted); }
.stats { display: grid; gap: 4px; font-size: 11px; color: var(--muted); }
.stat { display: grid; grid-template-columns: 30px 1fr; align-items: center; gap: 6px; }
.stat i { display: block; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.stat i b { display: block; height: 100%; background: var(--hl); }
.moves { grid-column: 1 / -1; margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 3px; font-size: 13px; }
.moves li { display: flex; gap: 8px; align-items: baseline; }
.key { font: 600 10px var(--body); text-transform: uppercase; letter-spacing: .06em; border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; color: var(--muted); white-space: nowrap; min-width: 64px; text-align: center; }
.moves small { color: var(--muted); }
.badge { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%; background: var(--p0); color: #1a0608; font: 700 15px var(--display); display: grid; place-items: center; }

.lobby-foot { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; position: sticky; bottom: 0; background: linear-gradient(transparent, var(--ink) 30%); padding: 18px 0 6px; }
.team-slots { display: flex; gap: 10px; }
.slot { width: 74px; height: 74px; border: 2px dashed var(--line); border-radius: 12px; display: grid; place-items: center; background: var(--panel); color: var(--muted); font-family: var(--display); font-size: 22px; cursor: pointer; padding: 0; }
.slot.filled { border-style: solid; border-color: var(--p0); }
.slot img { width: 64px; height: 64px; image-rendering: pixelated; }

/* ---------- batalha ---------- */
#battle { height: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; padding-block: 12px; }
.hud { width: 100%; max-width: 1100px; display: flex; justify-content: space-between; gap: 12px; }
.hud .side { display: flex; align-items: center; gap: 10px; }
.pname { font: 700 18px var(--display); }
.s0 .pname { color: var(--p0); }
.s1 .pname { color: var(--p1); }
.team { display: flex; gap: 6px; }
.tm { width: 46px; background: var(--panel); border: 2px solid var(--line); border-radius: 8px; padding: 2px 2px 4px; display: grid; justify-items: center; }
.tm img { width: 40px; height: 40px; image-rendering: pixelated; }
.tm .bar { width: 36px; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.tm .bar b { display: block; height: 100%; background: var(--ok); }
.tm.active { border-color: var(--hl); }
.tm.down img { filter: grayscale(1) brightness(.5); }

.stage-wrap { position: relative; border-radius: 12px; overflow: hidden; box-shadow: 0 0 0 3px var(--line), 0 20px 50px rgba(0,0,0,.5); flex: none; }
.stage { position: absolute; left: 0; top: 0; width: 960px; height: 540px; transform-origin: 0 0; cursor: crosshair; user-select: none; }
.stage canvas, .sprite-layer { position: absolute; inset: 0; transform: translate(var(--shx, 0), var(--shy, 0)); }
.sprite-layer { pointer-events: none; }
.mon { position: absolute; left: 0; top: 0; width: 0; height: 0; will-change: transform; }
.mon img { position: absolute; left: 0; image-rendering: pixelated; max-height: 130px; pointer-events: none; }
.layer-fx { pointer-events: none; }

.banner {
  position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%);
  font: 700 clamp(28px, 6vw, 64px) var(--display);
  color: var(--hl);
  text-shadow: 3px 3px 0 #b3412f, 0 0 24px rgba(0,0,0,.6);
  pointer-events: none; white-space: nowrap;
  animation: pop .25s ease-out;
}
@keyframes pop { from { transform: translate(-50%, -50%) scale(1.4); opacity: 0; } }
.end-panel {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px;
  background: rgba(10, 12, 26, .72); text-align: center;
}
.end-panel h2 { margin: 0; font: 700 clamp(36px, 7vw, 72px) var(--display); color: var(--hl); text-shadow: 4px 4px 0 #b3412f; }
.end-panel p { margin: 0 0 8px; color: var(--muted); }
.end-actions { display: flex; gap: 10px; }

.movebar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.mv { position: relative; overflow: hidden; min-width: 150px; background: var(--panel); border: 2px solid var(--line); border-radius: 10px; padding: 6px 10px; display: grid; gap: 2px; }
.mv .k { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.mv .n { font-weight: 600; font-size: 14px; position: relative; z-index: 1; }
.mv .cd { position: absolute; left: 0; bottom: 0; width: 100%; background: rgba(10,12,26,.7); height: 0; }
.mv.ready { border-color: var(--p0); }

@media (prefers-reduced-motion: reduce) {
  .banner { animation: none; }
  .btn { transition: none; }
}
