/* The live inventory and shop controls keep their original IDs and behavior. */
#shop-modal.shop-sheet { --shop-detail-width: 240px; width: min(1100px, calc(100vw - 24px)); }
#shop-modal.shop-sheet .shop-header { flex-wrap: nowrap; gap: 8px; padding: 6px 10px; }
#shop-modal.shop-sheet .shop-header-left { flex: 1; flex-wrap: nowrap; gap: 8px; }
#shop-modal.shop-sheet .shop-body { display: grid; grid-template-columns: minmax(0, 1fr) var(--shop-detail-width); grid-template-rows: minmax(0, 1fr); flex: 1; min-height: 0; }
#shop-modal.shop-sheet .shop-catalog { display: flex; flex-direction: column; gap: 6px; grid-column: 1; grid-row: 1; min-height: 0; padding: 10px; overflow: hidden; }
#shop-modal.shop-sheet .shop-catalog-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 18px; flex: 0 0 auto; color: #e8d5a8; font-size: 11px; }
#shop-modal.shop-sheet .shop-hint { margin: 0; font-size: 10px; color: #a6b4b0; }
#shop-modal.shop-sheet .shop-grid { flex: 1; min-height: 0; align-content: stretch; gap: 6px; }
#shop-modal.shop-sheet .shop-detail { display: flex; grid-column: 2; grid-row: 1; min-height: 0; padding: 10px; gap: 6px; overflow: hidden; background: #111b1de8; }
#shop-modal.shop-sheet #shop-detail-description { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
#shop-modal.shop-sheet #shop-buy-btn { display: block; flex: 0 0 auto; min-height: 44px; width: 100%; padding: 6px; border: 1px solid #c6a05b; border-radius: 6px; background: #70552c; color: #fff0ce; font-size: 12px; font-weight: bold; }
#shop-modal.shop-sheet .shop-footer { display: grid; position: relative; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; flex: 0 0 auto; padding: 6px 10px; }
#shop-modal.shop-sheet .shop-bag-panel { min-width: 0; overflow: visible; grid-column: 1; grid-row: 1; border: 0; padding: 0; background: none; }
#shop-modal.shop-sheet .shop-bag-heading { margin: 0 0 3px; font-size: 10px; line-height: 14px; }
#shop-modal.shop-sheet #shop-inventory-count { font-size: 10px; }
#shop-modal.shop-sheet #shop-inventory-host .console-center { display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; width: 100%; min-width: 0; }
#shop-modal.shop-sheet #shop-inventory-host .inventory-sidebar { display: flex; order: 2; flex: 0 0 52px; width: 52px; min-width: 0; height: 44px; min-height: 44px; margin: 0; padding: 0; gap: 4px; border: 0; }
#shop-modal.shop-sheet #shop-inventory-host .inv-side-title,
#shop-modal.shop-sheet #shop-inventory-host .inv-toggle-switch { display: none; }
#shop-modal.shop-sheet #shop-inventory-host .inventory-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); grid-template-rows: 44px; flex: 1; width: auto; min-width: 0; padding: 0; gap: 4px; border: 0; }
#shop-modal.shop-sheet #shop-inventory-host .inv-slot { box-sizing: border-box; min-width: 0; width: 100%; height: 44px; }
#shop-modal.shop-sheet #shop-inventory-host .inv-slot img { width: 34px; height: 34px; max-width: 100%; max-height: 100%; object-fit: contain; }
#shop-modal.shop-sheet #btn-toggle-destroy,
#shop-modal.shop-sheet #btn-toggle-corruption { box-sizing: border-box; flex: 0 0 44px; width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 4px; font-size: 11px; }
#shop-modal.shop-sheet #shop-inventory-host #inventory-inspector { position: absolute; z-index: 5; right: 10px; bottom: calc(100% + 4px); box-sizing: border-box; width: var(--shop-detail-width); max-height: calc(100dvh - 145px); overflow-y: auto; padding: 10px; border: 1px solid #8d8059; background: #152326; box-shadow: 0 4px 20px #000a; }
#shop-modal.shop-sheet #shop-inventory-host #inventory-item-description { max-height: none; }
#shop-modal.shop-sheet .shop-actions { grid-column: 2; grid-row: 1; display: flex; flex-wrap: nowrap; flex: none; width: auto; gap: 8px; justify-content: flex-end; align-items: end; }
#shop-modal.shop-sheet .shop-floating-tools { display: flex; gap: 6px; }
#shop-modal.shop-sheet .shop-fab { min-width: 44px; width: 44px; height: 44px; min-height: 44px; border-radius: 6px; padding: 3px; gap: 0; }
#shop-modal.shop-sheet .shop-fab svg { width: 16px; height: 16px; }
#shop-modal.shop-sheet .shop-fab span { font-size: 10px; }
#shop-modal.shop-sheet #shop-feedback { flex: 0 0 auto; box-sizing: border-box; max-height: 44px; overflow-y: auto; margin: 0; padding: 4px 6px; border: 1px solid #7a7955; border-radius: 5px; background: #15231ff5; color: #f0dfb3; font-size: 10px; line-height: 1.4; }
#shop-modal.shop-sheet #shop-feedback:empty { display: none; }
#shop-modal.shop-sheet #shop-feedback.shop-core-feedback { max-height: none; overflow: visible; white-space: pre-line; overflow-wrap: anywhere; font-size: 11px; }
#shop-modal.shop-sheet .shop-settings { flex: 0 0 auto; }
#shop-modal.shop-sheet .shop-settings > summary { display: flex; align-items: center; justify-content: center; box-sizing: border-box; min-width: 48px; min-height: 44px; padding: 5px 8px; list-style: none; border: 1px solid #756342; border-radius: 6px; background: #292b24; color: #e8d5a8; cursor: pointer; font-size: 12px; touch-action: manipulation; }
#shop-modal.shop-sheet .shop-settings > summary::-webkit-details-marker { display: none; }
#shop-modal.shop-sheet .shop-settings[open] > summary { border-color: #dab471; background: #4d432d; }
#shop-modal.shop-sheet .shop-settings-panel { position: absolute; z-index: 12; right: 8px; top: 58px; box-sizing: border-box; width: min(400px, calc(100% - 16px)); max-height: calc(100% - 68px); padding: 12px; overflow-y: auto; overscroll-behavior: contain; border: 1px solid #9a8657; border-radius: 8px; background: #142124; box-shadow: 0 8px 35px #000c; color: #e8ddc0; font-weight: normal; }
#shop-modal.shop-sheet .shop-settings-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#shop-modal.shop-sheet .shop-settings-panel h3 { margin: 12px 0 6px; font-size: 12px; color: #d8bd83; }
#shop-modal.shop-sheet .shop-settings-panel button { min-height: 44px; padding: 6px 9px; border: 1px solid #62736a; border-radius: 5px; background: #273c37; color: #e8dfc5; font-size: 11px; }
#shop-modal.shop-sheet .shop-setting-shortcuts { display: flex; gap: 6px; margin: 8px 0; }
#shop-modal.shop-sheet .shop-settings-note { margin: 0; font-size: 11px; line-height: 1.6; color: #aab9b2; }
#shop-modal.shop-sheet .shop-automation { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding: 0; border: 0; background: none; }
#shop-modal.shop-sheet .shop-automation .shop-auto-toggle { min-width: 0; max-width: none; }
#shop-modal.shop-sheet .shop-market-info { padding: 8px; border: 1px solid #3f5146; border-radius: 5px; background: #0f1c1b; }
#shop-modal.shop-sheet .shop-prob-bar,
#shop-modal.shop-sheet .shop-disabled-bar { padding: 4px 0; background: none; border: 0; display: flex; gap: 6px; flex-wrap: wrap; }
#shop-modal.shop-sheet #shop-disabled-tags { display: flex; gap: 5px; flex-wrap: wrap; }
#shop-modal.shop-sheet #shop-refresh-status { margin: 8px 0 0; font-size: 11px; }
#shop-modal.shop-sheet :is(button, summary):focus-visible { outline: 2px solid #ffe2a1; outline-offset: 2px; }

/* Frequent shop actions share one stable header and one six-slot inventory row. */
#shop-modal.shop-sheet [hidden] { display: none !important; }
#shop-modal.shop-sheet .shop-header { background: #1b2b2b; border-bottom: 1px solid #82784e; }
#shop-modal.shop-sheet .shop-header-left { min-width: 0; }
#shop-modal.shop-sheet #shop-disabled-bar { display: flex; flex-wrap: nowrap; align-items: center; min-width: 0; gap: 5px; margin-left: 2px; padding: 0; border: 0; background: none; font-size: 11px; font-weight: normal; }
#shop-modal.shop-sheet #shop-disabled-bar > span { flex: 0 0 auto; color: #c3d2c9; }
#shop-modal.shop-sheet #shop-disabled-tags { display: flex; flex-wrap: nowrap; gap: 5px; min-width: 0; overflow: hidden; }
#shop-modal.shop-sheet .disabled-faction-tag { padding: 0; border: 0; background: none; color: #efdfb9; white-space: nowrap; font-size: 11px; }
#shop-modal.shop-sheet :is(#shop-attributes-btn, #shop-display-labels) { flex: 0 0 auto; min-height: 44px; padding: 6px 10px; border: 1px solid #a48b53; border-radius: 6px; background: #363d2b; color: #f4dfac; font-size: 12px; }
#shop-modal.shop-sheet .shop-catalog { gap: 0; background: #162525; }
#shop-modal.shop-sheet .shop-detail { background: #142325; border-left: 1px solid #425649; }
#shop-modal.shop-sheet #shop-detail-description { flex: 1; }
#shop-modal.shop-sheet #shop-buy-btn { margin-top: auto; }
#shop-modal.shop-sheet .shop-footer { background: #1b2b2b; border-top: 1px solid #5a674c; }
#shop-modal.shop-sheet .shop-quick-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-height: 44px; margin-bottom: 4px; }
#shop-modal.shop-sheet .shop-quick-controls button { display: inline-flex; align-items: center; justify-content: center; gap: 4px; box-sizing: border-box; width: auto; min-width: 0; min-height: 44px; height: auto; padding: 4px 6px; border: 0; border-radius: 4px; background: #263c36; color: #e8e5cd; font-size: 11px; white-space: nowrap; }
#shop-modal.shop-sheet .shop-quick-controls button::before { content: ''; width: 18px; height: 10px; flex: 0 0 auto; border: 1px solid #a4b4aa; border-radius: 6px; background: #66776f; }
#shop-modal.shop-sheet .shop-quick-controls button[aria-pressed="true"] { background: #2f4b35; color: #ebf1c9; }
#shop-modal.shop-sheet .shop-quick-controls button[aria-pressed="true"]::before { background: #b9d49b; border-color: #d3e2b5; }
#shop-modal.shop-sheet #shop-quick-controls #btn-toggle-corruption { flex: 0 0 auto; width: auto; min-width: 0; height: 44px; min-height: 44px; padding: 4px 6px; }
#shop-modal.shop-sheet #shop-refresh-status { margin: 0; padding-inline: 3px; font-size: 11px; white-space: nowrap; color: #d6deca; }
#shop-modal.shop-sheet #shop-refresh-status.exhausted { color: #e5b49d; }
#shop-modal.shop-sheet #btn-toggle-destroy { width: 52px; min-width: 52px; flex-basis: 52px; font-size: 11px; }
#shop-modal.shop-sheet .shop-actions { align-self: end; }
#shop-modal.shop-sheet .shop-fab { display: flex; flex-direction: column; justify-content: center; min-height: 56px; height: 56px; }
#shop-modal.shop-sheet #shop-lock-toggle { width: 90px; min-width: 90px; gap: 3px; }
#shop-modal.shop-sheet #shop-lock-toggle svg { display: none; }
#shop-modal.shop-sheet #shop-lock-status { color: #f1e3bd !important; font-size: 12px; }
#shop-modal.shop-sheet #shop-lock-status::after { content: ''; display: inline-block; width: 5px; height: 5px; margin-left: 7px; border-bottom: 1px solid currentColor; border-right: 1px solid currentColor; transform: translateY(-2px) rotate(45deg); }
#shop-modal.shop-sheet #shop-reroll-btn { display: grid; grid-template-columns: 18px 1fr; grid-template-rows: 1fr 1fr; align-content: center; column-gap: 4px; width: 104px; min-width: 104px; padding: 6px; background: #35553b; border-color: #a3be8d; }
#shop-modal.shop-sheet #shop-reroll-btn svg { grid-column: 1; grid-row: 1 / 3; align-self: center; }
#shop-modal.shop-sheet #shop-reroll-action { align-self: end; font-size: 12px; }
#shop-modal.shop-sheet #shop-reroll-label { align-self: start; font-size: 11px; font-variant-numeric: tabular-nums; }
#shop-modal.shop-sheet .shop-lock-menu { position: absolute; right: 118px; bottom: calc(100% + 6px); z-index: 14; box-sizing: border-box; width: min(260px, calc(100% - 16px)); padding: 6px; background: #142525; border: 1px solid #9a8b5b; border-radius: 8px; box-shadow: 0 8px 24px #000a; }
#shop-modal.shop-sheet .shop-lock-menu button { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; width: 100%; min-height: 50px; padding: 8px 10px; border: 0; border-radius: 4px; background: none; color: #e8e2c8; text-align: left; }
#shop-modal.shop-sheet .shop-lock-menu button[aria-pressed="true"] { background: #35503c; color: #f3e7b4; }
#shop-modal.shop-sheet .shop-lock-menu small { color: #b9c9bd; font-size: 11px; }
#shop-modal.shop-sheet .shop-lock-menu p { margin: 5px 10px; color: #d1d9c5; font-size: 11px; }
#shop-modal.shop-sheet .shop-purchase-setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0; font-size: 12px; }
#shop-modal.shop-sheet #shop-purchase-mode { min-height: 44px; padding: 5px 10px; border: 1px solid #85946f; border-radius: 5px; background: #21362f; color: #f0e6c7; font: inherit; }
#shop-modal.shop-sheet .shop-market-info { border: 0; padding: 8px 0 0; background: none; }
#shop-modal.shop-sheet :is(button, summary, select):focus-visible { outline: 2px solid #ffe2a1; outline-offset: 2px; }
#shop-modal.shop-sheet ::selection { background: #ad945b; color: #0d1919; }
#shop-modal.shop-sheet * { scrollbar-width: thin; scrollbar-color: #8a936a #182c2a; }

@media (orientation: landscape) {
  /* Section backgrounds reach the edges; their own content keeps one safe inset. */
  body.mobile-layout #shop-modal.shop-sheet { --shop-detail-width: clamp(185px, 27vw, 250px); inset: 0; width: auto; height: auto; max-height: none; transform: none; border-radius: 0; }
  body.mobile-layout #shop-modal.shop-sheet .shop-header { flex: 0 0 calc(50px + var(--rd-safe-area-top)); box-sizing: border-box; min-height: calc(50px + var(--rd-safe-area-top)); padding: calc(3px + var(--rd-safe-area-top)) calc(8px + var(--rd-safe-area-right)) 3px calc(8px + var(--rd-safe-area-left)); gap: 6px; font-size: 13px; border-bottom-width: 1px; }
  body.mobile-layout #shop-modal.shop-sheet .shop-header-left { gap: 6px; }
  body.mobile-layout #shop-modal.shop-sheet #shop-upgrade-btn { min-height: 44px; max-width: 150px; padding: 4px 7px; font-size: 11px; }
  body.mobile-layout #shop-modal.shop-sheet .shop-wallet { gap: 4px; font-size: 11px; }
  body.mobile-layout #shop-modal.shop-sheet .shop-wallet svg { width: 14px; height: 14px; }
  body.mobile-layout #shop-modal.shop-sheet #shop-close-btn { box-sizing: border-box; flex: 0 0 44px; width: 44px; height: 44px; padding: 0; }
  body.mobile-layout #shop-modal.shop-sheet .shop-body { display: grid; grid-template-columns: minmax(0, 1fr) calc(var(--shop-detail-width) + var(--rd-safe-area-right)); grid-template-rows: minmax(0, 1fr); min-height: 0; overflow: hidden; }
  body.mobile-layout #shop-modal.shop-sheet .shop-catalog { padding: 7px 7px 7px calc(7px + var(--rd-safe-area-left)); overflow: hidden; }
  body.mobile-layout #shop-modal.shop-sheet .shop-catalog-heading { min-height: 16px; font-size: 10px; }
  body.mobile-layout #shop-modal.shop-sheet .shop-hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  body.mobile-layout #shop-modal.shop-sheet .shop-grid { gap: 5px; }
  body.mobile-layout #shop-modal.shop-sheet .shop-grid .shop-item { position: relative; display: grid; grid-template-rows: minmax(0, 1fr) auto auto; align-items: center; justify-items: center; align-content: stretch; box-sizing: border-box; width: 100%; height: 100%; min-width: 0; min-height: 0; padding: 5px 3px; gap: 2px; overflow: hidden; border-radius: 6px; }
  body.mobile-layout #shop-modal.shop-sheet .shop-grid .shop-item .item-icon { width: 36px; height: 36px; min-height: 0; max-width: 100%; max-height: 100%; margin: 0; object-fit: contain; }
  body.mobile-layout #shop-modal.shop-sheet .shop-grid .shop-item-name { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; width: 100%; min-height: 0; margin: 0; overflow: hidden; color: #f4e6ca; font-size: 11px; line-height: 1.15; text-align: center; overflow-wrap: anywhere; }
  body.mobile-layout #shop-modal.shop-sheet .shop-grid .item-level-badge { position: absolute; top: 3px; left: 3px; padding: 1px 3px; border-radius: 3px; font-size: 8px; line-height: 1.2; background: #0b141edb; }
  body.mobile-layout #shop-modal.shop-sheet .shop-grid .item-price-badge { position: static; min-height: 0; padding: 0; font-size: 11px; line-height: 1.15; background: none; }
  body.mobile-layout #shop-modal.shop-sheet .shop-grid[data-density="compact"] .shop-item-name { font-size: 10px; }
  body.mobile-layout #shop-modal.shop-sheet .shop-grid[data-density="compact"] .shop-item { padding: 3px 2px; gap: 1px; }
  body.mobile-layout #shop-modal.shop-sheet .shop-grid[data-density="compact"] .item-icon { width: 26px; height: 26px; }
  body.mobile-layout #shop-modal.shop-sheet .shop-catalog:has(.shop-grid[data-density="compact"]) { padding-block: 3px; gap: 2px; }
  body.mobile-layout #shop-modal.shop-sheet .shop-detail { display: flex; padding: 8px calc(8px + var(--rd-safe-area-right)) 8px 8px; gap: 5px; overflow: hidden; }
  body.mobile-layout #shop-modal.shop-sheet .shop-detail h3 { margin: 0; font-size: 13px; line-height: 1.4; }
  body.mobile-layout #shop-modal.shop-sheet #shop-detail-meta { font-size: 10px; }
  body.mobile-layout #shop-modal.shop-sheet #shop-detail-description { flex: 1; max-height: none; font-size: 11px; line-height: 1.55; }
  body.mobile-layout #shop-modal.shop-sheet .shop-footer { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto; gap: 8px; align-items: end; padding: 5px calc(8px + var(--rd-safe-area-right)) calc(5px + var(--rd-safe-area-bottom)) calc(8px + var(--rd-safe-area-left)); flex-wrap: nowrap; }
  body.mobile-layout #shop-modal.shop-sheet .shop-bag-panel { grid-column: 1; grid-row: 1; flex: none; padding: 0; border: 0; }
  body.mobile-layout #shop-modal.shop-sheet .shop-actions { width: auto; gap: 8px; align-items: end; justify-content: flex-end; }
  body.mobile-layout #shop-modal.shop-sheet .shop-settings-panel { top: calc(54px + var(--rd-safe-area-top)); right: calc(8px + var(--rd-safe-area-right)); width: min(400px, calc(100% - 16px - var(--rd-safe-area-left) - var(--rd-safe-area-right))); max-height: calc(100% - 68px - var(--rd-safe-area-top) - var(--rd-safe-area-bottom)); }
  body.mobile-layout #shop-modal.shop-sheet .shop-settings-panel button { min-width: 44px; }
  body.mobile-layout #shop-modal.shop-sheet .shop-lock-menu { right: calc(118px + var(--rd-safe-area-right)); max-width: calc(100% - 134px - var(--rd-safe-area-left) - var(--rd-safe-area-right)); }
  body.mobile-layout #shop-modal.shop-sheet #shop-disabled-bar { font-size: 10px; }
  body.mobile-layout #shop-modal.shop-sheet .disabled-faction-tag { font-size: 10px; }
  body.mobile-layout #shop-modal.shop-sheet .shop-quick-controls { gap: 3px 5px; }
  body.mobile-layout #shop-modal.shop-sheet .shop-floating-tools { gap: 6px; }
}

@media (orientation: landscape) and (max-width: 700px) {
  body.mobile-layout #shop-modal.shop-sheet .shop-hint { display: none; }
  body.mobile-layout #shop-modal.shop-sheet .shop-wallet > span { display: none; }
  body.mobile-layout #shop-modal.shop-sheet .shop-header-left { gap: 4px; }
  body.mobile-layout #shop-modal.shop-sheet #shop-upgrade-btn { max-width: 132px; }
}
/* Catalog art keeps its own square slot. Grid tracks may scroll for extra stock
 * instead of collapsing an otherwise64x64 icon into a thin contain letterbox. */
body.mobile-layout #shop-modal.shop-sheet .shop-grid button.shop-item {
  grid-template-rows: 32px 12px 12px; align-content: center; min-height: 66px;
  padding: 2px; gap: 2px; border-width: 1px; border-image: none;
  background-image: none; box-shadow: inset 0 1px 3px #0006;
}
body.mobile-layout #shop-modal.shop-sheet .shop-grid button.shop-item .item-icon {
  width: 32px; height: 32px; min-height: 32px; max-height: none; max-width: none;
  aspect-ratio: 1; object-fit: contain;
}
body.mobile-layout #shop-modal.shop-sheet .shop-grid button.shop-item .shop-item-name {
  display: block; line-height: 12px; height: 12px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
body.mobile-layout #shop-modal.shop-sheet .shop-grid button.shop-item .item-price-badge { line-height: 12px; }
#shop-modal.shop-sheet[data-show-item-labels='false'] #shop-grid button.shop-item {
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
}
#shop-modal.shop-sheet[data-show-item-labels='false'] #shop-grid button.shop-item .item-icon {
  width: min(100%, 120px);
  height: min(100%, 120px);
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: none;
}
