/* Smartphone trade workspace. Keep the desktop shop and all transaction handlers.
   New labels are absent from the desktop layout; the wrapper is transparent there. */
.trade-mobile-item-name,
.trade-mobile-pane-title { display: none; }
.trade-detail-inspection { display: contents; }

html.gom-compact #npcTradeOverlay {
  top: var(--compact-viewport-top, 0px);
  bottom: auto;
  height: var(--compact-viewport-height, 100dvh);
  padding: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) calc(var(--compact-nav-height, 52px) + env(safe-area-inset-bottom) + 6px) max(6px, env(safe-area-inset-left));
  box-sizing: border-box;
  align-items: stretch;
  justify-items: stretch;
  overflow: hidden;
}

html.gom-compact #npcTradeOverlay .npc-trade-shell {
  width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 0;
  max-height: 100%;
}

html.gom-compact #npcTradeOverlay .npc-dialog-lowerbar.is-trade-view {
  min-width: 0;
  min-height: 0;
  padding: 7px;
  overflow: hidden;
}

html.gom-compact #npcTradeOverlay .npc-dialog-body {
  min-width: 0;
  min-height: 0;
  padding: 4px;
}

html.gom-compact #npcTradeOverlay .trade-window { min-width: 0; min-height: 0; gap: 8px; }
html.gom-compact #npcTradeOverlay .trade-window-header { grid-template-columns: minmax(0, 1fr) auto; min-height: 60px; }
html.gom-compact #npcTradeOverlay .trade-title-block { min-width: 0; padding: 7px 8px; }
html.gom-compact #npcTradeOverlay .trade-window-header h3 { margin: 0; font-size: 20px; line-height: 1.12; overflow-wrap: break-word; }
html.gom-compact #npcTradeOverlay .trade-merchant-card { display: none; }
html.gom-compact #npcTradeOverlay .trade-role-line { flex-wrap: wrap; gap: 3px 6px; margin-top: 4px; }
html.gom-compact #npcTradeOverlay .trade-role-badge,
html.gom-compact #npcTradeOverlay .trade-role-mode { font-size: 9px; }
html.gom-compact #npcTradeOverlay .trade-window-controls { gap: 6px; padding: 5px 6px; }
html.gom-compact #npcTradeOverlay .trade-wallet { padding: 3px; background: transparent; border: 0; box-shadow: none; }
html.gom-compact #npcTradeOverlay .trade-wallet-label { display: none; }

/* The existing buy/sell buttons remain real controls. Flatten their two desktop
   sections onto one mobile grid: tabs, optional source, one list, transaction. */
html.gom-compact #npcTradeOverlay .trade-market-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: 44px auto minmax(88px, .75fr) minmax(200px, 1.25fr);
  gap: 6px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

html.gom-compact #npcTradeOverlay :is(.trade-pane, .trade-pane-header) { display: contents; }
html.gom-compact #npcTradeOverlay .trade-pane-selector {
  grid-row: 1;
  min-width: 0;
  min-height: 44px;
  height: 44px;
  justify-content: center;
  gap: 7px;
  padding: 7px 8px;
  border: 1px solid var(--mg-mobile-control-border, #9b83544d);
  border-radius: 8px;
  color: var(--ui-text, #eadfc9);
  background: var(--mg-mobile-control-fill, #0c0d0c66);
  box-shadow: none;
  text-align: center;
}

html.gom-compact #npcTradeOverlay .trade-catalog-pane .trade-pane-selector { grid-column: 1; }
html.gom-compact #npcTradeOverlay .trade-player-pane .trade-pane-selector { grid-column: 2; }
html.gom-compact #npcTradeOverlay .trade-pane-selector[aria-selected="true"] {
  border-color: #d5b67a;
  background: var(--mg-mobile-control-selected, #bf975229);
  color: #f1dfb4;
}
html.gom-compact #npcTradeOverlay .trade-pane-title { display: none; }
html.gom-compact #npcTradeOverlay .trade-mobile-pane-title { display: block; font-size: 15px; font-weight: 600; white-space: nowrap; }
html.gom-compact #npcTradeOverlay .trade-pane-meta { min-width: 22px; padding: 2px 5px; font-size: 11px; }

html.gom-compact #npcTradeOverlay .trade-source-tabs {
  grid-column: 1 / -1;
  grid-row: 2;
  width: 100%;
  max-width: none;
  box-sizing: border-box;
  margin: 0;
  padding: 2px;
  gap: 4px;
  transition: opacity 130ms ease;
}
html.gom-compact #npcTradeOverlay .trade-player-pane:not(.is-active) .trade-source-tabs { display: none; }
html.gom-compact #npcTradeOverlay .trade-source-tabs .trade-mode-tab {
  min-width: 0;
  min-height: 40px;
  padding: 6px;
  font-size: 12px;
  line-height: 1.2;
  text-transform: none;
  letter-spacing: 0;
  white-space: normal;
  word-break: normal;
  overflow-wrap: normal;
}

html.gom-compact #npcTradeOverlay .trade-pane-scroll {
  grid-column: 1 / -1;
  grid-row: 3;
  min-width: 0;
  min-height: 0;
  padding: 0 3px 0 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
html.gom-compact #npcTradeOverlay .trade-pane:not(.is-active) .trade-pane-scroll { display: none; }
html.gom-compact #npcTradeOverlay .trade-slot-grid { grid-template-columns: minmax(0, 1fr); gap: 5px; }
html.gom-compact #npcTradeOverlay .trade-slot {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 58px;
  padding: 5px 8px;
  border-radius: 7px;
}
html.gom-compact #npcTradeOverlay .trade-slot-art { width: 48px; height: 48px; min-height: 0; }
html.gom-compact #npcTradeOverlay .trade-slot-art img:not(.item-composite-layer),
html.gom-compact #npcTradeOverlay .trade-slot-art .item-composite-icon { width: 40px; height: 40px; max-width: 100%; }
html.gom-compact #npcTradeOverlay .trade-slot-footer { display: flex; min-width: 0; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 2px 12px; }
html.gom-compact #npcTradeOverlay .trade-mobile-item-name { display: block; flex: 1 0 100%; color: #eadfc9; font-size: 14px; line-height: 1.2; text-align: left; overflow-wrap: break-word; }
html.gom-compact #npcTradeOverlay .trade-slot-price { font-size: 12px; }
html.gom-compact #npcTradeOverlay .trade-slot-stack { font-size: 11px; white-space: normal; overflow-wrap: break-word; }

/* The framed workspace never scrolls. Long descriptions/quality lists scroll
   inside the paper card while its primary trade action remains in the dock. */
html.gom-compact #npcTradeOverlay .trade-focus-panel {
  grid-column: 1 / -1;
  grid-row: 4;
  min-width: 0;
  min-height: 0;
  max-height: none;
  overflow: hidden;
}
html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-detail-card,
html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-detail-card:has(.quality-amounts) {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: 8px;
  gap: 5px;
}
html.gom-compact #npcTradeOverlay .trade-detail-inspection { display: flex; flex: 1 1 0%; flex-direction: column; min-height: 0; gap: 5px; overflow: auto; overscroll-behavior: contain; }
html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-detail-head { flex-direction: row; align-items: flex-start; gap: 8px; }
html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-detail-art { width: 48px; height: 48px; flex: 0 0 48px; }
html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-detail-copy { min-width: 0; }
html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-detail-copy h4 { margin: 0 0 3px; font-size: 19px; line-height: 1.15; }
html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-detail-kicker { display: none; }
html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-detail-copy p { margin: 0; font-size: 12px; line-height: 1.3; }
html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-detail-stats { flex: 0 0 auto; padding: 0 0 3px; gap: 0; }
html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-detail-stat { min-height: 19px; padding: 1px 2px; }
html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-detail-stat span { font: 12px/1.2 var(--font-body, sans-serif); }
html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-detail-stat strong { font-size: 13px; }
html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-detail-note { padding: 5px; font-size: 11px; }
html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-detail-bottom {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  min-height: 0;
  max-height: 72%;
  gap: 6px;
  padding-top: 5px;
  border-top: 1px solid #76552d73;
}
html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-quantity-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  flex: 0 1 auto;
  min-height: 0;
  gap: 5px;
  padding: 0;
  overflow: auto;
}
html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-quantity-label { grid-column: 1 / -1; font: 12px/1.2 var(--font-body, sans-serif); }
html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-quantity-controls { justify-content: start; gap: 4px; }
html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-quantity-input { width: 62px; min-height: 44px; padding: 5px; box-sizing: border-box; font-size: 16px; }
html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-qty-btn { flex: 0 0 44px; min-width: 44px; min-height: 44px; padding: 5px; }
html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-quantity-presets { align-self: end; flex-wrap: nowrap; justify-content: end; gap: 3px; }
html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-qty-preset { min-width: 30px; min-height: 44px; padding: 4px; font-size: 12px; }
html.gom-compact #npcTradeOverlay .trade-focus-panel .quality-amounts { flex: 0 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; }
html.gom-compact #npcTradeOverlay .trade-focus-panel .quality-amount-row input { min-height: 44px; font-size: 16px; }
html.gom-compact #npcTradeOverlay .trade-focus-panel .quality-amounts button { min-width: 44px; min-height: 44px; }
html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-detail-actions { flex: 0 0 auto; width: 100%; flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; }
html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-total-confirm { flex: 1; flex-direction: row; flex-wrap: wrap; align-items: center; min-width: 0; gap: 2px 7px; padding: 0; border: 0; border-radius: 0; background: transparent; font-size: 12px; }
html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-total-confirm > span { color: #765d3f; letter-spacing: 0; text-transform: none; }
html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-total-confirm > strong { color: #302217; font-size: 16px; }
html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-detail-actions .npc-dialog-btn { width: auto; min-width: 128px; max-width: 70%; min-height: 44px; padding: 8px 16px; font-size: 15px; }

@media (max-width: 359px) {
  html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-quantity-row { grid-template-columns: minmax(0, 1fr); }
  html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-quantity-label { display: none; }
  html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-quantity-controls { justify-content: center; }
  html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-quantity-presets { justify-content: center; }
}

@media (max-height: 600px) and (orientation: portrait) {
  html.gom-compact #npcTradeOverlay .trade-market-layout { grid-template-rows: 44px auto minmax(58px, .55fr) minmax(210px, 1.45fr); }
}

/* Only wide landscape screens can afford parallel list/detail columns. Short
   portrait phones must retain the full-width stack and readable quantity input. */
@media (max-height: 600px) and (min-width: 480px) and (orientation: landscape) {
  html.gom-compact #npcTradeOverlay .trade-window { gap: 6px; }
  html.gom-compact #npcTradeOverlay .trade-window-header { min-height: 44px; }
  html.gom-compact #npcTradeOverlay .trade-window-header h3 { font-size: 18px; }
  html.gom-compact #npcTradeOverlay .trade-role-line { display: none; }
  html.gom-compact #npcTradeOverlay .trade-market-layout { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); grid-template-rows: 44px auto minmax(0, 1fr); }
  html.gom-compact #npcTradeOverlay .trade-pane-scroll { grid-column: 1; grid-row: 3; }
  html.gom-compact #npcTradeOverlay .trade-source-tabs { grid-column: 1; grid-row: 3; align-self: start; z-index: 1; }
  html.gom-compact #npcTradeOverlay .trade-player-pane.is-active .trade-pane-scroll { margin-top: 50px; }
  html.gom-compact #npcTradeOverlay .trade-focus-panel { grid-column: 2; grid-row: 3; }
  html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-detail-card,
  html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-detail-card:has(.quality-amounts) { padding: 6px; gap: 4px; }
  html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-detail-art { display: none; }
  html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-detail-copy h4 { font-size: 18px; }
  html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-detail-bottom { max-height: calc(100% - 22px); }
  html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-quantity-row { display: flex; flex-direction: row; flex-wrap: nowrap; align-items: center; overflow: visible; }
  html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-quantity-label { display: none; }
  html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-quantity-controls { flex: 0 0 auto; }
  html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-quantity-input { width: 48px; }
  html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-quantity-presets { flex: 1; align-self: center; justify-content: end; }
  html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-qty-preset:not(.is-max) { display: none; }
  html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-detail-actions { flex-wrap: nowrap; }
  html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-detail-actions .npc-dialog-btn { width: auto; min-width: 110px; max-width: 65%; padding: 6px 8px; font-size: 13px; }
  html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-detail-card:has(.quality-amounts) { padding: 4px; gap: 0; }
  html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-detail-card:has(.quality-amounts) .trade-detail-inspection { display: none; }
  html.gom-compact #npcTradeOverlay .trade-focus-panel .trade-detail-card:has(.quality-amounts) .trade-detail-bottom { flex: 1; max-height: none; padding-top: 0; border-top: 0; gap: 4px; }
  html.gom-compact #npcTradeOverlay .trade-focus-panel .quality-amounts { margin: 0; }
}
