/* Spark shop overlay */

#shop-overlay {
  z-index: 180;
  align-items: flex-start;
  padding:
    max(0.65rem, env(safe-area-inset-top))
    max(0.65rem, env(safe-area-inset-right))
    max(0.65rem, env(safe-area-inset-bottom))
    max(0.65rem, env(safe-area-inset-left));
}

#shop-overlay .shop-panel {
  width: min(96vw, 560px);
  max-height: min(92dvh, 760px);
  padding: 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: auto;
}

#shop-overlay .shop-panel > .shop-head,
#shop-overlay .shop-panel > .shop-tagline {
  padding-inline: 1.25rem;
}

.shop-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding-top: 1.25rem;
  padding-bottom: 0.5rem;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(180deg, rgba(22, 14, 40, 0.98) 75%, rgba(22, 14, 40, 0));
}

.shop-head h2 {
  flex: 1 1 auto;
  margin: 0;
  font-size: clamp(1.2rem, 4vw, 1.45rem);
  text-align: left;
  line-height: 1.15;
}

.shop-balance {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(200, 160, 255, 0.14);
  border: 1px solid rgba(200, 160, 255, 0.38);
  color: #c8a0ff;
  font-weight: 700;
  font-size: 0.88rem;
  white-space: nowrap;
  box-shadow: 0 0 20px rgba(200, 160, 255, 0.12);
}

.shop-close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.65);
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.shop-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  transform: scale(1.05);
}

.shop-close:focus {
  outline: none;
}

.shop-close:focus-visible {
  outline: 2px solid var(--green-glow);
  outline-offset: 2px;
}

.shop-tagline {
  color: rgba(255, 255, 255, 0.48);
  font-size: 0.8rem;
  line-height: 1.45;
  padding-bottom: 0.85rem;
  margin-bottom: 0;
  text-align: left;
  flex-shrink: 0;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(292px, auto);
  gap: 0.75rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0.15rem 1.1rem 1.15rem;
  flex: 1 1 auto;
  min-height: 0;
  align-items: stretch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 110, 180, 0.35) transparent;
}

.shop-grid::-webkit-scrollbar {
  width: 5px;
}

.shop-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 110, 180, 0.35);
  border-radius: 999px;
}

/* ── Card ── */
.shop-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 292px;
  height: 100%;
  padding: 0;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.2s ease;
}

.shop-card:hover {
  border-color: rgba(255, 110, 180, 0.32);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

.shop-card.equipped {
  border-color: rgba(94, 255, 168, 0.5);
  box-shadow: 0 0 28px rgba(94, 255, 168, 0.14);
}

.shop-card.tier-rare {
  border-color: rgba(100, 180, 255, 0.28);
}

.shop-card.tier-epic {
  border-color: rgba(200, 160, 255, 0.38);
  background: linear-gradient(165deg, rgba(155, 109, 255, 0.1), rgba(255, 255, 255, 0.02));
}

.shop-card.tier-legend {
  border-color: rgba(255, 213, 79, 0.38);
  background: linear-gradient(165deg, rgba(255, 213, 79, 0.09), rgba(255, 110, 180, 0.05));
}

.shop-card-badge,
.shop-card-tier {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  right: auto;
  z-index: 3;
  padding: 0.16rem 0.42rem;
  border-radius: 999px;
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  pointer-events: none;
}

.shop-card-badge {
  background: rgba(94, 255, 168, 0.18);
  border: 1px solid rgba(94, 255, 168, 0.45);
  color: var(--green-glow);
}

.shop-card-tier {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.65);
}

.shop-card.tier-rare .shop-card-tier {
  color: #90caf9;
  border-color: rgba(144, 202, 249, 0.35);
}

.shop-card.tier-epic .shop-card-tier {
  color: #c8a0ff;
  border-color: rgba(200, 160, 255, 0.35);
}

.shop-card.tier-legend .shop-card-tier {
  color: #ffd54f;
  border-color: rgba(255, 213, 79, 0.35);
}

/* ── Zorbie preview stage ── */
.shop-zorbie-preview {
  position: relative;
  flex: 0 0 112px;
  height: 112px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(ellipse 85% 70% at 50% 100%, rgba(94, 255, 168, 0.12), transparent 68%),
    radial-gradient(ellipse 60% 45% at 50% 55%, rgba(255, 255, 255, 0.06), transparent 70%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.shop-card.tier-epic .shop-zorbie-preview {
  background:
    radial-gradient(ellipse 85% 70% at 50% 100%, rgba(200, 160, 255, 0.16), transparent 68%),
    radial-gradient(ellipse 60% 45% at 50% 55%, rgba(255, 255, 255, 0.05), transparent 70%);
}

.shop-card.tier-legend .shop-zorbie-preview {
  background:
    radial-gradient(ellipse 85% 70% at 50% 100%, rgba(255, 213, 79, 0.14), transparent 68%),
    radial-gradient(ellipse 60% 45% at 50% 55%, rgba(255, 110, 180, 0.08), transparent 70%);
}

.shop-zorbie-stage {
  position: relative;
  width: 76px;
  height: 92px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
  flex-shrink: 0;
}

.shop-zorbie-preview .alien {
  position: relative;
  left: auto;
  top: auto;
  transform: scale(0.54);
  transform-origin: bottom center;
  animation: none !important;
  z-index: 1;
}

.shop-zorbie-preview .alien-body {
  width: 50px;
  height: 64px;
}

.shop-zorbie-preview .alien-head {
  width: 56px;
  height: 50px;
  top: -42px;
  --eye-w: 14px;
  --eye-h: 18px;
  --mouth-w: 13px;
  --mouth-h: 7px;
}

.shop-zorbie-preview .arm {
  width: 9px;
  height: 26px;
  animation: none !important;
}

.shop-zorbie-preview .arm.left {
  left: -5px;
  transform: rotate(22deg);
}

.shop-zorbie-preview .arm.right {
  right: -5px;
  transform: rotate(-22deg);
}

.shop-zorbie-preview .antenna {
  height: 15px;
  top: -13px;
}

.shop-zorbie-preview .antenna::after {
  width: 7px;
  height: 7px;
  top: -5px;
}

.shop-zorbie-preview .eye,
.shop-zorbie-preview .mouth,
.shop-zorbie-preview .pupil {
  animation: none !important;
}

.shop-zorbie-preview .game-zorbie.skin-retro::after {
  inset: -8% -15%;
  opacity: 0.35;
}

.shop-zorbie-preview .game-zorbie.skin-ghost {
  opacity: 0.82;
}

/* ── Card body ── */
.shop-card-meta {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.55rem 0.6rem 0.4rem;
  min-width: 0;
  min-height: 0;
}

.shop-card-name {
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.3;
  word-break: break-word;
  hyphens: auto;
}

.shop-card-tag {
  font-size: 0.66rem;
  color: rgba(255, 255, 255, 0.42);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1 1 auto;
}

.shop-card-foot {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
  padding: 0.45rem 0.55rem 0.65rem;
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.12);
}

.shop-card-price {
  font-size: 0.72rem;
  font-weight: 700;
  color: #c8a0ff;
  text-align: center;
  line-height: 1.2;
}

.shop-card.owned .shop-card-price {
  color: var(--green-glow);
}

.shop-card-btn.btn-cosmic,
.shop-card-btn.btn-cosmic.secondary {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 0.5rem 0.45rem;
  font-size: 0.72rem;
  margin-top: 0;
  box-sizing: border-box;
}

.shop-card-btn.disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Sparks card opens shop */
.glass-card.shop-trigger {
  cursor: pointer;
  position: relative;
}

.glass-card.shop-trigger::after {
  content: '🛸';
  position: absolute;
  top: 0.45rem;
  right: 0.5rem;
  font-size: 0.75rem;
  opacity: 0.55;
}

.glass-card.shop-trigger:hover {
  border-color: rgba(200, 160, 255, 0.35);
  box-shadow: 0 12px 32px rgba(200, 160, 255, 0.12);
}

body.shop-open {
  overflow: hidden;
}

@media (max-width: 380px) {
  .shop-grid {
    gap: 0.6rem;
    padding-inline: 0.85rem;
    grid-auto-rows: minmax(280px, auto);
  }

  #shop-overlay .shop-panel > .shop-head,
  #shop-overlay .shop-panel > .shop-tagline {
    padding-inline: 0.85rem;
  }

  .shop-card {
    min-height: 280px;
  }

  .shop-zorbie-preview {
    flex-basis: 104px;
    height: 104px;
  }
}

@media (min-width: 680px) {
  .shop-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: minmax(300px, auto);
  }

  .shop-card {
    min-height: 300px;
  }
}
