/* ── Custom dropdowns ─────────────────────────────────────
   Native select остаётся скрытым backing state, игрок видит только этот
   компонент — без белого системного popup в Telegram WebView. */
.custom-select {
  position: relative;
  display: inline-flex;
  min-width: 132px;
  max-width: 100%;
  vertical-align: middle;
  font-family: var(--font, 'Courier New', monospace);
  z-index: 1;
}

.custom-select--craft,
.wallet-modal-body .custom-select {
  display: flex;
  width: 100%;
}

#panelCraft .custom-select { z-index: 141; }

.custom-select.is-open { z-index: 120; }

.custom-select__native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-width: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
  appearance: none !important;
}

.custom-select__trigger {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--text, #e8e4f0);
  background:
    linear-gradient(180deg, rgba(143,111,212,.08), transparent 55%),
    var(--surface-2, #1c1930);
  border: 1px solid var(--line-strong, #4a4270);
  border-radius: var(--r-md, 4px);
  box-shadow: var(--bevel, inset 1px 1px 0 rgba(255,255,255,.07), inset -1px -1px 0 rgba(0,0,0,.55));
  font: inherit;
  font-size: 11px;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
}

.custom-select__trigger:hover,
.custom-select__trigger:focus-visible,
.custom-select.is-open .custom-select__trigger {
  color: #fff4bd;
  border-color: var(--gold, #f5c542);
  outline: none;
  box-shadow: var(--bevel, inset 1px 1px 0 rgba(255,255,255,.07), inset -1px -1px 0 rgba(0,0,0,.55)), 0 0 0 2px var(--gold-glow, rgba(245,197,66,.22));
}

.custom-select__value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select__arrow {
  flex: 0 0 auto;
  color: var(--gold, #f5c542);
  font-size: 16px;
  line-height: 10px;
  transform: translateY(-2px);
  transition: transform .12s ease;
}

.custom-select.is-open .custom-select__arrow { transform: rotate(180deg) translateY(2px); }

.custom-select__menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  max-height: min(260px, 42vh);
  padding: 4px;
  overflow-y: auto;
  background:
    linear-gradient(180deg, rgba(143,111,212,.11), transparent 42%),
    #100e1d;
  border: 1px solid var(--gold-dim, #a8842c);
  border-radius: var(--r-md, 4px);
  box-shadow: 0 8px 22px rgba(0,0,0,.65), var(--bevel, inset 1px 1px 0 rgba(255,255,255,.07), inset -1px -1px 0 rgba(0,0,0,.55));
  z-index: 130;
}

/* Author display:flex overrides the browser's default [hidden] rule. Keep
   closed menus out of both layout and hit-testing, including after redraw. */
.custom-select__menu[hidden] { display: none; }

.custom-select.is-up .custom-select__menu {
  top: auto;
  bottom: calc(100% + 4px);
}

.custom-select__option {
  display: block;
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  color: var(--text-2, #b3abc9);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 2px;
  font: inherit;
  font-size: 10px;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
}

.custom-select__option:hover,
.custom-select__option:focus-visible,
.custom-select__option.is-selected {
  color: #fff4bd;
  background: var(--surface-3, #262138);
  border-color: rgba(245,197,66,.55);
  outline: none;
}

.custom-select__option.is-selected::before {
  content: '› ';
  color: var(--gold, #f5c542);
}

.custom-select__option:disabled,
.custom-select__trigger:disabled {
  color: var(--text-4, #847da8);
  cursor: not-allowed;
  opacity: .55;
}

.custom-select__menu::-webkit-scrollbar { width: 4px; }
.custom-select__menu::-webkit-scrollbar-track { background: transparent; }
.custom-select__menu::-webkit-scrollbar-thumb { background: var(--line-strong, #4a4270); border-radius: 2px; }

@media (max-width: 420px) {
  .custom-select { min-width: 118px; }
  .custom-select__trigger { min-height: 36px; padding: 7px 8px; font-size: 10px; }
}
