* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: #000; color: #fff; font-family: sans-serif; overflow: hidden; }
header { display: flex; justify-content: center; padding: 6px; gap: 8px; }
select, button { padding: 4px 8px; }

#screen { display: flex; justify-content: center; align-items: center; height: calc(100vh - 160px); }
canvas { max-width: 100%; max-height: 100%; image-rendering: pixelated; }

/* 手柄布局 */
#pad { position: fixed; bottom: 10px; left: 0; right: 0; height: 120px; display: flex; justify-content: space-between; padding: 0 20px; }
#dpad { position: relative; width: 120px; height: 120px; }
#dpad button { position: absolute; width: 40px; height: 40px; font-size: 20px; }
#dpad .up    { left: 40px; top: 0; }
#dpad .down  { left: 40px; bottom: 0; }
#dpad .left  { top: 40px; left: 0; }
#dpad .right { top: 40px; right: 0; }

#btns { display: grid; grid-template: 40px 40px / 60px 60px; gap: 10px; align-content: center; }
#btns button { font-size: 18px; border-radius: 50%; }

/* 手机横屏微调 */
@media (orientation: landscape) and (max-height: 500px) {
  #pad { height: 80px; }
  #dpad { width: 80px; height: 80px; }
  #dpad button { width: 30px; height: 30px; font-size: 16px; }
  #btns { grid-template: 30px 30px / 50px 50px; }
}