.trade-up-open {
  overflow: hidden;
}

.trade-up-screen {
  position: fixed;
  z-index: 45;
  top: var(--header-height);
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-rows: 46px minmax(0, 1fr) 82px;
  color: rgba(244, 243, 237, 0.86);
  background:
    radial-gradient(circle at 50% 8%, rgba(111, 82, 59, 0.12), transparent 43%),
    linear-gradient(180deg, rgba(32, 31, 29, 0.995), rgba(22, 23, 22, 0.998));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.trade-up-top {
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(18, 19, 18, 0.36);
}

.trade-up-info {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(244, 243, 237, 0.45);
  font-size: 9px;
  letter-spacing: 0.025em;
}

.trade-up-info strong {
  color: rgba(244, 243, 237, 0.78);
  font-weight: 700;
}

.trade-up-info-icon {
  display: grid;
  width: 16px;
  height: 16px;
  place-items: center;
  border-radius: 50%;
  color: #343634;
  background: rgba(240, 240, 234, 0.84);
  font: 700 11px Arial, sans-serif;
}

.trade-up-columns {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.trade-up-column {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 44px minmax(0, 1fr);
}

.trade-up-source {
  border-right: 1px solid rgba(255, 255, 255, 0.065);
}

.trade-up-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.035);
  color: rgba(246, 245, 239, 0.42);
  font-size: 9px;
  letter-spacing: 0.035em;
}

.trade-up-quality {
  position: relative;
  width: 156px;
  height: 29px;
  flex: 0 0 156px;
}

.trade-up-quality::after {
  position: absolute;
  top: 50%;
  right: 10px;
  width: 6px;
  height: 6px;
  border-right: 1px solid rgba(246, 245, 239, 0.46);
  border-bottom: 1px solid rgba(246, 245, 239, 0.46);
  content: "";
  pointer-events: none;
  transform: translateY(-70%) rotate(45deg);
}

.trade-up-quality-select {
  width: 100%;
  height: 100%;
  padding: 0 30px 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0;
  outline: none;
  color: rgba(246, 245, 239, 0.72);
  background: #222421;
  font: 700 8px var(--font-ui);
  letter-spacing: 0.04em;
  appearance: none;
  cursor: pointer;
}

.trade-up-quality-select:hover,
.trade-up-quality-select:focus-visible {
  border-color: rgba(142, 184, 195, 0.28);
  background: #292b28;
}

.trade-up-quality-select:disabled {
  opacity: 0.66;
  cursor: default;
}

.trade-up-quality-select option {
  color: #e3e3dc;
  background: #222421;
}

.trade-up-grid {
  min-height: 0;
  overflow: auto;
  align-content: start;
  padding: 12px 14px 22px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
  scroll-behavior: smooth;
}

.trade-up-selected-grid {
  grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
}

.trade-up-item {
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.055);
  color: inherit;
  background: rgba(65, 67, 64, 0.34);
  cursor: pointer;
  text-align: left;
  transition: border-color 90ms ease, background-color 90ms ease;
}

.trade-up-item:hover,
.trade-up-item:focus-visible {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(75, 78, 74, 0.5);
  outline: none;
}

.trade-up-item.is-selected {
  border-color: rgba(130, 178, 191, 0.23);
  background: rgba(51, 66, 69, 0.43);
}

.trade-up-item-visual {
  position: relative;
  display: block;
  height: 95px;
  overflow: hidden;
  background: linear-gradient(145deg, rgba(72, 74, 71, 0.42), rgba(43, 45, 43, 0.38));
}

.trade-up-item-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 5px 5px rgba(0, 0, 0, 0.28));
}

.trade-up-item-rarity {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--trade-up-rarity, #4b69ff);
}

.trade-up-item-labels {
  min-width: 0;
  display: grid;
  padding: 5px 7px 6px;
}

.trade-up-item-labels strong,
.trade-up-item-labels span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trade-up-item-labels strong {
  color: rgba(255, 255, 255, 0.84);
  font-size: 9px;
}

.trade-up-item-labels span {
  color: rgba(255, 255, 255, 0.4);
  font-size: 7px;
}

.trade-up-slot {
  height: 128px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.11);
  background: rgba(255, 255, 255, 0.008);
  font-size: 17px;
}

.trade-up-empty {
  grid-column: 1 / -1;
  padding: 40px 10px;
  color: rgba(255, 255, 255, 0.28);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-align: center;
}

.trade-up-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.065);
  background: rgba(15, 16, 15, 0.48);
}

.trade-up-status {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.trade-up-status strong {
  color: rgba(255, 255, 255, 0.72);
  font-size: 9px;
}

.trade-up-status span {
  max-width: 52vw;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.28);
  font-size: 7px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trade-up-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.trade-up-ready {
  display: flex;
  align-items: center;
  gap: 7px;
  color: rgba(255, 255, 255, 0.44);
  font-size: 8px;
}

.trade-up-ready input {
  accent-color: #62813f;
}

.trade-up-clear,
.trade-up-proceed {
  height: 34px;
  padding: 0 15px;
  border: 1px solid rgba(255, 255, 255, 0.075);
  color: rgba(255, 255, 255, 0.6);
  background: rgba(50, 52, 49, 0.58);
  font: 700 8px var(--font-ui);
  letter-spacing: 0.035em;
  cursor: pointer;
}

.trade-up-clear:hover:not(:disabled) {
  background: rgba(65, 67, 63, 0.72);
}

.trade-up-proceed {
  border-color: rgba(139, 194, 157, 0.18);
  color: #e8efe8;
  background: #4f7352;
}

.trade-up-proceed:hover:not(:disabled) {
  background: #5c845f;
}

.trade-up-proceed:disabled,
.trade-up-clear:disabled {
  opacity: 0.32;
  cursor: default;
}

.trade-up-launch {
  margin-left: 4px;
  border-left: 1px solid rgba(255, 255, 255, 0.12) !important;
  color: #b9d6c7 !important;
}

@media (max-width: 900px) {
  .trade-up-screen {
    grid-template-rows: 43px minmax(0, 1fr) 90px;
  }
  .trade-up-columns {
    grid-template-columns: 1fr;
    overflow: auto;
  }
  .trade-up-source {
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }
  .trade-up-column {
    min-height: 330px;
  }
  .trade-up-info span:last-child {
    display: none;
  }
  .trade-up-footer {
    padding: 0 12px;
  }
}


/* 013: keep large Trade Up inventories in their own scroll regions without shrinking cards. */
.trade-up-source-grid,
.trade-up-selected-grid {
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  grid-auto-rows: 128px;
  align-content: start;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.trade-up-item {
  height: 128px;
  min-height: 128px;
}

.trade-up-slot {
  height: 128px;
  min-height: 128px;
}

/* Skip off-screen trade-up card painting while preserving layout and appearance. */
.trade-up-item {
  content-visibility: auto;
  contain-intrinsic-size: auto 128px;
}
