.app-scroll.is-upgrade {
  background: #141414;
}

.screen-game.is-upgrade {
  padding:
    12px
    var(--app-gutter)
    calc(18px + var(--tg-safe-bottom) + var(--tg-content-safe-bottom));
}

.upgrade-screen {
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-height: 100%;
  font-family: Montserrat, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.upgrade-screen button,
.upgrade-screen input {
  font-family: inherit;
}

.upgrade-screen button {
  cursor: pointer;
}

.upgrade-gauge {
  position: relative;
  width: 225px;
  height: 247.5px;
  flex-shrink: 0;
  margin: 4px auto 0;
}

.upgrade-gauge__strip,
.upgrade-gauge__art {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  width: 225px;
  height: 247.5px;
  pointer-events: none;
}

.upgrade-gauge__strip [data-strip-fill] {
  transition: stroke-dasharray 0.35s ease, transform 0.35s ease;
}

.upgrade-gauge__hub {
  position: absolute;
  left: 42px;
  top: 40.5px;
  z-index: 1;
  width: 141px;
  height: 141px;
  overflow: hidden;
  border-radius: 50%;
  border: 1.1px solid rgba(255, 255, 255, 0.32);
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 191, 50, 0.16), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04));
  box-shadow: inset 6px 10px 18px rgba(255, 255, 255, 0.12);
}

.upgrade-gauge__mascot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 96px;
  height: 96px;
  object-fit: contain;
  opacity: 0.42;
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: upgrade-mascot-breathe 4.8s ease-in-out infinite;
}

.upgrade-gauge__label {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.upgrade-gauge__pct {
  color: #fff;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.6px;
  line-height: 31px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.55);
}

.upgrade-gauge__hint {
  color: rgba(255, 255, 255, 0.45);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: -0.1px;
}

.upgrade-gauge__mark {
  position: absolute;
  color: rgba(255, 255, 255, 0.45);
  font-size: 8.25px;
  font-weight: 600;
  line-height: 10px;
  white-space: nowrap;
}

.upgrade-gauge__mark--top {
  left: 101.63px;
  top: -1px;
}

.upgrade-gauge__mark--left {
  left: -9.5px;
  top: 105px;
}

.upgrade-gauge__mark--right {
  left: 216.5px;
  top: 105px;
}

.upgrade-gauge__mark--bot {
  left: 106.13px;
  top: 213px;
  color: #ffbf32;
}

.upgrade-gauge__spin {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  transform-origin: 112.5px 111px;
}

.upgrade-gauge__pointer {
  position: absolute;
  left: 94.5px;
  top: 160px;
  display: block;
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.upgrade-pair {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.upgrade-pair .card,
.btn-upgrade,
.upgrade-panel,
.tab-chip,
.price-input,
.sort {
  isolation: isolate;
  backdrop-filter: blur(40px) saturate(120%);
  -webkit-backdrop-filter: blur(40px) saturate(120%);
}

.upgrade-pair .card {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-width: 0;
  height: 156px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
}

.upgrade-pair .card.is-picker {
  border-color: rgba(255, 191, 50, 0.7);
}

.card--empty {
  gap: 8px;
}

.card-plus {
  display: flex;
  color: rgba(255, 255, 255, 0.72);
}

.card-art {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  overflow: hidden;
}

.card-art img,
.card-prize {
  display: block;
  width: 72px;
  height: 72px;
  max-width: 72px;
  max-height: 72px;
  object-fit: contain;
}

.card-art.is-nft-gift img,
.card-art .is-nft-gift,
.cell.is-nft-gift img,
.cell .prize-img.is-nft {
  border-radius: 30px;
}

.card-name {
  margin-top: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-price {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  color: #ffbf32;
  font-size: 13px;
  font-weight: 700;
}

.card-price img {
  width: 13px;
  height: 13px;
  object-fit: cover;
}

.card-empty {
  color: rgba(255, 255, 255, 0.4);
  font-size: 13px;
  font-weight: 600;
}

.pair-arrow {
  display: block;
  width: 14px;
  height: 12px;
  flex-shrink: 0;
  object-fit: contain;
  opacity: 0.85;
}

.btn-upgrade {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 52px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 100px;
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.12);
  box-shadow:
    inset 1px 1px 0.5px -1px #fff,
    inset -1px -1px 0.5px -1px #fff,
    inset 0 0 3.5px rgba(255, 255, 255, 0.4);
  transition: transform 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

.btn-upgrade:active {
  transform: scale(0.97);
}

.btn-upgrade:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.upgrade-outcome {
  margin: 0;
  min-height: 18px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.upgrade-outcome.is-ok {
  color: #7dffa8;
}

.upgrade-outcome.is-bad {
  color: #ff8f9f;
}

.upgrade-outcome[hidden] {
  display: none;
}

.upgrade-stars-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.06);
}

.upgrade-stars-row.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.upgrade-stars-row.is-active {
  border-color: rgba(255, 191, 50, 0.4);
}

.upgrade-stars-row label {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
}

.upgrade-stars-row input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: #ffbf32;
}

.upgrade-stars-row__val {
  min-width: 36px;
  text-align: right;
  color: #ffbf32;
  font-weight: 700;
  font-size: 12px;
}

.upgrade-panels {
  display: none;
  gap: 10px;
  width: 100%;
  min-height: 229px;
}

.upgrade-panels.is-open {
  display: flex;
}

.upgrade-panels.is-open .upgrade-panel {
  height: 320px;
}

.upgrade-panels.is-open .grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: calc((100% - 18px) / 4);
}

.upgrade-panels.is-open .cell {
  height: 100%;
  min-height: 0;
}

.upgrade-panels.is-open .cell .prize-img,
.upgrade-panels.is-open .cell > img {
  width: 32px;
  height: 32px;
  max-width: 32px;
  max-height: 32px;
}

.upgrade-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
  height: 229px;
  padding: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.07);
  transition: border-color 0.28s ease, box-shadow 0.28s ease;
}

.upgrade-panel--right {
  gap: 6px;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 21px;
  flex-shrink: 0;
}

.upgrade-panel--left .tab-chip[data-mode="mine"] {
  order: 1;
}

.upgrade-panel--left .tab-chip[data-mode="shop"] {
  order: 2;
}

.upgrade-panel--left .filters--shop {
  order: 3;
}

.tab-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 21px;
  padding: 0 8px;
  border: none;
  border-radius: 100px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.06);
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.22s ease, background 0.22s ease, box-shadow 0.22s ease, width 0.28s ease, padding 0.22s ease;
}

.tab-chip--on {
  color: #ffbf32;
  background: rgba(255, 191, 50, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 191, 50, 0.9);
}

.upgrade-panel--left[data-mode="mine"] .tab-chip[data-mode="mine"] {
  width: 42px;
  padding: 0;
}

.upgrade-panel--left[data-mode="shop"] {
  border-color: rgba(255, 191, 50, 0.35);
}

.upgrade-panel--left[data-mode="shop"] .panel-head {
  gap: 3px;
}

.upgrade-panel--left[data-mode="shop"] .tab-chip[data-mode="shop"] {
  order: 1;
  width: 47px;
  padding: 0;
  font-size: 9px;
}

.upgrade-panel--left[data-mode="shop"] .tab-chip[data-mode="mine"] {
  order: 2;
  width: 37px;
  padding: 0;
  font-size: 9px;
}

.panel-title {
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.8);
  font-size: 12px;
  font-weight: 600;
}

.filters {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.filters--shop {
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transform: translateX(8px);
  transition: max-width 0.28s ease, opacity 0.22s ease, transform 0.28s ease;
}

.filters.is-on {
  max-width: none;
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.upgrade-panel--left[data-mode="shop"] .filters--shop {
  max-width: 84px;
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.upgrade-panel--left[data-mode="shop"] .price-input {
  flex: 0 0 27px;
  width: 27px;
  padding: 0 3px;
  text-align: center;
}

.price-input {
  width: 100%;
  min-width: 0;
  height: 22px;
  padding: 0 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: #fff;
  font-size: 9px;
  font-weight: 500;
  text-align: center;
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

.price-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.sort {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border: none;
  background: url("/img/upgrade/sort.svg") center / contain no-repeat;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.sort.is-up {
  transform: rotate(180deg);
}

.upgrade-panel--left[data-mode="shop"] .sort {
  width: 22px;
  height: 22px;
}

.shop-note {
  display: none;
  flex-shrink: 0;
  margin: 0;
  padding: 0 2px;
  color: rgba(255, 191, 50, 0.85);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.3;
}

.upgrade-panel--left[data-mode="shop"] .shop-note {
  display: block;
}

.grids {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: 50.667px;
  gap: 6px;
  align-content: start;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.grid--target {
  flex: 1;
  min-height: 0;
  height: auto;
}

.grid--mine,
.grid--shop {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  transform: translateX(0) scale(0.96);
  transition: opacity 0.32s ease, transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

.grid.is-in {
  opacity: 1;
  pointer-events: auto;
  transform: none;
  z-index: 2;
}

.grid--mine.is-out {
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  transform: translateX(-16px) scale(0.96);
}

.grid--shop.is-out {
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  transform: translateX(16px) scale(0.96);
}

.grid.is-enter .cell {
  animation: upgrade-cell-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--i, 0) * 28ms);
}

.cell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 100%;
  height: 50.667px;
  min-height: 50.667px;
  padding: 3px 2px 2px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.cell .prize-img,
.cell > img,
.cell .cell-price {
  pointer-events: none;
}

.cell .prize-img,
.cell > img {
  display: block;
  width: 26px;
  height: 26px;
  max-width: 26px;
  max-height: 26px;
  flex-shrink: 0;
  object-fit: contain;
}

.cell.is-on {
  border: 1.5px solid #ffbf32;
  box-shadow: 0 0 10px rgba(255, 191, 50, 0.22);
}

.cell-price {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 12px;
  padding: 1px 3px;
  border-radius: 4px;
  color: #ffbf32;
  font-size: 8px;
  font-weight: 700;
  background: rgba(20, 20, 20, 0.72);
}

.cell-price img {
  width: 8px;
  height: 8px;
  object-fit: cover;
}

.upgrade-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 18px 8px;
  color: rgba(255, 255, 255, 0.4);
  font-size: 11px;
  font-weight: 600;
}

@keyframes upgrade-mascot-breathe {
  0%,
  100% {
    opacity: 0.36;
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    opacity: 0.48;
    transform: translate(-50%, -50%) scale(1.04);
  }
}

@keyframes upgrade-cell-in {
  from {
    opacity: 0;
    transform: scale(0.82) translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 360px) {
  .upgrade-gauge {
    transform: scale(0.92);
    transform-origin: top center;
    margin-bottom: -12px;
  }

  .upgrade-pair .card {
    height: 136px;
  }

  .card-art,
  .card-art img,
  .card-prize {
    width: 60px;
    height: 60px;
    max-width: 60px;
    max-height: 60px;
  }
}
