/* Browser gestures belong outside the game cabinet. */
.arcade-player .cabinet,
.arcade-player .cabinet * {
 -webkit-user-select:none;
 user-select:none;
 -webkit-touch-callout:none;
 -webkit-tap-highlight-color:transparent;
}
.arcade-player .cabinet {touch-action:none}
.arcade-player .cabinet canvas,.arcade-player .cabinet button,.arcade-player .cabinet span,.arcade-player .cabinet i {-webkit-user-drag:none}
.arcade-player .cabinet input,.arcade-player .cabinet textarea {
 -webkit-user-select:text;
 user-select:text;
 touch-action:manipulation;
}
.action-key,.action-caption {display:block;pointer-events:none}
.action-caption {font:700 9px/1.2 -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;margin-top:3px;white-space:nowrap;letter-spacing:0;text-shadow:none}

html[data-controls=touch],html[data-controls=touch] body {overflow:hidden;overscroll-behavior:none}
html[data-controls=touch] .arcade-player {
 --hud-height:calc(64px + env(safe-area-inset-top));
 --grip-height:calc(224px + env(safe-area-inset-bottom));
 --grip-edge:clamp(12px,4vw,24px);
}
html[data-controls=touch] .arcade-player .cabinet {overflow:hidden;overscroll-behavior:none}
html[data-controls=touch] .arcade-player .system-buttons,
html[data-controls=touch] .arcade-player .bar {top:calc(10px + env(safe-area-inset-top))}
html[data-controls=touch] .arcade-player .system-buttons {left:calc(10px + env(safe-area-inset-left))}
html[data-controls=touch] .arcade-player .bar {right:calc(10px + env(safe-area-inset-right))}
html[data-controls=touch] .arcade-player .cabinet .screen {
 inset:var(--hud-height) 0 var(--grip-height);
 width:auto;height:calc(100% - var(--hud-height) - var(--grip-height));max-height:none;margin:0;align-self:stretch;
}
html[data-controls=touch] .arcade-player .touch::before {
 content:'';position:absolute;inset:auto 0 0;height:var(--grip-height);
 background:linear-gradient(#1a2922,#101c17 65%,#0b1410);
 border-top:1px solid #82977b3d;
 box-shadow:inset 0 1px #000,inset 0 18px 30px #0002;
 pointer-events:none;
}
html[data-controls=touch] .arcade-player .dpad {
 left:calc(var(--grip-edge) + env(safe-area-inset-left));
 bottom:calc(34px + env(safe-area-inset-bottom));
 width:clamp(112px,32vw,132px);height:clamp(112px,32vw,132px);
}
html[data-controls=touch] .arcade-player .actions {
 right:calc(var(--grip-edge) + env(safe-area-inset-right));
 bottom:calc(48px + env(safe-area-inset-bottom));
 gap:14px;grid-template-columns:repeat(2,62px);
}
html[data-controls=touch] .arcade-player .actions button {width:62px;height:62px;min-height:44px;touch-action:none}
/* One / two-button games keep the primary action under the outer right thumb.
   Secondary action sits above it, rather than pushing fire toward the stick. */
html[data-controls=touch] .arcade-player .arcade-controller .actions[data-count="1"],
html[data-controls=touch] .arcade-player .arcade-controller .actions[data-count="2"] {
 grid-template-columns:68px;gap:12px;justify-items:end;
 right:calc(24px + env(safe-area-inset-right));
 bottom:calc(62px + env(safe-area-inset-bottom));
}
html[data-controls=touch] .arcade-player .actions[data-count="2"] button:first-child {order:2}
html[data-controls=touch] .arcade-player .actions[data-count="2"] button:nth-child(2) {order:1;width:56px;height:56px;margin-right:6px}
html[data-controls=touch] .arcade-player .actions[data-count="1"] button,
html[data-controls=touch] .arcade-player .actions[data-count="2"] button:first-child {width:68px;height:68px}
html[data-controls=touch] .arcade-player .action-key {font-size:17px}
html[data-controls=touch] .arcade-player .action-caption {font-size:10px;color:#fff8e1}
html[data-controls=touch] .arcade-player .arcade-controller .actions[data-count="6"] {grid-template-columns:repeat(3,48px);gap:10px}
html[data-controls=touch] .arcade-player .actions[data-count="6"] button {width:48px;height:48px}
html[data-controls=touch] .arcade-player .rotate-tip {bottom:calc(var(--grip-height) - 30px);margin:0;font-size:10px;color:#a8b9a5}
html[data-controls=touch] .arcade-player #cover {padding:18px;gap:12px;justify-content:safe center}
html[data-controls=touch] .arcade-player #cover h1 {font-size:clamp(23px,5vw,36px)}
html[data-controls=touch] .arcade-player .boot-emblem {width:84px;height:84px}
html[data-controls=touch] .arcade-player .boot-emblem>.ph {font-size:38px}
@media(orientation:portrait) and (max-width:360px) {
 html[data-controls=touch] .arcade-player {--grip-height:calc(208px + env(safe-area-inset-bottom))}
 html[data-controls=touch] .arcade-player .arcade-controller .actions[data-count="6"] {grid-template-columns:repeat(3,44px);gap:8px}
 html[data-controls=touch] .arcade-player .actions[data-count="6"] button {width:44px;height:44px}
 html[data-controls=touch] .arcade-player .system-buttons {left:calc(7px + env(safe-area-inset-left))}
}
@media(orientation:portrait) and (max-height:740px) {
 html[data-controls=touch] .arcade-player .boot-emblem {display:none}
 html[data-controls=touch] .arcade-player #cover {padding:14px;gap:8px}
}
/* Landscape: a central display between two independent thumb zones. */
@media(orientation:landscape) {
 html[data-controls=touch] .arcade-player {--grip-rail:clamp(158px,23vw,210px)}
 html[data-controls=touch] .arcade-player .cabinet .screen {
  inset:var(--hud-height) calc(var(--grip-rail) + env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) calc(var(--grip-rail) + env(safe-area-inset-left));
  height:calc(100% - var(--hud-height) - 8px - env(safe-area-inset-bottom));
 }
 html[data-controls=touch] .arcade-player .touch::before {
  inset:var(--hud-height) 0 0;height:auto;border:0;
  background:linear-gradient(90deg,#17251d 0,transparent var(--grip-rail),transparent calc(100% - var(--grip-rail)),#17251d 100%);
 }
 html[data-controls=touch] .arcade-player .dpad {
  left:calc(22px + env(safe-area-inset-left));
  bottom:calc(40px + env(safe-area-inset-bottom));width:124px;height:124px;
 }
 html[data-controls=touch] .arcade-player .actions {right:calc(18px + env(safe-area-inset-right));bottom:calc(42px + env(safe-area-inset-bottom))}
 html[data-controls=touch] .arcade-player .arcade-controller .actions[data-count="1"],
 html[data-controls=touch] .arcade-player .arcade-controller .actions[data-count="2"] {right:calc(32px + env(safe-area-inset-right));bottom:calc(70px + env(safe-area-inset-bottom))}
 html[data-controls=touch] .arcade-player .arcade-controller .actions[data-count="6"] {grid-template-columns:repeat(3,52px);gap:10px}
 html[data-controls=touch] .arcade-player .actions[data-count="6"] button {width:52px;height:52px}
 html[data-controls=touch] .arcade-player #cover {padding:12px;gap:8px}
 html[data-controls=touch] .arcade-player .boot-emblem {display:none}
 html[data-controls=touch] .arcade-player .rotate-tip {display:none}
}
@media(orientation:landscape) and (max-height:360px) {
 html[data-controls=touch] .arcade-player {--hud-height:calc(58px + env(safe-area-inset-top))}
 html[data-controls=touch] .arcade-player .dpad {width:112px;height:112px;left:calc(18px + env(safe-area-inset-left));bottom:calc(28px + env(safe-area-inset-bottom))}
 html[data-controls=touch] .arcade-player .arcade-controller .actions[data-count="1"],
 html[data-controls=touch] .arcade-player .arcade-controller .actions[data-count="2"] {bottom:calc(50px + env(safe-area-inset-bottom))}
 html[data-controls=touch] .arcade-player .arcade-controller .actions[data-count="6"] {grid-template-columns:repeat(3,44px);gap:8px;right:calc(10px + env(safe-area-inset-right));bottom:calc(30px + env(safe-area-inset-bottom))}
 html[data-controls=touch] .arcade-player .actions[data-count="6"] button {width:44px;height:44px}
 html[data-controls=touch] .arcade-player #cover h1 {font-size:22px}
 html[data-controls=touch] .arcade-player #cover .boot {font-size:10px}
}
/* Short English hardware legends stay visible even on the narrowest phones. */
.arcade-player .system-buttons button span {font-family:monospace;letter-spacing:.06em}
html[data-controls=touch] .arcade-player .system-buttons {gap:6px}
html[data-controls=touch] .arcade-player .system-buttons button,
html[data-controls=touch] .arcade-player .system-buttons button:first-child,
html[data-controls=touch] .arcade-player .system-buttons button[data-code=KeyP] {width:auto;min-width:56px;padding:8px 9px;font:700 10px/1.2 monospace}
html[data-controls=touch] .arcade-player .system-buttons button i {display:none}
html[data-controls=touch] .arcade-player .system-buttons button span,
html[data-controls=touch] .arcade-player .system-buttons button:first-child span,
html[data-controls=touch] .arcade-player .system-buttons button[data-code=KeyP] span {display:block}
html[data-controls=touch] .arcade-player #fullscreen {font:700 9px/1.2 monospace;letter-spacing:.02em;padding:8px;min-height:44px}
