:root {
  --bg: #14110f;
  --panel: #221d19;
  --ink: #ece3d6;
  --dim: #a89a88;
  --accent: #d9a441;
  --key: #3a322b;
  --key-down: #5c4f43;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
button { font: inherit; color: var(--ink); background: var(--key); border: 1px solid #4b4037; border-radius: 6px; padding: 4px 10px; cursor: pointer; }
@media (hover: hover) { button:hover { border-color: var(--accent); } }

#app { max-width: 760px; margin: 0 auto; padding: max(8px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.bar h1 { font-size: 18px; margin: 0; letter-spacing: .04em; }
.bar .ver { color: var(--dim); font-weight: normal; font-size: 13px; }
.bar nav { display: flex; gap: 8px; align-items: center; font-size: 13px; }

#screen-wrap { position: relative; margin: 10px auto; width: 100%; aspect-ratio: 3 / 2; background: #000; border-radius: 6px; overflow: hidden; }
#screen { display: block; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; }
#overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.7); padding: 16px; text-align: center; }
#overlay[hidden] { display: none; }
#overlay.error { color: #ffb4a8; }

/* touch buttons: shown on touch screens */
#pad { display: none; user-select: none; -webkit-user-select: none; touch-action: none; -webkit-touch-callout: none; }
@media (pointer: coarse) { #pad { display: block; } #help h2, #help table { display: none; } }
#pad .shoulders { display: flex; justify-content: space-between; }
#pad .shoulders .key { width: 34%; height: 40px; border-radius: 8px 8px 14px 14px; }
#pad .row { display: flex; justify-content: space-between; align-items: center; margin: 14px 0; }
#pad .key { background: var(--key); font-weight: 600; touch-action: none; }
#pad .key.down { background: var(--key-down); border-color: var(--accent); }
#pad .round { width: 66px; height: 66px; border-radius: 50%; font-size: 20px; }
#pad .ab { display: flex; gap: 16px; align-items: center; }
#pad .ab .key[data-btn="A"] { transform: translateY(-18px); }
#pad .menu-keys { display: flex; justify-content: center; gap: 24px; }
#pad .pill { height: 30px; min-width: 84px; border-radius: 15px; font-size: 12px; letter-spacing: .06em; }

#dpad { position: relative; width: 150px; height: 150px; border-radius: 50%; touch-action: none; }
#dpad .arm { position: absolute; background: var(--key); border: 1px solid #4b4037; }
#dpad .up, #dpad .down { left: 50px; width: 50px; height: 52px; }
#dpad .left, #dpad .right { top: 50px; width: 52px; height: 50px; }
#dpad .up { top: 0; border-radius: 8px 8px 0 0; border-bottom: 0; }
#dpad .down { bottom: 0; border-radius: 0 0 8px 8px; border-top: 0; }
#dpad .left { left: 0; border-radius: 8px 0 0 8px; border-right: 0; }
#dpad .right { right: 0; border-radius: 0 8px 8px 0; border-left: 0; }
#dpad::after { content: ""; position: absolute; left: 50px; top: 50px; width: 50px; height: 50px; background: var(--key); }
#dpad.up .up, #dpad.down .down, #dpad.left .left, #dpad.right .right { background: var(--key-down); border-color: var(--accent); }

#help { color: var(--dim); font-size: 13px; }
#help h2 { font-size: 14px; color: var(--ink); margin: 14px 0 4px; }
#help table { border-collapse: collapse; }
#help th { text-align: left; color: var(--ink); font-weight: 600; padding: 2px 8px 2px 0; white-space: nowrap; }
#help td { padding: 2px 18px 2px 0; }
footer { color: var(--dim); font-size: 12px; margin-top: 16px; border-top: 1px solid #2e2722; padding-top: 8px; }

/* legal page */
.doc { max-width: 760px; margin: 0 auto; padding: 16px; }
.doc h1 { font-size: 22px; }
.doc h2 { font-size: 17px; margin-top: 28px; border-bottom: 1px solid #2e2722; padding-bottom: 4px; }
.doc pre { white-space: pre-wrap; background: var(--panel); padding: 12px; border-radius: 6px; font-size: 12.5px; line-height: 1.5; }
.doc .note { background: #2b2414; border-left: 3px solid var(--accent); padding: 8px 12px; }
