/* ==========================================================================
   Kheldra modal windows: shared chrome, backpack (inventory), merchant shop.
   Loaded as a separate stylesheet. Every selector is scoped under
   #mmorpgOverlay (or one of its IDs) so other pages are unaffected.
   Palette: deep forest panels, muted gold borders, parchment text.
   ========================================================================== */

/* ---- Tokens (reuse :root values from play.html, with fallbacks) ---------- */
#mmorpgOverlay {
  --modal-panel-a: #14231e;
  --modal-panel-b: #1a2d25;
  --modal-panel-c: #223a2f;
  --modal-edge: var(--edge, #496253);
  --modal-gold-border: #b49a6a;
  --modal-gold-text: #f0d59c;
  --modal-parchment: #f4e6c8;
  --modal-muted: #c9c4ae;
  --modal-focus: #f4d48c;
  --modal-btn-primary-a: #d8b97a;
  --modal-btn-primary-b: #b49a6a;
  --modal-btn-secondary-a: #2c4a3c;
  --modal-btn-secondary-b: #1c3027;
  --modal-touch: 44px;
}

/* ---- Overlay and window shell ------------------------------------------- */
#mmorpgOverlay[data-open="true"] #mmorpgWindow {
  border: 3px double var(--modal-gold-border);
  border-radius: 12px;
  background: linear-gradient(160deg, var(--modal-panel-b), var(--modal-panel-a));
  color: var(--modal-parchment);
  box-shadow: inset 0 0 0 1px #0006, inset 0 18px 40px #0004, 0 22px 60px #000c;
  font-family: Grenze Gotisch,Georgia,serif;
}

/* ---- Window header and close button ------------------------------------- */
#mmorpgOverlay #mmorpgWindowHeader {
  min-height: 56px;
  padding: 6px 14px;
  background: linear-gradient(120deg, #26402f, #15261e);
  border-bottom: 2px double var(--modal-gold-border);
  color: var(--modal-gold-text);
  gap: 10px;
}
#mmorpgOverlay #mmorpgWindowHeader strong,
#mmorpgOverlay #mmorpgWindowTitle {
  font: 700 1.21rem/1.2 Grenze Gotisch,Georgia,serif;
  letter-spacing: .02em;
  color: var(--modal-gold-text);
  overflow-wrap: anywhere;
}
#mmorpgOverlay #mmorpgClose {
  flex: 0 0 auto;
  width: var(--modal-touch);
  height: var(--modal-touch);
  min-width: var(--modal-touch);
  min-height: var(--modal-touch);
  margin: 0;
  padding: 0;
  border: 1px solid var(--modal-gold-border);
  border-radius: 8px;
  background: linear-gradient(var(--modal-btn-secondary-a), var(--modal-btn-secondary-b));
  color: var(--modal-parchment);
  font-size: 28.5px;
  line-height: 1;
  cursor: pointer;
}
#mmorpgOverlay #mmorpgClose:hover { border-color: var(--modal-focus); background: #3b6650; }

/* ---- Shared body panes (character, spellbook, hotbar, settings) --------- */
#mmorpgOverlay #mmorpgCharacterPanel,
#mmorpgOverlay #mmorpgSpellbook,
#mmorpgOverlay #mmorpgHotbarConfig,
#mmorpgOverlay #mmorpgSettings {
  color: var(--modal-parchment);
  scrollbar-color: #8d7950 #14231e;
}
#mmorpgOverlay h2,
#mmorpgOverlay h3 {
  color: var(--modal-gold-text);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

/* ---- Buttons: primary gold, secondary dark ------------------------------ */
#mmorpgOverlay button {
  min-height: var(--modal-touch);
  padding: 8px 14px;
  border: 1px solid var(--modal-gold-border);
  border-radius: 8px;
  background: linear-gradient(var(--modal-btn-secondary-a), var(--modal-btn-secondary-b));
  color: var(--modal-parchment);
  font: 600 1.012rem/1.2 Grenze Gotisch,Georgia,serif;
  cursor: pointer;
  touch-action: manipulation;
}
#mmorpgOverlay button:hover:not(:disabled) {
  border-color: var(--modal-focus);
  background: linear-gradient(#41694f, #2c4d3a);
}
#mmorpgOverlay button:disabled {
  opacity: .5;
  cursor: not-allowed;
}
#mmorpgOverlay button.primary,
#mmorpgOverlay .inventory-controls > button,
#mmorpgOverlay .character-card .actions button,
#mmorpgOverlay .merchant-shop-row button,
#mmorpgOverlay .merchant-loot-card button {
  background: linear-gradient(var(--modal-btn-primary-a), var(--modal-btn-primary-b));
  border-color: #6f5a34;
  color: #15231c;
  font-weight: 700;
}
#mmorpgOverlay button.primary:hover:not(:disabled),
#mmorpgOverlay .inventory-controls > button:hover:not(:disabled),
#mmorpgOverlay .character-card .actions button:hover:not(:disabled),
#mmorpgOverlay .merchant-shop-row button:hover:not(:disabled),
#mmorpgOverlay .merchant-loot-card button:hover:not(:disabled) {
  background: linear-gradient(#f0d59c, #c9a96e);
  border-color: var(--modal-focus);
}
#mmorpgOverlay button.secondary {
  background: linear-gradient(var(--modal-btn-secondary-a), var(--modal-btn-secondary-b));
  color: var(--modal-parchment);
}

/* ---- Inputs and selects ------------------------------------------------- */
#mmorpgOverlay input:not([type="checkbox"]):not([type="range"]),
#mmorpgOverlay select,
#mmorpgOverlay textarea {
  min-height: var(--modal-touch);
  padding: 8px 10px;
  border: 1px solid #687653;
  border-radius: 8px;
  background: #0f1d18;
  color: var(--modal-parchment);
  font: 16.5px/1.2 Grenze Gotisch,Georgia,serif;
  box-sizing: border-box;
}
#mmorpgOverlay input::placeholder { color: #8f9a88; }

/* ---- Focus visibility (keyboard and controller) ------------------------- */
#mmorpgOverlay :focus-visible {
  outline: 3px solid var(--modal-focus);
  outline-offset: 2px;
}

/* ---- Tabs (merchant and character progression) ------------------------- */
#mmorpgOverlay [role="tablist"] {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 0;
  background: #14251e;
  border-bottom: 1px solid var(--modal-gold-border);
}
#mmorpgOverlay [role="tab"] {
  min-height: 48px;
  margin: 0;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--modal-muted);
  font-weight: 700;
}
#mmorpgOverlay [role="tab"][aria-selected="true"] {
  border-bottom-color: var(--modal-gold-text);
  background: #ffffff0d;
  color: #fff4d4;
}

/* ---- Cards (generic character cards and loot cards) -------------------- */
#mmorpgOverlay .character-card,
#mmorpgOverlay .inventory-section,
#mmorpgOverlay .inventory-controls {
  background: linear-gradient(150deg, var(--modal-panel-c), var(--modal-panel-b));
  border: 1px solid var(--modal-gold-border);
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px #0004, inset 0 10px 24px #0003;
  color: var(--modal-parchment);
  padding: 12px;
  min-width: 0;
  overflow-wrap: anywhere;
}
#mmorpgOverlay .character-card h3 { margin: 0 0 8px; }
#mmorpgOverlay .character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

/* ---- Backpack (inventory) ---------------------------------------------- */
#mmorpgOverlay .inventory-panel {
  display: grid;
  gap: 12px;
  max-width: 100%;
}
#mmorpgOverlay .inventory-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
#mmorpgOverlay .inventory-heading h2 {
  margin: 0;
  font-size: 1.43rem;
  color: var(--modal-gold-text);
}
#mmorpgOverlay .inventory-summary {
  margin: 0;
  color: var(--modal-muted);
  font-size: 0.968rem;
}
#mmorpgOverlay .inventory-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(230px, 1fr);
  gap: 12px;
  align-items: start;
}
#mmorpgOverlay .inventory-section input[type="search"] {
  width: 100%;
  margin-bottom: 10px;
}
#mmorpgOverlay .inventory-section small {
  display: block;
  margin-bottom: 8px;
  color: var(--modal-muted);
}
#mmorpgOverlay .inventory-slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
  max-height: min(56vh, 460px);
  overflow-y: auto;
  padding: 2px;
  align-content: start;
}
#mmorpgOverlay .inventory-slots > p {
  grid-column: 1 / -1;
  margin: 8px 0;
  color: var(--modal-muted);
}
#mmorpgOverlay .inventory-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  min-height: 112px;
  padding: 8px 6px;
  border: 1px solid #5c6a57;
  border-radius: 8px;
  background: linear-gradient(#2a4236, #1d3029);
  box-shadow: inset 0 0 0 1px #0003;
  color: var(--modal-parchment);
  text-align: center;
}
#mmorpgOverlay .inventory-item:hover:not(:disabled) {
  border-color: var(--modal-gold-border);
  background: linear-gradient(#36554a, #26402f);
}
#mmorpgOverlay .inventory-item[aria-pressed="true"] {
  border: 2px solid var(--modal-gold-text);
  background: linear-gradient(#41604b, #2e4a38);
  box-shadow: 0 0 0 2px #f0d59c33, inset 0 0 0 1px #0005;
}
#mmorpgOverlay .inventory-item-glyph {
  display: grid;
  place-items: center;
  min-height: 40px;
  font-size: 28.5px;
  color: #ebc889;
}
#mmorpgOverlay .inventory-item-name {
  font-size: 0.858rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
#mmorpgOverlay .inventory-item small {
  color: #e5d3a7;
  font-size: 0.8125rem;
  margin: 0;
}
#mmorpgOverlay .inventory-controls {
  display: grid;
  gap: 10px;
  align-content: start;
}
#mmorpgOverlay .inventory-controls label {
  display: grid;
  gap: 6px;
  color: var(--modal-muted);
  font-size: 0.935rem;
  font-weight: 700;
}
#mmorpgOverlay .inventory-feedback {
  margin: 0;
  color: var(--modal-muted);
  font-size: 0.924rem;
  min-height: 1.2em;
}
#mmorpgOverlay .inventory-loadout {
  display: grid;
  gap: 8px;
}
#mmorpgOverlay .inventory-equipped-slot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  border-bottom: 1px solid #50644c;
}
#mmorpgOverlay .inventory-equipped-slot button {
  min-width: var(--modal-touch);
}
#mmorpgOverlay .inventory-durability {
  grid-column: 1 / -1;
  color: #e4c38a;
  font-size: 0.858rem;
}

/* ---- Merchant shop ------------------------------------------------------ */
#mmorpgOverlay .merchant-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#mmorpgOverlay .merchant-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 16px;
  align-items: center;
  padding: 14px 18px 10px;
  background: linear-gradient(135deg, #1e352a, #14251e);
  border-bottom: 1px solid #5d654b;
}
#mmorpgOverlay .merchant-identity p,
#mmorpgOverlay .merchant-status {
  margin: 0;
  color: var(--modal-muted);
  font-size: 0.935rem;
}
#mmorpgOverlay .merchant-status {
  grid-column: 1 / -1;
  min-height: 1.25em;
  color: #cfe4d3;
}
#mmorpgOverlay .merchant-funds {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 6px 12px;
  border: 1px solid #756947;
  border-radius: 8px;
  background: #0d1c16;
}
#mmorpgOverlay .merchant-funds span {
  color: var(--modal-muted);
  font-size: 0.792rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}
#mmorpgOverlay .merchant-funds strong {
  color: #f1d39a;
  font-size: 1.21rem;
  font-variant-numeric: tabular-nums;
}
#mmorpgOverlay .merchant-tab-panel {
  min-height: 0;
  padding: 14px 18px 18px;
  overflow-y: auto;
}
#mmorpgOverlay .merchant-shop-list,
#mmorpgOverlay .merchant-sell-list {
  display: grid;
  gap: 10px;
}
#mmorpgOverlay .merchant-shop-row,
#mmorpgOverlay .merchant-loot-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(110px, auto);
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #5d654b;
  border-left: 4px solid #9a8254;
  border-radius: 10px;
  background: linear-gradient(120deg, #223a2f, #1a2d25);
}
#mmorpgOverlay .merchant-loot-card {
  grid-template-columns: minmax(0, 1fr) auto auto minmax(110px, auto);
}
#mmorpgOverlay .merchant-item-copy { min-width: 0; }
#mmorpgOverlay .merchant-item-copy h3 {
  margin: 0;
  color: var(--modal-gold-text);
  font-size: 1.078rem;
  text-transform: capitalize;
}
#mmorpgOverlay .merchant-item-copy p {
  margin: 3px 0 0;
  color: var(--modal-muted);
  font-size: 0.88rem;
}
#mmorpgOverlay .merchant-owned,
#mmorpgOverlay .merchant-price {
  color: var(--modal-muted);
  font-size: 0.88rem;
  white-space: nowrap;
}
#mmorpgOverlay .merchant-price { color: #e2c47f; }
#mmorpgOverlay .merchant-shop-row label,
#mmorpgOverlay .merchant-loot-card label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--modal-muted);
  font-size: 0.88rem;
  font-weight: 700;
}
#mmorpgOverlay .merchant-shop-row input,
#mmorpgOverlay .merchant-loot-card input {
  width: 80px;
  text-align: center;
}
#mmorpgOverlay .merchant-shop-row button,
#mmorpgOverlay .merchant-loot-card button {
  min-width: 110px;
  white-space: nowrap;
}
#mmorpgOverlay .merchant-loot-card > h3 {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Window sizing and reduced motion ----------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  #mmorpgOverlay button,
  #mmorpgOverlay [role="tab"],
  #mmorpgOverlay .inventory-item {
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
  }
}
@media (prefers-reduced-motion: reduce) {
  #mmorpgOverlay *,
  #mmorpgOverlay *::before,
  #mmorpgOverlay *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* Tablet and narrow desktop: 800px reference width. */
@media (max-width: 800px) {
  #mmorpgOverlay[data-open="true"] #mmorpgWindow {
    border-radius: 10px;
  }
  #mmorpgOverlay #mmorpgWindowHeader {
    min-height: 52px;
    padding: 4px 10px;
  }
  #mmorpgOverlay .inventory-columns {
    grid-template-columns: minmax(0, 1fr) minmax(200px, 0.9fr);
  }
  #mmorpgOverlay .inventory-slots {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  }
}

/* Phone width: single column, full-window modal, 16px gutter. */
@media (max-width: 560px) {
  #mmorpgOverlay[data-open="true"] #mmorpgWindow {
    left: 0 !important;
    top: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-height: none !important;
    border-width: 2px;
    border-radius: 0;
    resize: none;
  }
  #mmorpgOverlay #mmorpgWindowHeader {
    min-height: 52px;
    padding: 4px 16px;
  }
  #mmorpgOverlay #mmorpgCharacterPanel,
  #mmorpgOverlay #mmorpgSpellbook,
  #mmorpgOverlay #mmorpgHotbarConfig,
  #mmorpgOverlay #mmorpgSettings,
  #mmorpgOverlay .merchant-tab-panel {
    padding-left: 16px;
    padding-right: 16px;
  }
  #mmorpgOverlay .inventory-columns {
    grid-template-columns: minmax(0, 1fr);
  }
  #mmorpgOverlay .inventory-slots {
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    max-height: none;
  }
  #mmorpgOverlay .inventory-item {
    min-height: 104px;
  }
  #mmorpgOverlay .merchant-summary {
    grid-template-columns: minmax(0, 1fr);
    padding: 12px 16px 10px;
  }
  #mmorpgOverlay .merchant-funds {
    justify-content: space-between;
  }
  #mmorpgOverlay .merchant-shop-row,
  #mmorpgOverlay .merchant-loot-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
  }
  #mmorpgOverlay .merchant-loot-card {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  #mmorpgOverlay .merchant-loot-card > h3 {
    grid-column: 1 / -1;
    white-space: normal;
  }
  #mmorpgOverlay .merchant-shop-row label,
  #mmorpgOverlay .merchant-loot-card label {
    justify-self: start;
  }
  #mmorpgOverlay .merchant-shop-row button,
  #mmorpgOverlay .merchant-loot-card button {
    width: 100%;
    min-width: 0;
  }
  #mmorpgOverlay .merchant-shop-row input,
  #mmorpgOverlay .merchant-loot-card input {
    width: 96px;
  }
}

/* ==========================================================================
   SELECTOR GROUP INDEX
   Every group above is scoped under #mmorpgOverlay. Which window it styles:

   1. Tokens (#mmorpgOverlay custom properties)
        Shared by all modal windows.
   2. Overlay and window shell (#mmorpgOverlay[data-open] #mmorpgWindow)
        Shared chrome: the main game window frame for every panel.
   3. Window header and close button (#mmorpgWindowHeader, #mmorpgClose)
        Shared chrome: title bar and X button on every modal.
   4. Body panes (#mmorpgCharacterPanel, #mmorpgSpellbook, #mmorpgHotbarConfig,
        #mmorpgSettings, headings h2/h3)
        Shared chrome: content areas of character, abilities, hotbar, settings.
   5. Buttons (button, button.primary, button.secondary, action button groups)
        Shared: primary gold, secondary dark, 44px touch targets.
   6. Inputs and selects (input, select, textarea)
        Shared: form controls inside every modal.
   7. Focus visibility (:focus-visible)
        Shared: gold focus ring on every focusable element in the overlay.
   8. Tabs ([role="tablist"], [role="tab"])
        Merchant Buy/Sell tabs and character progression tabs.
   9. Cards (.character-card, .character-grid, .inventory-section,
        .inventory-controls)
        Character panel cards, backpack sections, equipment controls.
  10. Backpack (.inventory-panel, .inventory-heading, .inventory-summary,
        .inventory-columns, .inventory-section, .inventory-slots,
        .inventory-item, .inventory-item-glyph, .inventory-item-name,
        .inventory-controls, .inventory-feedback, .inventory-loadout,
        .inventory-equipped-slot, .inventory-durability)
        Inventory / backpack window: responsive grid of slot cards,
        hover and aria-pressed selected states.
  11. Merchant shop (.merchant-panel, .merchant-summary, .merchant-identity,
        .merchant-funds, .merchant-status, .merchant-tab-panel,
        .merchant-shop-list, .merchant-sell-list, .merchant-shop-row,
        .merchant-loot-card, .merchant-item-copy, .merchant-owned,
        .merchant-price, .merchant-quantity)
        Merchant shop window: Buy goods and Sell loot tabs.
  12. Reduced motion (prefers-reduced-motion) and transitions
        Applies to every modal selector above.
  13. Breakpoints (max-width: 800px and max-width: 560px)
        560px phone layout: single column, full-screen window, 16px gutters.
   ========================================================================== */

/* ---- Merchant cards: two-row layout (details on top, controls below) --- */
#mmorpgOverlay .merchant-shop-row,
#mmorpgOverlay .merchant-loot-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px 12px;
}
#mmorpgOverlay .merchant-shop-row .merchant-item-copy { grid-area: 1 / 1 / 2 / 4; }
#mmorpgOverlay .merchant-loot-card > h3 { grid-area: 1 / 1; white-space: normal; }
#mmorpgOverlay .merchant-loot-card .merchant-owned { grid-area: 1 / 2 / 2 / 4; justify-self: end; }
#mmorpgOverlay .merchant-shop-row > label,
#mmorpgOverlay .merchant-loot-card > label { grid-area: 2 / 1; justify-self: start; }
#mmorpgOverlay .merchant-max { grid-area: 2 / 2; }
#mmorpgOverlay .merchant-shop-row > button:last-child,
#mmorpgOverlay .merchant-loot-card > button:last-child {
  grid-area: 2 / 3;
  width: auto;
  min-width: 104px;
}
#mmorpgOverlay .merchant-max {
  width: auto;
  min-width: 0;
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.88rem;
  background: transparent;
  border: 1px solid var(--modal-gold-border);
  color: var(--modal-gold-text);
}
#mmorpgOverlay .merchant-max:hover:not(:disabled) { background: #ffffff14; }

/* ==========================================================================
   Gold-framed modal chrome (supplement): gold tab strips, thin gold scrollbars,
   44px touch targets and focus rings for modal controls. Scoped to #mmorpgOverlay.
   The window frame, corner brackets and close button live in hud.css.
   ========================================================================== */
#mmorpgOverlay [role="tab"][aria-selected="true"] { border-color: var(--k-gold, #b9954f); color: var(--k-gold-hi, #ebd391); }
#mmorpgOverlay button:focus-visible,
#mmorpgOverlay [role="tab"]:focus-visible { outline: 2px solid var(--k-gold-hi, #ebd391); outline-offset: 2px; }
#mmorpgOverlay button { min-height: var(--modal-touch); }
@media (max-width: 560px) {
  #mmorpgOverlay #mmorpgWindow { width: calc(100vw - 16px) !important; left: 8px !important; right: 8px !important; }
}

/* art-pack: small item icons in merchant rows (added by art-pack task) */
.merchant-icon{width:40px;height:40px;object-fit:contain;flex:none;align-self:center;margin-right:8px;pointer-events:none}
.merchant-shop-row:has(>.merchant-icon),.merchant-loot-card:has(>.merchant-icon){position:relative;padding-left:56px}
.merchant-shop-row>.merchant-icon,.merchant-loot-card>.merchant-icon{position:absolute;left:8px;top:50%;transform:translateY(-50%);margin:0}

/* Shop rows: reserve a gutter for the item art so text never sits under it. */
#mmorpgOverlay .merchant-shop-row:has(>.merchant-icon),#mmorpgOverlay .merchant-loot-card:has(>.merchant-icon){padding-left:76px!important;min-height:64px}
#mmorpgOverlay .merchant-shop-row>.merchant-icon,#mmorpgOverlay .merchant-loot-card>.merchant-icon{width:52px;height:52px;left:10px}
.merchant-toolbar{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin:0 0 8px}
.merchant-toolbar input[type="search"]{flex:1 1 140px;min-width:0}
.merchant-toolbar select,.merchant-toolbar input[type="search"]{padding:5px 8px;border:1px solid #6e5a35;border-radius:5px;background:#0e1613;color:#ebd391;font:14.5px Grenze Gotisch,Georgia,serif}
.merchant-filter{display:flex;align-items:center;gap:5px;color:#d9c79b;font:14.5px Grenze Gotisch,Georgia,serif;white-space:nowrap}

/* Sell/buy cards: one definitive two-row layout so controls never spill past the card. */
html body #mmorpgOverlay .merchant-loot-card,html body #mmorpgOverlay .merchant-shop-row{grid-template-columns:minmax(0,1fr) auto auto!important;grid-template-rows:auto auto;gap:6px 10px!important;overflow:hidden;box-sizing:border-box}
html body #mmorpgOverlay .merchant-loot-card>h3{grid-area:1/1!important;min-width:0}
html body #mmorpgOverlay .merchant-loot-card .merchant-owned{grid-area:1/2/2/4!important;justify-self:end}
html body #mmorpgOverlay .merchant-loot-card>.merchant-quantity,html body #mmorpgOverlay .merchant-shop-row>label{grid-area:2/1!important;min-width:0;display:flex!important;flex-wrap:wrap;align-items:center;gap:4px 8px;font-size:0.88rem!important}
html body #mmorpgOverlay .merchant-loot-card .merchant-quantity input{width:64px!important}
html body #mmorpgOverlay .merchant-loot-card .merchant-price{grid-column:auto!important;font-size:0.8125rem!important}
html body #mmorpgOverlay .merchant-loot-card>.merchant-max,html body #mmorpgOverlay .merchant-shop-row>.merchant-max{grid-area:2/2!important;min-width:0!important;width:auto!important;padding-inline:10px}
html body #mmorpgOverlay .merchant-loot-card>button:last-child,html body #mmorpgOverlay .merchant-shop-row>button:last-child{grid-area:2/3!important;min-width:0!important;width:auto!important;padding-inline:12px}
html body #mmorpgOverlay .merchant-shop-row .merchant-item-copy{grid-area:1/1/2/4!important}
/* Max and Sell/Buy buttons: 10px shorter than the old 36px Max button. */
html body #mmorpgOverlay .merchant-loot-card>.merchant-max,html body #mmorpgOverlay .merchant-shop-row>.merchant-max,html body #mmorpgOverlay .merchant-loot-card>button:last-child,html body #mmorpgOverlay .merchant-shop-row>button:last-child{min-height:26px!important;height:26px;padding-block:0;font-size:0.858rem;line-height:1}

/* Z-index ladder (see docs/archive/REVIEW_CLIENT.md). HUD pieces <= 99900 (tracker) < modal windows 99940-99960
   < tooltips / context menus 100001-100003 < login 100010. Open windows used to sit at 18-30, under the
   tracker, dock/help/audio toggles, touch controls and NPC barks. */
:root{--z-world:5;--z-world-label:12;--z-hud:10;--z-hud-top:19;--z-toast:20;--z-menu:900;--z-window-base:1000;--z-popover:100000}
/* Windows share one z-order stack (window-frame.js): z = 1000 + 2*index, set inline. HUD and toasts stay below 1000. */
html body #townServicePanel.k-svcbox,html body #bankPanel.k-bankbox{z-index:var(--z-window-base,1000)}
html body #mmorpgOverlay[data-open="true"],html body #mmorpgLegacy[data-open="true"]{z-index:var(--z-window-base,1000)}
html body #khelpOverlay{z-index:var(--z-window-base,1000)}
html body #kheldraItemTooltip{z-index:100001}

/* Phone portrait sheet mode (window-frame.js): full-screen window with a visible 44px close button. */
.k-wf-sheet{overflow:auto!important;border-radius:0!important}
.k-wf-sheetclose{position:sticky;float:right;top:0;margin-left:auto;min-width:44px;min-height:44px;width:44px;height:44px;padding:0;border:1px solid #b99a5b;border-radius:6px;background:#3a2f1a;color:#f2e2b8;font:700 20px Grenze Gotisch,Georgia,serif;cursor:pointer;z-index:2}
/* World-space hover tooltips are suppressed while any menu, window or dialog is open (they must never show through a modal). */
body:has(#hudMenu[data-open="true"],#mmorpgOverlay[data-open="true"],#mmorpgLegacy[data-open="true"],#khelpOverlay[data-open="true"],#townServicePanel:not([hidden]),#bankPanel:not([hidden])) #worldHoverLabel{display:none!important}
