/**
 * 手机强制横屏。登录/大厅按壳=窗口；战场/构筑用 1920×1080 设计画布。
 * 样式只在 html.gr-force-landscape 下生效，电脑不受影响。
 */

html.gr-force-landscape,
html.gr-force-landscape body {
  margin: 0;
  overflow: hidden;
}

html.gr-force-landscape {
  width: 100%;
  height: 100%;
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #0a0c10;
}

html.gr-force-landscape body {
  z-index: 0;
  padding: 0 !important;
  max-width: none !important;
  max-height: none !important;
  min-height: 0 !important;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: none;
}

/* 登录/大厅：壳=窗口，结构与电脑相同 */
html.gr-force-landscape .gr-fit-root {
  box-sizing: border-box;
  overflow: hidden;
  position: relative;
}

html.gr-force-landscape body.page-login,
html.gr-force-landscape body.page-hub,
html.gr-force-landscape body.page-home,
html.gr-force-landscape body.page-lobby,
html.gr-force-landscape body.page-pve,
html.gr-force-landscape body.page-tutorial {
  width: 100%;
  height: 100%;
  min-height: 0 !important;
}

html.gr-force-landscape .gr-fit-root,
html.gr-force-landscape .gr-fit-root body,
html.gr-force-landscape .login-card {
  min-height: 0 !important;
}

html.gr-force-landscape .login-card,
html.gr-force-landscape .home,
html.gr-force-landscape .lobby,
html.gr-force-landscape .pve-stage,
html.gr-force-landscape .tutorial {
  height: 100%;
  min-height: 0 !important;
  max-height: 100%;
  box-sizing: border-box;
}

/* —— 默认（含苹果）：改安卓前的稳定滚动，勿在此写安卓专用 —— */
html.gr-force-landscape .pve-stage,
html.gr-force-landscape .tutorial {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

html.gr-force-landscape body.page-login .gr-fit-root,
html.gr-force-landscape body.page-home .gr-fit-root {
  overflow-x: hidden !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  z-index: 0;
}

html.gr-force-landscape .login-card {
  height: auto !important;
  min-height: 100% !important;
  max-height: none !important;
  overflow: visible;
  justify-content: flex-start;
  padding-top: 28px;
  padding-bottom: 48px;
  touch-action: pan-y;
}

html.gr-force-landscape .home {
  height: auto !important;
  min-height: 100% !important;
  max-height: none !important;
  overflow: visible !important;
  z-index: auto !important;
  -webkit-overflow-scrolling: auto;
  touch-action: pan-y;
}

/*
 * 仅安卓（html.gr-android）：login-card 自滚 + 手动触摸桥（JS）。
 * 苹果不加 gr-android，走上方默认，互不影响。
 */
html.gr-android.gr-force-landscape body.page-login .gr-fit-root {
  overflow: hidden !important;
  touch-action: manipulation;
}

html.gr-android.gr-force-landscape .login-card {
  height: 100% !important;
  min-height: 0 !important;
  max-height: 100% !important;
  overflow-x: hidden !important;
  overflow-y: scroll !important;
  -webkit-overflow-scrolling: touch;
  touch-action: none;
  overscroll-behavior: contain;
}

html.gr-android.gr-force-landscape .login-card > * {
  flex-shrink: 0;
}

html.gr-android.gr-force-landscape .login-card input,
html.gr-android.gr-force-landscape .login-card textarea,
html.gr-android.gr-force-landscape .login-card button,
html.gr-android.gr-force-landscape .login-card .login-tab {
  touch-action: manipulation;
}

html.gr-android.gr-force-landscape body.page-home .gr-fit-root,
html.gr-android.gr-force-landscape .pve-stage,
html.gr-android.gr-force-landscape .tutorial,
html.gr-android.gr-force-landscape .lobby-list-wrap {
  overflow-y: scroll !important;
  touch-action: none;
}

/* 弹窗打开：冻结主页滚层并禁止点穿到模式钮 */
html.gr-force-landscape body.is-home-modal-open .gr-fit-root {
  overflow: hidden !important;
  -webkit-overflow-scrolling: auto !important;
  pointer-events: none;
}

html.gr-force-landscape body.is-home-modal-open .home-cache-modal,
html.gr-force-landscape body.is-home-modal-open .home-records-modal,
html.gr-force-landscape body.is-home-modal-open .home-cache-btn {
  pointer-events: auto;
}

/* 大厅：列表占满剩余高度，房间多了可在列表里滚，不要整页矮一块看不见 */
html.gr-force-landscape .lobby {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 12px;
}

html.gr-force-landscape .lobby-header,
html.gr-force-landscape .lobby-toolbar {
  flex: 0 0 auto;
}

html.gr-force-landscape .lobby-list-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

html.gr-force-landscape .login-bg,
html.gr-force-landscape .home-bg {
  position: absolute;
  inset: 0;
}

html.gr-force-landscape .battle-arena,
html.gr-force-landscape .db-stage {
  width: 100% !important;
  height: 100% !important;
}

html.gr-force-landscape .battle-rail {
  top: 0;
  bottom: 0;
}

html.gr-force-landscape .battle-rail--left {
  left: 0;
}

html.gr-force-landscape .battle-rail--right {
  right: 0;
}

html.gr-force-landscape .db-back-home {
  top: 12px;
  left: 12px;
}

/* 竖屏物理宽度会命中 max-width 媒体查询，把主页改成单列。强制横屏后锁回电脑横排。 */
html.gr-force-landscape .home-modes {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  width: min(920px, 100%) !important;
}

html.gr-force-landscape .lobby-toolbar {
  flex-wrap: nowrap;
}

html.gr-force-landscape .lobby-auto-hint {
  margin-left: auto;
  width: auto;
}

/* 弹层在 fit-root 外：抬合成层，压过主页模式钮 / 公告 */
html.gr-force-landscape .home-cache-modal,
html.gr-force-landscape .home-records-modal {
  z-index: 10000;
  isolation: isolate;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/*
 * 对战记录：按逻辑壳 (--app-*) 拉满宽度并同比放大字号。
 * 禁止用物理 vw/vh（竖屏机上会按短边挤成一坨）。
 */
html.gr-force-landscape .home-records-modal {
  padding: 8px;
  box-sizing: border-box;
}

html.gr-force-landscape .home-records-modal__panel {
  width: calc(var(--app-vw, 100%) - 16px);
  max-width: none;
  max-height: calc(var(--app-vh, 100%) - 16px);
  /* 设计宽约 860：按壳宽同比缩放字距与内边距 */
  font-size: clamp(12px, calc(var(--app-vw, 860px) * 0.017), 16px);
  padding: 0.9em 1em 0.85em;
  border-radius: 10px;
}

html.gr-force-landscape .home-records-modal__head {
  margin-bottom: 0.35em;
}

html.gr-force-landscape .home-records-modal__head h2 {
  font-size: 1.15em;
}

html.gr-force-landscape .home-records-jump {
  gap: 0.5em;
  margin-bottom: 0.55em;
}

html.gr-force-landscape .home-records-jump__input,
html.gr-force-landscape .home-records-jump__btn {
  height: 2.4em;
  font-size: 1em;
}

html.gr-force-landscape .home-records-modal__meta {
  font-size: 0.85em;
  margin-bottom: 0.45em;
}

html.gr-force-landscape .home-records-table {
  font-size: 1em;
}

html.gr-force-landscape .home-records-table th,
html.gr-force-landscape .home-records-table td {
  padding: 0.55em 0.45em;
}

html.gr-force-landscape .home-records-table .home-records-id {
  max-width: none;
  font-size: 0.92em;
}

html.gr-force-landscape .home-records-table .btn-replay {
  font-size: 0.92em;
  padding: 0.4em 0.85em;
}
