/* Super Soldier Battle - mobile landscape layout (20261115mobile1).
   Everything is scoped to body.ssb-touch, which js/ssb-mobile-controls.js only sets on touch /
   coarse-pointer devices, so none of this applies on desktop. Control sizes come from
   css/mobile-gameplay-hud.css (the FPS Game Starter's shared mg-* contract). */

/* Right-half pointer-look fallback (FPS starter #lookZone). Real phones look via document Touch Events. */
#ssbLookZone { position: fixed; top: 0; right: 0; width: 50%; height: 100%; z-index: 5; display: none; touch-action: none; user-select: none; -webkit-user-select: none; }
body.ssb-touch-play #ssbLookZone { display: block; }
body.ssb-touch-play { touch-action: none; overscroll-behavior: none; }

/* Controls sit above the SSB HUD layers AND #appWrapper (position:fixed, z-index 10000, full
   screen), which would otherwise swallow every touch. */
body.ssb-touch { --mg-z-controls: 10050; --mg-z-corner: 10060; }
body.ssb-touch #ssbLookZone { z-index: 10040; }

/* The game CSS clamps every div/button (min/max-width 300px, margin-top, digital font,
   brown background). Pin our controls' box so the shared mg-* sizes win. */
#ssbTouchControls, #ssbTouchControls div, #ssbTouchControls button { min-width: 0 !important; max-width: none !important; margin: 0 !important; box-sizing: border-box !important; }
#ssbTouchControls button { font-family: Arial, Helvetica, sans-serif !important; }
#ssbLookZone { width: 50% !important; }
#ssbJoy { width: var(--mg-joy-size) !important; height: var(--mg-joy-size) !important; }
#ssbJoyKnob { width: var(--mg-knob-size) !important; height: var(--mg-knob-size) !important; margin: calc(var(--mg-knob-size) / -2) 0 0 calc(var(--mg-knob-size) / -2) !important; }
#ssbFireBtn { width: var(--mg-fire-size) !important; height: var(--mg-fire-size) !important; font-size: 14px !important; background: var(--mg-fire-bg) !important; }
#ssbJumpBtn { width: var(--mg-jump-size) !important; height: var(--mg-jump-size) !important; font-size: 13px !important; background: var(--mg-jump-bg) !important; }
#ssbTouchExit, #ssbTouchMax { width: var(--mg-corner-size) !important; height: var(--mg-corner-size) !important; }
#ssbTouchExit { background: var(--mg-exit-bg) !important; }
#ssbTouchMax { background: var(--mg-max-bg) !important; }
#ssbRotate { width: auto !important; }
body.ssb-touch .mg-btn.on { filter: brightness(1.35); transform: scale(0.94); }

/* Small extra buttons: RELOAD (above JUMP) and SHIELD (above FIRE). */
.ssb-mini { width: 46px !important; height: 46px !important; font-size: 9px !important; letter-spacing: 0; background: rgba(15,23,42,0.8) !important; color: #e2e8f0 !important; border-color: rgba(34,211,238,0.8) !important; }
#ssbReloadBtn { right: calc(var(--mg-jump-x) + 4px + var(--mg-safe-r)); bottom: calc(var(--mg-jump-y) + var(--mg-jump-size) + 10px + var(--mg-safe-b)); }
#ssbShieldBtn { right: calc(var(--mg-fire-x) + 14px + var(--mg-safe-r)); bottom: calc(var(--mg-fire-y) + var(--mg-fire-size) + 10px + var(--mg-safe-b)); }

/* Rotate prompt: the whole game page comes after PLAY, so portrait always shows it. */
body.ssb-touch.mg-portrait.ssb-played #ssbRotate { display: flex; }   /* mobile6: only after PLAY (FPS demo flow) */

/* HUD must not crowd the thumbs: move the bottom-right minimap to the top right (under the
   X / fullscreen corner buttons) and the bottom-left item slots up off the joystick. */
body.ssb-touch #vhud2 #vhud2-map { bottom: auto; top: calc(var(--mg-corner-top) + var(--mg-corner-size) + var(--mg-corner-gap) + var(--mg-safe-t)); right: calc(14px + var(--mg-safe-r)); width: 76px; height: 76px; transform: none; }
body.ssb-touch #vhud2 #vhud2-mapframe { display: none; }
body.ssb-touch #vhud2 #vhud2-items { bottom: auto; top: 30vh; left: calc(8px + var(--mg-safe-l)); transform: scale(0.8); transform-origin: left top; }
body.ssb-touch #vhud2 #vhud2-teams { top: calc(142px + var(--mg-safe-t)); right: calc(14px + var(--mg-safe-r)); transform: none; }
body.ssb-touch #sceneGameMapBottomRightWrapper.gameplay-mode { bottom: auto !important; top: calc(var(--mg-corner-top) + var(--mg-corner-size) + var(--mg-corner-gap) + var(--mg-safe-t)) !important; }
body.ssb-touch-play #divGamePlayerListWrapper { display: none !important; }

/* Pause / team-pick menu has to fit a phone's landscape height (iPhone SE: 375px). */
@media (max-height: 500px) {
	body.ssb-touch #instructions { max-height: calc(100vh - 16px); overflow-y: auto; -webkit-overflow-scrolling: touch; box-sizing: border-box; }
	body.ssb-touch #ssbTeamPrompt { font-size: 1.15rem !important; margin-bottom: 8px !important; letter-spacing: 2px !important; }
	body.ssb-touch #ssbTeamMenu { gap: 6px !important; }
	body.ssb-touch #ssbTeamMenu .ssb-team-btn { min-height: 0 !important; padding-top: 4px !important; padding-bottom: 4px !important; }
	body.ssb-touch #divGameTitleHeader { transform: scale(0.55); transform-origin: center top; }
}

/* Rotate prompt text: beat the game's global div font (digital font, 1.25vw, text-shadow). */
#ssbRotate div { font-family: "Press Start 2P", monospace !important; font-size: 16px; text-shadow: none !important; color: inherit; }
#ssbRotate .mg-rot-sub { font-size: 10px !important; color: #aaa !important; }

/* ---- 20261115mobile2 ---- */
/* Game canvas pinned full-screen (fixes the black gap left/top after rotating). */
body.ssb-touch #MainGameCanvas { position: fixed !important; left: 0 !important; top: 0 !important; width: 100vw !important; height: 100vh !important; height: 100dvh !important; margin: 0 !important; padding: 0 !important; max-width: none !important; min-width: 0 !important; }
html:has(body.ssb-touch), body.ssb-touch { margin: 0 !important; padding: 0 !important; width: 100vw; height: 100vh; height: 100dvh; overflow: hidden; }

/* Speaker corner button: gameplay only, third slot left of X / fullscreen
   so it never covers the minimap (which starts below the corner row). */
.ssb-sound { right: calc(var(--mg-corner-right) + 2 * (var(--mg-corner-size) + var(--mg-corner-gap)) + var(--mg-safe-r)); background: var(--mg-max-bg) !important; font-size: 18px !important; width: var(--mg-corner-size) !important; height: var(--mg-corner-size) !important; }
/* mobile3: speaker only during play, same states as the joystick / FIRE layer. */
body.ssb-touch.ssb-touch-play .ssb-sound { display: flex; }
body.ssb-touch:not(.ssb-touch-play) .ssb-sound, body.ssb-touch.mg-portrait .ssb-sound { display: none !important; }
body.ssb-touch:not(.ssb-touch-play) #ssbMixerPop { display: none !important; }
body.ssb-mixer-open .ssb-sound { box-shadow: 0 0 0 2px var(--mg-accent), 0 2px 8px rgba(0,0,0,.45); }
#ssbMixerPop { display: none; position: fixed; z-index: 10070; top: calc(var(--mg-corner-top) + var(--mg-corner-size) + var(--mg-corner-gap) + var(--mg-safe-t)); right: calc(var(--mg-corner-right) + var(--mg-safe-r)); width: 230px !important; max-height: calc(100vh - 70px); overflow-y: auto; padding: 8px 10px !important; background: rgba(8,18,32,0.94); border: 1px solid var(--mg-accent); border-radius: 10px; touch-action: pan-y; }
body.ssb-mixer-open #ssbMixerPop { display: block; }
#ssbMixerPop #divSoundMixer { min-width: 0 !important; max-width: none !important; width: 100% !important; padding: 0 !important; font: 11px/1.3 Arial, sans-serif !important; text-shadow: none !important; }
#ssbMixerPop #divSoundMixer strong { display: none; }
#ssbMixerPop #divSoundMixer br { display: none; }
#ssbMixerPop #divSoundMixer label { display: block; margin-top: 4px; font: 11px Arial, sans-serif !important; color: #e2e8f0; }
#ssbMixerPop #divSoundMixer input[type=range] { display: block; width: 100% !important; min-width: 0 !important; max-width: none !important; margin: 2px 0 0 !important; touch-action: none; }
body.ssb-touch .ssb-touch-hidden { display: none !important; }

/* Pause / team menu: nothing of ours over it when not playing; taps are plain taps. */
body.ssb-touch:not(.ssb-touch-play) #ssbLookZone,
body.ssb-touch:not(.ssb-touch-play) #ssbJoy,
body.ssb-touch:not(.ssb-touch-play) #ssbTouchControls .mg-btn,
body.ssb-touch:not(.ssb-touch-play) #ssbTouchExit,
body.ssb-touch:not(.ssb-touch-play) #ssbTouchMax { display: none !important; pointer-events: none !important; }
body.ssb-touch #instructions, body.ssb-touch #instructions button, body.ssb-touch #playGameIcon { touch-action: manipulation; }

/* Zero every offset that can push the game layers off 0,0 on phones (Shane: black gap
   left + top). The <=800px desktop rule shoves #imgLoading 500px left at 1591px wide, the
   global div rule adds margin-top:10px, and #appWrapper is min-height:110%. */
html:has(body.ssb-touch) { position: fixed; inset: 0; }
body.ssb-touch { position: fixed !important; inset: 0 !important; border: 0 !important; }
body.ssb-touch #imgLoading { left: 0 !important; top: 0 !important; width: 100vw !important; height: 100vh !important; height: 100dvh !important; min-width: 0 !important; max-width: none !important; margin: 0 !important; padding: 0 !important; }
body.ssb-touch #imgLoading video, body.ssb-touch #imgLoading img { width: 100% !important; height: 100% !important; object-fit: cover; max-width: none !important; }
body.ssb-touch #appWrapper { left: 0 !important; top: 0 !important; margin: 0 !important; padding: 0 !important; border: 0 !important; min-height: 100% !important; }
/* Empty .instructionsControls box (old controls panel) draws a thin bar across the screen on phones. */
body.ssb-touch #divGameObjectiveInstrunctions .instructionsControls { display: none !important; }

/* mobile3: block scroll / pinch / double-tap zoom during play with touch-action (the document
   touch listeners are passive), on html + body and the game layers. */
html:has(body.ssb-touch-play), body.ssb-touch-play, body.ssb-touch-play #appWrapper, body.ssb-touch-play #MainGameCanvas { touch-action: none !important; }

/* mobile4: '#ssbTouchControls div { margin:0 !important }' out-ranked the knob's centering
   margin, so the knob sat down-right of center (looked stuck pushed). Re-center it. */
#ssbTouchControls #ssbJoyKnob { margin: calc(var(--mg-knob-size) / -2) 0 0 calc(var(--mg-knob-size) / -2) !important; }

/* mobile5: the rotate prompt follows the real layout orientation, so it can never stay up
   (or keep its portrait size) after the phone is turned to landscape. */
#ssbRotate { width: 100vw !important; height: 100vh !important; height: 100dvh !important; }
@media (orientation: landscape) { body.ssb-touch #ssbRotate { display: none !important; } }

/* mobile5: team pick / PLAY menu sized for a phone held sideways. */
@media (max-height: 500px) {
	body.ssb-touch #ssbTeamPrompt { font-size: 1rem !important; margin-bottom: 4px !important; }
	body.ssb-touch #ssbTeamMenu { gap: 5px !important; max-width: 62vw !important; }
	body.ssb-touch #ssbTeamBlue, body.ssb-touch #ssbTeamRed { font-size: 0.85rem !important; padding: 5px 10px !important; gap: 6px !important; }
	body.ssb-touch #ssbTeamBlue .ssb-team-flag-canvas, body.ssb-touch #ssbTeamRed .ssb-team-flag-canvas { width: 28px !important; height: 19px !important; }
	body.ssb-touch #divMenuContent #playGameIcon { height: 40px !important; font-size: 1.1rem !important; border-radius: 8px !important; }
	body.ssb-touch #ssbPlayWithFriend, body.ssb-touch #ssbExitBtn { font-size: 0.75rem !important; padding: 5px 10px !important; }
	body.ssb-touch #ssbExitBtn { margin-top: 0 !important; }
	body.ssb-touch #divGameTitleHeader { transform: scale(0.45); }
}

/* mobile8: landscape phone menu - wider buttons, smaller text (Shane, Nov 16). */
@media (max-height: 500px) {
	body.ssb-touch #instructions { width: 74vw !important; max-width: 74vw !important; }
	body.ssb-touch #ssbTeamMenu { width: 100% !important; max-width: none !important; gap: 6px !important; }
	body.ssb-touch #ssbTeamPrompt { font-size: 0.85rem !important; letter-spacing: 2px !important; margin-bottom: 4px !important; }
	body.ssb-touch .ssb-team-btn-row { gap: 8px !important; }
	body.ssb-touch #ssbTeamBlue, body.ssb-touch #ssbTeamRed { flex: 1 1 0 !important; min-width: 0 !important; font-size: 0.7rem !important; padding: 7px 8px !important; }
	body.ssb-touch #ssbTeamBlue .ssb-team-flag-canvas, body.ssb-touch #ssbTeamRed .ssb-team-flag-canvas { width: 22px !important; height: 15px !important; }
	body.ssb-touch #divMenuContent #playGameIcon { height: 36px !important; font-size: 0.95rem !important; }
	body.ssb-touch #ssbPlayWithFriend, body.ssb-touch #ssbExitBtn { font-size: 0.68rem !important; padding: 7px 10px !important; }
}
