﻿#touch-pad[hidden], #player footer button[hidden], #stick[hidden] { display: none; }
#player.with-touch {
  position: relative; width: 100%;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
#player.with-touch #screen {
  width: min(100%, calc((100dvh - 48px - env(safe-area-inset-bottom, 0px)) * 16 / 9));
  height: min(56.25vw, calc(100dvh - 48px - env(safe-area-inset-bottom, 0px)));
  margin: 0 auto;
}
#player.with-touch canvas { position: absolute; inset: 0; }
#player.with-touch footer {
  gap: 6px; min-height: 48px;
  padding: 2px max(10px, env(safe-area-inset-right)) max(2px, env(safe-area-inset-bottom));
}
#player.with-touch footer button { min-height: 44px; touch-action: manipulation; }
#touch-pad {
  --small: clamp(44px, 12vmin, 62px);
  --large: clamp(54px, 15vmin, 75px);
  min-height: calc(var(--small) + var(--large) + 14px);
  pointer-events: none;
}
#stick-zone, #actions button {
  touch-action: none; pointer-events: auto; -webkit-tap-highlight-color: transparent;
}
#stick-zone {
  position: absolute; inset: 0 51% calc(48px + env(safe-area-inset-bottom)) 0;
  overflow: clip;
}
#stick-hint, #actions button {
  color: #fff7de; font: 700 11px/1.1 system-ui, sans-serif;
  text-shadow: 0 1px 3px #20101c, 0 0 3px #20101c;
}
#stick-hint {
  position: absolute; bottom: 15px; left: max(14px, env(safe-area-inset-left));
  padding: 6px 10px; border-radius: 20px; background: #21141cbb;
}
#stick {
  position: absolute; transform: translate(-50%, -50%); pointer-events: none;
  width: clamp(82px, 23vmin, 112px); aspect-ratio: 1; display: grid; place-items: center;
  border: 2px solid #e1b671b8; border-radius: 50%;
  background: radial-gradient(circle, #ad794e66 0 33%, #302027ab 35% 62%, #b99a6b77 64% 66%, #362831bb 68%);
  box-shadow: inset 0 1px 3px #fff0b884, 0 2px 6px #1e101a99;
}
#actions {
  position: absolute; right: max(12px, env(safe-area-inset-right));
  bottom: calc(52px + env(safe-area-inset-bottom)); width: calc(3 * var(--small) + 8px);
  display: grid; grid-template-columns: repeat(6, 1fr); row-gap: 3px; justify-items: center;
}
#actions button {
  position: relative; isolation: isolate; display: flex; align-items: flex-end; justify-content: center;
  width: var(--small); height: calc(var(--small) + 3px); min-height: 44px;
  grid-column: span 2; padding: 0 0 1px; border: 0; background: none; border-radius: 40%;
  white-space: nowrap;
}
#actions button[data-input="16"], #actions button[data-input="32"] {
  grid-column: span 3; width: var(--large); height: calc(var(--large) + 3px); font-size: 12px;
}
#actions button::before, #stick i {
  content: ""; position: absolute; width: 100%; aspect-ratio: 1; pointer-events: none;
  background-image: url("workshop-controls.webp"); background-size: 300% 200%;
  background-position: var(--tile); background-repeat: no-repeat;
  clip-path: circle(46.8% at 49.6% 49%);
}
#actions button::before { top: -1px; z-index: -1; filter: drop-shadow(0 2px 2px #22101bcc); }
#actions button[data-input="16"] { --tile: 0% 0%; }
#actions button[data-input="32"] { --tile: 50% 0%; }
#actions button[data-input="64"] { --tile: 100% 0%; }
#actions button[data-input="128"] { --tile: 0% 100%; }
#actions button[data-input="256"] { --tile: 50% 100%; }
#stick i { --tile: 100% 100%; width: 52%; }
#actions button.active::before { transform: translateY(2px) scale(.91); filter: brightness(1.26); }
#player footer button.active { background: #f7d69b; color: #351f2e; }
@media (orientation: landscape) {
  #touch-pad { min-height: 0; }
}
/* The WebGL drawing buffer follows the canvas client size. Remove the windowed
   aspect ratio and put controls on top of the canvas in either fullscreen mode. */
#player.full-window {
  position: fixed; inset: 0; z-index: 10; width: 100%; height: 100%; height: 100dvh;
  overflow: hidden; background: #17121c;
}
#player.full-window #screen {
  position: absolute; inset: 0; width: 100%; height: 100%; aspect-ratio: auto; margin: 0;
}
#player.full-window #stick-zone { bottom: 0; }
#player.full-window #stick-hint { bottom: max(14px, env(safe-area-inset-bottom)); }
#player.full-window #actions { bottom: max(9px, env(safe-area-inset-bottom)); }
#player.full-window footer {
  position: absolute; z-index: 1; right: max(8px, env(safe-area-inset-right));
  top: max(11vmin, env(safe-area-inset-top)); min-height: 0; padding: 0;
}
#player.full-window footer button {
  font-size: 12px; padding: 4px 10px; background: #2b1a23d9; border-color: #b79156;
}
#player.full-window #fullscreen { width: 44px; padding: 0; font-size: 0; }
#player.full-window #fullscreen::before { content: "⛶"; font: 22px/1 system-ui, sans-serif; }
