:root {
  --bg: #140c08;
  --btn: rgba(255, 255, 255, 0.16);
  --btn-on: rgba(255, 210, 63, 0.55);
  --btn-border: rgba(255, 255, 255, 0.45);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

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

canvas {
  display: block;
  background: #000;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
}

#touch {
  display: none;
}

body.touch #touch {
  display: block;
}

#stick {
  position: fixed;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.18));
  border: 2px solid var(--btn-border);
  touch-action: none;
}

#knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.7);
  pointer-events: none;
}

#buttons {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  width: 210px;
  height: 170px;
}

.btn,
.sysbtn {
  position: absolute;
  border-radius: 50%;
  border: 2px solid var(--btn-border);
  background: var(--btn);
  color: #fff;
  font: 700 13px 'Press Start 2P', monospace;
  text-shadow: 0 2px 0 #000;
  touch-action: none;
  padding: 0;
}

.btn.on,
.sysbtn.on {
  background: var(--btn-on);
}

.btn.attack {
  right: 0;
  bottom: 18px;
  width: 78px;
  height: 78px;
  font-size: 30px;
}

.btn.jump {
  right: 88px;
  bottom: 0;
  width: 66px;
  height: 66px;
  font-size: 26px;
}

.btn.shoot {
  right: 30px;
  bottom: 104px;
  width: 64px;
  height: 64px;
  font-size: 28px;
}

.btn.mine {
  right: 104px;
  bottom: 76px;
  width: 56px;
  height: 56px;
  font-size: 9px;
}

.btn.special {
  right: 164px;
  bottom: 18px;
  width: 54px;
  height: 54px;
  font-size: 7px;
  background: rgba(255, 180, 0, 0.25);
}

#sys {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  display: flex;
  gap: 8px;
}

.sysbtn {
  position: static;
  width: 40px;
  height: 40px;
  font-size: 14px;
  border-radius: 10px;
}

.sysbtn.mute.muted {
  opacity: 0.5;
  text-decoration: line-through;
}

#rotate {
  display: none;
}

/* Phone held upright: game on top, controls below it. */
@media (orientation: portrait) {
  body.touch #wrap {
    align-items: flex-start;
    padding-top: max(56px, env(safe-area-inset-top));
  }
  body.touch #rotate {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    top: 50%;
    margin: 0;
    padding: 0 24px;
    text-align: center;
    color: rgba(255, 255, 255, 0.55);
    font: 10px/1.8 'Press Start 2P', monospace;
  }
}

/* Small landscape phones: shrink the pad a bit. */
@media (max-height: 420px) and (orientation: landscape) {
  #stick {
    width: 116px;
    height: 116px;
  }
  #knob {
    width: 48px;
    height: 48px;
  }
  #buttons {
    transform: scale(0.82);
    transform-origin: bottom right;
  }
  #touch .btn,
  #stick {
    opacity: 0.75;
  }
}
