* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  background: #14181f;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  font-family: sans-serif;
}

#wrap {
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

#game {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
  border-radius: 6px;
  box-shadow: 0 4px 30px rgba(0,0,0,0.6);
}

#muteBtn, #fsBtn {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  width: 44px; height: 44px;
  font-size: 22px;
  color: #fff;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 10px;
  cursor: pointer;
  z-index: 10;
}
#muteBtn { right: max(10px, env(safe-area-inset-right)); }
#fsBtn { right: calc(max(10px, env(safe-area-inset-right)) + 52px); }

#touchPad {
  display: none;
  width: 100%;
  max-width: 832px;
  justify-content: space-between;
  align-items: center;
  padding: 0 14px 10px;
}

.padGroup { display: flex; gap: 14px; align-items: center; }

/* バーチャルスティック(タップしたまま左右にスライド) */
#stick {
  width: 120px; height: 120px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.08);
  position: relative;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
#stickKnob {
  width: 58px; height: 58px;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  border: 2px solid rgba(255,255,255,0.5);
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  font-weight: bold;
  pointer-events: none;
}
#stick.on #stickKnob { background: rgba(255,210,63,0.55); }

.padBtn {
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 26px;
  font-weight: bold;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.padBtn:active { background: rgba(255,210,63,0.45); }
.padBtn.act { background: rgba(255,90,60,0.25); }
.padBtn span { font-size: 9px; font-weight: normal; }

/* 横画面: ボタンをゲーム画面の上にオーバーレイして全画面表示 */
body.overlayPad #touchPad {
  position: fixed;
  left: 0; right: 0;
  bottom: max(10px, env(safe-area-inset-bottom));
  max-width: none;
  padding: 0 max(16px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-right));
  pointer-events: none;
  z-index: 5;
}
body.overlayPad .padBtn {
  pointer-events: auto;
  background: rgba(20,24,31,0.35);
  border-color: rgba(255,255,255,0.45);
}
body.overlayPad #stick {
  pointer-events: auto;
  background: rgba(20,24,31,0.25);
}
body.overlayPad .padBtn:active { background: rgba(255,210,63,0.5); }
