.insufficient-gems-modal, .token-topup-modal, .shop-paid-choice-modal {
  z-index: 13000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.insufficient-gems-panel {
  position: relative;
  width: min(100%, 32rem);
  max-height: min(90vh, 42rem);
  overflow-y: auto;
  padding: 1.5rem;
  border: 3px solid var(--theme-border-strong, #5b4c62);
  border-radius: 12px;
  background: var(--theme-modal-bg, #fff9f5);
  color: var(--theme-text, #5b4c62);
  box-shadow: 4px 6px 0 rgba(91, 76, 98, .28);
}

.insufficient-gems-panel h2 { display: flex; align-items: center; gap: .6rem; margin: 0 2rem .5rem 0; color: var(--theme-text, #5b4c62); text-shadow: 2px 2px 0 var(--theme-heading-shadow, #c9b4e8); }
.insufficient-gems-panel h2 img { width: 32px; height: 32px; object-fit: contain; flex: 0 0 32px; image-rendering: pixelated; }
.insufficient-gems-detail { margin: 0 0 1.25rem; line-height: 1.45; }
.insufficient-gems-item { display: inline-flex; align-items: center; gap: .2rem; font-weight: 900; color: var(--theme-text, #5b4c62); }
.insufficient-gems-item img { width: 1.4em; height: 1.4em; object-fit: contain; vertical-align: middle; }
.insufficient-gems-offers { display: grid; gap: .75rem; }
.insufficient-gems-offer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  padding: .85rem;
  border: 2px solid var(--theme-border-strong, #5b4c62);
  border-radius: 10px;
  background: var(--theme-control-bg, #fff9f5);
  color: var(--theme-control-text, #5b4c62);
}
.insufficient-gems-offer-copy { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.insufficient-gems-offer-icon { width: 42px; height: 42px; flex: 0 0 42px; object-fit: contain; image-rendering: pixelated; }
.insufficient-gems-offer-text { min-width: 0; }
.insufficient-gems-offer strong,
.insufficient-gems-offer span { display: block; }
.insufficient-gems-offer span { font-size: .85rem; }
.insufficient-gems-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.insufficient-gems-actions .action-btn { min-width: 5rem; }
.insufficient-gems-resume { margin-top: 1rem; width: 100%; }

.shop-feature-row .shop-paid-special-open,
.shop-feature-row .shop-paid-special-buy,
.shop-feature-row .shop-paid-credit-open {
  grid-column: 1 / -1;
  white-space: nowrap;
}
.shop-paid-credit-open[hidden] { display: none; }

.shop-paid-choice-modal { box-sizing: border-box; max-width: none; max-height: none; margin: 0; border: 0; backdrop-filter: none; -webkit-backdrop-filter: none; }
.shop-paid-choice-modal::backdrop { background: transparent; }
.shop-paid-choice-modal.active { align-items: flex-start; overflow-y: auto; }
.shop-paid-choice-panel { width: min(100%, 32rem); max-height: none; margin: auto; overflow: visible; border-radius: 30px; }
.shop-paid-choice-quantity { display: grid; gap: .4rem; margin-bottom: .65rem; font-weight: 900; }
.shop-paid-choice-quantity select { position: relative; z-index: 1; width: 100%; min-height: 44px; padding: .5rem .75rem; border: 2px solid var(--theme-border-strong, #5b4c62); border-radius: 12px; background: var(--theme-control-bg, #fff3ec); color: var(--theme-control-text, #5b4c62); font: inherit; cursor: pointer; }
.shop-paid-choice-total { margin: 0 0 1rem; font-weight: 900; }
.shop-paid-choice-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.shop-paid-choice-actions .action-btn { flex: 1 1 10rem; margin: 0; }

:is(#insufficientGemsModal, #tokenTopUpModal, #shopPaidChoiceModal, #starterBiasModal, #beginnerBundleModal) .close-modal {
  border: 1px solid var(--theme-border-strong, #5b4c62);
  border-radius: 12px;
  background: var(--theme-control-bg, #fff3ec);
}
:is(#insufficientGemsModal, #tokenTopUpModal, #shopPaidChoiceModal, #starterBiasModal, #beginnerBundleModal) .close-modal::before,
:is(#insufficientGemsModal, #tokenTopUpModal, #shopPaidChoiceModal, #starterBiasModal, #beginnerBundleModal) .close-modal::after {
  background: var(--theme-control-text, #5b4c62) !important;
}

/* Gem top-up uses the same pack art, price pills and colors as the Shop. */
.gem-topup-panel {
  width: min(100%, 560px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  border-radius: 16px;
  background: var(--theme-modal-bg, #fff9f5);
  color: var(--theme-text, #5b4c62);
  font-family: 'Courier New', monospace;
}
.gem-topup-panel .close-modal {
  top: 16px;
  right: 16px;
  width: 42px;
  height: 42px;
  border: 1px solid var(--theme-border-strong, #5b4c62);
  border-radius: 12px;
  background: var(--theme-control-bg, #fff3ec);
}
.gem-topup-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 94px;
  padding: 16px 68px 16px 22px;
  border-bottom: 3px solid var(--theme-border-strong, #5b4c62);
  background: var(--theme-control-bg, #fff3ec);
  color: var(--theme-control-text, #5b4c62);
}
.gem-topup-heading-icon { width: 58px; height: 58px; flex: 0 0 58px; object-fit: contain; image-rendering: pixelated; }
.gem-topup-kicker { display: block; margin-bottom: 5px; color: inherit; opacity: .78; font: 900 12px/1.2 'Courier New', monospace; letter-spacing: .08em; text-transform: uppercase; }
.gem-topup-panel h2 { display: block; margin: 0; color: inherit; font: 900 clamp(17px, 3vw, 22px)/1.3 'Press Start 2P', 'Courier New', monospace; text-shadow: none; }
.gem-topup-intro { margin: 0; padding: 18px 22px 12px; font: 700 16px/1.35 'Courier New', monospace; }
.gem-topup-summary { margin: 0 22px 18px; overflow: hidden; border: 2px solid var(--theme-border-strong, #5b4c62); border-radius: 12px; background: var(--theme-input-bg, #fff9f5); color: var(--theme-text, #5b4c62); }
.gem-topup-item { display: flex; align-items: center; gap: 12px; min-height: 80px; padding: 10px 14px; background: var(--theme-control-bg, #fff3ec); color: var(--theme-control-text, #5b4c62); }
.gem-topup-item-art { width: 60px; height: 60px; flex: 0 0 60px; object-fit: contain; image-rendering: pixelated; }
.gem-topup-item > div { min-width: 0; }
.gem-topup-item span { display: block; color: inherit; opacity: .78; font: 800 12px/1.2 'Courier New', monospace; text-transform: uppercase; }
.gem-topup-item-name { display: block; margin-top: 3px; overflow-wrap: anywhere; font: 900 18px/1.2 'Courier New', monospace; }
.gem-topup-totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 2px solid var(--theme-border-strong, #5b4c62); }
.gem-topup-totals > div { min-width: 0; padding: 10px 8px; text-align: center; }
.gem-topup-totals > div + div { border-left: 1px solid var(--theme-border, #d7c8d6); }
.gem-topup-totals > div > span { display: block; margin-bottom: 5px; color: inherit; opacity: .78; font: 800 12px/1.2 'Courier New', monospace; text-transform: uppercase; }
.gem-topup-totals strong { display: inline-flex; align-items: center; justify-content: center; gap: 4px; max-width: 100%; font: 900 18px/1.2 'Courier New', monospace; white-space: nowrap; }
.gem-topup-currency { display: inline-block !important; flex: 0 0 auto; font: 18px/1 'Segoe UI Emoji', 'Apple Color Emoji', sans-serif !important; vertical-align: middle; }
.gem-topup-totals-needed { background: color-mix(in srgb, var(--theme-accent-3, #ffd98d) 15%, var(--theme-input-bg, #fff9f5)); }
.gem-topup-offer-heading { margin: 0 22px 10px; color: var(--theme-text, #5b4c62); font: 900 18px/1.2 'Courier New', monospace; text-shadow: none; }
.gem-topup-panel .insufficient-gems-offers { gap: 10px; padding: 0 22px 22px; }
.gem-topup-loading { margin: 0; padding: 16px; text-align: center; font: 800 15px/1.3 'Courier New', monospace; }
.gem-topup-panel .gem-topup-offer { display: block; padding: 12px; border: 2px solid var(--theme-border-strong, #5b4c62); border-radius: 12px; background: var(--theme-control-bg, #fff9f5); color: var(--theme-control-text, #5b4c62); }
.gem-topup-offer-main { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 12px; align-items: center; min-height: 72px; }
.gem-topup-panel .insufficient-gems-offer-icon { width: 72px; height: 72px; object-fit: contain; }
.gem-topup-panel .insufficient-gems-offer-text strong { display: block; font: 900 19px/1.2 'Courier New', monospace; }
.gem-topup-reward { display: inline-flex !important; align-items: center; gap: 5px; margin-top: 6px; font: 900 16px/1.2 'Courier New', monospace !important; white-space: nowrap; }
.gem-topup-panel .gem-topup-price { display: inline-block; min-width: 56px; padding: 4px 7px; border: 2px solid rgba(91, 76, 98, .78); border-radius: 999px; background: rgba(255, 249, 245, .82); color: var(--theme-text, #5b4c62); font: 900 max(12px, .75rem)/1 'Courier New', monospace; text-align: center; white-space: nowrap; box-shadow: 0 2px 0 rgba(91, 76, 98, .14); }
:is(html[data-theme="dark"], html[data-theme="grey"], html[data-theme^="festival-"]) .gem-topup-panel .gem-topup-price { border-color: var(--theme-border-strong); background: var(--theme-surface-base); color: #fff3ec; }
.gem-topup-panel .insufficient-gems-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.gem-topup-panel .insufficient-gems-actions .shop-price-pill { width: 100%; min-height: 40px; margin: 0; font-family: 'Courier New', monospace; font-size: max(14px, .9rem); font-weight: 900; }
.gem-topup-panel .insufficient-gems-actions .shop-price-pill:only-child { grid-column: 1 / -1; }
.gem-topup-panel .insufficient-gems-resume { display: block; width: calc(100% - 44px); min-height: 44px; margin: 0 22px 22px; font: 900 13px/1.2 'Press Start 2P', 'Courier New', monospace; }
.gem-topup-panel .insufficient-gems-resume[hidden] { display: none; }

@media (max-width: 600px) {
  .gem-topup-heading { min-height: 82px; padding: 12px 58px 12px 16px; gap: 10px; }
  .gem-topup-heading-icon { width: 50px; height: 50px; flex-basis: 50px; }
  .gem-topup-panel .close-modal { top: 14px; right: 12px; }
  .gem-topup-intro { padding: 15px 16px 10px; font-size: 15px; }
  .gem-topup-summary { margin: 0 16px 16px; }
  .gem-topup-item { min-height: 70px; padding: 8px 12px; }
  .gem-topup-item-art { width: 52px; height: 52px; flex-basis: 52px; }
  .gem-topup-item-name { font-size: 17px; }
  .gem-topup-offer-heading { margin: 0 16px 9px; font-size: 17px; }
  .gem-topup-panel .insufficient-gems-offers { padding: 0 16px 16px; }
  .gem-topup-offer-main { grid-template-columns: 58px minmax(0, 1fr) auto; gap: 8px; min-height: 58px; }
  .gem-topup-panel .insufficient-gems-offer-icon { width: 58px; height: 58px; }
  .gem-topup-panel .insufficient-gems-offer-text strong { font-size: 17px; }
  .gem-topup-reward { font-size: 15px !important; }
  .gem-topup-panel .gem-topup-price { padding: 4px 7px; }
  .gem-topup-panel .insufficient-gems-resume { width: calc(100% - 32px); margin: 0 16px 16px; }
}

@media (max-width: 360px) {
  .gem-topup-offer-main { grid-template-columns: 58px minmax(0, 1fr); }
  .gem-topup-panel .gem-topup-price { grid-column: 2; justify-self: start; }
}
