.shop-page {
  touch-action: pan-y;
}

.shop-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
}

.shop-bar::before {
  content: "";
  position: absolute;
  inset: 0 0 -18px 0;
  z-index: -2;
  pointer-events: none;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 85%, transparent) 0%,
    color-mix(in srgb, var(--bg) 85.0%, transparent) 30.0%,
    color-mix(in srgb, var(--bg) 83.9%, transparent) 35.0%,
    color-mix(in srgb, var(--bg) 80.8%, transparent) 40.0%,
    color-mix(in srgb, var(--bg) 75.7%, transparent) 45.0%,
    color-mix(in srgb, var(--bg) 69.0%, transparent) 50.0%,
    color-mix(in srgb, var(--bg) 60.9%, transparent) 55.0%,
    color-mix(in srgb, var(--bg) 51.9%, transparent) 60.0%,
    color-mix(in srgb, var(--bg) 42.5%, transparent) 65.0%,
    color-mix(in srgb, var(--bg) 33.1%, transparent) 70.0%,
    color-mix(in srgb, var(--bg) 24.1%, transparent) 75.0%,
    color-mix(in srgb, var(--bg) 16.0%, transparent) 80.0%,
    color-mix(in srgb, var(--bg) 9.3%, transparent) 85.0%,
    color-mix(in srgb, var(--bg) 4.2%, transparent) 90.0%,
    color-mix(in srgb, var(--bg) 1.1%, transparent) 95.0%,
    color-mix(in srgb, var(--bg) 0.0%, transparent) 100.0%);
}

.no-blur .shop-bar::before {
  inset: 0 0 -26px 0;
  background: linear-gradient(to bottom,
    color-mix(in srgb, var(--bg) 96.0%, transparent) 0.0%,
    color-mix(in srgb, var(--bg) 96.0%, transparent) 10.0%,
    color-mix(in srgb, var(--bg) 96.0%, transparent) 20.0%,
    color-mix(in srgb, var(--bg) 96.0%, transparent) 30.0%,
    color-mix(in srgb, var(--bg) 96.0%, transparent) 40.0%,
    color-mix(in srgb, var(--bg) 96.0%, transparent) 45.0%,
    color-mix(in srgb, var(--bg) 93.8%, transparent) 50.0%,
    color-mix(in srgb, var(--bg) 87.6%, transparent) 55.0%,
    color-mix(in srgb, var(--bg) 78.5%, transparent) 60.0%,
    color-mix(in srgb, var(--bg) 67.1%, transparent) 65.0%,
    color-mix(in srgb, var(--bg) 54.5%, transparent) 70.0%,
    color-mix(in srgb, var(--bg) 41.5%, transparent) 75.0%,
    color-mix(in srgb, var(--bg) 28.9%, transparent) 80.0%,
    color-mix(in srgb, var(--bg) 17.5%, transparent) 85.0%,
    color-mix(in srgb, var(--bg) 8.4%, transparent) 90.0%,
    color-mix(in srgb, var(--bg) 2.2%, transparent) 95.0%,
    color-mix(in srgb, var(--bg) 0.0%, transparent) 100.0%);
}

.shop-blur {
  position: absolute;
  inset: 0 0 -18px 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.no-blur .shop-blur {
  display: none;
}

.lite-blur .shop-blur i:not(:nth-child(4)):not(:nth-child(7)):not(:nth-child(10)) {
  display: none;
}

.shop-blur i {
  position: absolute;
  inset: 0;
  font-style: normal;
  -webkit-backdrop-filter: blur(var(--gblur, 1px));
  backdrop-filter: blur(var(--gblur, 1px));
  -webkit-mask-image: var(--gmask);
  mask-image: var(--gmask);
}

.shop-blur i:nth-child(1) {
  --gblur: 0.2px;
  --gmask: linear-gradient(to bottom, #000 85.42%, rgba(0,0,0,0.84) 89.06%, rgba(0,0,0,0.5) 92.71%, rgba(0,0,0,0.16) 96.35%, transparent 100%);
}

.shop-blur i:nth-child(2) {
  --gblur: 0.36px;
  --gmask: linear-gradient(to bottom, #000 78.12%, rgba(0,0,0,0.84) 82.29%, rgba(0,0,0,0.5) 86.46%, rgba(0,0,0,0.16) 90.62%, transparent 94.79%);
}

.shop-blur i:nth-child(3) {
  --gblur: 0.47px;
  --gmask: linear-gradient(to bottom, #000 70.83%, rgba(0,0,0,0.84) 75.26%, rgba(0,0,0,0.5) 79.69%, rgba(0,0,0,0.16) 84.11%, transparent 88.54%);
}

.shop-blur i:nth-child(4) {
  --gblur: 0.85px;
  --gmask: linear-gradient(to bottom, #000 64.58%, rgba(0,0,0,0.84) 68.75%, rgba(0,0,0,0.5) 72.92%, rgba(0,0,0,0.16) 77.08%, transparent 81.25%);
}

.shop-blur i:nth-child(5) {
  --gblur: 1.44px;
  --gmask: linear-gradient(to bottom, #000 57.29%, rgba(0,0,0,0.84) 61.46%, rgba(0,0,0,0.5) 65.62%, rgba(0,0,0,0.16) 69.79%, transparent 73.96%);
}

.shop-blur i:nth-child(6) {
  --gblur: 2.07px;
  --gmask: linear-gradient(to bottom, #000 47.92%, rgba(0,0,0,0.84) 52.6%, rgba(0,0,0,0.5) 57.29%, rgba(0,0,0,0.16) 61.98%, transparent 66.67%);
}

.shop-blur i:nth-child(7) {
  --gblur: 2.88px;
  --gmask: linear-gradient(to bottom, #000 35.42%, rgba(0,0,0,0.84) 40.62%, rgba(0,0,0,0.5) 45.83%, rgba(0,0,0,0.16) 51.04%, transparent 56.25%);
}

.shop-blur i:nth-child(8) {
  --gblur: 3.83px;
  --gmask: linear-gradient(to bottom, #000 22.92%, rgba(0,0,0,0.84) 28.12%, rgba(0,0,0,0.5) 33.33%, rgba(0,0,0,0.16) 38.54%, transparent 43.75%);
}

.shop-blur i:nth-child(9) {
  --gblur: 4.95px;
  --gmask: linear-gradient(to bottom, #000 10.42%, rgba(0,0,0,0.84) 15.62%, rgba(0,0,0,0.5) 20.83%, rgba(0,0,0,0.16) 26.04%, transparent 31.25%);
}

.shop-blur i:nth-child(10) {
  --gblur: 6.75px;
  --gmask: linear-gradient(to bottom, #000 0%, rgba(0,0,0,0.84) 4.69%, rgba(0,0,0,0.5) 9.38%, rgba(0,0,0,0.16) 14.06%, transparent 18.75%);
}

.shop-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.shop-scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: calc(max(12px, env(safe-area-inset-top)) + 66px) 16px 150px;
  -webkit-overflow-scrolling: touch;
}

.shop-inner {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.shop-inner > * {
  animation: fadeInUp 0.5s cubic-bezier(0.33, 1, 0.68, 1) backwards;
}

.shop-inner > :nth-child(1) { animation-delay: 0.02s; }
.shop-inner > :nth-child(2) { animation-delay: 0.08s; }
.shop-inner > :nth-child(3) { animation-delay: 0.14s; }
.shop-inner > :nth-child(4) { animation-delay: 0.2s; }
.shop-inner > :nth-child(5) { animation-delay: 0.26s; }
.shop-inner > :nth-child(6) { animation-delay: 0.32s; }

.shop-bar-right .coin-dot {
  animation: coinTurn 3.2s linear infinite;
}

.shop-title {
  font-size: clamp(1.8rem, 8vmin, 2.6rem);
}

.shop-preview {
  position: relative;
  width: 100%;
  max-width: 340px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--shape-large);
}

#preview-canvas {
  display: block;
  width: 100%;
  height: 210px;
}

.preview-name {
  position: absolute;
  top: 12px;
  left: 14px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--sky-text);
  transition: color 0.6s ease;
}

.preview-world {
  position: absolute;
  top: 12px;
  right: 14px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--sky-meta);
  transition: color 0.6s ease;
}

.shop-note {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2px 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--meta-text);
  text-align: center;
}

.tabs {
  --i: 0;
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: 100%;
  max-width: 440px;
  padding: 4px;
  border-radius: 999px;
  background: var(--secondary-bg);
}

.tab-pill {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / 4);
  border-radius: 999px;
  background: var(--card-bg);
  box-shadow: 0 1px 4px rgba(16, 38, 27, 0.12);
  transform: translateX(calc(var(--i) * 100%));
  transition: transform 0.38s cubic-bezier(0.34, 1.3, 0.5, 1);
  will-change: transform;
}

.tab {
  position: relative;
  z-index: 1;
  padding: 8px 4px;
  border: none;
  border-radius: 999px;
  background: none;
  color: var(--meta-text);
  font-family: var(--font-family);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  transition: color 0.25s ease, transform 0.15s ease;
}

.tab:active {
  transform: scale(0.95);
}

.tab.active {
  color: var(--text);
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
}

.item-pane {
  display: contents;
}

.item-pane[hidden] {
  display: none;
}

.item-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 6px 10px;
  border: 2px solid var(--border);
  border-radius: 18px;
  background: var(--card-bg);
  color: var(--text);
  font-family: var(--font-family);
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.2s ease, transform 0.15s ease, box-shadow 0.25s ease;
  animation: cardIn 0.32s ease backwards;
  animation-delay: calc(min(var(--n, 0), 10) * 28ms);
}

.item-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}

.item-card:active {
  transform: scale(0.97);
}

.item-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  background: var(--secondary-bg);
}

.item-name {
  font-size: 0.82rem;
  font-weight: 700;
}

.item-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--meta-text);
  font-variant-numeric: tabular-nums;
}

.item-card.equipped .item-tag {
  color: var(--accent-strong);
}

.shop-action {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  padding: 48px 16px max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg));
  background: linear-gradient(to bottom, transparent 0.0%,
    color-mix(in srgb, var(--bg) 1.5%, transparent) 7.1%,
    color-mix(in srgb, var(--bg) 5.5%, transparent) 14.3%,
    color-mix(in srgb, var(--bg) 11.8%, transparent) 21.4%,
    color-mix(in srgb, var(--bg) 19.8%, transparent) 28.6%,
    color-mix(in srgb, var(--bg) 29.2%, transparent) 35.7%,
    color-mix(in srgb, var(--bg) 39.4%, transparent) 42.9%,
    color-mix(in srgb, var(--bg) 50.0%, transparent) 50.0%,
    color-mix(in srgb, var(--bg) 60.6%, transparent) 57.1%,
    color-mix(in srgb, var(--bg) 70.8%, transparent) 64.3%,
    color-mix(in srgb, var(--bg) 80.2%, transparent) 71.4%,
    color-mix(in srgb, var(--bg) 88.2%, transparent) 78.6%,
    color-mix(in srgb, var(--bg) 94.5%, transparent) 85.7%,
    color-mix(in srgb, var(--bg) 98.5%, transparent) 92.9%,
    var(--bg) 100.0%);
  pointer-events: none;
}

.shop-action .button {
  width: 100%;
  max-width: 360px;
  pointer-events: auto;
  animation: fadeInUp 0.5s cubic-bezier(0.33, 1, 0.68, 1) 0.35s backwards;
}