* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; background: #101418; font-family: system-ui, "Segoe UI", "Noto Sans SC", sans-serif; }
#game { position: fixed; inset: 0; }
#game canvas { image-rendering: pixelated; }
.hidden { display: none !important; }

/* ---------- tela de entrada ---------- */
#join, #disconnected {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #1b2a4a, #0d1526);
}
.card {
  background: #16213a; border: 2px solid #2c4a7c; border-radius: 12px;
  padding: 22px 26px; width: min(340px, 92vw); color: #dfe8ff;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.card h1 { font-size: 26px; color: #ffcb05; text-shadow: 2px 2px 0 #3b5ba7; letter-spacing: 1px; }
.card .sub { font-size: 13px; color: #9db2d8; margin: 4px 0 14px; }
.card label { display: block; font-size: 12px; color: #9db2d8; margin: 10px 0 4px; text-transform: uppercase; letter-spacing: .5px; }
.card input {
  width: 100%; padding: 9px 10px; border-radius: 8px; border: 1px solid #2c4a7c;
  background: #0d1526; color: #fff; font-size: 15px; outline: none;
}
.card input:focus { border-color: #ffcb05; }
.langs { display: flex; gap: 6px; }
.lang {
  flex: 1; padding: 7px 4px; border-radius: 8px; border: 1px solid #2c4a7c;
  background: #0d1526; color: #dfe8ff; cursor: pointer; font-size: 12px;
}
.lang.sel { border-color: #ffcb05; background: #223260; }
#skins { display: flex; gap: 8px; flex-wrap: wrap; }
.skin {
  width: 52px; height: 64px; border-radius: 8px; border: 2px solid #2c4a7c;
  background-color: #0d1526; cursor: pointer; position: relative; overflow: hidden;
}
.skin.sel { border-color: #ffcb05; background-color: #223260; }
.skin > div {
  width: 16px; height: 32px; position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(2.6); transform-origin: center;
  background-repeat: no-repeat; background-position: 0 0; image-rendering: pixelated;
}
#play {
  width: 100%; margin-top: 16px; padding: 11px; border: 0; border-radius: 8px;
  background: #ffcb05; color: #1b2a4a; font-size: 16px; font-weight: 700; cursor: pointer;
}
#play:active { transform: translateY(1px); }
.error { color: #ff7d7d; font-size: 13px; margin-top: 8px; min-height: 16px; }
.pokedex-link { display: block; text-align: center; margin-top: 10px; color: #8fc3ff; font-size: 13px; text-decoration: none; }
.pokedex-link:hover { color: #ffcb05; }

/* ---------- HUD ---------- */
#online {
  position: fixed; top: 8px; right: 10px; z-index: 10;
  background: rgba(13,21,38,.75); color: #dfe8ff; font-size: 13px;
  padding: 5px 10px; border-radius: 8px; border: 1px solid #2c4a7c;
}
#chat {
  position: fixed; left: 8px; bottom: 8px; z-index: 10;
  width: min(320px, 70vw); display: flex; flex-direction: column; gap: 5px;
}
#chatLog {
  max-height: 130px; overflow-y: auto; font-size: 13px; color: #fff;
  display: flex; flex-direction: column; gap: 2px;
}
#chatLog div {
  background: rgba(13,21,38,.7); padding: 3px 8px; border-radius: 6px;
  width: fit-content; max-width: 100%; word-wrap: break-word;
}
#chatLog .sys { color: #ffcb05; font-style: italic; }
#chatLog b { color: #8fc3ff; }
#chatInput {
  padding: 8px 10px; border-radius: 8px; border: 1px solid #2c4a7c;
  background: rgba(13,21,38,.85); color: #fff; font-size: 14px; outline: none;
}
#chatInput:focus { border-color: #ffcb05; }

/* ---------- party button ---------- */
#partyBtn {
  position: fixed; top: 8px; left: 10px; z-index: 10;
  background: rgba(13,21,38,.8); color: #dfe8ff; border: 1px solid #2c4a7c;
  border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer;
}
#partyBtn:hover { border-color: #ffcb05; }

/* ---------- escolha do inicial ---------- */
#starter {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #1b2a4a, #0d1526); padding: 14px;
}
.starter-box { text-align: center; color: #dfe8ff; }
.starter-box h2 { font-size: 22px; color: #ffcb05; text-shadow: 2px 2px 0 #3b5ba7; }
.starter-box p { color: #9db2d8; font-size: 14px; margin: 6px 0 18px; }
.starter-choices { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.starter-c {
  background: #16213a; border: 2px solid #2c4a7c; border-radius: 14px; padding: 14px 10px;
  width: 120px; cursor: pointer; color: #dfe8ff; transition: transform .08s, border-color .08s;
}
.starter-c:hover { transform: translateY(-3px); border-color: #ffcb05; }
.starter-c img { width: 80px; height: 80px; image-rendering: pixelated; }
.starter-c span { display: block; margin-top: 6px; font-weight: 600; }

/* ---------- batalha ---------- */
#battle { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; background: #0d1526; }
.b-field {
  flex: 1; position: relative;
  background: linear-gradient(#8fd0e6 0%, #a7dcc0 60%, #74c493 60%, #86cf9a 100%);
  overflow: hidden;
}
.b-enemy { position: absolute; top: 9%; right: 6%; display: flex; flex-direction: column; align-items: flex-end; }
.b-player { position: absolute; bottom: 4%; left: 6%; display: flex; flex-direction: column; align-items: flex-start; }
.b-sprite { width: 118px; height: 118px; image-rendering: pixelated; filter: drop-shadow(0 6px 4px rgba(0,0,0,.25)); }
.b-enemy .b-sprite { margin-right: 22px; }
.b-player .b-sprite { margin-left: 22px; }
.b-nameplate { background: rgba(22,33,58,.92); border: 2px solid #2c4a7c; border-radius: 10px; padding: 6px 12px; min-width: 170px; color: #fff; }
.b-nmrow { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.b-nm { font-weight: 700; font-size: 14px; }
.b-lv { font-size: 12px; color: #9db2d8; }
.b-hpbar { height: 8px; background: #0d1526; border-radius: 5px; overflow: hidden; margin-top: 4px; border: 1px solid #0a1120; }
.b-hpbar > div { height: 100%; width: 100%; background: #4caf50; transition: width .45s ease, background .45s; }
.b-hptext { font-size: 11px; color: #9db2d8; text-align: right; margin-top: 2px; }
.b-sprite.faint { transition: transform .45s, opacity .45s; transform: translateY(24px); opacity: 0; }

.b-bottom { background: #16213a; border-top: 3px solid #2c4a7c; padding: 12px; min-height: 128px; }
.b-msg { color: #fff; font-size: 15px; min-height: 42px; display: flex; align-items: center; }
.b-menu, .b-moves { display: grid; gap: 8px; }
.b-menu { grid-template-columns: 1fr 1fr 1fr; }
.b-moves { grid-template-columns: 1fr 1fr; }
.b-menu button, .b-move { padding: 12px 8px; border: 0; border-radius: 8px; font-size: 15px; font-weight: 700; cursor: pointer; color: #fff; }
#bFight { background: #c0392b; }
#bBall { background: #ffcb05; color: #1b2a4a; }
#bRun { background: #2c3a52; }
.b-move { text-align: left; }
.b-move small { display: block; font-size: 10px; opacity: .85; font-weight: 400; }
.b-move:disabled { opacity: .4; cursor: default; }
.b-back { grid-column: span 2; background: #2c3a52; color: #dfe8ff; border: 0; border-radius: 8px; padding: 8px; font-size: 16px; cursor: pointer; }

/* ---------- party panel ---------- */
#partyPanel {
  position: fixed; inset: 0; z-index: 30; background: rgba(6,10,20,.8);
  display: flex; align-items: center; justify-content: center; padding: 14px;
}
.party-sheet {
  background: #16213a; border: 2px solid #2c4a7c; border-radius: 14px;
  width: min(440px, 96vw); max-height: 88vh; overflow-y: auto; padding: 18px;
}
.party-close { float: right; background: none; border: 0; color: #9db2d8; font-size: 22px; cursor: pointer; }
.party-sheet h2 { font-size: 20px; color: #ffcb05; margin-bottom: 12px; }
.party-mon {
  display: flex; align-items: center; gap: 12px; background: #0d1526;
  border: 1px solid #2c4a7c; border-radius: 10px; padding: 8px 12px; margin-bottom: 8px;
}
.party-mon img { width: 48px; height: 48px; image-rendering: pixelated; }
.party-mon .pm-name { font-weight: 600; }
.party-mon .pm-sub { font-size: 12px; color: #9db2d8; }
.party-mon .badges { margin-top: 3px; }
.party-empty { color: #9db2d8; font-size: 14px; text-align: center; padding: 20px; }

/* ---------- d-pad ---------- */
#dpad {
  position: fixed; right: 14px; bottom: 20px; z-index: 10;
  display: grid; grid-template-columns: repeat(3, 54px); grid-template-rows: repeat(3, 54px);
}
.dp {
  border: 1px solid #2c4a7c; background: rgba(13,21,38,.6); color: #dfe8ff;
  font-size: 20px; border-radius: 10px; touch-action: none; user-select: none;
}
.dp:active { background: rgba(255,203,5,.5); }
#dpUp { grid-area: 1 / 2; }
#dpLeft { grid-area: 2 / 1; }
#dpRight { grid-area: 2 / 3; }
#dpDown { grid-area: 3 / 2; }
