/* Layout: 外枠なし。縦長＝ゲーム画面／タッチ画面／操作ボタン列を縦に、横長＝十字キー｜ゲーム画面（最大）｜タッチ画面＋ボタン */
:root {
  --page: #0e1016;
  --muted: #7d859a;
  --key: #2e3446;
  --key-hi: #4a5474;
  --ink: #e6e9f2;
  --btn-a: #d6564b;
  --btn-b: #d79a36;
  --btn-x: #4a7fd0;
  --btn-y: #4f9f55;
  --font-ui: "DotGothic16", "Hiragino Kaku Gothic ProN", "Yu Gothic", monospace;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--page); }
body {
  color: var(--ink); font-family: var(--font-ui); overflow: hidden;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-top: max(8px, env(safe-area-inset-top, 0px));
  padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  touch-action: manipulation; overscroll-behavior: none; -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none; -webkit-text-size-adjust: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
}
.app {
  display: grid; gap: 8px 12px; justify-items: center; align-items: center; max-width: 100%;
  grid-template-columns: 1fr 1fr;
  grid-template-areas: "top top" "bottom bottom" "dpad btns";
}
.app.wide {
  grid-template-columns: auto auto auto; gap: 12px 18px;
  grid-template-areas: "dpad top bottom" "dpad top btns";
}
#top { grid-area: top; }
#bottom { grid-area: bottom; }
.app.wide #bottom { align-self: end; }
.app.wide .btns { align-self: start; }
.dpad-wrap { grid-area: dpad; }
.btns { grid-area: btns; display: flex; align-items: center; gap: 14px; }
canvas.scr {
  display: block; max-width: 100%; image-rendering: pixelated; image-rendering: crisp-edges;
  background: #000; border-radius: 4px; touch-action: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.dpad, .abxy, .pill { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; }
.dpad { width: 126px; height: 126px; position: relative; }
.dpad .arm { position: absolute; width: 42px; height: 42px; background: var(--key); display: grid; place-items: center; color: #8f98b2; font-size: 12px; }
.dpad .arm.on { background: var(--key-hi); color: var(--ink); }
.dpad .up { left: 42px; top: 0; border-radius: 8px 8px 0 0; }
.dpad .down { left: 42px; bottom: 0; border-radius: 0 0 8px 8px; }
.dpad .left { left: 0; top: 42px; border-radius: 8px 0 0 8px; }
.dpad .right { right: 0; top: 42px; border-radius: 0 8px 8px 0; }
.dpad .hub { position: absolute; left: 42px; top: 42px; width: 42px; height: 42px; background: var(--key); }
.abxy { width: 126px; height: 126px; position: relative; }
.round { position: absolute; width: 42px; height: 42px; border-radius: 50%; border: 0; color: #fff;
  font-family: var(--font-ui); font-size: 15px; box-shadow: 0 3px 0 #00000066; }
.round.x { left: 42px; top: 0; background: var(--btn-x); }
.round.y { left: 0; top: 42px; background: var(--btn-y); }
.round.a { right: 0; top: 42px; background: var(--btn-a); }
.round.b { left: 42px; bottom: 0; background: var(--btn-b); }
.round.on, .pill.on { filter: brightness(1.35); transform: translateY(2px); box-shadow: 0 1px 0 #00000066; }
.pill { font-family: var(--font-ui); font-size: 11px; letter-spacing: .14em; color: var(--ink); background: var(--key);
  border: 0; border-radius: 999px; padding: 7px 12px; }
button:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.keys { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; text-align: center; text-wrap: balance; }
@media (hover: none), (pointer: coarse) { .keys { display: none; } }
#err { position: fixed; left: 8px; right: 8px; bottom: 8px; margin: 0; padding: 8px 12px; background: #5a1e22; color: #fff; font-size: 13px; border-radius: 6px; z-index: 9; }
