:root {
  --shop-cyan: #6ec8ff;
  --shop-cyan-dim: #3a9fd4;
  --shop-gold: #ffd27a;
  --shop-green: #8dff79;
  --shop-muted: #9ee2ff;
  --shop-muted-2: #8ecae6;
  --shop-bg: #07131b;
  --shop-card: rgba(12, 32, 48, 0.92);
  --shop-border: rgba(95, 163, 206, 0.45);
  --tm-ring: rgba(255, 255, 255, 0.85);
  --radius: 14px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: radial-gradient(ellipse at 50% -10%, #123048 0%, #020608 72%);
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #e8f4ff;
}

body.embed {
  height: 100%;
  overflow: hidden;
  background: transparent;
}

.shopWindow {
  width: min(1240px, calc(100vw - 20px));
  height: min(760px, calc(100vh - 20px));
  margin: 10px auto;
  background: linear-gradient(165deg, #1a2f42 0%, #0f1c28 52%, #0a1219 100%);
  border-radius: var(--radius);
  border: 1px solid rgba(120, 200, 255, 0.42);
  box-shadow: 0 16px 56px rgba(0, 0, 0, 0.58), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.embed .shopWindow {
  width: 100%;
  height: 100%;
  max-height: 100%;
  margin: 0;
  border-radius: 0;
  border-left: none;
  border-right: none;
  box-shadow: none;
}

/* Header */
.shopHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px 10px;
  border-bottom: 1px solid rgba(95, 163, 206, 0.22);
  background: linear-gradient(180deg, rgba(30, 58, 82, 0.95), rgba(14, 26, 38, 0.85));
  flex-shrink: 0;
}

.shopBrand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.shopBrandIcon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(110, 200, 255, 0.25), rgba(255, 210, 122, 0.15));
  border: 1px solid rgba(120, 200, 255, 0.35);
  color: var(--shop-gold);
  font-size: 20px;
  flex-shrink: 0;
}

.shopTitle {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--shop-cyan);
  text-transform: uppercase;
}

.shopTagline {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--shop-muted-2);
  line-height: 1.35;
}

.shopHeaderActions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.shopBadge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(141, 255, 121, 0.12);
  border: 1px solid rgba(141, 255, 121, 0.35);
  color: var(--shop-green);
}

.adminLink {
  color: var(--shop-gold);
  text-decoration: none;
  font-size: 11px;
  font-weight: 800;
  border: 1px solid rgba(255, 193, 77, 0.45);
  background: rgba(255, 180, 60, 0.12);
  padding: 6px 10px;
  border-radius: 8px;
}

.adminLink:hover { color: #fff; border-color: rgba(255, 220, 140, 0.7); }

.shopCrossLink {
  color: var(--shop-cyan);
  background: rgba(110, 200, 255, 0.1);
  border: 1px solid rgba(110, 200, 255, 0.35);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.shopCrossLink:hover {
  color: #fff;
  border-color: rgba(110, 200, 255, 0.65);
}

/* Toolbar */
.shopToolbar {
  padding: 10px 14px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.topTabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tabBtn {
  background: rgba(50, 85, 110, 0.55);
  padding: 9px 18px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid rgba(127, 170, 209, 0.32);
  color: #d4ecff;
  font-size: 13px;
  font-weight: 700;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.tabBtn:hover { background: rgba(70, 115, 145, 0.7); }

.tabBtn.active {
  background: linear-gradient(180deg, var(--shop-cyan), var(--shop-cyan-dim));
  color: #042a3d;
  font-weight: 900;
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 4px 14px rgba(58, 159, 212, 0.35);
}

.tab-count {
  font-size: 10px;
  opacity: 0.8;
  font-weight: 600;
}

.shopFilters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
}

.searchInput {
  flex: 1;
  min-width: 180px;
  max-width: 280px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--shop-border);
  background: rgba(7, 19, 27, 0.85);
  color: #fff;
  font-size: 13px;
}

.searchInput:focus {
  outline: none;
  border-color: var(--shop-cyan);
  box-shadow: 0 0 0 2px rgba(110, 200, 255, 0.2);
}

.filterChips { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(127, 170, 209, 0.28);
  background: rgba(20, 40, 58, 0.7);
  color: var(--shop-muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.chip.active,
.chip:hover {
  border-color: rgba(110, 200, 255, 0.55);
  color: #fff;
  background: rgba(58, 159, 212, 0.22);
}

/* Content layout */
.shopContent {
  display: flex;
  flex: 1;
  min-height: 0;
  padding: 0 14px 14px;
  gap: 12px;
}

.itemSide {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.itemPageContainer {
  flex: 1;
  overflow: auto;
  border-radius: 12px;
  border: 1px solid rgba(95, 163, 206, 0.45);
  background: var(--shop-bg);
}

.itemPages { min-height: 100%; }

.itemPage {
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  align-content: start;
}

.itemPage.page-titles {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.itemPage.page-premium {
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.itemPage.page-premium .itemCard img {
  width: 80px;
  max-height: 80px;
  object-fit: contain;
}

.itemCard.is-premium {
  border-color: rgba(255, 210, 122, 0.35);
}

.itemCard.is-premium .itemMeta {
  color: var(--shop-gold);
}

.itemCard.is-gold {
  border-color: rgba(255, 210, 122, 0.5);
  background: linear-gradient(160deg, rgba(48, 38, 12, 0.45), rgba(12, 32, 48, 0.95));
}

.itemCard.is-gold .itemMeta,
.itemCard.is-gold .itemPrice {
  color: var(--shop-gold);
}

.gold-amount-badge {
  align-self: center;
  min-width: 72px;
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 900;
  font-size: 18px;
  color: #3d2a00;
  background: linear-gradient(180deg, #ffe566, #ffd27a);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 4px 14px rgba(255, 210, 122, 0.25);
}

/* Product cards */
.itemCard {
  background: var(--shop-card);
  border-radius: var(--radius);
  border: 1px solid var(--shop-border);
  padding: 14px 12px 12px;
  text-align: center;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.itemCard:hover {
  transform: translateY(-2px);
  border-color: rgba(110, 200, 255, 0.65);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.itemCard.is-custom {
  border-color: rgba(255, 210, 122, 0.45);
  background: linear-gradient(160deg, rgba(40, 35, 20, 0.5), rgba(12, 32, 48, 0.95));
}

.title-preview-chip {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  font-weight: 900;
  font-size: 14px;
  word-break: break-word;
}

.title-color-bar {
  height: 4px;
  border-radius: 4px;
  margin: 0 4px;
}

.itemName {
  font-weight: 900;
  color: #dff6ff;
  font-size: 13px;
  line-height: 1.25;
}

.itemDesc {
  font-size: 11px;
  color: #7a9bb5;
  line-height: 1.35;
  min-height: 2.7em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.itemMeta {
  font-size: 10px;
  color: var(--shop-muted-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.itemPrice {
  color: var(--shop-gold);
  font-weight: 900;
  font-size: 15px;
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
}

.itemPriceList {
  color: rgba(180, 190, 210, 0.72);
  font-weight: 700;
  font-size: 12px;
  text-decoration: line-through;
}

.itemPriceSale {
  color: #7dff9a;
  font-weight: 900;
  font-size: 15px;
}

.itemDisc {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  background: linear-gradient(180deg, #ff8a3d, #c44512);
  color: #fff;
  font-weight: 900;
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.addBtn {
  margin-top: 4px;
  background: linear-gradient(180deg, var(--shop-cyan), var(--shop-cyan-dim));
  color: #012;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 900;
  font-size: 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  transition: filter 0.15s;
}

.addBtn:hover { filter: brightness(1.08); }

/* Cart */
.cartSide {
  width: 300px;
  flex-shrink: 0;
  align-self: stretch;
  background: linear-gradient(180deg, #122636, #081018);
  border: 1px solid rgba(95, 163, 206, 0.32);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

.cartHead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.cartTitle {
  font-weight: 900;
  font-size: 15px;
  color: var(--shop-muted);
}

.cartPilot {
  font-size: 12px;
  color: var(--shop-gold);
  font-weight: 700;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cartHint {
  font-size: 10px;
  color: #6a8aa3;
  line-height: 1.4;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(95, 163, 206, 0.18);
  flex-shrink: 0;
}

.cartList {
  flex: 1 1 auto;
  overflow: auto;
  font-size: 12px;
  min-height: 0;
}

.cartList:not(:empty) + .cartEmpty { display: none; }

.cartEmpty {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #6a8aa3;
  font-size: 12px;
  padding: 20px 8px;
}

.cartItem {
  padding: 10px 0;
  border-bottom: 1px solid rgba(95, 163, 206, 0.16);
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
}

.cartItemName {
  font-weight: 700;
  color: #dff6ff;
  line-height: 1.25;
}

.cartItemSub {
  font-size: 10px;
  color: #7a9bb5;
  margin-top: 2px;
}

.cartItemPrice {
  color: var(--shop-gold);
  font-weight: 800;
  white-space: nowrap;
}

.cartItem button {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 1px solid rgba(255, 100, 100, 0.35);
  background: rgba(255, 80, 80, 0.15);
  color: #ff8a8a;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.cartFooter {
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 4px;
}

.totalBar {
  margin: 12px 0 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(95, 163, 206, 0.22);
  display: flex;
  justify-content: space-between;
  font-weight: 900;
  color: var(--shop-green);
  font-size: 14px;
}

.checkoutBtn {
  width: 100%;
  background: linear-gradient(180deg, var(--shop-cyan), var(--shop-cyan-dim));
  color: #012;
  text-align: center;
  padding: 13px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 900;
  font-size: 13px;
  border: none;
  transition: filter 0.15s;
  flex-shrink: 0;
}

.checkoutBtn:hover { filter: brightness(1.06); }
.checkoutBtn:disabled { opacity: 0.45; cursor: not-allowed; }

.pageNav {
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin-top: 8px;
}

.pageBtn {
  cursor: pointer;
  color: var(--shop-muted);
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(95, 163, 206, 0.25);
  background: rgba(20, 40, 58, 0.6);
  font-size: 14px;
}

.pageBtn:hover { color: #fff; border-color: var(--shop-cyan); }

.shop-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: #9cafc4;
  padding: 48px 24px;
  line-height: 1.5;
}

/* My titles */
.my-titles-page {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  padding: 14px;
}

.my-title-card {
  background: var(--shop-card);
  border: 1px solid rgba(95, 163, 206, 0.4);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  position: relative;
}

.my-title-card.is-active {
  border-color: rgba(120, 255, 180, 0.75);
  box-shadow: 0 0 24px rgba(80, 255, 160, 0.18);
}

.my-title-swatch {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  margin: 0 auto 10px;
  border: 2px solid rgba(255, 255, 255, 0.35);
}

.my-title-name {
  font-weight: 900;
  font-size: 17px;
  margin: 8px 0 4px;
}

.my-title-meta {
  font-size: 11px;
  color: var(--shop-muted);
  margin-bottom: 12px;
}

.my-title-equip-btn {
  width: 100%;
  padding: 9px;
  border-radius: 8px;
  border: 1px solid rgba(120, 200, 255, 0.45);
  background: rgba(55, 182, 255, 0.22);
  color: #dff6ff;
  cursor: pointer;
  font-weight: 700;
}

.my-title-equip-btn:disabled { opacity: 0.55; cursor: default; }

.my-title-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  background: rgba(80, 255, 160, 0.18);
  color: var(--shop-green);
  padding: 3px 7px;
  border-radius: 6px;
}

/* Modals */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 8, 14, 0.78);
  z-index: 9998;
  display: none;
}

#overlay.is-visible { display: block; }

#instructions,
#titlePicker {
  display: none;
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  background: linear-gradient(165deg, #1a2f42, #0a1219);
  border: 1px solid rgba(120, 200, 255, 0.48);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 520px;
  width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  overflow: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

#titlePicker { z-index: 10000; max-width: 640px; }
#instructions.is-open,
#titlePicker.is-open { display: block; }

.modalClose,
.title-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(150, 220, 255, 0.35);
  background: rgba(70, 160, 220, 0.45);
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

#instructions h3,
.title-picker-heading {
  margin: 0 0 12px;
  color: var(--shop-cyan);
  font-size: 1.1rem;
}

.order-code {
  display: inline-block;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 6px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: var(--shop-gold);
}

.title-preview-hero {
  text-align: center;
  padding: 18px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.38);
  margin-bottom: 14px;
}

#titlePreviewText {
  font-size: 1.45rem;
  font-weight: 900;
  margin: 0;
  color: #ffd400;
}

#titlePreviewText.is-neon-glow {
  text-shadow: 0 0 8px currentColor, 0 0 20px currentColor;
}

.title-preview-label {
  display: block;
  margin-top: 8px;
  font-size: 10px;
  color: #7a9bb5;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.title-color-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}

.title-color-grid label span {
  display: block;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
}

.title-color-grid input { display: none; }

.title-color-grid input:checked + span {
  box-shadow: 0 0 0 2px var(--tm-ring), 0 0 0 4px #fff;
}

.title-input,
#titlePicker select {
  width: 100%;
  box-sizing: border-box;
  padding: 10px;
  background: #0d2b3c;
  color: #fff;
  border: 1px solid rgba(95, 163, 206, 0.45);
  border-radius: 10px;
  margin: 6px 0;
}

.title-btn-primary {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 0;
  font-weight: 900;
  cursor: pointer;
  background: linear-gradient(180deg, var(--shop-cyan), var(--shop-cyan-dim));
  color: #012;
  margin-top: 12px;
}

.title-card-title {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--shop-muted-2);
  margin: 0 0 6px;
  letter-spacing: 0.06em;
}

.title-hex-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--shop-muted);
  margin: 8px 0;
}

@media (max-width: 900px) {
  .shopWindow { height: auto; min-height: calc(100vh - 20px); }
  body.embed .shopWindow { height: 100%; min-height: 0; }
  .shopContent { flex-direction: column; min-height: 0; }
  .cartSide { width: 100%; max-height: min(320px, 42vh); }
  html, body { overflow: auto; }
  body.embed { overflow: hidden; }
}
