/* v215 — 전투 메뉴 단순화 / 설정 라벨 확대 / 카드 20% 확대 / 전투열 좌측 밀착 */

/* 모바일에서는 기존 전투 설정 제목을 유지한다. */
.v215-setup-labels .v215-desktop-setup-label{display:none;}
.v215-setup-labels .v215-mobile-setup-title{display:inline;}

@media (min-width:851px){
  body.unified-left-layout:not(.ui-mode-mobile-preview){
    /* v198 최종 높이 132px의 120%, 비율 2.5 : 3.5 */
    --v215-card-h:158.4px;
    --v215-card-w:113.142857px;
    --v215-field-gap:6px;
    --v215-hand-section-h:355px;
    --v215-formation-w:708.857142px;
    --v215-five-card-w:589.714285px;
    --v215-four-card-w:470.571428px;
    --v215-three-card-w:351.428571px;
    --v215-two-card-w:232.285714px;
    --v215-lane-h:162px;
    --hand-card-width:var(--v215-card-w);
    --hand-card-height:var(--v215-card-h);
  }

  /* 왼쪽 UI 폭을 고정해 3장의 핸드 카드가 내부 폭을 정확히 채우게 한다. */
  body.unified-left-layout:not(.ui-mode-mobile-preview) .app,
  body.unified-left-layout:not(.ui-mode-mobile-preview) .app[style]{
    grid-template-columns:352px minmax(720px,1fr)!important;
    column-gap:0!important;
    gap:0!important;
  }

  /* 1) '전투 메뉴' 제목 줄과 외곽 박스를 제거한다. */
  body.unified-left-layout:not(.ui-mode-mobile-preview) .left-menu-dock{
    padding:0 5px 5px!important;
    border:0!important;
    border-bottom:0!important;
    background:transparent!important;
    box-shadow:none!important;
  }
  body.unified-left-layout:not(.ui-mode-mobile-preview) .left-menu-dock>.ornate-title{
    display:none!important;
  }
  body.unified-left-layout:not(.ui-mode-mobile-preview) #leftMenuMount,
  body.unified-left-layout:not(.ui-mode-mobile-preview) #leftMenuMount .reference-topbar{
    margin:0!important;
    padding:0!important;
    border:0!important;
    background:transparent!important;
    box-shadow:none!important;
  }
  body.unified-left-layout:not(.ui-mode-mobile-preview) #leftMenuMount .top-card-actions{
    display:grid!important;
    grid-template-columns:repeat(3,minmax(0,1fr))!important;
    gap:5px!important;
    width:100%!important;
  }
  body.unified-left-layout:not(.ui-mode-mobile-preview) #leftMenuMount .top-card-actions #cardShopBtn,
  body.unified-left-layout:not(.ui-mode-mobile-preview) #leftMenuMount .top-card-actions #boosterPackBtn,
  body.unified-left-layout:not(.ui-mode-mobile-preview) #leftMenuMount .top-card-actions #cardManagerBtn{
    display:flex!important;
    align-items:center!important;
    justify-content:center!important;
    width:100%!important;
    min-width:0!important;
    height:36px!important;
    min-height:36px!important;
    max-height:36px!important;
    padding:4px 5px!important;
    font-size:11px!important;
    font-weight:900!important;
    line-height:1.1!important;
    white-space:nowrap!important;
  }
  body.unified-left-layout:not(.ui-mode-mobile-preview) #leftMenuMount .top-card-actions #cardManagerBtn{
    border-color:#7c5cff!important;
    background:linear-gradient(180deg,#4932a8,#281568)!important;
    color:#f5efff!important;
  }
  body.unified-left-layout:not(.ui-mode-mobile-preview) .left-auth-logged-in{
    grid-template-columns:minmax(0,1fr) minmax(72px,auto)!important;
  }

  /* 관리자 권한이 없거나 hidden 상태이면 기존 접근 제어를 유지한다. */
  html:not(.is-card-admin) body.unified-left-layout:not(.ui-mode-mobile-preview) #leftMenuMount .top-card-actions #cardManagerBtn,
  body.unified-left-layout:not(.ui-mode-mobile-preview) #leftMenuMount .top-card-actions #cardManagerBtn[hidden]{
    display:none!important;
  }
  html:not(.is-card-admin) body.unified-left-layout:not(.ui-mode-mobile-preview) #leftMenuMount .top-card-actions{
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
  }

  /* 2) 전투진영 / 덱설정 / 덱편집 라벨 및 조작 글씨 확대 */
  body.unified-left-layout:not(.ui-mode-mobile-preview) .v215-setup-labels{
    display:grid!important;
    grid-template-columns:82px minmax(0,1fr) 76px!important;
    align-items:center!important;
    gap:5px!important;
    height:34px!important;
    min-height:34px!important;
    padding:0 7px!important;
    margin:0 -7px 6px!important;
  }
  body.unified-left-layout:not(.ui-mode-mobile-preview) .v215-setup-labels .v215-mobile-setup-title{
    display:none!important;
  }
  body.unified-left-layout:not(.ui-mode-mobile-preview) .v215-setup-labels .v215-desktop-setup-label{
    display:block!important;
    min-width:0!important;
    color:#f3d39d!important;
    font-size:15px!important;
    font-weight:950!important;
    line-height:1!important;
    text-align:center!important;
    letter-spacing:-.04em!important;
    white-space:nowrap!important;
  }
  body.unified-left-layout:not(.ui-mode-mobile-preview) .formation-inline{
    grid-template-columns:82px minmax(0,1fr) 76px!important;
    gap:5px!important;
  }
  body.unified-left-layout:not(.ui-mode-mobile-preview) .formation-inline select,
  body.unified-left-layout:not(.ui-mode-mobile-preview) .formation-inline .btn{
    height:35px!important;
    min-height:35px!important;
    max-height:35px!important;
    padding:3px 5px!important;
    font-size:12px!important;
    font-weight:900!important;
  }

  /* 카드 애니메이션 박스: 최신 PC 높이 251px에서 5% 축소 */
  body.unified-left-layout:not(.ui-mode-mobile-preview) .left-card-effect-body{
    height:238.45px!important;
    min-height:238.45px!important;
    max-height:238.45px!important;
  }

  /* 3) 핸드 카드 20% 확대, 2.5 : 3.5 비율, 핸드 영역을 빈틈없이 채움 */
  body.unified-left-layout:not(.ui-mode-mobile-preview) .left-hand-host,
  body.unified-left-layout:not(.ui-mode-mobile-preview) .left-hand-host .right-hand-section{
    height:var(--v215-hand-section-h)!important;
    min-height:var(--v215-hand-section-h)!important;
    max-height:var(--v215-hand-section-h)!important;
  }
  body.unified-left-layout:not(.ui-mode-mobile-preview) .left-hand-host .handbox{
    padding:5px!important;
    overflow:hidden!important;
  }
  body.unified-left-layout:not(.ui-mode-mobile-preview) .left-hand-host #hand.hand{
    display:grid!important;
    grid-template-columns:repeat(3,var(--v215-card-w))!important;
    grid-template-rows:repeat(2,var(--v215-card-h))!important;
    grid-auto-rows:var(--v215-card-h)!important;
    width:100%!important;
    height:316.8px!important;
    min-height:316.8px!important;
    max-height:316.8px!important;
    gap:0!important;
    padding:0!important;
    margin:0!important;
    justify-content:start!important;
    align-content:start!important;
    overflow:hidden!important;
  }
  body.unified-left-layout:not(.ui-mode-mobile-preview) .left-hand-host #hand.hand .card{
    width:var(--v215-card-w)!important;
    min-width:var(--v215-card-w)!important;
    max-width:var(--v215-card-w)!important;
    height:var(--v215-card-h)!important;
    min-height:var(--v215-card-h)!important;
    max-height:var(--v215-card-h)!important;
    margin:0!important;
    aspect-ratio:2.5 / 3.5!important;
    border-radius:0!important;
  }

  /* 전투필드 카드도 핸드와 같은 크기와 비율로 통일 */
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel .battlefield-layout .slot,
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel .battlefield-layout .hq-field-slot{
    width:var(--v215-card-w)!important;
    min-width:var(--v215-card-w)!important;
    max-width:var(--v215-card-w)!important;
    height:var(--v215-card-h)!important;
    min-height:var(--v215-card-h)!important;
    max-height:var(--v215-card-h)!important;
    margin:0!important;
    padding:0!important;
    aspect-ratio:2.5 / 3.5!important;
    border-radius:0!important;
    overflow:hidden!important;
  }
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel .battlefield-layout .slot>.unit,
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel .battlefield-layout .hq-field-slot>.unit{
    width:100%!important;
    height:100%!important;
    min-width:0!important;
    min-height:0!important;
    max-width:none!important;
    max-height:none!important;
    border-radius:0!important;
    overflow:hidden!important;
  }

  /* 확대된 카드에 맞춰 모든 전투열 박스와 슬롯 그리드를 재계산 */
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel .battlefield-layout>.board > #enemyBaseDefenseLane,
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel .battlefield-layout>.board > .lane[data-row="e1"],
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel .battlefield-layout>.board > .lane[data-row="e2"],
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel .battlefield-layout>.board > .neutral-lane,
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel .battlefield-layout>.board > .lane[data-row="a2"],
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel .battlefield-layout>.board > .lane[data-row="a1"],
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel .battlefield-layout>.board > #allyBaseDefenseLane{
    width:var(--v215-formation-w)!important;
    min-width:var(--v215-formation-w)!important;
    max-width:var(--v215-formation-w)!important;
    height:var(--v215-lane-h)!important;
    min-height:var(--v215-lane-h)!important;
    max-height:var(--v215-lane-h)!important;
    flex:0 0 var(--v215-lane-h)!important;
    padding:1px 0 0!important;
    margin-left:0!important;
    margin-right:0!important;
    overflow:hidden!important;
    box-sizing:border-box!important;
  }
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel .battlefield-layout .slots,
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel .battlefield-layout .hq-battlefield-grid{
    height:var(--v215-card-h)!important;
    min-height:var(--v215-card-h)!important;
    max-height:var(--v215-card-h)!important;
    padding:0!important;
    gap:var(--v215-field-gap)!important;
    align-items:stretch!important;
    align-content:stretch!important;
    justify-content:center!important;
    overflow:hidden!important;
    box-sizing:border-box!important;
  }
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel .battlefield-layout .slots.n5,
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel .battlefield-layout .hq-battlefield-grid{
    display:grid!important;
    grid-template-columns:repeat(5,var(--v215-card-w))!important;
    width:var(--v215-five-card-w)!important;
    min-width:var(--v215-five-card-w)!important;
    max-width:var(--v215-five-card-w)!important;
    margin:0 auto!important;
  }
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel .battlefield-layout .slots.n4{
    display:grid!important;
    grid-template-columns:repeat(4,var(--v215-card-w))!important;
    width:var(--v215-four-card-w)!important;
    min-width:var(--v215-four-card-w)!important;
    max-width:var(--v215-four-card-w)!important;
    margin:0 auto!important;
  }
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel .battlefield-layout .slots.n3{
    display:grid!important;
    grid-template-columns:repeat(3,var(--v215-card-w))!important;
    width:var(--v215-three-card-w)!important;
    min-width:var(--v215-three-card-w)!important;
    max-width:var(--v215-three-card-w)!important;
    margin:0 auto!important;
  }
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel .battlefield-layout .slots.n2{
    display:grid!important;
    grid-template-columns:repeat(2,var(--v215-card-w))!important;
    width:var(--v215-two-card-w)!important;
    min-width:var(--v215-two-card-w)!important;
    max-width:var(--v215-two-card-w)!important;
    margin:0 auto!important;
  }

  /* 4) 전투열 박스를 왼쪽 게임창에 바로 붙임 */
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel,
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel .boardwrap,
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel .battlefield-layout,
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel .battlefield-layout>.board{
    margin-left:0!important;
    margin-right:auto!important;
    padding-left:0!important;
  }
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel .boardwrap,
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel .battlefield-layout,
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel .battlefield-layout>.board,
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel .battlefield-layout>.board>.river{
    width:var(--v215-formation-w)!important;
    min-width:var(--v215-formation-w)!important;
    max-width:var(--v215-formation-w)!important;
  }
  body.unified-left-layout:not(.ui-mode-mobile-preview) .battle-panel .battlefield-layout>.board{
    align-items:flex-start!important;
  }
}

@media (min-width:851px) and (max-height:900px){
  body.unified-left-layout:not(.ui-mode-mobile-preview) .app,
  body.unified-left-layout:not(.ui-mode-mobile-preview) .app[style]{
    grid-template-columns:352px minmax(720px,1fr)!important;
  }
  /* 낮은 화면에서 기존 238px 기준으로 동일하게 5% 축소 */
  body.unified-left-layout:not(.ui-mode-mobile-preview) .left-card-effect-body{
    height:226.1px!important;
    min-height:226.1px!important;
    max-height:226.1px!important;
  }
}
