* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #0b1026; color: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.hidden { display: none !important; }

.screen {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; padding: 20px;
  text-align: center;
  background: radial-gradient(circle at 50% 20%, #2a2f6b 0%, #0b1026 70%);
}
#menu {
  background: linear-gradient(rgba(11,16,38,.35), rgba(11,16,38,.35) 45%, rgba(11,16,38,.9)),
              url('bg.jpg?v=1') center / cover no-repeat,
              radial-gradient(circle at 50% 20%, #2a2f6b 0%, #0b1026 70%);
  justify-content: flex-end; padding-bottom: 48px;
}
#menu h1 { text-shadow: 0 2px 8px #000, 0 0 24px #000; }
h1 { font-size: 30px; margin: 0; }
h2 { font-size: 20px; margin: 8px 0 0; }
.sub { margin: 0; opacity: .8; }
.small { font-size: 13px; }
.err { color: #ff7b7b; min-height: 20px; margin: 0; }

button.big {
  font-size: 22px; padding: 16px 28px; border: 0; border-radius: 16px;
  background: linear-gradient(#ffb347, #ff7a00); color: #1b0d00; font-weight: 700;
  box-shadow: 0 6px 0 #a34c00; cursor: pointer; min-width: 220px;
}
button.big:active { transform: translateY(4px); box-shadow: 0 2px 0 #a34c00; }
button.big.secondary { background: linear-gradient(#8fa3ff, #4b63d6); color: #fff; box-shadow: 0 6px 0 #2a3a8a; }
button.big:disabled { opacity: .5; }
.row { display: flex; gap: 10px; align-items: center; }
input#joinCode {
  width: 110px; font-size: 26px; text-align: center; padding: 12px; border-radius: 14px;
  border: 2px solid #4b63d6; background: #141a3f; color: #fff; letter-spacing: 6px;
}
#roomCode { font-size: 64px; font-weight: 800; letter-spacing: 10px; color: #ffd166; }

#heroes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; max-width: 380px; }
.hero {
  border-radius: 16px; padding: 12px 8px; background: #141a3f; border: 3px solid transparent;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.hero.selected { border-color: #ffd166; background: #222a63; }
.hero canvas { width: 64px; height: 64px; }
.hero .name { font-weight: 700; }
.hero .power { font-size: 12px; opacity: .8; }
#playersList { font-size: 15px; opacity: .9; min-height: 40px; }

#game { position: fixed; inset: 0; display: flex; flex-direction: column; background: #0b1026; }
#c {
  flex: 1; width: 100%; min-height: 0; display: block;
  object-fit: contain; image-rendering: auto;
}
#controls {
  display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 8px;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); height: 110px;
  background: #0b1026;
}
.ctl {
  border: 0; border-radius: 18px; font-size: 34px; color: #fff;
  background: #27306a; box-shadow: 0 5px 0 #141a3f; position: relative; overflow: hidden;
}
.ctl:active, .ctl.down { transform: translateY(4px); box-shadow: 0 1px 0 #141a3f; filter: brightness(1.3); }
.ctl.ability { background: #6a2fa0; box-shadow: 0 5px 0 #3b1a5c; }
.ctl.attack { background: #a03030; box-shadow: 0 5px 0 #5c1a1a; }
.ctl .cd {
  position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.55);
  height: 0%; pointer-events: none;
}
@media (min-width: 700px) {
  #controls { max-width: 500px; margin: 0 auto; width: 100%; }
}

.ctl.pause {
  position: absolute; top: calc(8px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  width: 52px; height: 44px; font-size: 22px; border-radius: 12px; background: rgba(39,48,106,.85); box-shadow: 0 3px 0 #141a3f; z-index: 5;
}
.ctl.pause:active, .ctl.pause.down { transform: translateX(-50%) translateY(3px); box-shadow: 0 0 0 #141a3f; }
