.custom-select {
  position: relative;
  min-width: 0;
  width: 100%;
  font-family: var(--font-ui, "Barlow", sans-serif);
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 36px;
  gap: 6px;
  padding: 3px 7px 3px 4px;
  border: 1px solid #80653c;
  border-radius: 0;
  background: #151b18;
  color: #f0dfb9;
  text-align: left;
}

.custom-select-trigger:hover:not(:disabled),
.custom-select.is-open .custom-select-trigger {
  border-color: #c9a15a;
  background: #1b241e;
}

.custom-select-trigger:focus-visible,
.custom-select-option:focus-visible,
.custom-select-buy:focus-visible {
  outline: 2px solid #f6d979;
  outline-offset: -2px;
}

.custom-select-trigger:disabled {
  opacity: 0.5;
  cursor: default;
}

.custom-select-trigger.is-placeholder .custom-select-primary,
.custom-select-trigger.is-unavailable .custom-select-primary {
  color: #e59078;
}

.custom-select-icon {
  display: block;
  width: 26px;
  height: 26px;
  flex: none;
  object-fit: contain;
  image-rendering: pixelated;
}

.custom-select-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
  line-height: 1.06;
}

.custom-select-secondary {
  color: var(--ui-color-text-muted);
  font-size: 7px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.custom-select-primary {
  overflow: hidden;
  color: #f0dfb9;
  font-size: 10px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select-chevron {
  margin-left: auto;
  flex: none;
  color: #d2bb87;
  font-size: 11px;
  transition: transform 120ms ease;
}

.custom-select-trailing {
  flex: none;
  color: var(--ui-color-text-muted);
  font: 500 9px/1 var(--ui-font-body);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.custom-select.is-open .custom-select-chevron {
  transform: rotate(180deg);
}

.custom-select-menu {
  position: absolute;
  z-index: 60;
  top: calc(100% + 3px);
  left: 0;
  width: 100%;
  max-height: var(--custom-select-max-height, 222px);
  margin: 0;
  padding: 3px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #bc8d3e;
  background: #131712;
  box-shadow:
    0 7px 18px #050604d9,
    inset 0 0 0 1px #f2d58118;
  list-style: none;
  scrollbar-color: #8e692f #181e18;
  scrollbar-width: thin;
}

.custom-select.opens-up .custom-select-menu {
  top: auto;
  bottom: calc(100% + 3px);
}

.custom-select-row {
  display: flex;
  align-items: stretch;
  min-height: 34px;
}

.custom-select-menu-title {
  padding: var(--ui-space-2);
  color: var(--ui-color-text-muted);
  font: 600 11px/1.3 var(--ui-font-body);
  overflow-wrap: anywhere;
}

.custom-select-row + .custom-select-row {
  border-top: 1px solid #d6aa6026;
}

.custom-select-row:hover,
.custom-select-row.is-active,
.custom-select-row:focus-within {
  background: #2a3329;
}

.custom-select-option {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  gap: 6px;
  padding: 3px 5px;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
}

.custom-select-option[aria-selected="true"] .custom-select-primary {
  color: #f6d979;
}
.custom-select-option.is-unavailable .custom-select-primary {
  color: #e59078;
}

.custom-select-option:disabled {
  opacity: 0.45;
  cursor: default;
}

.custom-select-buy {
  position: relative;
  align-self: stretch;
  min-width: 27px;
  padding: 0 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #d9b368;
  font-family: var(--font-display, "Pixelify Sans", sans-serif);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.custom-select-buy:hover {
  color: #fff0bb;
  background: #5b4426;
}
.custom-select-buy::after {
  position: absolute;
  z-index: 2;
  top: 50%;
  right: calc(100% + 4px);
  padding: 3px 5px;
  border: 1px solid #9c8150;
  background: #171c18;
  color: #f2e3bd;
  content: attr(data-tooltip);
  font-family: var(--font-ui, "Barlow", sans-serif);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-50%);
}
.custom-select-buy:is(:hover, :focus-visible)::after {
  opacity: 1;
  visibility: visible;
}

.custom-select-menu.custom-select-menu--icon-grid {
  position: fixed;
  z-index: 900;
  right: auto;
  bottom: auto;
  box-sizing: border-box;
  background: var(--ui-color-background);
  font-family: var(--ui-font-body);
  box-shadow: 0 8px 24px #000c;
}
.custom-select-menu--icon-grid:not([hidden]) {
  display: flex;
  flex-flow: row wrap;
  align-content: flex-start;
  gap: var(--ui-space-1);
  padding: var(--ui-space-2);
}
.custom-select-menu--icon-grid .custom-select-menu-title,
.custom-select-menu--icon-grid .custom-select-shop-row,
.custom-select-menu--icon-grid .custom-select-modes {
  flex: 0 0 100%;
  min-width: 0;
}
.custom-select-mode-options {
  display: flex;
  flex-flow: row wrap;
  gap: var(--ui-space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}
.custom-select-menu--icon-grid .custom-select-row--mode {
  flex: 0 0 auto;
  min-width: 0;
}
.custom-select-menu--icon-grid .custom-select-menu-title {
  padding: 0 0 var(--ui-space-1);
}
.custom-select-menu--icon-grid .custom-select-row {
  border: 0;
  background: transparent;
}
.custom-select-menu--icon-grid .custom-select-row--icon {
  flex: 0 0 calc((100% - 5 * var(--ui-space-1)) / 6);
  min-width: 0;
}
.custom-select-menu--icon-grid .custom-select-option {
  border: 1px solid var(--ui-color-border);
  background: var(--ui-color-surface);
  color: var(--ui-color-text);
}
.custom-select-menu--icon-grid .custom-select-icon-choice {
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-height: 54px;
  padding: 4px 2px;
}
.custom-select-quantity {
  max-width: 100%;
  color: var(--ui-color-text);
  font: 600 10px/1.2 var(--ui-font-body);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.custom-select-menu--icon-grid .custom-select-icon-choice.is-effective {
  border-color: color-mix(in srgb, var(--ui-color-accent) 70%, var(--ui-color-border));
  background: color-mix(in srgb, var(--ui-color-accent) 8%, var(--ui-color-surface));
  box-shadow: none;
}
.custom-select-menu--icon-grid
  .custom-select-option:is(:hover, :focus-visible) {
  border-color: var(--ui-color-focus);
  background: var(--ui-color-surface-control);
}
.custom-select-menu--icon-grid .custom-select-option[aria-selected="true"] {
  border-color: var(--ui-color-primary);
  background: color-mix(
    in srgb,
    var(--ui-color-primary) 18%,
    var(--ui-color-surface)
  );
  box-shadow: inset 0 0 0 1px var(--ui-color-primary);
}
.custom-select-menu--icon-grid .is-unavailable .custom-select-quantity {
  color: var(--ui-color-text-muted);
}
.custom-select-menu--icon-grid .is-unavailable .custom-select-icon {
  opacity: 0.45;
}
.custom-select-menu--icon-grid .custom-select-row--mode .custom-select-option {
  min-height: 32px;
  padding: 6px 8px;
}
.custom-select-menu--icon-grid .custom-select-row--mode .custom-select-primary {
  white-space: normal;
  overflow-wrap: anywhere;
}
.custom-select-menu--icon-grid
  .custom-select-row--mode
  .custom-select-secondary,
.custom-select-menu--icon-grid .custom-select-row--mode .custom-select-icon {
  display: none;
}
.custom-select-shop-row {
  margin-top: var(--ui-space-1);
  padding-top: var(--ui-space-2);
  border-top: 1px solid var(--ui-color-border);
}
.custom-select-shop {
  width: 100%;
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid var(--ui-color-border);
  background: var(--ui-color-surface-raised);
  color: var(--ui-color-text);
  font: 600 11px/1.2 var(--ui-font-body);
}
.custom-select-shop:hover {
  border-color: var(--ui-color-primary);
  background: var(--ui-color-surface-control);
}
.custom-select-shop:focus-visible {
  outline: 2px solid var(--ui-color-focus);
  outline-offset: -2px;
}

@media (max-width: 650px) {
  .custom-select-menu--icon-grid .custom-select-row--icon {
    flex-basis: 44px;
  }
  .custom-select-menu--icon-grid .custom-select-row--mode .custom-select-option,
  .custom-select-menu--icon-grid .custom-select-shop {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .custom-select-chevron {
    transition: none;
  }
}
