/* 기존 게임 카드·버튼을 재배치한다. 동적으로 추가되는 스타일보다 구체적으로 지정. */
body.touch #hudL { left: calc(70px + env(safe-area-inset-left)); max-width: calc(100% - 230px - env(safe-area-inset-left) - env(safe-area-inset-right)); }
body.touch #status { max-width: 100%; box-sizing: border-box; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.touch #xp { left: calc(12px + env(safe-area-inset-left)); }
body.touch #inquiryGo { right: calc(12px + env(safe-area-inset-right)); }
body.touch #donateGo { right: calc(68px + env(safe-area-inset-right)); }
body.touch #rally { font-size: clamp(14px, 3.8vw, 20px); }
@media (max-width: 560px) and (orientation: portrait) {
  body.touch #hudL { max-width: calc(100% - 210px - env(safe-area-inset-left) - env(safe-area-inset-right)); }
  body.touch #rally { font-size: 14px; white-space: nowrap; }
}
body.touch #stage :is(#qMenu, #wMenu) { box-sizing: border-box; max-height: calc(100dvh - 100px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y: auto; }

@media (orientation: landscape) and (max-height: 540px) {
  /* 아래 모서리 조작부 사이의 중앙은 캐릭터와 코트에 남긴다. */
  body.touch #acts { max-width: min(280px, calc(100% - 151px - env(safe-area-inset-left) - env(safe-area-inset-right))); }
  body.touch #acts #mine { display: flex; align-items: center; gap: 4px; }
  body.touch #acts #mine[hidden] { display: none; }
  body.touch #acts #mine #megaGo { position: static; width: 48px; height: 44px; margin-left: 4px; flex-direction: column; padding: 2px; }
  body.touch #acts #mine #megaGo:not(.on) { display: none; }
  body.touch #acts.mega-only #mine { bottom: 0; }
  #stage #sortBox { top: 62%; } /* 콕 정리방: 위 정리판(sortHud) 아래로 */
  #stage #sortPlus { top: 84%; font-size: 40px; }
  body.touch #acts.mega-only:has(> button:not([hidden])) #mine { bottom: calc(100% + 8px); } /* 콕 정리방 「콕 정리」처럼 버튼이 같이 있으면 채팅은 그 위 */
  body.touch #serveGo small { font-weight: 700; }
  body.touch #stage :is(#sgBtn, #dgBtn) { width: 88px; height: 88px; }
  /* 낮은 가로 화면: 세로 줄이 위 경험치 칸에 닿지 않게 스윙 버튼 왼쪽에 아래부터 쌓는다 */
  body.touch #stage :is(#sgDock, #dgDock) { right: calc(116px + env(safe-area-inset-right)); bottom: calc(26px + env(safe-area-inset-bottom)); }
  body.touch #stage :is(#sgTop, #dgTop) { top: calc(62px + env(safe-area-inset-top)); width: min(52vw, 360px); gap: 4px; }
  body.touch #stage :is(#sgScore, #dgScore) { box-sizing: border-box; padding: 4px 10px; }
  body.touch #stage :is(#sgNum, #dgNum) { font-size: 22px; }
  body.touch #stage :is(#call, #start, #result, .sgModal, .dgModal) { top: 50%; box-sizing: border-box; max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y: auto; padding: 12px 18px; }
  body.touch #stage #startNum { font-size: 48px; }
  body.touch #stage #resNum { font-size: 40px; }
  body.touch #join { overflow-y: auto; box-sizing: border-box; padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left)); }
  body.touch #join .box { max-height: 100%; overflow-y: auto; padding: 14px 18px; }
}

/* 왼손 조작(설정 「조이스틱 위치」 오른쪽): 아래쪽 조작부를 좌우로 바꾼다. 위쪽 HUD는 그대로 */
body.touch.lefty #stage #pad { left: auto; right: calc(16px + env(safe-area-inset-right)); }
body.touch.lefty #stage #acts { right: auto; left: calc(16px + env(safe-area-inset-left)); justify-content: flex-start; }
body.touch.lefty #stage #acts #mine, body.touch.lefty #stage #acts #mine #megaGo { right: auto; left: -1px; }
body.touch.lefty #stage .activity-exit, body.touch.lefty #bar .activity-exit { left: auto; right: calc(16px + env(safe-area-inset-right)); }
body.touch.lefty #stage #towerLeaveBtn, body.touch.lefty #stage #sortLeaveBtn, body.touch.lefty #bar #exit { right: auto; left: calc(16px + env(safe-area-inset-left)); }
body.touch.lefty #stage #galBar { left: auto; right: calc(132px + env(safe-area-inset-right)); }
body.touch.lefty #stage #galBar .activity-exit { left: auto; right: calc(16px + env(safe-area-inset-right)); }
body.touch.lefty #opSayGo { left: auto; right: 12px; }
body.touch.lefty #stage :is(#sgBtn, #dgBtn) { right: auto; left: calc(18px + env(safe-area-inset-left)); }
body.touch.lefty #stage :is(#sgDock, #dgDock) { right: auto; left: calc(16px + env(safe-area-inset-left)); align-items: flex-start; }
@media (orientation: landscape) and (max-height: 540px) {
  body.touch.lefty #stage :is(#sgDock, #dgDock) { left: calc(116px + env(safe-area-inset-left)); }
}
