body {
  background: #c0c0c0;
  color: #000;
  font-family: "Times New Roman", Times, serif;
  max-width: 640px;
  margin: 8px auto;
  padding: 0 16px;
}
a:link { color: #0000ee; }
a:visited { color: #551a8b; }
h1, .nav { text-align: center; }
address { font-style: normal; text-align: center; }
code { overflow-wrap: anywhere; }
th { text-align: left; }
td.num { text-align: right; }
#canvas { position: absolute; left: -100px; width: 64px; height: 64px; }
#beam { display: block; margin: 0 auto; width: min(100%, 67.5vh); aspect-ratio: 3 / 4; background: #000; }
#screenWrap { display: flex; justify-content: center; align-items: center; background: #000; }
#screen { display: block; image-rendering: pixelated; }
#controls button { touch-action: none; }
.tside, #turn { display: none; }
#tleft { grid-area: left; }
#tright { grid-area: right; }
body.touch { overflow: hidden; }
body.touch #status { position: fixed; z-index: 2; top: 40%; left: 0; right: 0; text-align: center; color: #fff; pointer-events: none; }
body.touch #stage {
  position: fixed; inset: 0; z-index: 1; display: grid; background: #000;
  grid-template: "pic pic" minmax(0, 1fr) "left right" max(170px, calc(100dvh - 100vw / var(--aspect))) / 1fr 1fr;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
body.touch #pic { grid-area: pic; position: relative; container-type: size; display: flex; justify-content: center; align-items: center; }
body.touch #beam { width: min(100cqw, 75cqh); }
body.touch #screenWrap { width: 100%; height: 100%; }
body.touch #turn { position: absolute; top: 0; left: 0; right: 0; margin: 4px; text-align: center; color: #fff; font-size: 14px; pointer-events: none; }
body.touch .tside { display: flex; flex-direction: column; gap: 8px; padding: 8px; min-width: 0; min-height: 0; }
.trow { display: flex; gap: 8px; }
.tgrid { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tsmall { flex: 1; min-height: 36px; touch-action: none; }
.tbtn { min-height: 56px; font-size: 20px; touch-action: none; }
.tstick { flex: 1; min-height: 0; position: relative; border: 1px solid #808080; touch-action: none; }
.tdpad { border: 0; container-type: size; }
.tpad { position: absolute; left: 50%; top: 50%; width: min(100cqw, 100cqh); height: min(100cqw, 100cqh); transform: translate(-50%, -50%); display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); pointer-events: none; }
.tpad div { border: 1px solid #808080; display: flex; align-items: center; justify-content: center; color: #c0c0c0; font-size: 20px; }
.tpad .on { background: #c0c0c0; color: #000; }
.tknob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px; border-radius: 50%; background: #c0c0c0; pointer-events: none; }
@media (orientation: landscape) {
  body.touch #stage { grid-template: "left pic right" minmax(0, 1fr) / minmax(0, 1fr) min(calc(100dvh * var(--aspect)), calc(100vw - 220px)) minmax(0, 1fr); }
  body.touch #stage[data-best="portrait"] #turn { display: block; }
}
@media (orientation: portrait) {
  body.touch #stage[data-best="landscape"] #turn { display: block; }
}
