/* 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 / §7.2 — supplied battle artwork is shared with
   the original inventory; this layer only corrects placement and image use. */
.official-ui-active #terrain-legend-modal .rules-box {
  width: 770px; height: 500px; padding: 0; background: none;
}
.official-ui-active #terrain-legend-modal .modal-title { display: none; }
.official-ui-active #terrain-legend-modal #terrain-legend-content {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 770px; height: 500px;
  padding: 0; margin: 0; overflow: hidden; background: none;
}
.official-terrain-legend-page { display: block; width: 770px; height: 500px; }
/* §4.2 — retain a 28px hit area around the supplied 16px close icon. */
.official-ui-active #terrain-legend-modal #btn-close-terrain-legend {
  left: auto; right: 1px; top: 2px; bottom: auto;
  width: 28px; min-width: 28px; height: 28px; min-height: 28px;
  padding: 0; transform: none;
  background-image: url("../assets/ui/rules/button_close_icon.png") !important;
  background-size: 16px 16px !important;
}

/* §4.3 — the complete small terrain image sits between vertically aligned totals. */
.official-ui-active .terrain-octagon.terrain-assets-enabled .terrain-base-layer {
  display: block; top: 50%; right: auto; bottom: auto; left: 50%; width: 240px; height: 50px;
  transform: translate(-50%, -50%); background-size: 240px 50px;
}
.official-ui-active .terrain-octagon.terrain-assets-enabled:not(.terrain-asset-fallback) .t-name,
.official-ui-active .terrain-octagon.terrain-assets-enabled:not(.terrain-asset-fallback) .t-hint {
  display: none !important;
}
.official-ui-active .terrain-octagon.terrain-asset-fallback .terrain-base-layer { display: none; }
.official-ui-active .terrain-octagon::before { content: none; }
.official-ui-active .terrain-oct-total,
.official-ui-active .terrain-oct-body { text-align: center; }
.official-ui-active #top-bar .hero-detail { align-items: center; text-align: center; }
/* design/SKILL.md §4.3 — identity rows follow the outer edge of their own HP bar. */
.official-ui-active #top-bar .hero-name,
.official-ui-active #top-bar .hero-title:not([hidden]) {
  display: flex; align-items: center; width: 100%;
}
.official-ui-active #top-bar .player-panel .hero-name,
.official-ui-active #top-bar .player-panel .hero-title:not([hidden]) {
  justify-content: flex-start; text-align: left;
}
.official-ui-active #top-bar .enemy-panel .hero-name,
.official-ui-active #top-bar .enemy-panel .hero-title:not([hidden]) {
  justify-content: flex-end; text-align: right;
}

/* §4.3 — supplied zone and preview images replace generated outline treatments. */
/* design/SKILL.md §4.3 — the supplied shelf fades into the battlefield;
   native-size ornaments sit at the two ends without stretching their pattern. */
.official-ui-active #hand-panel {
  /* §4.2 / §4.3 — move the complete hand shelf to the viewport bottom. */
  margin-top: auto;
  background: url("../assets/ui/battle/card_shelf_mask.png") center bottom / auto 105px repeat-x;
}
.official-ui-active #hand-panel::before,
.official-ui-active #hand-panel::after {
  content: ''; position: absolute; top: auto; right: auto; bottom: 0; left: 0; width: 142px; height: 138px;
  background: url("../assets/ui/battle/card_shelf_ornament.png") center / contain no-repeat;
  pointer-events: none; z-index: 0;
}
/* design/SKILL.md §2.3 / §4.3 — swap the handedness of the two shelf ornaments. */
.official-ui-active #hand-panel::before { transform: scaleX(-1); }
.official-ui-active #hand-panel::after { left: auto; right: 0; transform: none; }

/* design/SKILL.md §4.2 / §4.3 — horizontal scrolling also clips vertically.
   Extend its top by the 6px selection lift, preserving resting card positions. */
.official-ui-active #hand-cards {
  height: 242px; min-height: 242px; flex: 0 0 242px;
  margin-top: -6px; padding-top: 6px; box-sizing: border-box;
  overflow-y: hidden;
}

/* design/SKILL.md §6.4 — keep the battlefield readable during confirmation. */
.official-ui-active #confirm-modal { background: rgba(0, 0, 0, .5); }

/* §4.3 / §6.4 — use the supplied numeric preview frame. The corners remain
   native while the middle can extend for three-digit attack totals. */
.official-ui-active .terrain-oct-total { width: max-content; min-width: 24px; }
.official-ui-active .terrain-oct-total.lane-total-preview {
  outline: none; box-shadow: none; opacity: 1;
}
.official-ui-active .terrain-oct-total.lane-total-preview::after {
  content: ''; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: max(36px, calc(100% + 6px)); height: 34px; box-sizing: border-box;
  border: 3px solid transparent;
  border-image: url("../assets/ui/battle/total_power_preview_frame.png") 3 / 3px / 0 stretch;
  pointer-events: none;
}

.official-ui-active .player-lane.can-drop:not(.best-lane)::after,
.official-ui-active .player-lane.drag-over:not(.best-lane)::after {
  width: 308px; height: 170px; z-index: 1;
  background: url("../assets/ui/battle/terrain_bonus_popup.png") center / 100% 100% no-repeat;
}
.official-ui-active .player-lane.best-lane::before {
  /* §4.3 — the supplied 322×184 frame includes 7px of outer glow on each side. */
  width: 322px; height: 184px; z-index: 1;
  background: url("../assets/ui/battle/bonus_popup.png") center / 100% 100% no-repeat;
}
.official-ui-active .lane-cards .card-preview-ghost {
  border: 0 !important; opacity: .7;
}
.official-ui-active #game-screen .lane-cards .card.card-preview-ghost::after,
.official-ui-active #game-screen .lane-cards .card.one-click-preview-slot::after {
  content: ''; display: block !important; position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  width: 100%; height: 100%; z-index: 9; opacity: 1; border: 0;
  background: url("../assets/ui/battle/bonus_card_frame.png") center / 100% 100% no-repeat;
  animation: none; transform: none; mix-blend-mode: normal; pointer-events: none;
}

/* design/SKILL.md §4.3 / §6.4 — action-specific warning art shares the established confirmation frame. */
.official-ui-active #confirm-modal.official-quit-dialog .confirm-box,
.official-ui-active #confirm-modal.official-clear-dialog .confirm-box,
.official-ui-active #confirm-modal.official-prep-quit-dialog .confirm-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 480px; min-width: 480px; max-width: none; height: 108px; min-height: 108px;
  padding: 14px 20px; gap: 12px; border: 0; box-shadow: none;
  background: url("../assets/ui/prep/dialog/frame_bottom.png") center / 100% 100% no-repeat;
}
.official-ui-active #confirm-modal.official-quit-dialog .modal-title,
.official-ui-active #confirm-modal.official-clear-dialog .modal-title,
.official-ui-active #confirm-modal.official-prep-quit-dialog .modal-title { display: none; }
.official-ui-active #confirm-modal.official-quit-dialog .confirm-msg,
.official-ui-active #confirm-modal.official-clear-dialog .confirm-msg {
  width: 100%; height: 26px; min-height: 26px; flex: 0 0 26px; margin: 0;
  background-size: auto; background-position: center; background-repeat: no-repeat;
}
.official-ui-active #confirm-modal.official-quit-dialog .confirm-msg { background-image: url("../assets/ui/dialogs/quit/warning.png"); }
.official-ui-active #confirm-modal.official-clear-dialog .confirm-msg { background-image: url("../assets/ui/prep/dialog/warning.png"); }
.official-ui-active #confirm-modal.official-prep-quit-dialog .confirm-msg {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  width: 100%; min-height: 26px; margin: 0; color: #fff; font-size: 16px;
  line-height: 26px; letter-spacing: 0; background: none;
}
/* design/SKILL.md §4.3 — the supplied sentence already includes its warning icon. */
.official-ui-active #confirm-modal.official-prep-quit-dialog .confirm-msg img {
  display: block; width: 284px; height: 26px; flex: none;
}
.official-ui-active #confirm-modal.official-quit-dialog .confirm-actions,
.official-ui-active #confirm-modal.official-clear-dialog .confirm-actions,
.official-ui-active #confirm-modal.official-prep-quit-dialog .confirm-actions {
  align-items: center; height: 26px; margin: 0;
}
.official-ui-active #confirm-modal.official-quit-dialog .confirm-actions .btn-sm,
.official-ui-active #confirm-modal.official-prep-quit-dialog .confirm-actions .btn-sm {
  min-width: 112px; min-height: 26px; height: 26px; padding: 0 12px;
  font-size: 14px; line-height: 26px;
}

/* design/SKILL.md §4.2 / §4.3 — native state art sits inside a stable target.
   These selectors apply only while showConfirm has bound an exact action skin. */
.official-ui-active #confirm-modal.official-clear-dialog .confirm-actions,
.official-ui-active #confirm-modal.official-quit-dialog .confirm-actions,
.official-ui-active #confirm-modal.official-prep-quit-dialog .confirm-actions {
  height: 32px;
}
.official-ui-active #confirm-modal #btn-confirm-ok.official-confirm-control,
.official-ui-active #confirm-modal #btn-confirm-cancel.official-confirm-control {
  width: 112px; min-width: 112px; height: 32px; min-height: 32px; padding: 0;
  border: 0 !important; border-image: none !important; border-radius: 0;
  background-image: var(--official-control-art) !important;
  background-position: center !important; background-size: auto !important;
  background-repeat: no-repeat !important; color: transparent !important;
  text-shadow: none !important; box-shadow: none; filter: none; opacity: 1;
  transform: none; transition: none;
}
.official-ui-active #confirm-modal #btn-confirm-ok.official-confirm-control:hover,
.official-ui-active #confirm-modal #btn-confirm-cancel.official-confirm-control:hover {
  background-image: var(--official-control-art-hover, var(--official-control-art)) !important;
}
.official-ui-active #confirm-modal #btn-confirm-ok.official-confirm-control:focus-visible,
.official-ui-active #confirm-modal #btn-confirm-cancel.official-confirm-control:focus-visible {
  background-image: var(--official-control-art-hover, var(--official-control-art)) !important;
}
.official-ui-active #confirm-modal #btn-confirm-ok.official-confirm-control:active,
.official-ui-active #confirm-modal #btn-confirm-cancel.official-confirm-control:active {
  background-image: var(--official-control-art-pressed, var(--official-control-art-hover, var(--official-control-art))) !important;
}
.official-ui-active #confirm-modal #btn-confirm-ok.official-confirm-control:disabled,
.official-ui-active #confirm-modal #btn-confirm-cancel.official-confirm-control:disabled {
  background-image: var(--official-control-art-disabled, var(--official-control-art)) !important;
  cursor: not-allowed; filter: none; opacity: 1;
}

/* §4.3 — values occupy the lower half of each baked result cell. */
.official-ui-active #result-box .official-result-stats {
  top: 220px; left: 146px; width: 598px !important; height: 32px;
  grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px;
}
.official-ui-active #result-box .official-result-stat {
  width: 100%; height: 32px; min-height: 32px; gap: 3px; text-align: center;
}
/* design/SKILL.md §4.3 — result digits keep their native 14px height and
   individual source widths; the 17px word artwork remains independent. */
.official-ui-active #result-box .official-result-stat .bitmap-glyph {
  height: auto; width: auto; max-height: none; max-width: none; flex: none;
}
.official-ui-active #result-box .official-result-stat--round > .official-result-round-label {
  display: block; width: 34px; height: 17px;
}
.official-ui-active #result-box .official-result-stat--hp { gap: 2px; }
.result-hp-word {
  display: block; height: 17px; flex: none;
  background: url("../assets/ui/results/player_enemy_separator.png") left center / 80px 17px no-repeat;
}
.result-hp-word--player { width: 18px; }
.result-hp-word--separator { width: 11px; background-position-x: -43px; }
.result-hp-word--enemy { width: 18px; background-position-x: -62px; }

/* §4.3 — center the count on the front card silhouette in the baked HUD. */
.official-ui-active #top-bar #enemy-hero .enemy-deck-remain {
  right: 139px; top: 63px; width: 46px; height: 50px;
  display: flex; align-items: center; justify-content: center; padding: 0; gap: 0;
}
.official-ui-active #top-bar #enemy-hand-num {
  position: static; left: auto; min-width: 0; transform: none; line-height: 1;
}

/* design/SKILL.md §4.3 / §5.2 — the supplied 306×168 mask follows both
   settling rectangles above resting cards, below attack and result effects. */
.official-ui-active .lane > .lane-settlement-mask {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%;
  z-index: 3; object-fit: fill; pointer-events: none; user-select: none;
}

/* design/SKILL.md §4.3 — native HUD grooves are 214×20 at image y=58/59.
   Leave a 2px air gap inside each 2px frame edge; the fill stays readable. */
.official-ui-active #top-bar .hp-wrap,
.official-ui-active #top-bar .hp-track { height: 20px; }
.official-ui-active #top-bar .player-panel .hp-wrap { top: 53px; }
.official-ui-active #top-bar .enemy-panel .hp-wrap { top: 54px; }
.official-ui-active #top-bar .hp-track { padding: 4px; }
.official-ui-active #top-bar .hp-fill {
  height: 12px; background-size: 206px 12px; overflow: hidden;
  box-shadow: inset 0 1px rgba(255,255,255,.28), inset 0 -1px rgba(0,0,0,.2);
}
/* §4.3 Visual Guidance — the bright edge follows remaining HP; clip it at
   zero and mirror the enemy fill so both bars face their commander. */
.official-ui-active #top-bar .hp-fill::after {
  content: ''; position: absolute; top: 0; bottom: 0; right: 0; width: 6px;
  background: linear-gradient(to right, transparent, rgba(207,246,255,.9));
  pointer-events: none;
}
.official-ui-active #top-bar #enemy-hp-bar { margin-left: auto; }
.official-ui-active #top-bar #enemy-hp-bar::after {
  left: 0; right: auto;
  background: linear-gradient(to left, transparent, rgba(255,213,184,.9));
}
.official-ui-active #top-bar .hp-num { top: -3.5px; height: 27px; line-height: 1; }
/* design/SKILL.md §4.3 — give both HP values a clear 6px gap from their bars. */
.official-ui-active #top-bar .player-panel .hp-num { left: calc(100% + 6px); }
.official-ui-active #top-bar .enemy-panel .hp-num { right: calc(100% + 6px); }

/* §4.3 — a flex center keeps both one- and two-digit counts on the front
   card silhouette; an oversized grid item previously expanded its column. */
.official-ui-active #top-bar .player-deck-remain {
  left: 114.5px; top: 63px; width: 46px; height: 50px;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.official-ui-active #top-bar #hand-count-num {
  position: static; left: auto; min-width: 0; transform: none; line-height: 1;
}

/* §4.3 — bring both power readings toward their terrain; offsetTop also
   moves the existing uncertainty and formation markers with the numbers. */
.official-ui-active .terrain-oct-total.enemy-total { margin-top: 6px; }
.official-ui-active .terrain-oct-total.player-total { margin-bottom: 6px; }

/* §4.2 / §4.3 — deployment hover/selection can extend past the inner card
   row without clipping edge cards. Battle animation keeps its own clipping. */
.official-ui-active #game-screen[data-phase="deploy"] .player-lane,
.official-ui-active #game-screen[data-phase="deploy"] .player-lane > .lane-cards {
  overflow: visible;
}

/* design/SKILL.md §4.3 — the native 148×228 selection art exactly follows
   the visible face inside its 156×236 canvas (4px left, 2px top). Keep the
   square frame separate from the existing sheen and avoid an outer gap. */
.official-ui-active #hand-cards .card { border-radius: 0; }
.official-ui-active #hand-cards .card:hover,
.official-ui-active #hand-cards .card.selected { outline: none; }
.official-ui-active #hand-cards .card:hover::before,
.official-ui-active #hand-cards .card.selected::before {
  content: '' !important; display: block !important; position: absolute; top: 2px; right: auto; bottom: auto; left: 4px;
  width: 148px; height: 228px; border: 0; border-radius: 0; box-shadow: none;
  background: url("../assets/ui/prep/selection_highlight.png") center / auto no-repeat;
  mix-blend-mode: normal; opacity: 1; transform: none; animation: none;
  pointer-events: none; z-index: 10;
}
.official-ui-active .lane-cards .battlefield-card:hover {
  outline: 2px solid rgba(145, 222, 212, .85); outline-offset: -2px;
}
/* §4.3 — retain the numeric clash pulse without the rectangular light box.
   Deployment prediction keeps its separate supplied preview frame. */
.official-ui-active .terrain-oct-total.lane-total-clash { box-shadow: none; }
.official-ui-active #hand-cards .card:hover::after,
.official-ui-active #hand-cards .card.selected::after,
.official-ui-active .lane-cards .battlefield-card:hover::after,
.official-ui-active #game-screen .card.official-card-face:not(.card-preview-ghost):not(.one-click-preview-slot)::after {
  background: linear-gradient(115deg, transparent 40%, rgba(255,239,178,.18) 50%, transparent 60%) -150% 0 / 300% 100%;
  mix-blend-mode: normal; opacity: 1; animation: officialCardSheen 6s linear infinite;
}
/* design/SKILL.md §4.3 — the complete supplied best-bonus frame owns its label. */
.official-ui-active .player-lane.best-lane::after {
  content: none;
}
/* §4.3 — reserve the top strip so even three deployed cards keep their whole
   frame and attack values visible beneath the recommendation. */
.official-ui-active .player-lane.best-lane > .lane-cards {
  padding-top: 19px; padding-bottom: 1px;
}

/* design/SKILL.md §4.3 — align player name/rank art to the enemy 44px bottom
   line, leaving the same 10px HP gap while preserving its bitmap size. */
.official-ui-active #top-bar #player-hero-name.official-composite-name {
  height: 44px; max-height: 44px; align-items: flex-end;
}
.official-ui-active #top-bar #player-hero-name.official-composite-name .official-hero-name-art {
  margin-top: 0; width: auto; height: auto; max-width: 100%; max-height: 47px;
}

/* design/SKILL.md §4.2 / §4.3 — supplement 7 restores the complete 889×432
   victory panel, including both feathered sides. Values follow the baked cells. */
.official-ui-active #result-box.official-result-panel.result-win {
  width: 889px; min-width: 889px; height: 432px; min-height: 432px;
}
.official-ui-active #result-box.official-result-panel.result-win .official-result-stats {
  left: 146px; top: 220px;
}
.official-ui-active #result-box.official-result-panel.result-win .result-actions {
  top: 294px;
}

/* design/SKILL.md §4.3 — keep each portrait at its source aspect ratio and
   native size, shrinking only art taller than the 122px HUD. The source alpha
   >=220 bounds sit 6px from the unchanged VS silhouette on their own side. */
.official-ui-active #top-bar .hero-avatar {
  align-items: flex-end;
}
.official-ui-active #top-bar .hero-art-img,
.official-ui-active #top-bar .hero-avatar.is-neutral-banner .hero-art-img {
  width: auto; height: auto; max-width: none; max-height: 122px; flex: none;
}
.official-ui-active #top-bar .player-panel .hero-avatar {
  left: auto; right: calc(50% + 45.7027px); justify-content: flex-end;
}
.official-ui-active #top-bar .enemy-panel .hero-avatar {
  left: calc(50% + 42.1892px); right: auto; justify-content: flex-start;
}
.official-ui-active #top-bar .player-panel .hero-art-img {
  margin-right: calc(-1 * var(--portrait-inner-inset, 0px)); object-position: right bottom;
}
.official-ui-active #top-bar .enemy-panel .hero-art-img {
  margin-left: calc(-1 * var(--portrait-inner-inset, 0px)); object-position: left bottom;
}
/* §4.3 — measured source padding, not a crop; Shi Chaoyi's 22px inset scales
   by 122/144 together with his original 136×144 portrait. */
.official-ui-active #top-bar .hero-art-img[src*="/player/huangfu_weide/portrait.png"] { --portrait-inner-inset: 16px; }
.official-ui-active #top-bar .hero-art-img[src*="/player/leng_tianfeng/portrait.png"] { --portrait-inner-inset: 49px; }
.official-ui-active #top-bar .hero-art-img[src*="/player/li_wuyi/portrait.png"] { --portrait-inner-inset: 26px; }
.official-ui-active #top-bar .hero-art-img[src*="/player/wang_zhengbei/portrait.png"] { --portrait-inner-inset: 22px; }
.official-ui-active #top-bar .hero-art-img[src*="/player/yang_su/portrait.png"] { --portrait-inner-inset: 32px; }
.official-ui-active #top-bar .hero-art-img[src*="/player/default/emblem.png"] { --portrait-inner-inset: 5px; }
.official-ui-active #top-bar .hero-art-img[src*="/enemy/an_xiuren/portrait.png"] { --portrait-inner-inset: 28px; }
.official-ui-active #top-bar .hero-art-img[src*="/enemy/ashina_jingbian/portrait.png"] { --portrait-inner-inset: 24px; }
.official-ui-active #top-bar .hero-art-img[src*="/enemy/chen_shubao/portrait.png"] { --portrait-inner-inset: 24px; }
.official-ui-active #top-bar .hero-art-img[src*="/enemy/hunxie_yan/portrait.png"] { --portrait-inner-inset: 28px; }
.official-ui-active #top-bar .hero-art-img[src*="/enemy/molu_guichen/portrait.png"] { --portrait-inner-inset: 28px; }
.official-ui-active #top-bar .hero-art-img[src*="/enemy/murong_hanjiang/portrait.png"] { --portrait-inner-inset: 23px; }
.official-ui-active #top-bar .hero-art-img[src*="/enemy/shi_chaoyi/portrait.png"] { --portrait-inner-inset: 18.6389px; }
.official-ui-active #top-bar .hero-art-img[src*="/enemy/tian_chengsi/portrait.png"] { --portrait-inner-inset: 41px; }
.card.official-card-face:has(> .card-power-badge), .card.deck-preview-card, .campaign-combat-unit {
  container-type: inline-size;
}
.official-ui-active .card.campaign-combat-unit {
  padding: 0;
  border: 0;
  border-radius: 3px;
  isolation: isolate;
}
.campaign-combat-unit > .combat-face { width: 100%; height: 100%; }
.campaign-combat-unit::before { display: none; }
