/* Mobile-only dialog sizing; desktop retains its original layouts. */
body.mobile-layout .modal-wrapper {
  top: var(--mobile-viewport-top, 0px);
  left: var(--mobile-viewport-left, 0px);
  width: var(--mobile-viewport-width, 100%);
}
body.mobile-layout :is(#card-view-modal, #offer-modal, #npc-chat-modal, #loot-containers-modal) {
  max-width: 100%;
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
body.mobile-layout :is(#offer-modal, #npc-chat-modal) { width: 420px; }
body.mobile-layout #loot-containers-modal { width: 700px; }
body.mobile-layout :is(#offer-modal, #npc-chat-modal, #loot-containers-modal) .modal-header {
  padding-right: 38px;
  overflow-wrap: anywhere;
}
body.mobile-layout :is(#card-view-modal, #offer-modal, #npc-chat-modal, #loot-containers-modal) .close-button-transparent {
  position: sticky;
  top: 0;
  float: right;
  z-index: 5;
  width: 40px;
  height: 40px;
  margin-bottom: -40px;
}
body.mobile-layout :is(#card-view-modal, #offer-modal, #loot-containers-modal) .modal-footer {
  position: sticky;
  bottom: -8px;
  z-index: 3;
  padding: 6px 0;
  background: #292c29 url('../png/bg2.png');
}
body.mobile-layout :is(#card-view-modal, #offer-modal, #npc-chat-modal, #loot-containers-modal) button {
  min-height: 40px;
  white-space: normal;
  overflow-wrap: anywhere;
}
body.mobile-layout :is(#offer-modal, #npc-chat-modal, #loot-containers-modal) input:not([type='checkbox']):not([type='radio']) {
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
  font-size: 16px;
  min-height: 40px;
}
body.mobile-layout #offer-search { width: 100%; }
body.mobile-layout #offer-modal .offers.tibia-scroll-wrapper { height: clamp(88px, calc(var(--mobile-vh) * .3), 240px); }
body.mobile-layout #offer-modal .offer-info-row { flex-wrap: wrap; gap: 4px; }
body.mobile-layout #buy-count-wrapper .offer-info-row { width: 100%; }
body.mobile-layout #buy-count-scrollbar { min-width: 100px; height: 40px; }
body.mobile-layout #buy-count-scrollbar button { min-width: 32px; }
body.mobile-layout #buy-count-value { width: 70px; }
body.mobile-layout #npc-chat-modal .npc-chat-header { padding-right: 32px; }
body.mobile-layout #npc-chat-log-scroll-wrapper { height: clamp(80px, calc(var(--mobile-vh) - 250px), 260px); }
body.mobile-layout #npc-chat-log { height: 100%; box-sizing: border-box; }
body.mobile-layout #npc-chat-modal .npc-chat-footer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
body.mobile-layout #npc-chat-modal .npc-chat-icons { grid-column: 1; grid-row: 1; }
body.mobile-layout #npc-chat-modal .npc-chat-icon-button { width: 40px; margin: 0; }
body.mobile-layout #npc-chat-modal .npc-chat-toggle-button { grid-column: 2; grid-row: 1; margin: 0; }
body.mobile-layout #npc-chat-input { grid-column: 1 / -1; grid-row: 2; width: 100%; }
body.mobile-layout #loot-containers-modal .loot-containers-columns {
  min-width: 0;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr);
  height: auto;
  overflow: visible;
}
body.mobile-layout #loot-containers-modal .loot-containers-list { flex: none; height: 220px; }
body.mobile-layout #loot-containers-modal .loot-containers-list-button {
  flex: 0 0 auto;
  width: 100%;
  height: auto;
  font-size: 11px;
  padding: 4px;
  background: #373b37;
  border: 1px solid #666b65;
}
body.mobile-layout #loot-containers-modal :is(.loot-clear-icon, .loot-select-icon) {
  flex: 0 0 36px;
  width: 36px;
  background-position: center;
  background-color: #373b37;
}
body.mobile-layout #loot-containers-modal .loot-containers-filter label { min-height: 36px; }
body.mobile-layout #loot-containers-modal .loot-containers-row { min-height: 40px; }
body.mobile-layout #loot-containers-modal .loot-containers-row-label { white-space: normal; overflow-wrap: anywhere; }
body.mobile-layout #loot-containers-modal .loot-containers-row-slot { width: 36px; height: 36px; }
body.mobile-layout #loot-containers-modal .loot-containers-fallback { min-height: 36px; }
body.mobile-layout #loot-containers-modal .loot-containers-search-results { min-height: 120px; }
body.mobile-layout #card-view-modal .card-view-info { overflow-y: auto; }
body.mobile-layout #trade-window {
  z-index: 40000;
  width: min(340px, calc(100vw - 16px)) !important;
  max-height: calc(var(--mobile-vh) - 16px);
  left: 50%; right: auto;
  top: calc(var(--mobile-viewport-top, 0px) + var(--mobile-vh) / 2);
  transform: translate(-50%, -50%);
  overflow: hidden;
}
body.mobile-layout #trade-window .body.tibia-scroll-wrapper { max-height: calc(var(--mobile-vh) - 108px); }
body.mobile-layout #trade-window .trade-window-side-title { white-space: normal; overflow-wrap: anywhere; }
body.mobile-layout #trade-window .trade-window-actions { position: relative; flex-shrink: 0; }
@media (max-width: 600px) {
  body.mobile-layout #loot-containers-modal .loot-containers-columns { grid-template-columns: minmax(0, 1fr); }
  body.mobile-layout #loot-containers-modal .loot-containers-list { flex: none; height: 180px; }
  body.mobile-layout #loot-containers-modal .loot-containers-filter,
  body.mobile-layout #loot-containers-modal .loot-containers-search { flex: none; }
  body.mobile-layout #loot-containers-modal .loot-containers-search-results { flex: none; height: 160px; }
}
