:root {
  --bg: #07030d;
  --gold: #ffc83a;
  --ink: #fff6e0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: Anton, Impact, sans-serif;
}

#stage {
  position: relative;
  flex: none;
  touch-action: none;
  /* As medidas em cqh (botão VOLTAR) seguem a altura do palco, não da tela (iPad 4:3 tem faixas). */
  container-type: size;
  width: 1280px;
  height: 720px;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  background: #12081d;
}

#touch[hidden] { display: none; }

#touch {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.touch-stick {
  position: absolute;
  left: 4%;
  bottom: 8%;
  width: 22vmin;
  height: 22vmin;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.25);
  pointer-events: auto;
  display: grid;
  place-items: center;
}

.touch-knob {
  width: 40%;
  height: 40%;
  border-radius: 50%;
  background: rgba(255, 200, 58, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.6);
}

.touch-buttons {
  position: absolute;
  right: 3%;
  bottom: 7%;
  display: grid;
  grid-template-columns: repeat(3, 11vmin);
  gap: 1.6vmin;
  pointer-events: auto;
}

.touch-buttons button {
  width: 11vmin;
  height: 11vmin;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 59, 59, 0.35);
  color: var(--ink);
  font: 2.6vmin Anton, Impact, sans-serif;
  touch-action: none;
}

.touch-buttons button.sp { background: rgba(255, 200, 58, 0.4); }
.touch-buttons button.su { background: rgba(140, 90, 255, 0.45); font-size: 2.1vmin; }
/* Trio: troca de lutador, uma pílula em cima dos botões. */
.touch-buttons button.tg { grid-column: 1 / 4; width: auto; height: 7vmin; border-radius: 4vmin; background: rgba(60, 200, 120, 0.42); }
.touch-buttons button[hidden] { display: none; }
.touch-buttons button.on { transform: scale(0.92); background: rgba(255, 255, 255, 0.45); }

/* Pausa (celular): bolinha no canto de cima, ao lado da barra de vida do 2P. O botão é maior
   que o desenho para ser fácil de acertar com o dedo. Pausado, vira "play" e os controles somem. */
.touch-pause {
  position: absolute;
  right: 0;
  top: 3.4%;
  width: 6.4%;
  height: 11.4%;
  padding: 0;
  border: 0;
  background: none;
  pointer-events: auto;
  touch-action: none;
}
.touch-pause[hidden] { display: none; }
.touch-pause::before {
  content: '';
  position: absolute;
  inset: 18% 14% 18% 22%;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.6);
  background: rgba(10, 5, 22, 0.62);
}
.touch-pause::after {
  content: '';
  position: absolute;
  left: 46%;
  top: 39%;
  width: 16%;
  height: 22%;
  background: linear-gradient(90deg, var(--ink) 0 34%, transparent 34% 66%, var(--ink) 66%);
}
.touch-pause.on::before { background: rgba(255, 200, 58, 0.55); }
#touch.pausado .touch-pause::after {
  left: 49%;
  background: var(--gold);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}
#touch.pausado .touch-stick,
#touch.pausado .touch-buttons { display: none; }

/* Menus (celular): sem direcional e botões, que voltam na luta. O dedo vai direto nas opções e
   o VOLTAR fica no canto de cima, do lado oposto ao da pausa. */
#touch.menu .touch-stick,
#touch.menu .touch-buttons { display: none; }
.touch-voltar {
  position: absolute;
  left: 1.4%;
  top: 2.2%;
  height: 7.4%;
  min-width: 12%;
  padding: 0 2.2vmin 0 1.8vmin;
  padding: 0 2.2cqh 0 1.8cqh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.2vmin;
  gap: 1.2cqh;
  border: 2px solid var(--gold);
  border-radius: 99px;
  background: rgba(10, 5, 22, 0.78);
  box-shadow: 0 0.6vmin 0 rgba(0, 0, 0, 0.45);
  color: var(--ink);
  font: 2.4vmin 'Press Start 2P', monospace;
  font-size: 2.4cqh;
  line-height: 1;
  white-space: nowrap;
  pointer-events: auto;
  touch-action: none;
}
.touch-voltar::before {
  content: '';
  width: 0;
  height: 0;
  border-top: 1.1vmin solid transparent;
  border-bottom: 1.1vmin solid transparent;
  border-right: 1.5vmin solid var(--gold);
  border-width: 1.1cqh 1.5cqh 1.1cqh 0;
}
.touch-voltar[hidden] { display: none; }
.touch-voltar.on { background: rgba(255, 200, 58, 0.55); transform: scale(0.95); }
