* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: #06040f;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#stage-wrap {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game {
  display: block;
  image-rendering: auto;
  background: #0d0a1e;
  border-radius: 6px;
  box-shadow: 0 0 60px rgba(80, 60, 200, 0.25);
}

/* ------------------- touch controls ------------------- */
#touch {
  display: none;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}
#touch.visible { display: block; }

#dpad {
  position: absolute;
  left: max(14px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: rgba(20, 16, 49, 0.45);
  border: 2px solid rgba(159, 196, 255, 0.35);
  pointer-events: auto;
  touch-action: none;
}
.dpad-arrow {
  position: absolute;
  color: rgba(255, 255, 255, 0.75);
  font-size: 26px;
  transform: translate(-50%, -50%);
  text-shadow: 0 2px 4px rgba(0,0,0,0.6);
}
.dpad-arrow.up    { left: 50%; top: 17%; }
.dpad-arrow.down  { left: 50%; top: 83%; }
.dpad-arrow.left  { left: 17%; top: 50%; }
.dpad-arrow.right { left: 83%; top: 50%; }
.dpad-nub {
  position: absolute;
  left: 50%; top: 50%;
  width: 54px; height: 54px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(159, 196, 255, 0.2);
  border: 2px solid rgba(159, 196, 255, 0.3);
}

#actions {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 96px 96px;
  grid-template-rows: 96px 96px;
  gap: 12px;
  pointer-events: none;
}
.btn {
  pointer-events: auto;
  touch-action: none;
  width: 96px; height: 96px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-family: 'Arial Black', sans-serif;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.6);
  border: 2px solid rgba(255,255,255,0.35);
  transition: transform 0.05s;
}
.btn span { font-size: 11px; letter-spacing: 0.5px; margin-top: 2px; }
.btn.active { transform: scale(0.92); filter: brightness(1.5); }
.btn.punch   { grid-column: 1; grid-row: 1; background: rgba(219, 68, 55, 0.55); }
.btn.kick    { grid-column: 2; grid-row: 1; background: rgba(244, 160, 20, 0.55); }
.btn.special { grid-column: 1 / span 2; grid-row: 2; justify-self: center; background: rgba(66, 133, 244, 0.55); box-shadow: 0 0 18px rgba(100, 180, 255, 0.35); }

/* ------------------- system buttons ------------------- */
#sysbtns {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  display: flex;
  gap: 10px;
  z-index: 20;
}
.sysbtn {
  width: 42px; height: 42px;
  border-radius: 10px;
  background: rgba(20, 16, 49, 0.6);
  border: 1px solid rgba(159, 196, 255, 0.3);
  color: #fff;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: none;
}

/* ------------------- rotate hint ------------------- */
#rotate-hint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(6, 4, 15, 0.95);
  color: #fff;
  text-align: center;
  font-family: 'Arial Black', sans-serif;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px;
}
#rotate-hint div { font-size: 64px; }
#rotate-hint p { font-size: 20px; color: #9fc4ff; max-width: 420px; }

@media (orientation: portrait) and (pointer: coarse) {
  #rotate-hint { display: flex; }
}
