/* Game-only mobile presentation; load AFTER mobile-layout.css.
 * No DOM, action/ID, asset bytes, facility popup or durable-close changes.
 * Main HUD keeps source image-local geometry. Small screens pan the original
 * HUD horizontally; 44px auxiliary targets live in the existing mobile bar.
 * Icon-to-web-action bindings below are reconstructed, not native bindings.
 */
@media (max-width: 700px),
  (max-width: 950px) and (max-height: 500px),
  (max-width:1100px) and (pointer:coarse), (max-width:1600px) and (max-height:700px) and (any-pointer:coarse) {
  body[data-hud-profile='portal-mobile'] {
    --tc-hud-u: max(
      0.7px,
      calc((100vw - var(--tc-safe-left, 0px) - var(--tc-safe-right, 0px) - 8px) / 800)
    );
    --tc-native-hud-width: calc(800 * var(--tc-hud-u));
    --tc-native-hud-height: calc(194 * var(--tc-hud-u));
    --tc-toolbar-left: calc(256px + var(--tc-safe-left, 0px));
    --tc-toolbar-right: calc(48px + var(--tc-safe-right, 0px));
  }
  body[data-hud-profile='portal-mobile'][data-reference-hud='original-variant'] {
    --tc-native-hud-height: calc(185 * var(--tc-hud-u));
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #viewport {
    position: relative;
    display: block;
    grid-template-columns: none;
    grid-template-rows: none;
    min-height: 0;
    height: 100%;
    gap: 0;
    padding: 0 max(4px, var(--tc-safe-right, 0px)) max(2px, var(--tc-safe-bottom, 0px))
      max(4px, var(--tc-safe-left, 0px));
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    scrollbar-color: #687162 #090c09;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #screen-wrap {
    width: max(100%, var(--tc-native-hud-width)) !important;
    min-width: var(--tc-native-hud-width);
    height: 100% !important;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #screen {
    position: relative;
    width: 100%;
    height: 100%;
    transform: none !important;
    overflow: hidden;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #world {
    width: 100%;
    height: max(44px, calc(100% - var(--tc-native-hud-height)));
    touch-action: none;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #hud {
    display: block;
    position: absolute;
    left: 0;
    top: auto;
    bottom: 0;
    width: var(--tc-native-hud-width);
    height: var(--tc-native-hud-height);
    border: 0;
    padding: 0;
    background: transparent;
    z-index: 8;
    pointer-events: none;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #hud::before {
    content: '';
    display: block;
    position: absolute;
    inset: 0;
    clip-path: none;
    width: calc(800 * var(--tc-hud-u));
    height: calc(194 * var(--tc-hud-u));
    background: var(--hud-image, none) left bottom / 100% 100% no-repeat;
    box-shadow: none;
    filter: none;
    image-rendering: pixelated;
    pointer-events: none;
  }
  body[data-hud-profile='portal-mobile'][data-reference-hud='original-variant']:not(
      .mobile-keyboard
    )
    #hud::before {
    top: auto;
    width: calc(801 * var(--tc-hud-u));
    height: calc(184 * var(--tc-hud-u));
    background-image: var(--reference-hud-image);
  }
  body[data-hud-profile='portal-mobile'][data-reference-hud='original-variant']:not(
      .mobile-keyboard
    )
    #hud[data-scene='capital']::before {
    height: calc(185 * var(--tc-hud-u));
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) .minimap-frame,
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #hud::after,
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #commander-status::before,
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #commander-status::after,
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #chat-form::before,
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #chat-form::after {
    display: none;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #mini {
    display: block;
    position: absolute;
    left: calc(657 * var(--tc-hud-u));
    right: auto;
    top: calc(50 * var(--tc-hud-u));
    width: calc(137 * var(--tc-hud-u));
    height: calc(137 * var(--tc-hud-u));
    border: 0;
    background: #020502;
    image-rendering: pixelated;
    pointer-events: auto;
  }
  body[data-hud-profile='portal-mobile'][data-reference-hud='original-variant']:not(
      .mobile-keyboard
    )
    #mini {
    left: calc(8 * var(--tc-hud-u));
    top: calc(44 * var(--tc-hud-u));
    width: calc(132 * var(--tc-hud-u));
    height: calc(132 * var(--tc-hud-u));
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #location-label {
    display: block;
    left: calc(646 * var(--tc-hud-u));
    top: calc(10 * var(--tc-hud-u));
    width: calc(140 * var(--tc-hud-u));
    height: 14px;
    overflow: hidden;
    font-size: 9px;
    line-height: 12px;
    color: #c2c9ad;
    pointer-events: none;
  }
  body[data-hud-profile='portal-mobile'][data-reference-hud='original-variant']:not(
      .mobile-keyboard
    )
    #location-label {
    left: calc(12 * var(--tc-hud-u));
    top: calc(27 * var(--tc-hud-u));
    width: calc(106 * var(--tc-hud-u));
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #commander-status {
    display: flex;
    position: absolute;
    left: calc(197 * var(--tc-hud-u));
    right: auto;
    top: calc(6 * var(--tc-hud-u));
    width: calc(408 * var(--tc-hud-u));
    height: calc(20 * var(--tc-hud-u));
    min-height: 0;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 0 2px;
    border: 0;
    background: transparent;
    font:
      9px/12px Tahoma,
      'Malgun Gothic',
      sans-serif;
    pointer-events: none;
  }
  body[data-hud-profile='portal-mobile'][data-reference-hud='original-variant']:not(
      .mobile-keyboard
    )
    #commander-status {
    left: calc(157 * var(--tc-hud-u));
    top: calc(36 * var(--tc-hud-u));
    width: calc(380 * var(--tc-hud-u));
    height: calc(17 * var(--tc-hud-u));
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard)
    :is(#commander-name, #commander-rank) {
    min-width: 0;
    max-width: 40%;
    font-size: 9px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #wallet {
    margin-left: auto;
    white-space: nowrap;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #order-bar {
    display: block;
    position: absolute;
    left: 0;
    top: 0;
    width: calc(187 * var(--tc-hud-u));
    height: calc(194 * var(--tc-hud-u));
    padding: 0;
    border: 0;
    background: transparent;
    pointer-events: none;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) .radial-frame {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    background: var(--command-rim-image, none) left top / 100% 100% no-repeat;
    box-shadow: none;
    pointer-events: none;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) .radial-frame::after {
    display: none;
  }
  body[data-hud-profile='portal-mobile'][data-reference-hud='original-variant']:not(
      .mobile-keyboard
    )
    #order-bar {
    left: calc(636 * var(--tc-hud-u));
    top: calc(28 * var(--tc-hud-u));
    width: calc(156 * var(--tc-hud-u));
    height: calc(151 * var(--tc-hud-u));
  }
  body[data-hud-profile='portal-mobile'][data-reference-hud='original-variant']:not(
      .mobile-keyboard
    )
    .radial-frame {
    display: none;
  }
  body[data-hud-profile='portal-mobile'][data-reference-hud='original-variant']:not(
      .mobile-keyboard
    )
    #hud[data-scene='capital']
    .radial-frame {
    display: block;
    left: calc(1 * var(--tc-hud-u));
    top: calc(-1 * var(--tc-hud-u));
    width: calc(153 * var(--tc-hud-u));
    height: calc(151 * var(--tc-hud-u));
    background-image: var(--reference-radial-image);
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #order-bar .radial-command {
    position: absolute;
    display: block;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 50%;
    clip-path: circle(50%);
    transform: translate(-50%, -50%);
    background: transparent;
    box-shadow: none;
    pointer-events: auto;
    touch-action: manipulation;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #order-bar .order-move {
    left: 50%;
    top: 17%;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #order-bar .order-attack {
    left: 82%;
    top: 50%;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #order-bar .order-hold {
    left: 50%;
    top: 82%;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #order-bar .order-ability {
    left: 17%;
    top: 50%;
  }
  body[data-hud-profile='portal-mobile'][data-reference-hud='original-variant']:not(
      .mobile-keyboard
    )
    #order-bar
    .order-move {
    top: 15%;
  }
  body[data-hud-profile='portal-mobile'][data-reference-hud='original-variant']:not(
      .mobile-keyboard
    )
    #order-bar
    .order-attack {
    left: 80.45%;
  }
  body[data-hud-profile='portal-mobile'][data-reference-hud='original-variant']:not(
      .mobile-keyboard
    )
    #order-bar
    .order-hold {
    top: 82.45%;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard)
    #order-bar
    .radial-command:is(.active, :focus-visible) {
    outline: 1px solid #d9d58a;
    outline-offset: -2px;
    background-color: #b5d49d20;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #order-bar .radial-command svg {
    display: none;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #order-bar .radial-command::before {
    content: '';
    position: absolute;
    inset: 9px;
    background: var(--tc-original-icon) center / contain no-repeat;
    image-rendering: pixelated;
    pointer-events: none;
  }
  body[data-hud-profile='portal-mobile'] .order-move {
    --tc-original-icon: url('/games/tactical-commanders/assets/sprites/ntf-cur-nrm.png?v=v3-ui-541e55200f43');
  }
  body[data-hud-profile='portal-mobile'] .order-attack {
    --tc-original-icon: url('/games/tactical-commanders/assets/sprites/ntf-aticon.png?v=v3-ui-541e55200f43');
  }
  body[data-hud-profile='portal-mobile'] .order-hold {
    --tc-original-icon: url('/games/tactical-commanders/assets/sprites/ntf-nsc-hand.png?v=v3-ui-541e55200f43');
  }
  body[data-hud-profile='portal-mobile'] .order-ability {
    --tc-original-icon: url('/games/tactical-commanders/assets/sprites/ntf-vwicon.png?v=v3-ui-541e55200f43');
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) .battle-dial {
    display: flex;
    position: absolute;
    left: 50%;
    top: 50%;
    width: calc(40 * var(--tc-hud-u));
    height: calc(40 * var(--tc-hud-u));
    transform: translate(-50%, -50%);
    border: 0;
    border-radius: 50%;
    box-shadow: none;
    background: transparent;
    pointer-events: none;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #battle-clock {
    font:
      10px/12px Tahoma,
      monospace;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #clock-mode {
    font-size: 8px;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) .hud-menu {
    display: contents;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard)
    .hud-menu
    > :is(#territory-button, #capital-button) {
    display: none;
  }
  /* The real F4/F1/follow controls stay outside the replaceable menu dialog. */
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard)
    :is(#commander-sheet, #squad-button, #focus),
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #system-menu > summary {
    position: fixed;
    top: var(--tc-safe-top, 0px);
    left: calc(80px + var(--tc-safe-left, 0px));
    display: block;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    margin: 0;
    padding: 28px 0 1px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: url('/games/tactical-commanders/assets/sprites/ntf-nsp-wbd.png?v=v3-ui-541e55200f43') center / 41px 42px
      no-repeat;
    color: #d4d6bf;
    font:
      9px/11px 'Malgun Gothic',
      sans-serif;
    z-index: 35;
    pointer-events: auto;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #squad-button {
    left: calc(124px + var(--tc-safe-left, 0px));
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #focus {
    left: calc(168px + var(--tc-safe-left, 0px));
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard)
    :where(#commander-sheet, #squad-button, #focus, #system-menu > summary)
    svg {
    display: none !important;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard)
    :where(#commander-sheet, #squad-button, #focus, #system-menu > summary)::before {
    content: '';
    position: absolute;
    left: 11px;
    top: 3px;
    width: 22px;
    height: 23px;
    background: url('/games/tactical-commanders/assets/full-sprites/ntf-nsc-but1-000.png?v=v3-ui-541e55200f43') -176px -23px /
      352px 46px no-repeat;
    image-rendering: pixelated;
    pointer-events: none;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #squad-button::before {
    background: url('/games/tactical-commanders/assets/sprites/ntf-brd-mb.png?v=v3-ui-541e55200f43') center / 16px 20px
      no-repeat;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #focus::before {
    background: url('/games/tactical-commanders/assets/sprites/ntf-cur-tg.png?v=v3-ui-541e55200f43') center / 22px 22px
      no-repeat;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #commander-sheet::after {
    content: '지휘관';
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #squad-button::after {
    content: '편성';
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #focus::after {
    content: '추적';
  }
  /* Existing summary opens the original system/settings window. Capital
     navigation remains on the existing capital/mobile-city action handlers. */
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #system-menu {
    display: block;
    position: fixed;
    left: calc(212px + var(--tc-safe-left, 0px));
    top: var(--tc-safe-top, 0px);
    width: 44px;
    height: 44px;
    pointer-events: auto;
    z-index: 35;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #system-menu > summary {
    position: relative;
    left: 0;
    top: 0;
    list-style: none;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #system-menu > summary::before {
    background-position: -44px -23px;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #system-menu > summary::after {
    content: '설정';
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard)
    .page-bar
    > span:not(#mobile-fullscreen-slot) {
    visibility: hidden;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #mobile-portal-leave {
    position: fixed;
    left: var(--tc-safe-left, 0px);
    top: var(--tc-safe-top, 0px);
    width: 80px;
    min-width: 80px;
    max-width: 80px;
    height: 44px;
    min-height: 44px;
    margin: 0 !important;
    padding: 0 4px;
    box-sizing: border-box;
    z-index: 40;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #mobile-fullscreen-slot {
    margin-left: auto;
    flex: 0 0 48px;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #mobile-fullscreen-slot button {
    width: 48px;
    padding: 0 1px;
    font-size: 10px;
  }
  /* The shared fullscreen control deliberately has width/min-width !important.
     Override only this game's mobile control, preserving its text/ARIA/handler. */
  html
    body[data-hud-profile='portal-mobile']:not(.mobile-keyboard)
    #fullscreen[data-game-fullscreen] {
    position: fixed !important;
    left: auto !important;
    right: var(--tc-safe-right, 0px) !important;
    top: var(--tc-safe-top, 0px) !important;
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;
    margin: 0 !important;
    padding: 0 !important;
    gap: 0 !important;
    box-sizing: border-box;
    border: 0;
    border-radius: 0;
    background: url('/games/tactical-commanders/assets/sprites/ntf-nsp-wbd.png?v=v3-ui-541e55200f43') center / 41px 42px
      no-repeat;
    font-size: 0 !important;
    line-height: 0 !important;
    color: transparent !important;
    z-index: 40;
  }
  html
    body[data-hud-profile='portal-mobile']:not(.mobile-keyboard)
    #fullscreen[data-game-fullscreen]::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 10px;
    width: 24px;
    height: 24px;
    background: url('/games/tactical-commanders/assets/sprites/ntf-cur-tg.png?v=v3-ui-541e55200f43') center / 24px 24px
      no-repeat;
    image-rendering: pixelated;
    pointer-events: none;
  }
  /* Eight existing auxiliary IDs remain in one horizontal, scrollable native-art rail.
     The four duplicate data-order cells remain in the DOM; original radial buttons
     expose those same existing action handlers, without a second touch target. */
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #viewport > .mobile-orders {
    display: flex;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: flex-start !important;
    position: fixed;
    top: var(--tc-safe-top, 0px);
    left: var(--tc-toolbar-left);
    right: var(--tc-toolbar-right);
    bottom: auto;
    width: auto;
    min-width: 0 !important;
    height: 44px;
    min-height: 44px;
    max-height: 44px;
    margin: 0;
    padding: 0;
    gap: 0;
    align-items: flex-start !important;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: none !important;
    z-index: 35;
    background: #090d09;
    pointer-events: auto;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard)
    #viewport
    > .mobile-orders::-webkit-scrollbar {
    display: none;
    height: 0;
    width: 0;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) .mobile-orders > button[data-order] {
    display: none;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard)
    .mobile-orders
    > button:not([data-order]) {
    position: relative;
    display: block;
    flex: 0 0 44px !important;
    width: 44px;
    height: 44px;
    min-width: 44px;
    max-width: 44px;
    min-height: 44px;
    margin: 0;
    padding: 28px 0 1px;
    border: 0;
    border-radius: 0;
    background: url('/games/tactical-commanders/assets/sprites/ntf-nsp-wbd.png?v=v3-ui-541e55200f43') center / 41px 42px
      no-repeat;
    box-shadow: none;
    color: #d7d8bc;
    font-size: 9px;
    line-height: 11px;
    white-space: nowrap;
    text-overflow: clip;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard)
    .mobile-orders
    > button:not([data-order])::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 2px;
    width: 24px;
    height: 24px;
    background: var(--tc-original-icon) center / contain no-repeat;
    image-rendering: pixelated;
    pointer-events: none;
  }
  body[data-hud-profile='portal-mobile'] #mobile-select {
    --tc-original-icon: url('/games/tactical-commanders/assets/sprites/ntf-nsc-butc.png?v=v3-ui-541e55200f43');
  }
  body[data-hud-profile='portal-mobile'] #mobile-pan {
    --tc-original-icon: url('/games/tactical-commanders/assets/sprites/ntf-cur-move.png?v=v3-ui-541e55200f43');
  }
  body[data-hud-profile='portal-mobile'] #mobile-map {
    --tc-original-icon: url('/games/tactical-commanders/assets/sprites/ntf-brd-bt1.png?v=v3-ui-541e55200f43');
  }
  body[data-hud-profile='portal-mobile'] #mobile-city {
    --tc-original-icon: url('/games/tactical-commanders/assets/sprites/ntf-nsc-but2.png?v=v3-ui-541e55200f43');
  }
  body[data-hud-profile='portal-mobile'] #mobile-squad {
    --tc-original-icon: url('/games/tactical-commanders/assets/full-sprites/ntf-nsc-but1-000.png?v=v3-ui-541e55200f43');
  }
  body[data-hud-profile='portal-mobile'] #mobile-chat {
    --tc-original-icon: url('/games/tactical-commanders/assets/full-sprites/ntf-nsc-but1-000.png?v=v3-ui-541e55200f43');
  }
  body[data-hud-profile='portal-mobile'] #zoom-out {
    --tc-original-icon: url('/games/tactical-commanders/assets/sprites/ntf-stg-zo.png?v=v3-ui-541e55200f43');
  }
  body[data-hud-profile='portal-mobile'] #zoom-in {
    --tc-original-icon: url('/games/tactical-commanders/assets/sprites/ntf-stg-zi.png?v=v3-ui-541e55200f43');
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #mobile-chat::before {
    left: 11px;
    width: 22px;
    height: 23px;
    background-position: -242px -23px;
    background-size: 352px 46px;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #mobile-squad::before {
    left: 11px;
    width: 22px;
    height: 23px;
    background-position: -44px -23px;
    background-size: 352px 46px;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard)
    :is(.mobile-orders button, #focus)[aria-pressed='true'],
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard) #focus[data-following='true'] {
    outline: 1px solid #b7d49b;
    outline-offset: -2px;
    background-color: #91bd6328;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard)
    :is(.mobile-orders button, #commander-sheet, #squad-button, #focus):focus-visible {
    outline: 2px solid #ead98f;
    outline-offset: -2px;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-keyboard)
    :is(.mobile-orders button, #squad-button):disabled {
    opacity: 0.45;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-chat-open):not(.mobile-keyboard) #chat-log {
    display: block;
    position: absolute;
    left: calc(197 * var(--tc-hud-u));
    right: auto;
    top: calc(70 * var(--tc-hud-u));
    bottom: auto;
    width: calc(400 * var(--tc-hud-u));
    height: calc(116 * var(--tc-hud-u));
    padding: 2px 4px;
    border: 0;
    background: #020602a0;
    font:
      10px/13px Tahoma,
      'Malgun Gothic',
      sans-serif;
    overflow: auto;
  }
  body[data-hud-profile='portal-mobile'][data-reference-hud='original-variant']:not(
      .mobile-chat-open
    ):not(.mobile-keyboard)
    #chat-log {
    left: calc(157 * var(--tc-hud-u));
    top: calc(64 * var(--tc-hud-u));
    width: calc(436 * var(--tc-hud-u));
    height: min(
      calc(92 * var(--tc-hud-u)),
      calc(var(--tc-native-hud-height) - 64 * var(--tc-hud-u) - 26px)
    );
    background: #1002029a;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-chat-open):not(.mobile-keyboard) #chat-form {
    display: flex;
    position: absolute;
    left: calc(203 * var(--tc-hud-u));
    right: auto;
    top: calc(32 * var(--tc-hud-u));
    bottom: auto;
    width: calc(407 * var(--tc-hud-u));
    height: max(22px, calc(24 * var(--tc-hud-u)));
    padding: 0;
    gap: 1px;
    border: 0;
    background: transparent;
    pointer-events: auto;
  }
  body[data-hud-profile='portal-mobile'][data-reference-hud='original-variant']:not(
      .mobile-chat-open
    ):not(.mobile-keyboard)
    #chat-form {
    left: calc(157 * var(--tc-hud-u));
    top: min(calc(159 * var(--tc-hud-u)), calc(var(--tc-native-hud-height) - 24px));
    width: calc(436 * var(--tc-hud-u));
    height: max(22px, calc(20 * var(--tc-hud-u)));
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-chat-open):not(.mobile-keyboard) #chat-input {
    min-width: 0;
    min-height: 0;
    height: 100%;
    padding: 0 2px;
    border: 0;
    background: #020502c0;
    color: #d5d8ba;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-chat-open):not(.mobile-keyboard)
    #chat-form
    > button {
    min-width: 22px;
    min-height: 0;
    height: 100%;
    padding: 0;
    line-height: 12px;
    font-size: 10px;
  }
  body[data-hud-profile='portal-mobile']:not(.mobile-chat-open):not(.mobile-keyboard)
    #chat-form
    > .mobile-chat-dismiss {
    display: none;
  }
  /* Direct focus in the original thin input must get the same safe keyboard
     overlay as the 44px mobile-chat entry point; no JS flag is fabricated. */
  body[data-hud-profile='portal-mobile'].mobile-keyboard:has(#chat-input:focus) #chat-form {
    display: flex;
    position: fixed;
    left: max(8px, var(--tc-safe-left, 0px));
    right: max(8px, var(--tc-safe-right, 0px));
    top: auto;
    bottom: calc(max(8px, var(--tc-safe-bottom, 0px)) + var(--mobile-keyboard-inset, 0px));
    width: auto;
    height: 54px;
    padding: 5px;
    gap: 4px;
    background: #060b08f5;
    pointer-events: auto;
    z-index: 120;
  }
  body[data-hud-profile='portal-mobile'].mobile-keyboard:has(#chat-input:focus) #chat-log {
    display: block;
    position: fixed;
    left: max(8px, var(--tc-safe-left, 0px));
    right: max(8px, var(--tc-safe-right, 0px));
    top: auto;
    bottom: calc(68px + var(--mobile-keyboard-inset, 0px));
    width: auto;
    height: 64px;
    background: #030704ee;
    pointer-events: auto;
    z-index: 119;
  }
  body[data-hud-profile='portal-mobile'].mobile-keyboard:has(#chat-input:focus) #chat-input {
    min-height: 44px;
    height: 44px;
  }
  body[data-hud-profile='portal-mobile'].mobile-keyboard:has(#chat-input:focus)
    #chat-form
    > button {
    min-height: 44px;
  }
  body[data-hud-profile='portal-mobile']:has(#panel:not([hidden])) #viewport > .mobile-orders,
  body[data-hud-profile='portal-mobile']:has(#panel:not([hidden]))
    :where(#commander-sheet, #squad-button, #focus, #system-menu > summary) {
    visibility: hidden;
  }
  /* Embedded hosts already own leave/fullscreen. Reserve only the command rail;
     do not reveal or replace their hidden host-control elements. */
  body[data-hud-profile='portal-mobile'].embedded:not(.mobile-keyboard) #viewport {
    padding-top: calc(44px + var(--tc-safe-top, 0px));
  }
  body[data-hud-profile='portal-mobile'].embedded {
    --tc-toolbar-left: calc(176px + var(--tc-safe-left, 0px));
    --tc-toolbar-right: var(--tc-safe-right, 0px);
  }
  body[data-hud-profile='portal-mobile'].embedded:not(.mobile-keyboard) #commander-sheet {
    left: var(--tc-safe-left, 0px);
  }
  body[data-hud-profile='portal-mobile'].embedded:not(.mobile-keyboard) #squad-button {
    left: calc(44px + var(--tc-safe-left, 0px));
  }
  body[data-hud-profile='portal-mobile'].embedded:not(.mobile-keyboard) #focus {
    left: calc(88px + var(--tc-safe-left, 0px));
  }
  body[data-hud-profile='portal-mobile'].embedded:not(.mobile-keyboard) #system-menu {
    left: calc(132px + var(--tc-safe-left, 0px));
  }
}
