/* =====================================================================
 * GoPower Web PC · V131.2.14 responsive audit final overrides
 * Loaded last on purpose: several mode-specific stylesheets are loaded after
 * pc.css and previously restored 1080px minimum widths / fixed three-column
 * geometries. This file is the final narrow-window safety net.
 * ===================================================================== */

/* Long dynamic labels must be shrinkable even inside late mode styles. */
.topbar .brand,
.topbar-user,
.user-chip,
.autogo-top-title,
.battle-top-title,
.train-play,
.train-board-column,
.train-side-stack,
.battle-wing-card,
.train-match-panel{
  min-width:0!important;
}

@media (min-width:901px) and (max-width:1099px){
  /* The PC site must fit the browser viewport instead of pretending every
     901px+ window is at least 1080px wide. */
  html,body,.web-shell,
  body.train-autogo-open,
  body.train-team-open,
  body.train-challenge-open,
  body.train-stage-open{
    min-width:0!important;
    max-width:100vw!important;
    overflow-x:hidden!important;
  }

  body.train-autogo-open .topbar,
  body.train-team-open .topbar,
  body.train-challenge-open .topbar,
  body.train-stage-open .topbar{
    min-width:0!important;
    padding-inline:14px!important;
  }
  body.train-autogo-open .topbar .brand,
  body.train-team-open .topbar .brand,
  body.train-challenge-open .topbar .brand,
  body.train-stage-open .topbar .brand{
    width:auto!important;
    min-width:0!important;
    max-width:200px!important;
    flex:0 1 200px!important;
  }
  body.train-autogo-open .topbar-user,
  body.train-team-open .topbar-user,
  body.train-challenge-open .topbar-user,
  body.train-stage-open .topbar-user{
    min-width:0!important;
    max-width:210px!important;
    flex:0 1 210px!important;
    margin-left:auto!important;
  }
  body.train-autogo-open .topbar .brand-wordmark img,
  body.train-team-open .topbar .brand-wordmark img,
  body.train-challenge-open .topbar .brand-wordmark img,
  body.train-stage-open .topbar .brand-wordmark img{
    width:104px!important;
    max-width:104px!important;
  }
  body.train-autogo-open .topbar .brand-tag,
  body.train-team-open .topbar .brand-tag,
  body.train-challenge-open .topbar .brand-tag,
  body.train-stage-open .topbar .brand-tag{
    display:none!important;
  }
  .autogo-top-title,
  .battle-top-title{max-width:34vw!important;gap:6px!important}
  .autogo-top-title b,
  .battle-top-title b{font-size:20px!important;white-space:nowrap!important}
  .autogo-top-title small,
  .battle-top-title small{display:none!important}

  /* 自走棋：压缩左右角色区，棋盘永远以中央剩余空间为上限。 */
  .train-play[data-train-mode="aiAuto"]{
    width:calc(100vw - 18px)!important;
    grid-template-columns:clamp(164px,18vw,194px) minmax(0,1fr) clamp(202px,22vw,238px)!important;
    gap:8px!important;
  }
  .train-play[data-train-mode="aiAuto"] .train-board-wrap{
    width:min(100%,calc(100dvh - 128px),590px)!important;
    height:auto!important;
    max-width:100%!important;
    max-height:calc(100dvh - 128px)!important;
    aspect-ratio:1/1!important;
    flex:0 1 auto!important;
    border-radius:24px!important;
    padding:7px!important;
  }
  .train-play[data-train-mode="aiAuto"] .train-auto-enemy-wing,
  .train-play[data-train-mode="aiAuto"] .train-side-stack{
    overflow-x:hidden!important;
    overflow-y:auto!important;
    overscroll-behavior:contain!important;
    scrollbar-width:none!important;
  }
  .train-play[data-train-mode="aiAuto"] .train-auto-enemy-wing::-webkit-scrollbar,
  .train-play[data-train-mode="aiAuto"] .train-side-stack::-webkit-scrollbar{display:none!important}

  /* 联棋 / 单挑：原来的晚加载样式最少需要约 1240px，901~1099px 会
     被硬挤出屏幕。窄窗口改成更瘦的双侧栏，中心仍保持完整正方形棋盘。 */
  .train-play[data-train-mode="aiTeam"],
  .train-play[data-train-mode="aiChallenge"]{
    width:calc(100vw - 18px)!important;
    max-width:none!important;
    grid-template-columns:clamp(168px,18vw,196px) minmax(0,1fr) clamp(196px,22vw,238px)!important;
    gap:8px!important;
  }
  .train-play[data-train-mode="aiTeam"] .train-board-wrap,
  .train-play[data-train-mode="aiChallenge"] .train-board-wrap{
    width:min(100%,calc(100dvh - 164px),580px)!important;
    height:auto!important;
    max-width:100%!important;
    max-height:calc(100dvh - 164px)!important;
    aspect-ratio:1/1!important;
    flex:0 1 auto!important;
  }
  .train-play[data-train-mode="aiTeam"] .battle-wing-card,
  .train-play[data-train-mode="aiChallenge"] .battle-wing-card,
  .train-play[data-train-mode="aiTeam"] .train-match-panel,
  .train-play[data-train-mode="aiChallenge"] .train-match-panel{
    min-width:0!important;
    padding:10px!important;
    overflow-x:hidden!important;
  }
  .train-play[data-train-mode="aiTeam"] .battle-wing-card,
  .train-play[data-train-mode="aiChallenge"] .battle-wing-card{
    overflow-y:auto!important;
    overscroll-behavior:contain!important;
    scrollbar-width:none!important;
  }
  .train-play[data-train-mode="aiTeam"] .battle-wing-card::-webkit-scrollbar,
  .train-play[data-train-mode="aiChallenge"] .battle-wing-card::-webkit-scrollbar{display:none!important}
  .train-play[data-train-mode="aiTeam"] .battle-wing-card .train-role-card,
  .train-play[data-train-mode="aiTeam"] .battle-self-roster .train-role-card,
  .train-play[data-train-mode="aiChallenge"] .battle-wing-card .train-role-card,
  .train-play[data-train-mode="aiChallenge"] .battle-self-roster .train-role-card{
    grid-template-columns:44px minmax(0,1fr)!important;
    min-width:0!important;
  }
  .train-play[data-train-mode="aiTeam"] .battle-wing-card .train-role-avatar,
  .train-play[data-train-mode="aiTeam"] .battle-self-roster .train-role-avatar,
  .train-play[data-train-mode="aiChallenge"] .battle-wing-card .train-role-avatar,
  .train-play[data-train-mode="aiChallenge"] .battle-self-roster .train-role-avatar{
    width:44px!important;height:44px!important;
  }

  /* 名局续下：晚加载的 292 / center / 292 布局在窄窗口会吞掉棋盘。
     缩侧栏而不是压扁棋盘，并让侧栏自身在极端低高度时滚动。 */
  .train-play[data-train-mode="aiStage"]{
    width:calc(100vw - 18px)!important;
    max-width:none!important;
    grid-template-columns:clamp(168px,18vw,194px) minmax(0,1fr) clamp(204px,22vw,238px)!important;
    column-gap:8px!important;
  }
  .train-play[data-train-mode="aiStage"] .train-board-wrap{
    width:min(100%,calc(100dvh - 158px),590px)!important;
    height:auto!important;
    max-width:100%!important;
    max-height:calc(100dvh - 158px)!important;
    aspect-ratio:1/1!important;
  }
  .train-play[data-train-mode="aiStage"] .battle-wing-card.stage-mentor-wing,
  .train-play[data-train-mode="aiStage"] .train-match-panel.stage-mode{
    min-width:0!important;
    padding:11px!important;
    overflow-x:hidden!important;
    overflow-y:auto!important;
    overscroll-behavior:contain!important;
    scrollbar-width:none!important;
  }
  .train-play[data-train-mode="aiStage"] .battle-wing-card.stage-mentor-wing::-webkit-scrollbar,
  .train-play[data-train-mode="aiStage"] .train-match-panel.stage-mode::-webkit-scrollbar{display:none!important}
  .train-play[data-train-mode="aiStage"] .challenge-mentor-avatar{
    width:min(112px,100%)!important;
    height:min(112px,100%)!important;
  }

  /* Long names on role cards / stage source data should truncate rather than
     widen the side columns. */
  .autogo-side-role-copy,
  .train-role-copy,
  .challenge-mentor-hero>div:last-child,
  .stage-source-card,
  .stage-source-players,
  .battle-self-roster,
  .battle-wing-roster{min-width:0!important}
  .autogo-side-role-copy b,
  .autogo-side-role-copy small,
  .train-role-copy b,
  .train-role-copy small,
  .challenge-mentor-hero>div:last-child b,
  .challenge-mentor-hero>div:last-child small{
    max-width:100%!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
    white-space:nowrap!important;
  }
}

/* Low-height laptop / tablet landscape: reclaim topbar height without putting
   controls above or below the board. */
@media (min-width:901px) and (max-width:1099px) and (max-height:760px){
  body.train-autogo-open .topbar,
  body.train-team-open .topbar,
  body.train-challenge-open .topbar,
  body.train-stage-open .topbar{
    height:66px!important;
    min-height:66px!important;
  }
  body.train-autogo-open .view-page[data-view="train"],
  body.train-team-open .view-page[data-view="train"],
  body.train-challenge-open .view-page[data-view="train"],
  body.train-stage-open .view-page[data-view="train"]{
    height:calc(100dvh - 66px)!important;
  }
  body.train-autogo-open .topbar .brand-logo-asset,
  body.train-team-open .topbar .brand-logo-asset,
  body.train-challenge-open .topbar .brand-logo-asset,
  body.train-stage-open .topbar .brand-logo-asset{
    width:38px!important;height:38px!important;
  }
  .autogo-top-title b,.battle-top-title b{font-size:18px!important}
}

/* Touchscreen Windows tablets still use the PC surface. Preserve dense mouse
   layout for desktops, but give touch users a dependable hit target. */
@media (pointer:coarse){
  .topbar-settings,
  .topbar-logout,
  .user-chip,
  .side-nav-btn,
  .train-controls>button,
  .train-match-controls-host button,
  .autogo-controls-host button,
  .stage-source-open{
    min-height:44px!important;
  }
  .topbar-settings{min-width:44px!important}
}
