/* ================================================================
   v182 — 모바일 본진 전투열 5장 기준 카드 비율 유지
   ================================================================
   본진 전투열은 모바일 화면 너비를 5등분하되, 필드 카드와 같은
   가로:세로 비율(1 : 1.767)을 사용한다. 이전 패치의 고정 높이를
   제거하여 화면이 좁아질 때 세로만 늘어나는 현상을 방지한다.
   ================================================================ */

@media (max-width:850px){
  body.ui-mode-mobile:not(.prebattle),
  body.ui-mode-mobile-preview:not(.prebattle){
    --v182-hq-card-ratio:1.767;
    --v182-hq-grid-gap:4px;
  }

  body.ui-mode-mobile:not(.prebattle) .hq-defense-lane.active,
  body.ui-mode-mobile-preview:not(.prebattle) .hq-defense-lane.active{
    height:auto!important;
    min-height:0!important;
    max-height:none!important;
    padding:4px 5px!important;
    overflow:hidden!important;
  }

  body.ui-mode-mobile:not(.prebattle) .hq-defense-lane .hq-battlefield-grid,
  body.ui-mode-mobile-preview:not(.prebattle) .hq-defense-lane .hq-battlefield-grid{
    display:grid!important;
    grid-template-columns:repeat(5,minmax(0,1fr))!important;
    grid-template-rows:auto!important;
    grid-auto-rows:auto!important;
    width:min(100%,430px)!important;
    max-width:100%!important;
    height:auto!important;
    min-height:0!important;
    max-height:none!important;
    gap:var(--v182-hq-grid-gap)!important;
    margin:0 auto!important;
    padding:0!important;
    align-items:start!important;
    justify-content:center!important;
    overflow:visible!important;
  }

  body.ui-mode-mobile:not(.prebattle) .hq-defense-lane .hq-field-slot,
  body.ui-mode-mobile-preview:not(.prebattle) .hq-defense-lane .hq-field-slot{
    box-sizing:border-box!important;
    width:100%!important;
    min-width:0!important;
    max-width:none!important;
    height:auto!important;
    min-height:0!important;
    max-height:none!important;
    aspect-ratio:1 / var(--v182-hq-card-ratio)!important;
    align-self:start!important;
  }

  body.ui-mode-mobile:not(.prebattle) .hq-defense-lane .hq-field-slot>.unit,
  body.ui-mode-mobile-preview:not(.prebattle) .hq-defense-lane .hq-field-slot>.unit{
    box-sizing:border-box!important;
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;
    height:100%!important;
    min-height:0!important;
    max-height:100%!important;
    grid-template-rows:15.2% minmax(0,1fr) 17.7%!important;
  }

  body.ui-mode-mobile:not(.prebattle) .hq-defense-lane .hq-advisor-field-slot .hq-advisor-slot,
  body.ui-mode-mobile:not(.prebattle) .hq-defense-lane .hq-advisor-field-slot .advisor,
  body.ui-mode-mobile-preview:not(.prebattle) .hq-defense-lane .hq-advisor-field-slot .hq-advisor-slot,
  body.ui-mode-mobile-preview:not(.prebattle) .hq-defense-lane .hq-advisor-field-slot .advisor{
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;
    height:100%!important;
    min-height:0!important;
    max-height:100%!important;
  }

  body.ui-mode-mobile:not(.prebattle) .hq-defense-lane .hq-advisor-field-slot .advisor-card,
  body.ui-mode-mobile:not(.prebattle) .hq-defense-lane .hq-advisor-field-slot .advisor-image-only,
  body.ui-mode-mobile:not(.prebattle) .hq-defense-lane .hq-advisor-field-slot .advisor-portrait,
  body.ui-mode-mobile-preview:not(.prebattle) .hq-defense-lane .hq-advisor-field-slot .advisor-card,
  body.ui-mode-mobile-preview:not(.prebattle) .hq-defense-lane .hq-advisor-field-slot .advisor-image-only,
  body.ui-mode-mobile-preview:not(.prebattle) .hq-defense-lane .hq-advisor-field-slot .advisor-portrait{
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;
    height:100%!important;
    min-height:0!important;
    max-height:100%!important;
  }
}

/* 데스크톱에서 실행하는 모바일 미리보기는 창 너비가 850px보다 커도
   430px 플레이 영역을 사용하므로 동일한 5장 비율 규칙을 별도로 적용한다. */
body.ui-mode-mobile-preview:not(.prebattle){
  --v182-hq-card-ratio:1.767;
  --v182-hq-grid-gap:4px;
}
body.ui-mode-mobile-preview:not(.prebattle) .hq-defense-lane.active{
  height:auto!important;
  min-height:0!important;
  max-height:none!important;
  padding:4px 5px!important;
  overflow:hidden!important;
}
body.ui-mode-mobile-preview:not(.prebattle) .hq-defense-lane .hq-battlefield-grid{
  display:grid!important;
  grid-template-columns:repeat(5,minmax(0,1fr))!important;
  grid-template-rows:auto!important;
  grid-auto-rows:auto!important;
  width:min(100%,430px)!important;
  max-width:100%!important;
  height:auto!important;
  min-height:0!important;
  max-height:none!important;
  gap:var(--v182-hq-grid-gap)!important;
  margin:0 auto!important;
  padding:0!important;
  align-items:start!important;
  justify-content:center!important;
  overflow:visible!important;
}
body.ui-mode-mobile-preview:not(.prebattle) .hq-defense-lane .hq-field-slot{
  box-sizing:border-box!important;
  width:100%!important;
  min-width:0!important;
  max-width:none!important;
  height:auto!important;
  min-height:0!important;
  max-height:none!important;
  aspect-ratio:1 / var(--v182-hq-card-ratio)!important;
  align-self:start!important;
}
body.ui-mode-mobile-preview:not(.prebattle) .hq-defense-lane .hq-field-slot>.unit{
  box-sizing:border-box!important;
  width:100%!important;
  min-width:0!important;
  max-width:100%!important;
  height:100%!important;
  min-height:0!important;
  max-height:100%!important;
  grid-template-rows:15.2% minmax(0,1fr) 17.7%!important;
}
