/* design/SKILL.md §4.2 / §4.3 / §6.4 — physical offsets and expanded selectors
   keep legacy Android WebViews in the same fitted stage as modern hosts. */
/* design/SKILL.md §2.3 / §4.3 — the supplied complete rules image owns its text. */

/* H5 fallback page pinch zoom. The native WebView may not expose pinch zoom
   on every Android build, so app.js scales the complete logical page here. */
html.h5-page-zoom #game-container {
  transform-origin: 0 0;
  /* Once zoomed, background panning is owned by app.js. Prevent Android
     WebView's one-finger page pan from cancelling the pointer stream. */
  touch-action: none;
  transform: translate3d(var(--h5-page-pan-x, 0px), var(--h5-page-pan-y, 0px), 0)
    scale(var(--h5-page-zoom, 1));
}
html.h5-page-zoom.dx-host-layout #game-container {
  transform: translate3d(var(--h5-page-pan-x, 0px), var(--h5-page-pan-y, 0px), 0)
    scale(calc(var(--dx-stage-scale, 1) * var(--h5-page-zoom, 1)));
}
.official-ui-active #rules-modal.supplied-rules .rules-box {
  /* §4.2 / §4.3 — the fitted stage owns viewport scaling; 86vh here
     shrinks the 500px panel twice and moves its close button over the text. */
  max-height: none;
  background: none;
}
.official-ui-active #rules-modal.supplied-rules #rules-content {
  top: 0; right: 0; bottom: 0; left: 0;
  width: 770px;
  height: 500px;
  padding: 0;
  margin: 0;
  overflow: hidden;
  background: none !important;
}
.official-ui-active #rules-modal.supplied-rules .supplied-rules-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.official-ui-active #rules-modal.supplied-rules #btn-close-rules {
  z-index: 2;
}
/* design/SKILL.md §4.2 / §4.3 — center the 16px icon on the supplied 33px
   title band while retaining a 44px-wide interactive target. */
.official-ui-active #rules-modal.supplied-rules #btn-close-rules-icon {
  top: 0; right: 0; width: 44px; height: 33px; min-height: 33px;
  background-position: center !important; background-size: 16px 16px !important;
}
/* design/SKILL.md §4.2 / §4.3 — compact life glyphs and adjacent action targets. */
.official-ui-active .official-enemy-hp .bitmap-glyph {
  height: 14px;
}
.official-ui-active #enemy-select-screen .select-actions-fixed {
  gap: 10px;
}
.official-ui-active #btn-back-start,
.official-ui-active #btn-deck-prep {
  width: 116px;
  min-width: 116px;
}

/* design/SKILL.md §4.2 / §6.4 — the native 16px glyph has a 44px target,
   stays inside the safe area and remains reachable during tutorial steps. */
.official-ui-active.h5-exit-enabled #btn-close-game {
  display: block; position: fixed; top: 8px; right: 8px;
  top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right));
  width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 0;
  z-index: 800; border: 0; background-color: transparent;
  background-size: 16px 16px !important; background-position: center !important;
  background-repeat: no-repeat !important; touch-action: manipulation;
}
.official-ui-active.h5-exit-enabled #btn-close-game:focus-visible {
  outline: 1px solid #d6b774; outline-offset: -4px;
}
.official-ui-active #confirm-modal.official-game-exit-dialog { z-index: 850; }

/* design/SKILL.md §2.3 / §4.3 — supplement 7 supplies the screen dimming.
   Preserve its alpha once, without stacking the old dim and vignette over it. */
/* design/SKILL.md §1.3 / §4.3 — the neutral home filter must not allocate a full-screen effect during navigation. */
.official-ui-active #global-bg-stage.bg-focus-start #global-bg-media,
.official-ui-active #global-bg-stage.bg-focus-enemy-select #global-bg-media,
.official-ui-active #global-bg-stage.bg-focus-deck-prep #global-bg-media,
.official-ui-active #global-bg-stage.bg-focus-battle #global-bg-media,
.official-ui-active #global-bg-stage.bg-focus-result #global-bg-media {
  filter: none;
}
.official-ui-active #global-bg-stage.bg-focus-enemy-select #global-bg-vignette,
.official-ui-active #global-bg-stage.bg-focus-deck-prep #global-bg-vignette,
.official-ui-active #global-bg-stage.bg-focus-battle #global-bg-vignette,
.official-ui-active #global-bg-stage.bg-focus-result #global-bg-vignette {
  opacity: 0;
}
.official-ui-active #global-bg-stage.bg-focus-enemy-select #global-bg-dim,
.official-ui-active #global-bg-stage.bg-focus-deck-prep #global-bg-dim {
  background: url("../assets/ui/prep/screen_mask.png") center / 100px 100px repeat;
}
.official-ui-active #global-bg-stage.bg-focus-battle #global-bg-dim,
.official-ui-active #global-bg-stage.bg-focus-result #global-bg-dim {
  background: url("../assets/ui/battle/right_panel_mask.png") center / 100px 100px repeat;
}

/* design/SKILL.md §4.3 / §5.3 — the homepage shows the supplied background
   without the old edge masks, dim layer or vignette. */
.official-ui-active #start-screen::before,
.official-ui-active #start-screen::after { content: none; }
.official-ui-active #global-bg-stage.bg-focus-start #global-bg-dim,
.official-ui-active #global-bg-stage.bg-focus-start #global-bg-vignette {
  opacity: 0;
}

/* design/SKILL.md §4.2 / §4.3 — keep the two start actions centered with a 24px gap. */
.official-ui-active #start-screen .start-secondary-actions {
  bottom: -161px;
}

/* design/SKILL.md §4.2 / §4.3 — native 61×16 label, with a 98×44 click target.
   The supplied transparent lettering replaces the former painted button. */
.official-ui-active #btn-rules-start {
  width: 98px; min-width: 98px; height: 44px; min-height: 44px;
  border: 0 !important; border-radius: 0; color: transparent !important;
  background: transparent var(--official-control-art) center / 61px 16px no-repeat !important;
  box-shadow: none !important; font-size: 0; text-shadow: none;
}
.official-ui-active #btn-rules-start::before,
.official-ui-active #btn-rules-start::after { content: none; }
/* design/SKILL.md §4.3 / §5.2 / §7.2 — official panels have fixed transforms.
   Their legacy slide keyframes conflict with transform:none!important and
   force all seven entrance animations off the compositor during camera zoom.
   Keep the existing fade timing and stagger, animating only opacity. */
@keyframes officialEnemySelectFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.official-ui-active #enemy-select-screen .select-content-main,
.official-ui-active #enemy-select-screen .enemy-select-card {
  animation-name: officialEnemySelectFadeIn;
}
/* design/SKILL.md §5.2 / §7.2 — return to the existing choice immediately;
   the background camera supplies the motion, as on the homepage. */
.official-ui-active #enemy-select-screen.is-battle-return .select-content-main,
.official-ui-active #enemy-select-screen.is-battle-return .enemy-select-card {
  animation: none;
}

/* design/SKILL.md §4.1 / §4.2 / §4.3 — the fitted canvas already handles
   phone scaling. Keep three complete opponents in logical pixels so the
   visible cards, page counter and three-card navigation share one page size. */
.official-ui-active.dx-host-layout .enemy-selector-viewport {
  /* §4.2 / §6.4 — prevent percentage max-width and an auto grid track
     from shrinking the three-card canvas inside a mobile WebView. */
  width: 1028px;
  min-width: 1028px;
  max-width: none;
}
.official-ui-active.dx-host-layout .enemy-selector-shell.is-single .enemy-selector-viewport {
  width: 306px;
  min-width: 306px;
}

/* design/SKILL.md §4.3 — draw one continuous frame for pointer and keyboard
   feedback without changing layout or covering the opponent's identity. */
.official-ui-active .enemy-select-card::before {
  content: ''; position: absolute; top: 3px; right: 3px; bottom: 3px; left: 3px; z-index: 6;
  border: 2px solid #86fff0; border-radius: 0; opacity: 0;
  pointer-events: none; box-shadow: 0 0 5px rgba(103, 255, 233, .6);
}
.official-ui-active .enemy-select-card:hover::before,
.official-ui-active .enemy-select-card:active::before,
.official-ui-active .enemy-select-card.card-selected::before {
  opacity: 1;
}
.official-ui-active .enemy-select-card:focus-visible::before {
  opacity: 1;
}
/* design/SKILL.md §4.3 — the corrected supplied commander cards include
   difficulty icons and lettering; retain only live HP above those originals. */
.official-ui-active .enemy-select-card:has(.official-enemy-panel[src*="/tian_chengsi.png"]) .official-enemy-difficulty > img,
.official-ui-active .enemy-select-card:has(.official-enemy-panel[src*="/hunxie_yan.png"]) .official-enemy-difficulty > img {
  visibility: hidden;
}
/* design/SKILL.md §4.3 — this complete card owns its heart/divider positions.
   War 6 uses a different difficulty from the baked strip; anchor live HP to
   the artwork's slot so the divider cannot cross the last digit. */
.official-ui-active .official-enemy-panel[src*="/tian_chengsi.png"] ~ .enemy-card-body .official-enemy-hp {
  left: 66px;
  top: 79px;
}
/* design/SKILL.md §4.3 — Hunxie Yan's baked strip has its own HP slot,
   shared by the regular and War 4 cards regardless of gameplay difficulty. */
.official-ui-active .official-enemy-panel[src*="/hunxie_yan.png"] ~ .enemy-card-body .official-enemy-hp {
  left: 76px;
  top: 78px;
}

/* design/SKILL.md §4.3 / §7.4 — cover labels are live text, not 16px baked
   lettering resampled with the stage. Keep the supplied blank button art. */
.official-ui-active #start-screen .start-content { animation: none; }
.official-ui-active #start-screen #btn-start::after,
.official-ui-active #start-screen #btn-rules-start::after {
  content: attr(aria-label); position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  display: flex; align-items: center; justify-content: center;
  color: #f4f4ed; font: 14px/1.2 var(--font); letter-spacing: 0;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .6); pointer-events: none;
}
.official-ui-active #start-screen #btn-rules-start {
  background: none !important;
}
.official-ui-active #start-screen #btn-rules-start::after { text-decoration: underline; }

/* design/SKILL.md §4.2 / §7.4 — the card library scrolls within the logical
   stage, without a second physical-vh reduction of its card reading area. */
.official-ui-active.dx-host-layout #deck-modal .modal-box {
  height: 758px; max-height: 90%; max-width: 95%;
}

/* §4.2 / §4.3 — the 500px terrain page shares the same stage sizing as rules. */
.official-ui-active.dx-host-layout #terrain-legend-modal .rules-box { max-height: none; }
