/* Phones and tablets: the touch controls over the 3D games (js/touch/), and the site's small-screen fixes */

/* ---- the controls: a stick wherever the left thumb lands, the right side to look, and the buttons */
#touchpad { display: none; }
#touchpad.on { display: block; position: fixed; inset: 0; z-index: 80; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#touchpad.thin { pointer-events: none; }
#touchpad.thin .tcb { pointer-events: auto; }
.tcring { position: fixed; width: 112px; height: 112px; margin: -56px 0 0 -56px; border-radius: 50%; border: 2px solid rgba(255, 243, 176, 0.45); background: rgba(0, 0, 0, 0.22); display: none; pointer-events: none; }
.tcring.on { display: block; }
.tcnub { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; background: rgba(255, 243, 176, 0.55); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); }
.tcb {
  position: fixed; width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 24px; line-height: 1;
  color: #fff3b0; background: rgba(18, 20, 26, 0.5); border: 2px solid rgba(242, 182, 50, 0.55); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}
.tcb.down { background: rgba(242, 182, 50, 0.5); transform: scale(0.94); }
.tcb.hide { display: none; }
/* (the bottom corners keep clear of a phone's rounded edges and home bar) */
#touchpad .tcb { --sb: env(safe-area-inset-bottom, 0px); --sr: env(safe-area-inset-right, 0px); }

/* Goblin Arena (and the training room): fire under the right thumb, everything else round it */
#touchpad.arena .tcb[data-id=fire] { width: 84px; height: 84px; font-size: 34px; right: calc(96px + var(--sr)); bottom: calc(64px + var(--sb)); background: rgba(179, 32, 44, 0.6); }
#touchpad.arena .tcb[data-id=jump] { right: calc(18px + var(--sr)); bottom: calc(112px + var(--sb)); }
#touchpad.arena .tcb[data-id=crouch] { right: calc(18px + var(--sr)); bottom: calc(40px + var(--sb)); }
#touchpad.arena .tcb[data-id=aim] { right: calc(196px + var(--sr)); bottom: calc(36px + var(--sb)); }
#touchpad.arena .tcb[data-id=reload] { right: calc(196px + var(--sr)); bottom: calc(108px + var(--sb)); width: 50px; height: 50px; font-size: 21px; }
#touchpad.arena .tcb[data-id=swap] { right: calc(110px + var(--sr)); bottom: calc(164px + var(--sb)); width: 50px; height: 50px; font-size: 21px; }
#touchpad.arena .tcb[data-id=nade] { right: calc(24px + var(--sr)); bottom: calc(184px + var(--sb)); width: 48px; height: 48px; font-size: 20px; }
#touchpad.arena .tcb[data-id=knife] { right: calc(262px + var(--sr)); bottom: calc(28px + var(--sb)); width: 48px; height: 48px; font-size: 20px; }
#touchpad.arena .tcb[data-id=use] { left: 50%; bottom: calc(96px + var(--sb)); transform: translateX(-50%); width: 64px; height: 64px; background: rgba(60, 110, 30, 0.6); }
#touchpad.arena .tcb[data-id=holster] { right: calc(168px + var(--sr)); bottom: calc(172px + var(--sb)); width: 48px; height: 48px; font-size: 20px; }
#touchpad .tcb[data-id=pause] { top: 8px; right: calc(12px + var(--sr)); width: 44px; height: 44px; font-size: 18px; }
#touchpad .tcb[data-id=tab] { top: 8px; right: calc(64px + var(--sr)); width: 44px; height: 44px; font-size: 18px; }
#touchpad .tcb[data-id=emote] { top: 8px; right: calc(116px + var(--sr)); width: 44px; height: 44px; font-size: 18px; }
#touchpad .tcb[data-id=streak] { top: 8px; right: calc(116px + var(--sr)); width: 44px; height: 44px; font-size: 18px; }

/* a shooter wants the phone on its side */
.tcturn { display: none; position: fixed; left: 50%; top: 64px; transform: translateX(-50%); padding: 6px 14px; border-radius: 99px; background: rgba(0, 0, 0, 0.6); color: #fff3b0; font: 14px var(--f-ui); pointer-events: none; white-space: nowrap; }
@media (orientation: portrait) { #touchpad.arena .tcturn { display: block; top: 100px; } }

/* the game's own pieces, moved out from under the thumbs */
body.touchplaying #gsfeed { top: 96px; }
/* (the place and who's here goes under the row of little buttons along the top, right-hand side: centred, it sat over
   them, and 🎵, 🙂 and 📋 were lost behind its words on a phone) */
body.touchplaying #gsscore { top: 58px; left: auto; right: calc(12px + env(safe-area-inset-right, 0px)); transform: none; max-width: calc(100% - 140px); font-size: 13px; padding: 3px 10px; }
body.touchplaying #gsstreaks { bottom: auto; top: 120px; }

/* ---- the rest of the site on a small screen: nothing wider than the screen, wide tables scroll sideways in their
   place, and typing into a box doesn't zoom the page on iPhones */
@media (max-width: 600px) {
  html, body { overflow-x: clip; }
  img, video { max-width: 100%; }
  .thtable, .gstable { display: block; max-width: 100%; overflow-x: auto; }
  input, select, textarea { font-size: max(16px, 1em); }
}
