/*
 * Phone landscape is a distinct working space, not a squeezed portrait page.
 * These overrides load last so the battle stage keeps the board as its primary
 * surface while setup, campaign, and reference screens use the extra width.
 */

/* 手机端横屏战斗状态栏默认隐藏，仅在横屏战斗工作区展开。 */
.mobile-status-hud {
  display: none;
}

@media (max-width: 900px) and (orientation: landscape) {
  /* The mobile deck no longer occupies a bottom command rail in landscape.
     Never let a stale measured dock height push a reaction sheet off-screen. */
  .app.device-mobile.battle-started.mobile-battle-workspace {
    --mobile-dock-stack-height: 0px !important;
    --mobile-extra-float-height: 0px !important;
  }

  /* Keep ordinary out-of-turn actions compact and away from both board centre
     and the radial commands. The section remains absent when it has no action. */
  .app.device-mobile.battle-started #extraActionSection.hidden,
  .app.device-mobile.battle-started #extraActionSection:not(.active) {
    display: none !important;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace #extraActionSection.active:not(.reaction-window) {
    position: fixed !important;
    top: max(43px, calc(env(safe-area-inset-top, 0px) + 43px)) !important;
    right: max(7px, env(safe-area-inset-right, 0px)) !important;
    bottom: auto !important;
    left: auto !important;
    display: grid !important;
    width: min(286px, calc(100dvw - 14px)) !important;
    max-width: min(286px, calc(100dvw - 14px)) !important;
    max-height: calc(100dvh - 50px) !important;
    margin: 0 !important;
    padding: 7px !important;
    overflow: auto !important;
    transform: none !important;
    border-radius: 10px;
    z-index: 126;
  }

  /* 拼招是需要即时判断的模态操作：固定在视觉中心，并以视口高度
     限制边长，任何手机横屏都不会只露出半张。 */
  .app.device-mobile.battle-started.mobile-battle-workspace #extraActionSection.active.reaction-window {
    position: fixed !important;
    top: 50% !important;
    right: auto !important;
    bottom: auto !important;
    left: 50% !important;
    display: block !important;
    width: min(232px, calc(100dvw - 20px), calc(100dvh - 68px)) !important;
    max-width: min(232px, calc(100dvw - 20px), calc(100dvh - 68px)) !important;
    max-height: calc(100dvh - 68px) !important;
    margin: 0 !important;
    padding: 5px 6px !important;
    overflow: auto !important;
    transform: translate(-50%, -50%) !important;
    border-radius: 11px;
    z-index: 151;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace #extraActionSection.active.reaction-window .reaction-grid {
    gap: 2px;
    padding: 7px 6px;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace #extraActionSection.active.reaction-window .reaction-guard {
    width: 60px !important;
    height: 60px !important;
    flex-basis: 60px !important;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace #extraActionSection.active.reaction-window .dir-glyph,
  .app.device-mobile.battle-started.mobile-battle-workspace #extraActionSection.active.reaction-window .guard-glyph {
    font-size: 18px;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace #extraActionSection.active.reaction-window .dir-sub,
  .app.device-mobile.battle-started.mobile-battle-workspace #extraActionSection.active.reaction-window .guard-sub {
    font-size: 7px;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace #extraActionSection.active.reaction-window .skill-main strong {
    font-size: 10px;
  }

  /* Status and log are small, top-anchored sheets rather than full-width
     bottom drawers. Their header keeps the existing close/control buttons. */
  .app.device-mobile.battle-started.mobile-battle-workspace[data-mobile-panel-open="focus"] #focusFloat,
  .app.device-mobile.battle-started.mobile-battle-workspace[data-mobile-panel-open="log"] #logPanel {
    top: max(43px, calc(env(safe-area-inset-top, 0px) + 43px)) !important;
    bottom: auto !important;
    display: flex !important;
    width: min(252px, calc(100dvw - 14px)) !important;
    max-width: min(252px, calc(100dvw - 14px)) !important;
    max-height: min(72dvh, 258px) !important;
    margin: 0 !important;
    padding: 5px !important;
    overflow: hidden !important;
    transform: none !important;
    border-radius: 10px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.62);
    z-index: 132;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace[data-mobile-panel-open="focus"] #focusFloat {
    right: auto !important;
    left: max(7px, env(safe-area-inset-left, 0px)) !important;
    flex-direction: column;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace[data-mobile-panel-open="log"] #logPanel {
    right: max(7px, env(safe-area-inset-right, 0px)) !important;
    left: auto !important;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace[data-mobile-panel-open="focus"] .battle-stage::before,
  .app.device-mobile.battle-started.mobile-battle-workspace[data-mobile-panel-open="log"] .battle-stage::before {
    background: rgba(0, 0, 0, 0.32);
  }

  .app.device-mobile.battle-started.mobile-battle-workspace #focusFloat .float-handle,
  .app.device-mobile.battle-started.mobile-battle-workspace #logPanel .float-handle {
    min-height: 22px;
    margin: -5px -5px 4px;
    padding: 3px 5px;
    gap: 4px;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace #focusFloat .float-handle > strong,
  .app.device-mobile.battle-started.mobile-battle-workspace #logPanel .float-handle > strong {
    font-size: 10px;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace #focusFloat .float-handle-actions,
  .app.device-mobile.battle-started.mobile-battle-workspace #logPanel .float-handle-actions {
    gap: 2px;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace #focusFloat .chip,
  .app.device-mobile.battle-started.mobile-battle-workspace #focusFloat .icon-btn,
  .app.device-mobile.battle-started.mobile-battle-workspace #logPanel .chip {
    min-height: 18px;
    padding: 1px 3px;
    font-size: 8px;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace #focusCard,
  .app.device-mobile.battle-started.mobile-battle-workspace #logPanel .log-stream {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace #focusCard {
    font-size: 9px;
    line-height: 1.2;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace #focusCard .unit-head {
    gap: 4px;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace #focusCard .unit-head-side,
  .app.device-mobile.battle-started.mobile-battle-workspace #focusCard .unit-label {
    font-size: 8px;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace #focusCard .focus-bars {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 3px 5px;
    margin-top: 3px;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace #focusCard .resource-bar {
    gap: 1px;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace #focusCard .resource-bar .small {
    gap: 2px;
    font-size: 8px;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace #focusCard .barline {
    height: 3px;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace #focusCard .status-grid {
    grid-template-columns: repeat(auto-fit, minmax(48px, 1fr));
    gap: 2px;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace #focusCard .status-chip {
    min-height: 16px;
    padding: 1px 2px;
    font-size: 8px;
  }

  /* The newer illustrated meters retain their silhouettes while using a
     smaller phone footprint inside the detached bottom resource float. */
  .app.device-mobile.battle-started .combat-resource-hud .yaowang-medicine-meter {
    width: 78px;
    height: 78px;
    flex-basis: 78px;
  }

  .app.device-mobile.battle-started .combat-resource-hud .yanyun-meter-board,
  .app.device-mobile.battle-started .combat-resource-hud .yanyun-wings {
    width: 94px;
    height: 50px;
  }

  .app.device-mobile.battle-started .combat-resource-hud .yanyun-meter-board {
    flex-basis: 94px;
  }

  .app.device-mobile.battle-started .combat-resource-hud .yanyun-wing-left,
  .app.device-mobile.battle-started .combat-resource-hud .yanyun-wing-right {
    width: 47px;
    height: 35px;
  }

  .app.device-mobile.battle-started .combat-resource-hud .yanyun-swallow {
    width: 68px;
    height: 34px;
  }

  .app.device-mobile.battle-started .combat-resource-hud .xianming-resource-controls {
    width: 116px;
    height: 68px;
    flex-basis: 116px;
  }

  .app.device-mobile.battle-started .combat-resource-hud .xianming-resource-group.xianming-chess-zone,
  .app.device-mobile.battle-started .combat-resource-hud .xianming-resource-group.xianming-tea-zone {
    width: 50px;
    height: 50px;
  }

  .app.device-mobile.battle-started .combat-resource-hud .xianming-chess .xianming-resource-frame,
  .app.device-mobile.battle-started .combat-resource-hud .xianming-tea .xianming-resource-frame {
    width: 35px;
    height: 35px;
  }

  .app.device-mobile.battle-started .combat-resource-hud .xianming-miaoshou-diagonal {
    top: 4px;
    height: 60px;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace #logPanel .log-stream {
    min-height: 96px;
    max-height: calc(100dvh - 86px);
  }

  /* Choice windows should sit above the board, with a usable internal scroll,
     instead of inheriting the old portrait deck width. */
  .app.device-mobile.battle-started #divinationActionSection:not(.hidden),
  .app.device-mobile.battle-started #variantDock:not(.hidden) {
    position: fixed !important;
    top: 50% !important;
    right: auto !important;
    bottom: auto !important;
    left: 50% !important;
    width: min(360px, calc(100dvw - 20px)) !important;
    max-width: min(360px, calc(100dvw - 20px)) !important;
    max-height: calc(100dvh - 36px) !important;
    overflow: auto !important;
    transform: translate(-50%, -50%) !important;
    z-index: 146;
  }

  /* Setup and menu pages use the short dimension as a deliberate two-column
     canvas. They still stay in normal document flow: a screen that has not
     received a compact layout must remain reachable by ordinary page scroll. */
  .app.device-mobile:not(.battle-started) {
    min-height: 100dvh;
    max-height: none;
    gap: 6px;
    padding: 8px;
    overflow: visible;
  }

  .app.device-mobile:not(.battle-started) .prebattle-stack,
  .app.device-mobile:not(.battle-started) .prebattle-panel {
    min-height: 0;
  }

  .app.device-mobile:not(.battle-started) .prebattle-stack {
    overflow: visible;
  }

  .app.device-mobile:not(.battle-started) .prebattle-panel {
    padding: 10px;
    overflow: visible;
  }

  /* The resource-mode gateway used to inherit the 1180px portrait breakpoint
     and stack all three choices. Landscape instead gives every mode a compact,
     touch-sized card in one visible row. */
  .app.device-mobile:not(.battle-started) .setup-mode-gateway {
    grid-template-columns: 132px minmax(0, 1fr);
    align-items: center;
    justify-self: center;
    width: min(780px, calc(100% - 16px));
    min-height: calc(100dvh - 16px);
    margin-inline: auto;
    gap: 10px;
    padding: 12px;
  }

  .app.device-mobile:not(.battle-started) .setup-mode-gateway > :first-child {
    align-self: start;
  }

  .app.device-mobile:not(.battle-started) .test-mode-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .app.device-mobile:not(.battle-started) .test-mode-card {
    min-height: 118px;
    gap: 4px;
    padding: 9px;
    border-radius: 9px;
  }

  .app.device-mobile:not(.battle-started) .test-mode-card strong {
    font-size: 15px;
  }

  .app.device-mobile:not(.battle-started) .test-mode-card span,
  .app.device-mobile:not(.battle-started) .test-mode-estimate {
    font-size: 9px;
    line-height: 1.3;
  }

  .app.device-mobile:not(.battle-started) .test-mode-estimate {
    padding-top: 3px;
    gap: 3px;
  }

  .app.device-mobile:not(.battle-started) .test-mode-cache-badge {
    padding: 1px 4px;
    font-size: 8px;
  }

  .app.device-mobile:not(.battle-started) .setup-version-stamp {
    right: max(6px, env(safe-area-inset-right, 0px));
    bottom: max(5px, env(safe-area-inset-bottom, 0px));
    padding: 3px 5px;
    font-size: 8px;
  }

  .app.device-mobile:not(.battle-started) .setup-main-menu {
    min-height: calc(100dvh - 16px);
    padding: 0;
  }

  .app.device-mobile:not(.battle-started) .setup-main-menu-book {
    display: grid;
    grid-template-columns: 118px minmax(0, 1fr);
    align-items: center;
    width: min(760px, 100%);
    padding: 14px 20px 14px 42px;
    gap: 8px;
  }

  .app.device-mobile:not(.battle-started) .setup-main-menu-book::before {
    top: 10px;
    bottom: 10px;
    left: 26px;
  }

  .app.device-mobile:not(.battle-started) .setup-book-logo {
    width: 108px;
    height: 96px;
    margin: 0;
  }

  .app.device-mobile:not(.battle-started) .setup-main-menu-box .setup-section-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2px 10px;
    margin: 0;
    padding-top: 24px;
  }

  .app.device-mobile:not(.battle-started) .setup-main-menu-box .setup-section-card {
    grid-template-columns: 26px minmax(0, 1fr);
    min-height: 42px;
    gap: 6px;
    padding: 5px 2px;
  }

  .app.device-mobile:not(.battle-started) .setup-main-menu-box .setup-section-card:last-child {
    grid-column: 1 / -1;
  }

  .app.device-mobile:not(.battle-started) .setup-main-menu-box .setup-section-card.recommended {
    margin: 1px -4px;
    padding-inline: 6px;
  }

  .app.device-mobile:not(.battle-started) .setup-main-menu-box .setup-section-card strong {
    font-size: 14px;
  }

  .app.device-mobile:not(.battle-started) .setup-first-play-button {
    top: 7px;
    right: 9px;
    min-height: 25px;
    padding: 3px 7px;
    font-size: 9px;
  }

  .app.device-mobile:not(.battle-started) .setup-main-menu-box .setup-menu-desc {
    font-size: 10px;
    line-height: 1.25;
  }

  .app.device-mobile:not(.battle-started) .setup-recommended-badge,
  .app.device-mobile:not(.battle-started) .setup-menu-tag {
    margin-left: 4px;
    padding: 1px 4px;
    font-size: 8px;
  }

  .app.device-mobile:not(.battle-started) .setup-section-panel .setup-section-grid,
  .app.device-mobile:not(.battle-started) .setup-choice-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .app.device-mobile:not(.battle-started) .setup-section-card,
  .app.device-mobile:not(.battle-started) .setup-choice-card {
    min-height: 58px;
    padding: 8px;
  }

  .app.device-mobile:not(.battle-started) .setup-option-columns-2,
  .app.device-mobile:not(.battle-started) .setup-option-columns-3,
  .app.device-mobile:not(.battle-started) .setup-duel-grid,
  .app.device-mobile:not(.battle-started) .setup-env-grid,
  .app.device-mobile:not(.battle-started) .setup-guide-stack,
  .app.device-mobile:not(.battle-started) .tutorial-entry-grid-featured,
  .app.device-mobile:not(.battle-started) .other-tests-menu {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .app.device-mobile:not(.battle-started) button,
  .app.device-mobile:not(.battle-started) select {
    min-height: 32px;
    padding: 5px 8px;
    font-size: 12px;
  }

  .app.device-mobile:not(.battle-started) .setup-formation-overlay {
    padding: 8px;
  }

  .app.device-mobile:not(.battle-started) .setup-formation-modal,
  .app.device-mobile:not(.battle-started) .setup-formation-picker {
    width: min(820px, calc(100dvw - 16px));
    max-height: calc(100dvh - 16px);
    padding: 12px;
    overflow: auto;
  }

  .app.device-mobile:not(.battle-started) .setup-formation-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
  }

  /* Reference pages have a fixed navigation rail and a two-card reading area. */
  .app.device-mobile:not(.battle-started) .game-data-layout {
    grid-template-columns: 176px minmax(0, 1fr);
    height: calc(100dvh - 98px);
    gap: 8px;
  }

  .app.device-mobile:not(.battle-started) .game-data-sidebar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: min-content;
    align-content: start;
    padding: 6px;
    gap: 2px;
    overflow-y: auto;
  }

  .app.device-mobile:not(.battle-started) .game-data-sidebar-label {
    grid-column: 1 / -1;
  }

  .app.device-mobile:not(.battle-started) .game-data-nav-item {
    min-height: 24px;
    padding: 3px 4px;
    font-size: 10px;
  }

  .app.device-mobile:not(.battle-started) .game-data-sidebar-label {
    margin: 3px 2px 1px;
    font-size: 9px;
  }

  .app.device-mobile:not(.battle-started) .game-data-modules {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    height: 100%;
    gap: 8px;
    overflow: hidden;
  }

  .app.device-mobile:not(.battle-started) .game-data-module.combat {
    grid-column: auto;
    max-height: none;
  }

  .app.device-mobile:not(.battle-started) .game-data-module {
    min-height: 0;
  }

  .app.device-mobile:not(.battle-started) .game-data-module.collapsible,
  .app.device-mobile:not(.battle-started) .game-data-module.collapsible[open] {
    align-self: stretch;
    height: 100%;
    max-height: none;
    overflow: hidden;
  }

  .app.device-mobile:not(.battle-started) .game-data-combat-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }

  .app.device-mobile:not(.battle-started) .game-data-combat-actions .setup-choice-card {
    min-height: 38px;
    padding: 4px 3px;
    border-radius: 7px;
    font-size: 10px;
    line-height: 1.2;
  }

  .app.device-mobile:not(.battle-started) .game-data-modules.demonstrations {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }

  .app.device-mobile:not(.battle-started) .game-data-module > header,
  .app.device-mobile:not(.battle-started) .game-data-module-body {
    padding: 8px;
  }

  .app.device-mobile:not(.battle-started) .game-data-module.collapsible > summary {
    padding: 8px;
    font-size: 12px;
  }

  .app.device-mobile:not(.battle-started) .game-data-module.collapsible[open] {
    max-height: none;
  }

  .app.device-mobile:not(.battle-started) .game-data-portrait-list img {
    min-height: 120px;
    max-height: 220px;
  }

  .app.device-mobile:not(.battle-started) .game-data-module.animations .game-data-module-body {
    display: grid;
    align-content: center;
  }

  .app.device-mobile:not(.battle-started) .game-data-animation-button {
    min-height: 34px;
    padding: 5px 7px;
    font-size: 10px;
  }

  .app.device-mobile:not(.battle-started) .game-data-modal {
    padding: 8px;
  }

  .app.device-mobile:not(.battle-started) .game-data-dialog {
    width: min(880px, calc(100dvw - 16px));
    max-height: calc(100dvh - 16px);
  }

  .app.device-mobile:not(.battle-started) .game-data-dialog > header,
  .app.device-mobile:not(.battle-started) .game-data-dialog-body {
    padding: 8px 10px;
  }

  .app.device-mobile:not(.battle-started) .catalog-animation-viewer {
    grid-template-columns: minmax(0, 1.15fr) minmax(164px, 0.85fr);
    align-items: start;
    gap: 8px;
  }

  .app.device-mobile:not(.battle-started) .catalog-animation-player video {
    max-height: calc(100dvh - 92px);
  }

  .app.device-mobile:not(.battle-started) .catalog-animation-list {
    grid-template-columns: minmax(0, 1fr);
    max-height: calc(100dvh - 92px);
    gap: 5px;
    overflow-y: auto;
  }

  .app.device-mobile:not(.battle-started) .catalog-animation-item {
    min-height: 32px;
    padding: 5px 7px;
  }

  .app.device-mobile:not(.battle-started) .catalog-animation-item > span,
  .app.device-mobile:not(.battle-started) .catalog-animation-item > strong {
    font-size: 9px;
  }

  /* Campaign selection puts the strip and the current-character sheet side by
     side. The important start choices fit on the first landscape screen while
     the strip keeps its own horizontal fallback for the full roster. */
  .app.device-mobile:not(.battle-started) .campaign-setup {
    padding: 10px;
  }

  .app.device-mobile:not(.battle-started) .campaign-setup-head {
    padding-bottom: 8px;
  }

  .app.device-mobile:not(.battle-started) .campaign-setup-head h3 {
    margin: 2px 0;
    font-size: 21px;
  }

  .app.device-mobile:not(.battle-started) .campaign-difficulty-select {
    min-height: 0;
  }

  .app.device-mobile:not(.battle-started) .campaign-difficulty-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
    margin: 12px auto 4px;
  }

  .app.device-mobile:not(.battle-started) .campaign-difficulty-card {
    min-height: 106px;
    gap: 5px;
    padding: 6px 3px;
  }

  .app.device-mobile:not(.battle-started) .campaign-difficulty-card strong,
  .app.device-mobile:not(.battle-started) .campaign-difficulty-card.solo strong {
    font-size: clamp(17px, 3.2vw, 28px);
  }

  .app.device-mobile:not(.battle-started) .campaign-difficulty-card span {
    font-size: 9px;
  }

  .app.device-mobile:not(.battle-started) .campaign-difficulty-card small {
    font-size: 8px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-lineup {
    grid-template-columns: repeat(9, minmax(82px, 1fr));
    grid-auto-rows: 148px;
    min-height: 148px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-portrait {
    height: 148px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-top-tags {
    inset: 5px 4px auto;
    gap: 2px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-badge,
  .app.device-mobile:not(.battle-started) .campaign-character-tags .formation-role-tag {
    padding: 2px 4px;
    font-size: 7px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-portrait > span {
    padding: 30px 4px 5px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-portrait > span strong {
    font-size: 11px;
  }

  .app.device-mobile:not(.battle-started) .campaign-selection-preview {
    grid-template-columns: 160px minmax(0, 1fr);
    min-height: 148px;
    gap: 10px;
    padding: 8px;
  }

  .app.device-mobile:not(.battle-started) .campaign-selection-preview > video,
  .app.device-mobile:not(.battle-started) .campaign-selection-preview > img,
  .app.device-mobile:not(.battle-started) .campaign-preview-media {
    height: 132px;
  }

  .app.device-mobile:not(.battle-started) .campaign-preview-scroll {
    max-height: 132px;
  }

  .app.device-mobile:not(.battle-started) .campaign-setup.campaign-character-select {
    display: grid;
    grid-template-columns: minmax(252px, 0.78fr) minmax(0, 1.22fr);
    align-content: start;
    gap: 6px 8px;
    padding: 8px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-setup-head {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    padding: 0;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-setup-head h3 {
    font-size: 18px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-setup-head .campaign-kicker {
    font-size: 8px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-duty-back {
    min-height: 26px;
    padding: 3px 6px;
    font-size: 9px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-setup-toolbar {
    grid-column: 2;
    grid-row: 1;
    min-height: 30px;
    margin: 0;
    justify-content: flex-end;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-setup-toolbar > span {
    font-size: 10px;
    letter-spacing: 0.1em;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-gender-switch .segmented-pill {
    min-width: 48px;
    min-height: 26px;
    padding: 3px 6px;
    font-size: 10px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-character-lineup {
    grid-column: 1;
    grid-row: 2;
    grid-template-columns: repeat(9, minmax(56px, 1fr));
    grid-auto-rows: 122px;
    min-height: 122px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-character-portrait {
    height: 122px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-selection-preview {
    grid-column: 2;
    grid-row: 2;
    grid-template-columns: 120px minmax(0, 1fr);
    min-height: 122px;
    gap: 7px;
    padding: 5px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-selection-preview > video,
  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-selection-preview > img,
  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-preview-media,
  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-preview-scroll {
    height: 110px;
    max-height: 110px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-preview-copy {
    min-height: 0;
    gap: 3px;
    align-content: start;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-preview-copy > .campaign-kicker {
    font-size: 8px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-preview-copy h2 {
    font-size: 11px;
    line-height: 1.2;
    letter-spacing: 0.02em;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-preview-copy h2 .campaign-starter-skill > img,
  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-preview-copy h2 .campaign-starter-skill > .skill-icon-art {
    width: 18px;
    height: 18px;
    flex-basis: 18px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-school-intro {
    gap: 4px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-school-intro > section {
    gap: 2px;
    padding: 4px 6px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-intro-label,
  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-school-intro strong,
  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-school-intro summary {
    font-size: 8px;
    line-height: 1.25;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-school-intro summary {
    padding: 4px 6px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-token-select {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: 112px minmax(0, 1fr);
    align-items: stretch;
    gap: 6px;
    margin: 0;
    padding-top: 4px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-section-title {
    display: grid;
    align-content: center;
    gap: 2px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-section-title h3 {
    margin: 0;
    font-size: 10px;
    line-height: 1.25;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-section-title span {
    font-size: 8px;
    line-height: 1.2;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-token-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-token-card {
    min-height: 58px;
    gap: 1px;
    padding: 4px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-token-card strong {
    font-size: 10px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-token-card em {
    font-size: 8px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-token-card span {
    display: -webkit-box;
    overflow: hidden;
    font-size: 8px;
    line-height: 1.2;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-launch-row {
    grid-column: 1 / -1;
    margin: 0;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-launch {
    min-height: 32px;
    margin: 0;
    padding: 4px 8px;
    font-size: 10px;
  }

  /* The character step is deliberately a single compact sequence: portrait
     selection first, relics second. It has no school copy or media preview. */
  .app.device-mobile:not(.battle-started) .campaign-setup.campaign-character-select {
    grid-template-columns: minmax(0, 1fr);
    gap: 5px;
    margin-top: 4px;
    padding: 6px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-setup-toolbar {
    grid-column: auto;
    grid-row: auto;
    min-height: 28px;
    justify-content: space-between;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-gender-switch {
    margin-left: auto;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-character-lineup {
    grid-column: auto;
    grid-row: auto;
    grid-template-columns: repeat(12, minmax(56px, 1fr));
    grid-auto-rows: 94px;
    min-height: 94px;
    border-radius: 8px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-character-portrait {
    height: 94px;
    overflow: hidden;
    border: 1px solid transparent;
    border-radius: 7px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-character-portrait.active {
    border-color: rgba(110, 216, 164, 0.82);
    box-shadow: inset 0 -2px 0 var(--accent), 0 0 12px rgba(110, 216, 164, 0.2);
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-character-role-tags {
    position: absolute;
    inset: auto 3px 3px;
    z-index: 4;
    display: flex;
    justify-content: center;
    gap: 2px;
    max-width: calc(100% - 6px);
    pointer-events: none;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-character-role-tags .formation-role-tag {
    min-height: 0;
    padding: 1px 3px;
    border-color: rgba(228, 214, 174, 0.52);
    font-size: 7px;
    line-height: 1.15;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-token-select {
    grid-column: auto;
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 5px;
    padding-top: 0;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-token-card {
    min-height: 50px;
    padding: 3px 4px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-token-card span {
    -webkit-line-clamp: 1;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-launch-row {
    grid-column: auto;
  }

  .app.device-mobile:not(.battle-started) .setup-config-box:has(.campaign-character-select) {
    padding: 7px;
  }

  .app.device-mobile:not(.battle-started) .setup-config-box:has(.campaign-character-select) .setup-detail-nav {
    padding-bottom: 5px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-character-lineup {
    grid-auto-rows: 78px;
    min-height: 78px;
    margin-top: 0;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-character-portrait {
    height: 78px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-character-portrait > .campaign-character-name {
    inset: auto 0 0;
    padding: 2px 1px;
    font-size: 9px;
    line-height: 14px;
    letter-spacing: 0;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-character-role-tags {
    inset: auto 3px 21px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-setup-toolbar {
    gap: 6px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-setup-toolbar > span {
    font-size: 10px;
    letter-spacing: 0;
    white-space: nowrap;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-setup-toolbar .campaign-school-tutorial {
    min-height: 24px;
    padding: 3px 8px;
    font-size: 10px;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-token-select .campaign-section-title span {
    display: none;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-token-card {
    box-sizing: border-box;
    height: 50px;
    min-height: 0;
    overflow: hidden;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-token-card strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app.device-mobile:not(.battle-started) .campaign-character-select .campaign-launch {
    min-height: 28px;
  }

  /* Other setup screens share the same compact card rhythm. Long catalogs
     still use the restored document scroll rather than clipping their tail. */
  .app.device-mobile:not(.battle-started) .setup-section-panel:has([data-battle-config="devicePreset"]) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-top: 4px;
  }

  .app.device-mobile:not(.battle-started) .setup-section-panel:has([data-battle-config="devicePreset"]) .setup-section-head {
    grid-column: 1 / -1;
  }

  .app.device-mobile:not(.battle-started) .setup-section-panel:has([data-battle-config="devicePreset"]) .setup-option-columns {
    display: contents;
  }

  .app.device-mobile:not(.battle-started) .setup-section-panel:has([data-battle-config="devicePreset"]) .setup-box {
    min-width: 0;
    padding: 6px;
    border-radius: 8px;
  }

  .app.device-mobile:not(.battle-started) .setup-section-panel:has([data-battle-config="devicePreset"]) .setup-box .small {
    font-size: 10px;
  }

  .app.device-mobile:not(.battle-started) .setup-section-panel:has([data-battle-config="devicePreset"]) .segmented {
    gap: 4px;
    margin: 3px 0;
  }

  .app.device-mobile:not(.battle-started) .setup-section-panel:has([data-battle-config="devicePreset"]) .segmented-pill {
    min-height: 26px;
    padding: 3px 6px;
    font-size: 10px;
  }

  .app.device-mobile:not(.battle-started) .setup-section-panel:has([data-battle-config="devicePreset"]) select {
    min-height: 28px;
    padding: 3px 5px;
    font-size: 10px;
  }

  .app.device-mobile:not(.battle-started) .setup-section-panel:has([data-battle-config="devicePreset"]) .setup-effect {
    font-size: 9px;
    line-height: 1.25;
  }

  .app.device-mobile:not(.battle-started) .setup-section-panel:has([data-battle-config="devicePreset"]) .setup-inline-config {
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 4px 0 0;
    padding: 4px;
    border-radius: 6px;
  }

  .app.device-mobile:not(.battle-started) .setup-config-box:has(.setup-option-columns-3) {
    padding: 7px;
  }

  .app.device-mobile:not(.battle-started) .setup-config-box:has(.setup-option-columns-3) .setup-detail-nav {
    padding-bottom: 5px;
  }

  .app.device-mobile:not(.battle-started) .setup-section-panel:has(.setup-option-columns-3) {
    gap: 6px;
    margin-top: 4px;
  }

  .app.device-mobile:not(.battle-started) .setup-section-panel:has(.setup-option-columns-3) .setup-option-columns-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
  }

  .app.device-mobile:not(.battle-started) .setup-section-panel:has(.setup-option-columns-3) .setup-box,
  .app.device-mobile:not(.battle-started) .setup-section-panel:has(.setup-option-columns-3) .setup-summary-box {
    min-width: 0;
    padding: 6px;
  }

  .app.device-mobile:not(.battle-started) .setup-section-panel:has(.setup-option-columns-3) .setup-box > .small {
    font-size: 10px;
    line-height: 1.1;
  }

  .app.device-mobile:not(.battle-started) .setup-section-panel:has(.setup-option-columns-3) .setup-choice-stack {
    gap: 4px;
    margin-top: 4px;
  }

  .app.device-mobile:not(.battle-started) .setup-section-panel:has(.setup-option-columns-3) [data-pve-scenario] {
    height: 42px;
    min-height: 42px;
    padding: 4px;
    overflow: hidden;
  }

  .app.device-mobile:not(.battle-started) .setup-section-panel:has(.setup-option-columns-3) [data-pve-scenario] strong,
  .app.device-mobile:not(.battle-started) .setup-section-panel:has(.setup-option-columns-3) [data-battle-config-mode] strong {
    font-size: 12px;
  }

  .app.device-mobile:not(.battle-started) .setup-section-panel:has(.setup-option-columns-3) [data-pve-scenario] span,
  .app.device-mobile:not(.battle-started) .setup-section-panel:has(.setup-option-columns-3) [data-battle-config-mode] span,
  .app.device-mobile:not(.battle-started) .setup-section-panel:has(.setup-option-columns-3) .setup-effect {
    font-size: 9px;
    line-height: 1.2;
  }

  .app.device-mobile:not(.battle-started) .setup-section-panel:has(.setup-option-columns-3) [data-battle-config-mode] {
    min-height: 48px;
    padding: 5px;
  }

  .app.device-mobile:not(.battle-started) .setup-section-panel:has(.setup-option-columns-3) .formation-summary-box {
    gap: 4px;
  }

  .app.device-mobile:not(.battle-started) .setup-section-panel:has(.setup-option-columns-3) .formation-school-summary {
    min-height: 20px;
  }

  .app.device-mobile:not(.battle-started) .setup-section-panel:has(.setup-option-columns-3) .formation-summary-count {
    font-size: 11px;
  }

  .app.device-mobile:not(.battle-started) .setup-section-panel:has(.setup-option-columns-3) .setup-start-row button {
    min-height: 30px;
    padding: 4px 9px;
    font-size: 11px;
  }

  .app.device-mobile:not(.battle-started) .setup-section-panel {
    gap: 8px;
  }

  .app.device-mobile:not(.battle-started) .setup-section-panel .setup-choice-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .app.device-mobile:not(.battle-started) .setup-section-panel .setup-choice-stack .setup-choice-card {
    min-height: 44px;
    padding: 6px;
  }

  .app.device-mobile:not(.battle-started) .tutorial-entry-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .app.device-mobile:not(.battle-started) .tutorial-entry-card {
    min-height: 54px;
    padding: 6px;
  }

  /* Rest keeps battle-started on the app. Scope these rules to the overlay
     itself, otherwise the desktop camp and every second-level window win. */
  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] {
    align-items: stretch;
    overflow: auto;
    width: 100dvw;
    max-width: 100dvw;
    height: 100dvh;
    padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] > [data-campaign-camp-modal-host],
  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] > [data-campaign-camp-event-host],
  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] > [data-campaign-camp-capability-host] {
    display: contents;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] > .campaign-camp-card {
    width: 100%;
    height: 100%;
    max-height: none;
    gap: 5px;
    padding: 6px;
    overflow: hidden;
    /* Its fill-mode entrance transform made fixed child dialogs relative to
       this card, clipping their right and bottom edges on narrow screens. */
    animation: none;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-scene {
    flex: 1 1 auto;
    min-height: 0;
    grid-template-rows: auto auto auto minmax(0, 1fr);
    gap: 5px;
    overflow: hidden;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-top {
    align-items: center;
    flex-wrap: nowrap;
    margin: 5px 6px 0;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-name,
  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-stats span {
    padding: 3px 5px;
    font-size: 9px;
    letter-spacing: 0;
    white-space: nowrap;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-paths,
  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-paths.single {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    padding: 0 6px;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-paths.single {
    grid-template-columns: minmax(0, 1fr);
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-path {
    min-width: 0;
    min-height: 68px;
    gap: 1px;
    padding: 5px 6px;
    overflow: hidden;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-path::before,
  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-path > small,
  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-path > em {
    display: none;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-path > span,
  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-path > strong {
    font-size: 11px;
    line-height: 1.2;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-banners {
    display: flex;
    gap: 4px;
    margin: 0 6px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-banners span {
    flex: 0 0 auto;
    max-width: 80%;
    padding: 2px 5px;
    overflow: hidden;
    font-size: 9px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-ground {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(190px, 0.72fr);
    align-items: end;
    gap: 5px;
    min-height: 0;
    padding: 0 6px 6px;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-members {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    min-width: 0;
    overflow-x: auto;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-member {
    flex: 0 0 72px;
    min-width: 0;
    gap: 2px;
    padding: 4px 3px;
    transform: none;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-member > strong {
    font-size: 11px;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-member-vitals span {
    padding: 2px;
    font-size: 8px;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-fire {
    display: none;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-services {
    gap: 4px;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-merchant,
  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-blacksmith {
    min-width: 45px;
    min-height: 72px;
    gap: 2px;
    padding: 5px 3px;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-merchant span,
  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-blacksmith span {
    writing-mode: horizontal-tb;
    font-size: 9px;
    letter-spacing: 0;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-merchant em,
  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-blacksmith em {
    font-size: 8px;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-spots {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    width: 100%;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-spot {
    gap: 4px;
    min-width: 0;
    min-height: 35px;
    padding: 3px 5px;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-spot-icon {
    width: 14px;
    height: 14px;
    padding: 2px;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-spot strong {
    font-size: 10px;
    letter-spacing: 0;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-spot span {
    display: none;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-footer {
    gap: 2px;
    padding: 0;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-footer .campaign-continue {
    min-height: 36px;
    margin: 0;
    padding: 4px 8px;
    font-size: 12px;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-pending,
  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-optional {
    margin: 0;
    overflow: hidden;
    font-size: 9px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Second-level camp windows use a fixed header and an independently
     scrollable body. Short choices shrink to content; large inventories fill
     the remaining height without losing the close control. */
  .app.device-mobile .campaign-camp-modal,
  .app.device-mobile .campaign-event-modal,
  .app.device-mobile .campaign-capability-backdrop {
    padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
  }

  .app.device-mobile .campaign-camp-modal {
    overflow: hidden;
    width: 100dvw;
    max-width: 100dvw;
    height: 100dvh;
  }

  .app.device-mobile .campaign-camp-dialog {
    box-sizing: border-box;
    width: min(880px, 100%);
    min-width: 0;
    height: auto;
    max-height: calc(100dvh - 12px);
  }

  .app.device-mobile .campaign-member-dialog,
  .app.device-mobile .campaign-merchant-dialog,
  .app.device-mobile .campaign-blacksmith-dialog:not(.campaign-blacksmith-menu-dialog) {
    height: calc(100dvh - 12px);
  }

  .app.device-mobile .campaign-camp-dialog-head {
    flex: 0 0 auto;
    align-items: center;
    padding: 6px 9px;
  }

  .app.device-mobile .campaign-camp-dialog-head h3 {
    font-size: 13px;
  }

  .app.device-mobile .campaign-camp-dialog-head span {
    margin-top: 1px;
    font-size: 9px;
  }

  .app.device-mobile .campaign-camp-dialog-close {
    flex: 0 0 auto;
    min-height: 28px;
    padding: 3px 9px;
    font-size: 10px;
  }

  .app.device-mobile .campaign-camp-dialog-body {
    flex: 0 1 auto;
    max-height: calc(100dvh - 56px);
    padding: 3px 9px 9px;
    overflow-y: auto;
  }

  .app.device-mobile .campaign-member-dialog .campaign-camp-dialog-body,
  .app.device-mobile .campaign-merchant-dialog .campaign-camp-dialog-body,
  .app.device-mobile .campaign-blacksmith-dialog:not(.campaign-blacksmith-menu-dialog) .campaign-camp-dialog-body {
    flex: 1 1 auto;
    max-height: none;
  }

  .app.device-mobile .campaign-camp-dialog-body .campaign-rest-section {
    margin-top: 5px;
    padding-block: 4px;
  }

  .app.device-mobile .campaign-camp-dialog-body .campaign-section-title {
    gap: 5px;
    margin-bottom: 5px;
    padding-bottom: 4px;
  }

  .app.device-mobile .campaign-camp-dialog-body .campaign-section-title h3 {
    font-size: 12px;
  }

  .app.device-mobile .campaign-camp-dialog-body .campaign-section-title span {
    font-size: 9px;
  }

  .app.device-mobile .campaign-camp-dialog-body .campaign-choice-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
  }

  .app.device-mobile .campaign-camp-dialog-body .campaign-choice {
    min-height: 66px;
    gap: 2px;
    padding: 6px;
  }

  .app.device-mobile .campaign-camp-dialog-body .campaign-choice strong {
    font-size: 11px;
  }

  .app.device-mobile .campaign-camp-dialog-body .campaign-choice span {
    font-size: 9px;
    line-height: 1.3;
  }

  .app.device-mobile .campaign-member-dialog .campaign-member-card {
    display: grid;
    grid-template-columns: minmax(138px, 0.28fr) minmax(0, 1fr);
    grid-template-areas: "head equipment" "vitals equipment" "ai attributes" "skills attributes" "sets sets";
    align-content: start;
    gap: 5px 8px;
  }

  .app.device-mobile .campaign-member-dialog .campaign-member-head {
    grid-area: head;
    min-height: 0;
    gap: 5px;
    margin: 0;
    padding: 0;
  }

  .app.device-mobile .campaign-member-dialog .campaign-member-head img {
    width: 35px;
    height: 43px;
  }

  .app.device-mobile .campaign-member-dialog .campaign-member-head strong,
  .app.device-mobile .campaign-member-dialog .campaign-member-head span {
    font-size: 10px;
  }

  .app.device-mobile .campaign-member-dialog .campaign-vitals.prominent {
    grid-area: vitals;
    gap: 3px;
    padding: 0;
  }

  .app.device-mobile .campaign-member-dialog .campaign-vitals.prominent .campaign-vital {
    grid-template-columns: 18px minmax(0, 1fr) auto;
    gap: 3px;
    font-size: 9px;
  }

  .app.device-mobile .campaign-member-dialog .campaign-vitals.prominent .campaign-vital em {
    min-width: 0;
    padding: 2px;
  }

  .app.device-mobile .campaign-member-dialog .campaign-vitals.prominent .campaign-vital em strong {
    font-size: 12px;
  }

  .app.device-mobile .campaign-member-dialog .campaign-vitals.prominent .campaign-vital em small {
    font-size: 8px;
  }

  .app.device-mobile .campaign-member-dialog .campaign-ai-toggle {
    grid-area: ai;
    margin: 0;
    padding: 4px;
    font-size: 9px;
  }

  .app.device-mobile .campaign-member-dialog .campaign-member-capabilities {
    grid-area: skills;
    margin: 0;
  }

  .app.device-mobile .campaign-member-dialog .campaign-member-capabilities summary {
    padding: 5px;
    font-size: 9px;
  }

  .app.device-mobile .campaign-member-dialog .campaign-equip-slots {
    grid-area: equipment;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    margin: 0;
  }

  .app.device-mobile .campaign-member-dialog .campaign-equip-slot {
    min-height: 48px;
    padding: 4px;
  }

  .app.device-mobile .campaign-member-dialog .campaign-equip-slot > span,
  .app.device-mobile .campaign-member-dialog .campaign-equip-slot > strong {
    overflow: hidden;
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app.device-mobile .campaign-member-dialog .campaign-attribute-grid {
    grid-area: attributes;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
  }

  .app.device-mobile .campaign-member-dialog .campaign-attribute-grid button {
    min-height: 48px;
    gap: 2px;
    padding: 4px;
  }

  .app.device-mobile .campaign-member-dialog .campaign-attribute-grid button strong {
    font-size: 10px;
  }

  .app.device-mobile .campaign-member-dialog .campaign-attribute-grid button span {
    display: -webkit-box;
    overflow: hidden;
    font-size: 8px;
    line-height: 1.2;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .app.device-mobile .campaign-member-dialog .campaign-set-bonuses {
    grid-area: sets;
    margin: 0;
  }

  .app.device-mobile .campaign-merchant-dialog .campaign-merchant-layout {
    flex: 1 1 auto;
    grid-template-columns: minmax(155px, 0.32fr) minmax(0, 1fr);
    align-items: stretch;
    gap: 7px;
    min-height: 0;
    overflow: hidden;
  }

  .app.device-mobile .campaign-merchant-dialog .campaign-camp-dialog-body {
    overflow: hidden;
  }

  .app.device-mobile .campaign-merchant-dialog .campaign-rest-section {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    margin: 0;
    overflow: hidden;
  }

  .app.device-mobile .campaign-merchant-dialog .campaign-merchant-summary {
    align-content: start;
    gap: 5px;
    min-height: 0;
    padding: 5px;
    overflow-y: auto;
  }

  .app.device-mobile .campaign-merchant-dialog .campaign-merchant-stock {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 5px;
    min-height: 0;
    overflow: hidden;
  }

  .app.device-mobile .campaign-merchant-dialog .campaign-merchant-refresh,
  .app.device-mobile .campaign-merchant-dialog .campaign-merchant-sell,
  .app.device-mobile .campaign-merchant-dialog .campaign-merchant-sold {
    grid-column: 1 / -1;
  }

  .app.device-mobile .campaign-merchant-dialog .campaign-merchant-refresh {
    min-height: 27px;
    margin: 0;
    padding: 4px;
    font-size: 10px;
  }

  .app.device-mobile .campaign-merchant-dialog .campaign-merchant-group {
    min-height: 0;
    margin: 0;
    overflow-y: auto;
  }

  .app.device-mobile .campaign-merchant-dialog .campaign-merchant-group .campaign-choice-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .app.device-mobile .campaign-merchant-dialog .campaign-merchant-sell-grid {
    display: flex;
    gap: 4px;
    max-height: 46px;
    overflow-x: auto;
  }

  .app.device-mobile .campaign-merchant-dialog .campaign-merchant-sell-grid button {
    flex: 0 0 130px;
    min-height: 32px;
    padding: 3px 5px;
  }

  .app.device-mobile .campaign-blacksmith-dialog .campaign-blacksmith-menu {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }

  .app.device-mobile .campaign-blacksmith-dialog .campaign-blacksmith-mode {
    min-height: 80px;
    gap: 3px;
    padding: 6px;
  }

  .app.device-mobile .campaign-blacksmith-dialog .campaign-blacksmith-mode strong {
    font-size: 12px;
  }

  .app.device-mobile .campaign-blacksmith-dialog .campaign-blacksmith-mode span,
  .app.device-mobile .campaign-blacksmith-dialog .campaign-blacksmith-mode em,
  .app.device-mobile .campaign-blacksmith-dialog .campaign-forge-uses {
    font-size: 9px;
  }

  .app.device-mobile .campaign-blacksmith-dialog .campaign-section-title .ghost {
    flex: 0 0 auto;
    min-height: 28px;
    padding: 4px 7px;
    font-size: 10px;
  }

  .app.device-mobile .campaign-blacksmith-dialog:not(.campaign-blacksmith-menu-dialog) .campaign-rest-section {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
  }

  .app.device-mobile .campaign-blacksmith-dialog .campaign-forge-grid {
    flex: 1 1 auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
    min-height: 0;
    overflow-y: auto;
  }

  .app.device-mobile .campaign-blacksmith-dialog .campaign-forge-item {
    padding: 6px;
  }

  .app.device-mobile .campaign-camp-dialog-body .campaign-recruit-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }

  .app.device-mobile .campaign-camp-dialog-body .campaign-recruit-grid button {
    min-height: 88px;
    padding-bottom: 4px;
  }

  .app.device-mobile .campaign-camp-dialog-body .campaign-recruit-grid img {
    height: 62px;
  }

  .app.device-mobile .campaign-capability-modal {
    width: min(720px, calc(100dvw - 12px));
    max-height: calc(100dvh - 12px);
    gap: 5px;
    padding: 10px;
    overflow-y: auto;
  }

  .app.device-mobile .campaign-capability-modal h2 {
    margin: 0;
    font-size: 17px;
  }

  .app.device-mobile .campaign-skill-choice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }

  .app.device-mobile .campaign-skill-choice-grid button {
    min-height: 90px;
    gap: 3px;
    padding: 6px;
  }

  .app.device-mobile .campaign-skill-choice-grid button > strong {
    font-size: 12px;
  }

  .app.device-mobile .campaign-skill-choice-grid button p {
    margin: 0;
    font-size: 9px;
    line-height: 1.25;
  }

  .app.device-mobile .campaign-drop[data-set-tooltip]:hover::after {
    display: none;
  }

  .app.device-mobile .campaign-event-dialog {
    width: min(680px, calc(100dvw - 16px));
    max-height: calc(100dvh - 16px);
    gap: 9px;
    padding: 14px;
  }

  .app.device-mobile .campaign-event-dialog h2 {
    font-size: 22px;
  }

  .app.device-mobile .campaign-event-dialog .campaign-event-flavor {
    font-size: 12px;
    line-height: 1.5;
  }

  .app.device-mobile .campaign-event-modal .campaign-choice-grid,
  .app.device-mobile .campaign-event-modal .campaign-attribute-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .app.device-mobile .campaign-event-modal .campaign-choice,
  .app.device-mobile .campaign-event-modal .campaign-event-option {
    min-height: 58px;
    padding: 8px;
  }

  .app.device-mobile .campaign-summary,
  .app.device-mobile .campaign-special-stage {
    gap: 8px;
    margin-top: 8px;
  }

  .app.device-mobile .campaign-summary-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .app.device-mobile .campaign-summary-stats > div,
  .app.device-mobile .campaign-summary-member {
    padding: 7px;
  }

  .app.device-mobile .campaign-exit {
    min-height: 36px;
    margin-top: 8px;
    font-size: 12px;
  }
}

@media (max-width: 900px) and (orientation: landscape) and (max-height: 340px) {
  /* Extra-short displays may scroll the whole camp rather than clipping a
     required route, service, or continue button. */
  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] > .campaign-camp-card {
    height: auto;
    min-height: 340px;
    overflow: visible;
  }

  .app.device-mobile .campaign-overlay[data-campaign-overlay-mode="rest"] .campaign-camp-scene {
    min-height: 275px;
    overflow: visible;
  }
}

/* Desktop and portrait retain the existing continuous camp document. */
.campaign-mobile-tabs,
.campaign-equip-back { display: none; }
.campaign-member-profile,
.campaign-member-main,
.campaign-member-pane,
.campaign-mobile-workspace,
.campaign-chest-pane { display: contents; }

@media (max-width: 900px) and (orientation: landscape) {
  .app.device-mobile .campaign-camp-dialog {
    height: calc(100dvh - 12px);
    animation: none;
  }

  .app.device-mobile .campaign-chest-dialog,
  .app.device-mobile .campaign-recovery-dialog {
    width: min(740px, 100%);
    height: auto;
    max-height: calc(100dvh - 12px);
  }

  .app.device-mobile .campaign-chest-dialog .campaign-camp-dialog-body,
  .app.device-mobile .campaign-recovery-dialog .campaign-camp-dialog-body {
    flex: 0 1 auto;
    max-height: calc(100dvh - 54px);
    overflow-y: auto;
  }

  .app.device-mobile .campaign-camp-dialog-body {
    flex: 1 1 auto;
    max-height: none;
    min-height: 0;
    padding: 6px 10px 9px;
  }

  .app.device-mobile .campaign-camp-dialog-body .campaign-section-title {
    flex-direction: row;
    align-items: center;
  }

  .app.device-mobile .campaign-mobile-tabs {
    display: flex;
    flex: 0 0 auto;
    gap: 5px;
    min-height: 35px;
    overflow-x: auto;
  }

  .app.device-mobile .campaign-mobile-tabs button {
    flex: 1 0 auto;
    min-height: 33px;
    padding: 5px 10px;
    border: 1px solid rgba(177, 153, 98, 0.3);
    border-radius: 7px;
    background: rgba(3, 8, 8, 0.56);
    color: #d7ceae;
    font-size: 11px;
    white-space: nowrap;
  }

  .app.device-mobile .campaign-mobile-tabs button[aria-pressed="true"] {
    border-color: rgba(215, 175, 84, 0.9);
    background: rgba(157, 116, 48, 0.25);
    color: #fff0be;
  }

  .app.device-mobile .campaign-mobile-tabs:has(> :only-child) { display: none; }

  .app.device-mobile .campaign-member-dialog .campaign-camp-dialog-body,
  .app.device-mobile .campaign-camp-dialog-body:has(.campaign-reading-groups) {
    overflow: hidden;
  }

  .app.device-mobile .campaign-member-dialog .campaign-member-workspace {
    display: grid;
    grid-template-columns: clamp(130px, 24%, 190px) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: none;
    align-content: stretch;
    gap: 8px;
    height: 100%;
    min-height: 0;
  }

  .app.device-mobile .campaign-member-dialog .campaign-member-profile {
    display: grid;
    grid-template-rows: auto auto auto;
    align-content: start;
    gap: 8px;
    min-width: 0;
    min-height: 0;
    padding: 7px;
    border: 1px solid rgba(177, 153, 98, 0.18);
    border-radius: 8px;
    background: rgba(3, 8, 8, 0.34);
    overflow-y: auto;
  }

  .app.device-mobile .campaign-member-dialog .campaign-member-head,
  .app.device-mobile .campaign-member-dialog .campaign-vitals.prominent,
  .app.device-mobile .campaign-member-dialog .campaign-ai-toggle {
    grid-area: auto;
  }

  .app.device-mobile .campaign-member-dialog .campaign-member-head {
    display: flex;
    align-items: center;
    gap: 5px;
  }

  .app.device-mobile .campaign-member-dialog .campaign-member-main,
  .app.device-mobile .campaign-reading-groups {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    align-content: stretch;
    gap: 7px;
    min-width: 0;
    min-height: 0;
    height: 100%;
  }

  .app.device-mobile .campaign-chest-workspace {
    display: grid;
    grid-template-rows: auto auto;
    gap: 5px;
    min-width: 0;
    height: auto;
  }

  .app.device-mobile .campaign-member-dialog .campaign-member-pane,
  .app.device-mobile .campaign-reading-member-section {
    display: none;
    min-height: 0;
    overflow-y: auto;
  }

  .app.device-mobile .campaign-chest-pane { display: none; min-width: 0; }

  .app.device-mobile .campaign-member-dialog .campaign-member-pane[data-active="true"],
  .app.device-mobile .campaign-chest-pane[data-active="true"],
  .app.device-mobile .campaign-reading-member-section[data-active="true"] {
    display: block;
  }

  .app.device-mobile .campaign-member-dialog .campaign-attribute-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: minmax(96px, 1fr);
    height: 100%;
    gap: 6px;
  }

  .app.device-mobile .campaign-member-dialog .campaign-attribute-grid button {
    min-height: 96px;
    align-content: center;
    gap: 5px;
    padding: 8px;
  }

  .app.device-mobile .campaign-member-dialog .campaign-attribute-grid button strong { font-size: 13px; }
  .app.device-mobile .campaign-member-dialog .campaign-attribute-grid button span {
    display: block;
    font-size: 10px;
    line-height: 1.3;
  }

  .app.device-mobile .campaign-member-dialog .campaign-equip-slots {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: minmax(98px, 1fr);
    height: 100%;
    gap: 6px;
  }

  .app.device-mobile .campaign-member-dialog .campaign-equip-slot-wrap { min-height: 0; }
  .app.device-mobile .campaign-member-dialog .campaign-equip-slot {
    width: 100%;
    min-height: 96px;
    align-content: center;
    gap: 8px;
    padding: 9px;
  }

  .app.device-mobile .campaign-member-dialog .campaign-equip-slot > span,
  .app.device-mobile .campaign-member-dialog .campaign-equip-slot > strong { font-size: 12px; }

  .app.device-mobile .campaign-member-dialog .campaign-member-capabilities { margin: 0; }
  .app.device-mobile .campaign-member-dialog .campaign-member-capabilities summary { padding: 9px; font-size: 12px; }
  .app.device-mobile .campaign-member-dialog .campaign-set-bonuses { margin-top: 7px; }

  .app.device-mobile .campaign-equip-dialog .campaign-equip-back {
    display: inline-flex;
    align-items: center;
    min-height: 29px;
    padding: 4px 10px;
    font-size: 11px;
  }

  .app.device-mobile .campaign-equip-dialog .campaign-inventory-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }

  .app.device-mobile .campaign-chest-dialog .campaign-choice-grid,
  .app.device-mobile .campaign-camp-dialog-body .campaign-recovery-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .app.device-mobile .campaign-chest-dialog .campaign-choice,
  .app.device-mobile .campaign-recovery-options .campaign-choice {
    min-height: 96px;
    align-content: center;
    gap: 5px;
    padding: 9px;
  }

  .app.device-mobile .campaign-chest-dialog .campaign-choice strong,
  .app.device-mobile .campaign-recovery-options .campaign-choice strong { font-size: 12px; }
  .app.device-mobile .campaign-chest-dialog .campaign-choice span,
  .app.device-mobile .campaign-recovery-options .campaign-choice span { font-size: 10px; line-height: 1.35; }

  .app.device-mobile .campaign-camp-dialog-body:has(.campaign-recovery-options) {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .app.device-mobile .campaign-recovery-options:has(> :nth-child(4)) { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  .app.device-mobile .campaign-reading-groups .campaign-mobile-tabs button { flex: 0 0 auto; }
  .app.device-mobile .campaign-reading-member-section { margin: 0; }
  .app.device-mobile .campaign-reading-member-section .campaign-choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .app.device-mobile .campaign-reading-member-section .campaign-choice {
    min-height: 95px;
    align-content: center;
    padding: 10px;
  }
  .app.device-mobile .campaign-reading-member-section .campaign-choice strong { font-size: 13px; }
  .app.device-mobile .campaign-reading-member-section .campaign-choice span { font-size: 10px; }

  .app.device-mobile .campaign-reading-back {
    flex: 0 0 auto;
    min-height: 29px;
    padding: 4px 10px;
    font-size: 11px;
  }

  .app.device-mobile .campaign-jingdu-options .campaign-choice {
    min-height: 112px;
    align-content: center;
    padding: 11px;
  }

  .app.device-mobile .campaign-jingdu-options .campaign-choice strong { font-size: 13px; }
  .app.device-mobile .campaign-jingdu-options .campaign-choice span { font-size: 10px; line-height: 1.4; }
  .app.device-mobile .campaign-jingdu-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app.device-mobile .campaign-jingdu-options:has(> :nth-child(3)) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* 手机视图战斗状态栏：左侧我方队伍框架 + 右侧焦点目标面板。
   由实际手机视图决定是否显示，覆盖宽屏 iPad 和手动手机预设。
   复用现有的 BUFF 芯片与点击详情交互，不引入新的状态逻辑。 */
  .app.device-mobile.battle-started.mobile-battle-workspace .mobile-status-hud {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: block;
    pointer-events: none;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace .mobile-status-hud.hidden {
    display: none !important;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace .mobile-ally-frames {
    position: fixed;
    top: max(52px, calc(env(safe-area-inset-top, 0px) + 52px));
    bottom: max(86px, calc(env(safe-area-inset-bottom, 0px) + 86px));
    left: max(4px, env(safe-area-inset-left, 0px));
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: clamp(92px, 18vw, 148px);
    padding: 2px;
    pointer-events: auto;
    overflow-y: auto;
    scrollbar-width: none;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace .mobile-ally-frames::-webkit-scrollbar {
    display: none;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace .mobile-focus-bar {
    position: fixed;
    top: max(52px, calc(env(safe-area-inset-top, 0px) + 52px));
    bottom: auto;
    max-height: calc(100dvh - 138px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    right: max(4px, env(safe-area-inset-right, 0px));
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: clamp(108px, 22vw, 176px);
    padding: 6px 7px;
    pointer-events: auto;
    overflow-y: auto;
    scrollbar-width: none;
    border: 1px solid rgba(215, 175, 84, 0.28);
    border-radius: 10px;
    background: rgba(8, 11, 8, 0.78);
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.42);
  }

  .app.device-mobile.battle-started.mobile-battle-workspace .mobile-focus-bar::-webkit-scrollbar {
    display: none;
  }

  /* 详细状态卡/日志、反应窗口或历练菜单打开时，让常驻 HUD 让出空间。 */
  .app.device-mobile.battle-started.mobile-battle-workspace[data-mobile-panel-open="focus"] .mobile-status-hud,
  .app.device-mobile.battle-started.mobile-battle-workspace[data-mobile-panel-open="log"] .mobile-status-hud,
  .app.device-mobile.battle-started.mobile-battle-workspace:has(#extraActionSection.active.reaction-window, .campaign-overlay:not(.hidden)) .mobile-status-hud {
    visibility: hidden;
    pointer-events: none;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace .mobile-ally-frame {
    position: relative;
    padding: 5px 6px;
    border: 1px solid rgba(215, 175, 84, 0.28);
    border-radius: 10px;
    background: rgba(8, 11, 8, 0.78);
    backdrop-filter: blur(8px);
    color: #f3dda3;
    cursor: pointer;
    transition: transform 100ms ease, border-color 100ms ease, box-shadow 100ms ease;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace .mobile-ally-frame.is-focus {
    border-color: rgba(244, 201, 79, 0.85);
    box-shadow: 0 0 0 1px rgba(244, 201, 79, 0.22), 0 0 12px rgba(244, 201, 79, 0.22);
  }

  .app.device-mobile.battle-started.mobile-battle-workspace .mobile-ally-frame.is-acting {
    border-color: rgba(110, 216, 164, 0.7);
  }

  .app.device-mobile.battle-started.mobile-battle-workspace .mobile-ally-frame.is-dead {
    opacity: 0.45;
    filter: grayscale(0.7);
  }

  .app.device-mobile.battle-started.mobile-battle-workspace .mobile-ally-frame .frame-name,
  .app.device-mobile.battle-started.mobile-battle-workspace .mobile-focus-bar .mobile-focus-head strong {
    display: block;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.2;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace .mobile-focus-bar .mobile-focus-head .small {
    font-size: 8px;
    color: rgba(243, 221, 163, 0.72);
  }

  .app.device-mobile.battle-started.mobile-battle-workspace .frame-bars {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 3px 0;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace .frame-bar {
    position: relative;
    height: 6px;
    border: 1px solid rgba(8, 10, 7, 0.72);
    border-radius: 999px;
    background: rgba(20, 24, 18, 0.9);
    overflow: hidden;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace .frame-bar.ep {
    height: 10px;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace .frame-bar i {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    display: block;
    border-radius: 999px;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace .frame-bar.hp i {
    background: linear-gradient(90deg, #a0403a, #d8544f);
  }

  .app.device-mobile.battle-started.mobile-battle-workspace .frame-bar.ep i {
    background: linear-gradient(90deg, #ae811b, #f2cf59);
  }

  .app.device-mobile.battle-started.mobile-battle-workspace .frame-bar b {
    position: absolute;
    top: 50%;
    right: 3px;
    transform: translateY(-50%);
    color: #fff;
    font-size: 7px;
    line-height: 1;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  }

  .app.device-mobile.battle-started.mobile-battle-workspace .mobile-status-hud .status-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    margin: 0;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace .mobile-status-hud .status-chip {
    min-height: 15px;
    padding: 1px 3px;
    font-size: 8px;
  }

  .app.device-mobile.battle-started.mobile-battle-workspace .mobile-status-hud .status-chip.empty {
    display: none;
  }

  /* 只让出展开技能盘所在的一侧，另一侧仍可查看状态或切换角色。 */
  .app.device-mobile.battle-started.mobile-battle-workspace:has(#readyActionSection.radial-open, #constructActionSection.radial-open) .mobile-ally-frames,
  .app.device-mobile.battle-started.mobile-battle-workspace:has(#turnFloat.radial-open, #comboActionSection.radial-open) .mobile-focus-bar {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 120ms ease, visibility 0s linear 120ms;
  }

/* 同一状态入口：头像显示生命/定力，详情复用完整角色卡。 */
.app.device-mobile.battle-started.mobile-battle-workspace .mobile-unit-summary {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.app.device-mobile.battle-started.mobile-battle-workspace .mobile-unit-vitals {
  flex: 1;
  min-width: 0;
}
.app.device-mobile.battle-started.mobile-battle-workspace .mobile-unit-portrait {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(215, 190, 125, .42);
  border-radius: 50%;
  background: #20251b;
  color: #f3dda3;
  touch-action: manipulation;
}
.app.device-mobile.battle-started.mobile-battle-workspace .mobile-unit-portrait img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 22%;
}
.app.device-mobile.battle-started.mobile-battle-workspace .frame-bar.hp {
  height: 10px;
}
.app.device-mobile.battle-started.mobile-battle-workspace .frame-bar b {
  font-size: 8px;
}
.app.device-mobile.battle-started.mobile-battle-workspace #focusFloat {
  display: none !important;
}
.app.device-mobile.battle-started.mobile-battle-workspace[data-mobile-panel-open="focus"] #focusFloat {
  position: fixed !important;
  top: max(48px, env(safe-area-inset-top, 0px)) !important;
  left: max(7px, env(safe-area-inset-left, 0px)) !important;
  right: auto !important;
  bottom: auto !important;
  display: flex !important;
  flex-direction: column;
  width: min(340px, calc(100dvw - 14px)) !important;
  max-width: min(340px, calc(100dvw - 14px)) !important;
  height: auto !important;
  max-height: calc(100dvh - 62px - env(safe-area-inset-bottom, 0px)) !important;
  margin: 0 !important;
  padding: 8px !important;
  overflow: hidden !important;
  transform: none !important;
  z-index: 132;
}
.app.device-mobile.battle-started.mobile-battle-workspace #focusFloat .float-handle {
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 5px;
  margin: -8px -8px 8px;
  padding: 6px 8px;
}
.app.device-mobile.battle-started.mobile-battle-workspace #focusFloat .float-handle > strong {
  font-size: 13px;
}
.app.device-mobile.battle-started.mobile-battle-workspace #focusFloat .chip,
.app.device-mobile.battle-started.mobile-battle-workspace #focusFloat .icon-btn {
  min-height: 30px;
  padding: 4px 6px;
  font-size: 12px;
}
.app.device-mobile.battle-started.mobile-battle-workspace #focusFloat .panel-collapse-btn {
  display: none;
}
.app.device-mobile.battle-started.mobile-battle-workspace #focusCard,
.app.device-mobile.battle-started.mobile-battle-workspace #focusFloat.collapsed #focusCard {
  display: block !important;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  font-size: 12px;
  line-height: 1.4;
}
.app.device-mobile.battle-started.mobile-battle-workspace #focusCard .small {
  font-size: 12px;
}
.app.device-mobile.battle-started.mobile-battle-workspace #focusCard .resource-bar .small {
  font-size: 12px;
  gap: 4px;
}
.app.device-mobile.battle-started.mobile-battle-workspace #focusCard .focus-bars {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 10px;
  margin-top: 8px;
}
.app.device-mobile.battle-started.mobile-battle-workspace #focusCard .barline {
  height: 7px;
}
.app.device-mobile.battle-started.mobile-battle-workspace #focusCard .unit-status-area {
  display: grid;
  gap: 6px;
}
.app.device-mobile.battle-started.mobile-battle-workspace #focusCard .status-grid {
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
}

/* The stricter of BUFF count and party size determines both HUD columns.
   Keep names and counters inside narrow cells; full text remains in details. */
.app.device-mobile.battle-started.mobile-battle-workspace .mobile-status-hud .status-grid[data-status-columns],
.app.device-mobile.battle-started.mobile-battle-workspace #focusCard .status-grid[data-status-columns] {
  display: grid;
  grid-template-columns: repeat(var(--status-columns), minmax(0, 1fr));
}
.app.device-mobile.battle-started.mobile-battle-workspace .mobile-status-hud .status-grid[data-status-columns] .status-chip {
  min-width: 0;
  gap: 1px;
  padding-inline: 2px;
}
.app.device-mobile.battle-started.mobile-battle-workspace .mobile-status-hud .status-grid[data-status-columns] .status-chip strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app.device-mobile.battle-started.mobile-battle-workspace .mobile-status-hud .status-grid[data-status-columns] .status-chip strong,
.app.device-mobile.battle-started.mobile-battle-workspace .mobile-status-hud .status-grid[data-status-columns] .status-chip em {
  font-size: inherit;
}
.app.device-mobile.battle-started.mobile-battle-workspace .mobile-status-hud .status-grid[data-status-columns] .status-chip--tick {
  padding-inline: 1px;
}
.app.device-mobile.battle-started.mobile-battle-workspace .mobile-status-hud .status-grid[data-status-columns] .status-chip em.status-tick-value {
  font-size: 7px;
}
.app.device-mobile.battle-started.mobile-battle-workspace .mobile-ally-frames {
  container: mobile-buff-list / inline-size;
}
@container mobile-buff-list (max-width: 132px) {
  .app.device-mobile.battle-started.mobile-battle-workspace .mobile-ally-frames .status-grid[data-status-columns="3"] .status-chip--tick {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    line-height: 1;
  }
  .app.device-mobile.battle-started.mobile-battle-workspace .mobile-ally-frames .status-grid[data-status-columns="3"] .status-tick-value {
    justify-self: end;
  }
}
.app.device-mobile.battle-started.mobile-battle-workspace #focusCard .status-chip {
  min-height: 30px;
  font-size: 12px;
}
.app.device-mobile.battle-started.mobile-battle-workspace #focusCard .fill.ep {
  background: #e7bd43;
}
.app.device-mobile.battle-started.mobile-battle-workspace #focusCard .unit-attributes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 8px 0;
}
.app.device-mobile.battle-started.mobile-battle-workspace #focusCard .unit-attributes span {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  padding: 4px;
  background: rgba(20, 25, 18, .8);
  border-radius: 4px;
}
.app.device-mobile .skill-tooltip-anchor {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
.app.device-mobile .skill-tooltip-anchor button:disabled {
  /* Disabled controls can swallow touch events in Safari. Let their existing
     tooltip wrapper receive the hold while the actual action stays disabled. */
  pointer-events: none;
}

/* Phone layout also applies to tablets that explicitly select the mobile view. */
.settlement-mobile-actions { display: none; }
.app.device-mobile.battle-finished #settlementPanel:not(.hidden) {
  position: fixed;
  inset: max(8px, env(safe-area-inset-top, 0px)) max(8px, env(safe-area-inset-right, 0px)) max(8px, env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
  z-index: 160;
  width: auto;
  height: auto;
  max-height: none;
  overflow: auto;
  background: #121810;
  pointer-events: auto;
}
.app.device-mobile.battle-started.battle-finished .battle-stage {
  z-index: 130;
}
.app.device-mobile.battle-finished .settlement-mobile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}
.app.device-mobile.battle-finished .settlement-mobile-actions button {
  min-height: 36px;
}
.app.device-mobile.battle-finished #settlementPanel > .row {
  flex-wrap: wrap;
  gap: 8px;
}
.app.device-mobile.battle-finished .settlement-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.app.device-mobile.battle-finished[data-mobile-panel-open="log"] #settlementPanel {
  display: none;
}
.app.device-mobile.battle-finished #logPanel {
  display: none !important;
}
.app.device-mobile.battle-finished[data-mobile-panel-open="log"] #logPanel {
  display: flex !important;
}
.app.device-mobile.battle-finished .combat-resource-float,
.app.device-mobile.battle-finished .action-dock,
.app.device-mobile.battle-finished #boardMoveControl {
  pointer-events: none;
}
.app.device-mobile.battle-started .battle-cue-stack {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  bottom: auto;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  width: min(300px, calc(100dvw - 220px));
  gap: 0;
  filter: none;
  pointer-events: none;
}
.app.device-mobile.battle-started .battle-action-cue {
  grid-template-columns: auto minmax(0, 1fr);
  min-height: 24px;
  padding: 3px 7px;
  gap: 5px;
  border-radius: 5px;
  border-left-width: 2px;
  background: rgba(13, 18, 14, .72);
  backdrop-filter: none;
  box-shadow: none;
}
.app.device-mobile.battle-started .battle-action-cue > span {
  font-size: 8px;
  line-height: 1.2;
  white-space: nowrap;
}
.app.device-mobile.battle-started .battle-action-cue > div {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 5px;
}
.app.device-mobile.battle-started .battle-action-cue small {
  max-width: 70px;
  font-size: 9px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app.device-mobile.battle-started .battle-action-cue strong {
  min-width: 0;
  font-size: 11px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app.device-mobile.battle-started .battle-action-cue em {
  display: none;
}
