/* ================================================================
   v139 — (1) PC 화면(강제 PC 모드 포함)에서 불필요하게 넓은 배경 영역 제거
          (2) 실제 모바일 화면에서 하단 고정 스택(본진·핸드·항복/셔플/턴종료
              버튼)을 진짜 화면 하단에 고정 + 전장 부드러운 스크롤
   game.css / mobile_preview.css / v132·v133 fix 파일보다 항상 나중에
   로드되는 최종 패치이므로 기존 규칙과 동일하거나 더 깊은 선택자로
   항상 우선 적용된다.
   ================================================================ */

/* ----------------------------------------------------------------
   (1) PC 레이아웃: 지금까지의 여러 버전이 .app/.boardwrap 등을
   100vh(또는 calc(100vh-Npx)) 고정 높이로 강제해 왔다. 평소 데스크톱
   에서는 화면 높이와 얼추 비슷해 티가 안 났지만, 휴대폰에서 "PC 버전"
   으로 전환하면 뷰포트 메타(width=1440, initial-scale=0.28)로 인해
   1vh가 실제보다 훨씬 커져, 실제 콘텐츠(전장·덱·핸드)보다 몇 배나 큰
   빈 배경이 화면 하단에 남는다. 높이를 콘텐츠 기준(auto)으로 바꿔
   이 문제를 근본적으로 해결한다. 화면이 콘텐츠보다 작을 때는
   body 스크롤로 대체한다. */
@media (min-width:851px){
  html,body{overflow:auto!important}
  .app{height:auto!important;min-height:0!important;align-items:start!important}
  .reference-left,.battle-panel,.reference-right{height:auto!important;min-height:0!important;max-height:none!important}
  .boardwrap{flex:0 0 auto!important;height:auto!important;min-height:0!important;max-height:none!important;overflow:visible!important}
  .battlefield-layout{height:auto!important;min-height:0!important}
  .battlefield-layout>.board{height:auto!important;min-height:0!important}
}

/* ----------------------------------------------------------------
   (2) 실제 모바일 화면: 하단 고정 스택이 실제로는 position:fixed가
   아니라(본진은 static, 핸드/버튼은 sticky) 일반 문서 흐름에 얹혀
   있어, 페이지 맨 위에서는 본진 바로 아래 핸드가 붙어 보이고 화면
   아래로 완전히 스크롤해야만 "고정"처럼 보였다. 세 요소 모두
   position:fixed로 화면 하단에 항상 고정하고, 전장(board)은 그
   높이만큼 padding-bottom을 확보한 채(v132에서 이미 계산) 자유롭게
   스크롤되도록 한다. */
@media (max-width:850px){
  body.ui-mode-mobile:not(.prebattle) .mobile-ally-hq-mount{
    position:fixed!important;
    left:0!important;right:0!important;width:100%!important;
    bottom:var(--dock-action-h)!important;
    z-index:88!important;
  }
  body.ui-mode-mobile:not(.prebattle) .mobile-hand-mount{
    position:fixed!important;
    left:0!important;right:0!important;width:100%!important;
    bottom:calc(var(--dock-action-h) + var(--dock-hq-h))!important;
    z-index:89!important;
  }
  body.ui-mode-mobile:not(.prebattle) .bottom-hud{
    position:fixed!important;
    left:0!important;right:0!important;width:100%!important;
    bottom:0!important;
    z-index:92!important;
  }
  /* 전장(board)이 담긴 영역이 body 스크롤로 부드럽게 넘어가도록 보장 */
  body.ui-mode-mobile:not(.prebattle){
    -webkit-overflow-scrolling:touch!important;
    overscroll-behavior-y:contain!important;
  }
}
