* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #05081a;
  color: #c9d8ff;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

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

#screen {
  background: #0a0f2c;
  box-shadow: 0 0 0 2px #151d47, 0 0 40px rgba(80, 140, 255, 0.15);
}

#touch { display: none; }

body.touch #touch {
  display: block;
  position: fixed;
  inset: auto 0 0 0;
  height: 0;
  pointer-events: none;
}

body.touch #touch > * { pointer-events: auto; }

#dpad {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(20px, env(safe-area-inset-bottom));
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background:
    linear-gradient(#ffffff22, #ffffff22) center / 46px 100% no-repeat,
    linear-gradient(#ffffff22, #ffffff22) center / 100% 46px no-repeat,
    rgba(40, 60, 130, 0.35);
  border: 2px solid rgba(150, 175, 255, 0.35);
  touch-action: none;
}

#dpad-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: rgba(150, 175, 255, 0.45);
  pointer-events: none;
}

#btn-jump {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(36px, calc(env(safe-area-inset-bottom) + 16px));
  width: 104px;
  height: 104px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font: bold 18px monospace;
  color: #fff;
  background: rgba(232, 58, 74, 0.6);
  border: 2px solid rgba(255, 160, 170, 0.6);
  touch-action: none;
}

#btn-jump.down { background: rgba(232, 58, 74, 0.9); transform: scale(0.95); }

#side-buttons {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(156px, calc(env(safe-area-inset-bottom) + 156px));
  display: flex;
  gap: 10px;
}

#side-buttons button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid rgba(150, 175, 255, 0.4);
  background: rgba(40, 60, 130, 0.45);
  color: #fff;
  font: bold 15px monospace;
}

@media (orientation: portrait) {
  body.touch #wrap { bottom: min(220px, 33vh); }
}
