.commerce {
  width: min(720px, calc(100% - 28px));
  max-height: min(680px, calc(100% - 34px));
  padding: 0;
  border: 1px solid #586578;
  border-top-color: #acbacd;
  color: #e5e8ee;
  background: #151b24;
  box-shadow: 0 22px 75px #000c;
  font: 13px/1.4 Tahoma, sans-serif;
}
.commerce::backdrop { background: #060a10a8; }
.commerce__header { display: flex; align-items: center; gap: 14px; padding: 12px 16px; background: #242d3a; border-bottom: 1px solid #485565; }
.commerce h2, .commerce h3 { margin: 0; }
.commerce h2 { flex: 1; font-size: 17px; }
.commerce h3 { font-size: 12px; color: #bec9d7; margin-bottom: 9px; }
.commerce__balance, .commerce__price { color: #e8c57b; font-variant-numeric: tabular-nums; white-space: nowrap; }
.commerce button, .commerce select { background: #273344; color: inherit; border: 1px solid #4d5d73; border-radius: 2px; padding: 5px 9px; }
.commerce button:enabled { cursor: pointer; }
.commerce button:enabled:is(:hover, :focus-visible), .commerce select:focus-visible { outline: 1px solid #dac28d; outline-offset: 1px; }
.commerce button:disabled { opacity: .46; }
.commerce__close { font-size: 18px; line-height: 1; }
.commerce__body { padding: 16px; }
.commerce[data-mode='inventory'] {
  --inventory-cell: clamp(26px, 4.3vw, 39px);
  --gear-cell: clamp(28px, 4.3vw, 38px);
  width: min(760px, calc(100% - 24px));
  border-color: #8c9eaa #485661 #333f4b;
  border-radius: 6px;
  background: #18212b;
}
.commerce[data-mode='inventory'] .commerce__header {
  background: linear-gradient(#3a4a57, #27333f 48%, #1e2732);
  border-bottom-color: #596875;
}
.commerce__inventory { display: grid; grid-template-columns: minmax(170px, 1fr) auto; align-items: start; gap: 12px; }
.commerce__pack, .commerce__gear {
  min-width: 0;
  padding: 10px;
  border: 1px solid #4d5e6d;
  border-radius: 4px;
  background: #111922;
  box-shadow: inset 0 1px 2px #0009;
}
.commerce__pages, .commerce__controls { display: flex; gap: 8px; align-items: center; }
.commerce__pages { margin: 0 0 8px; gap: 3px; }
.commerce__pages button { flex: 1; min-width: 0; padding: 4px 0; }
.commerce__pages button[aria-pressed='true'] { background: #3a4a58; border-color: #968365; color: #ffe0a8; }
.commerce__equipment-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.commerce__equipment-tabs button { min-width: 0; flex: 1; padding: 5px 3px; }
.commerce__equipment-tabs button[aria-selected='true'] { background: #3a4a58; border-color: #968365; color: #ffe0a8; }
.commerce__grid {
  display: grid;
  grid-template-columns: repeat(8, var(--inventory-cell));
  grid-auto-rows: var(--inventory-cell);
  gap: 2px;
  width: fit-content;
}
.commerce .commerce__cell,
.commerce .commerce__gear-slot {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  min-width: 0;
  padding: 2px;
  border: 1px solid #425467;
  border-radius: 3px;
  background: #202d3a;
}
.commerce .commerce__cell { height: 100%; min-height: 0; }
.commerce__equipment-display { display: grid; grid-template-columns: var(--gear-cell) minmax(64px, 1fr) var(--gear-cell); gap: 5px; }
.commerce__equipment-display--secondary {
  --gear-rail: clamp(50px, 8vw, 66px);
  grid-template: 'artifact avatar special' 1fr 'crest avatar cube' 1fr / var(--gear-rail) minmax(58px, 1fr) var(--gear-rail);
  gap: 9px 5px;
}
.commerce__equipment-display--secondary .commerce__avatar { grid-area: avatar; min-height: calc(8 * var(--gear-cell)); }
.commerce__gear-group { align-self: center; min-width: 0; }
.commerce__gear-group[data-position='artifact'] { grid-area: artifact; }
.commerce__gear-group[data-position='crest'] { grid-area: crest; }
.commerce__gear-group[data-position='special'] { grid-area: special; }
.commerce__gear-group[data-position='cube'] { grid-area: cube; }
.commerce__gear-group h4 { margin: 0 0 4px; color: #b8c5d3; font-size: 10px; font-weight: 600; text-align: center; }
.commerce__gear-group .commerce__gear-empty { line-height: 1.15; overflow-wrap: anywhere; }
.commerce__equipment-grid {
  display: grid;
  grid-auto-rows: var(--gear-cell);
  align-content: start;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.commerce__equipment-extra { display: grid; grid-template-columns: repeat(auto-fit, var(--gear-cell)); gap: 3px; margin: 6px 0 0; padding: 0; list-style: none; }
.commerce .commerce__gear-slot { height: var(--gear-cell); }
.commerce__avatar {
  position: relative;
  overflow: hidden;
  min-height: calc(10 * var(--gear-cell));
  overflow: hidden;
  border: 1px solid #3c4b57;
  border-radius: 3px;
  background: radial-gradient(ellipse at 50% 45%, #31414f, #161f29 75%);
}
.commerce__preview-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.commerce__preview-canvas[hidden] { display: none; }
.commerce .commerce__gear-empty { color: #a6b3c3; background: #111821; font-size: 9px; text-align: center; }
.commerce .commerce__bag-empty { background: #10151d; border-color: #354454; }
.commerce button.commerce__gear-empty[aria-disabled='false'] { border-color: #93835f; }
.commerce button:is(.commerce__cell, .commerce__gear-slot)[aria-pressed='true'] { background: #50442b; border-color: #e8c57b; }
.commerce__selection { color: #f5e6c4; margin: 9px 0 6px; }
.commerce__list { display: grid; margin: 0; padding: 0; list-style: none; }
.commerce__list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 4px; border-bottom: 1px solid #354251; }
.commerce[data-mode='shop'] {
  --shop-cell: clamp(23px, min(calc((100dvh - 268px) * .0625), calc((100vw - 68px) * .125)), 40px);
  --shop-gap: 3px;
  width: min(calc(100% - 22px), max(290px, calc(var(--shop-cell) * 8 + 57px)));
  max-height: calc(100% - 22px);
  overscroll-behavior: contain;
  scrollbar-color: #526779 #1b2632;
  scrollbar-width: thin;
  background: #18222c;
  border-color: #748697;
  border-bottom-color: #354454;
  border-radius: 7px;
}
.commerce[data-mode='shop'] .commerce__header {
  gap: 8px;
  padding: 8px 11px;
  background: linear-gradient(135deg, #304655, #202c3a 65%);
}
.commerce[data-mode='shop'] h2 { font-size: 14px; font-weight: 600; }
.commerce[data-mode='shop'] .commerce__body { padding: 8px 10px 0; }
.commerce[data-mode='shop'] .commerce__balance { font-size: 11px; }
.commerce[data-mode='shop'][data-vendor='true'] {
  --inventory-cell: clamp(26px, 4vw, 40px);
  width: calc(100% - 22px);
  margin-block: 11px auto;
  padding: 1px;
  overflow-y: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.commerce[data-mode='shop'][data-vendor='true'][open] {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.commerce__vendor-pane {
  width: min(100%, max(290px, calc(var(--shop-cell) * 8 + 57px)));
  min-width: 0;
  border: 1px solid #748697;
  border-bottom-color: #354454;
  border-radius: 7px;
  background: #18222c;
  box-shadow: 0 8px 28px #0009;
}
.commerce__vendor-pane > .commerce__header { border-radius: 6px 6px 0 0; }
.commerce__vendor-pane:not(.commerce__vendor-pack) .commerce__balance { display: none; }
.commerce__vendor-pack { width: min(100%, calc(var(--inventory-cell) * 8 + 60px)); }
.commerce[data-mode='shop'] .commerce__vendor-pack .commerce__body { padding: 9px; }
.commerce__vendor-pack .commerce__pack { min-width: 0; }
.commerce__vendor-pack .commerce__grid { margin-inline: auto; }
.commerce__sale-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 9px; }
.commerce__sale-controls .commerce__selection { flex: 1 1 auto; margin: 0; overflow-wrap: anywhere; }
.commerce__sale-controls .commerce__price { margin-inline-start: auto; }
.commerce .commerce__sale-confirm { border-color: #c0a673; color: #fcdfac; background: #493d2a; }
.commerce__shop-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 7px; }
.commerce .commerce__shop-tabs button { padding: 4px 9px; background: #1a2632; color: #afc1cf; }
.commerce .commerce__shop-tabs button[aria-pressed='true'] {
  color: #f1e7cc;
  background: #344956;
  border-color: #8c9ca4;
}
.commerce .commerce__shop-inventory { margin-left: auto; }
.commerce__shop-grid {
  display: grid;
  grid-template-columns: repeat(8, var(--shop-cell));
  grid-auto-rows: var(--shop-cell);
  gap: var(--shop-gap);
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  padding: 5px;
  background: #111922;
  border: 1px solid #4b5b6a;
  border-radius: 4px;
}
.commerce__shop-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding: 8px 0; }
.commerce__shop-actions > span { margin-right: auto; }
.commerce__shop-actions[hidden] { display: none; }
.commerce .commerce__shop-slot {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 0;
  border: 1px solid #34424e;
  border-radius: 2px;
  background: #0f161f;
}
.commerce button.commerce__shop-slot { background: #20303b; border-color: #4b6572; }
.commerce button.commerce__shop-slot[aria-pressed='true'] { border-color: #e7c484; background: #3e412e; }
.commerce__item-image { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.commerce__shop-quantity {
  position: absolute;
  inset: auto 1px 0 auto;
  color: #eef1f2;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px #000, 0 0 3px #000;
  pointer-events: none;
}
.commerce__shop-placeholder {
  width: 42%;
  aspect-ratio: 1;
  background: #6d8493;
  clip-path: polygon(50% 0, 95% 23%, 95% 76%, 50% 100%, 5% 76%, 5% 23%, 50% 0, 50% 14%, 17% 31%, 17% 69%, 50% 86%, 83% 69%, 83% 31%, 50% 14%);
}
.commerce__tooltip {
  position: fixed;
  z-index: 2;
  width: min(320px, calc(100vw - 16px));
  max-height: calc(100dvh - 16px);
  overflow: auto;
  padding: 11px 13px;
  border: 1px solid #647383;
  border-radius: 6px;
  color: #edf0f5;
  background: #101821f7;
  box-shadow: 0 8px 28px #0009;
  pointer-events: none;
}
.commerce__tooltip-heading { display: flex; align-items: center; gap: 9px; color: #f6dfaa; }
.commerce__tooltip-heading .commerce__tooltip-image { flex: 0 0 36px; width: 36px; height: 36px; }
.commerce__tooltip section { margin-top: 8px; padding-top: 7px; border-top: 1px solid #455363; }
.commerce__tooltip section h3 { margin-bottom: 3px; color: #d9caa4; }
.commerce__tooltip p { margin: 0 0 3px; }
.commerce__payment { display: flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.commerce__payment img, .commerce__payment .commerce__shop-placeholder { flex: 0 0 20px; width: 20px; height: 20px; }
.commerce__payment strong { margin-left: auto; white-space: nowrap; }
.commerce__shortfall { color: #ffa890; }
.commerce__covered { color: #c1e1b2; }
.commerce__item-description { white-space: pre-line; }
.commerce[data-mode='shop'] .commerce__status { padding: 6px 11px; font-size: 11px; }
.commerce__empty, .commerce__status { color: #b8c5d3; }
.commerce__status { margin: 0; padding: 9px 16px; border-top: 1px solid #485565; }
.commerce__status[data-error='true'] { color: #ffc4b0; }
@media (max-width: 620px) {
  .commerce[data-mode='inventory'] { --inventory-cell: clamp(21px, calc((100vw - 75px) / 8), 45px); }
  .commerce__inventory { grid-template-columns: 1fr; }
  .commerce__equipment-display:not(.commerce__equipment-display--secondary) { grid-template-columns: var(--gear-cell) minmax(64px, 150px) var(--gear-cell); }
  .commerce[data-mode='shop'][data-vendor='true'][open] { flex-direction: column; align-items: center; }
  .commerce[data-mode='shop'][data-vendor='true'] { --inventory-cell: clamp(21px, calc((100vw - 92px) / 8), 40px); }
  .commerce__vendor-pane { flex: none; }
}
