:root {
  --bg: #0c0d12;
  --surface: #161821;
  --surface2: #1e2130;
  --border: rgba(255,255,255,0.07);
  --text: #f2f3f7;
  --text2: #9ba3b5;
  --text3: #6b7385;
  --primary: #e83a4f;
  --primary-soft: rgba(232,58,79,0.12);
  --success: #22c55e;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: 'Noto Sans SC', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  background: var(--bg);
}

/* Topbar */
.topbar {
  height: 52px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(12,13,18,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 20;
}

.topbar-left { display: flex; align-items: center; gap: 10px; }
.logo-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #e83a4f, #ff7a45);
}
.logo-name { font-weight: 700; font-size: 16px; letter-spacing: 0.3px; }
.topbar-right { display: flex; gap: 4px; }
.icon-btn {
  width: 40px; height: 40px;
  border: none; background: transparent;
  color: var(--text2); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:active { background: var(--surface); }

/* Search */
.search-panel {
  display: none;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 10px;
  align-items: center;
}
.search-panel.open { display: flex; }
.search-panel input {
  flex: 1;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 0 14px;
  font-size: 15px;
  outline: none;
}
.search-panel input:focus { border-color: var(--primary); }
#searchClose {
  border: none; background: none;
  color: var(--primary); font-size: 14px; font-weight: 500;
  padding: 0 4px;
}

/* Main */
.main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(64px + var(--safe-b));
}

.page { display: none; }
.page.active { display: block; }

/* Banner */
.banner {
  margin: 16px;
  padding: 28px 20px;
  border-radius: 18px;
  background: linear-gradient(145deg, #1a1520 0%, #12141c 60%, #0e1018 100%);
  border: 1px solid rgba(232,58,79,0.15);
  position: relative;
  overflow: hidden;
}
.banner::after {
  content: '';
  position: absolute;
  right: -30px; top: -30px;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232,58,79,0.25), transparent 70%);
}
.banner-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 12px;
}
.banner h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
  position: relative;
}
.banner p {
  font-size: 13px;
  color: var(--text2);
  position: relative;
}

/* Sections */
.section-block { padding: 8px 0 4px; }
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 10px;
}
.section-title h2 { font-size: 16px; font-weight: 600; }
.section-title .more {
  font-size: 13px;
  color: var(--text3);
}
.section-title .more:active { color: var(--primary); }

/* Game scroll */
.game-scroll {
  display: flex;
  gap: 12px;
  padding: 0 16px 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.game-scroll::-webkit-scrollbar { display: none; }
.game-item {
  flex: 0 0 72px;
  text-align: center;
}
.game-icon {
  width: 56px; height: 56px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin: 0 auto 6px;
}
.game-item:active .game-icon {
  border-color: rgba(232,58,79,0.4);
  background: var(--surface2);
}
.game-name {
  font-size: 11px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Products */
.product-list {
  padding: 0 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.product-card {
  display: flex;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: background 0.15s;
}
.product-card:active { background: var(--surface2); }
.p-cover {
  width: 88px;
  height: 88px;
  border-radius: 12px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  position: relative;
  overflow: hidden;
}
.p-cover .badge {
  position: absolute;
  top: 6px; left: 6px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
}
.p-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.p-game {
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 2px;
}
.p-title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 6px;
}
.p-bottom {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.p-price {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
}
.p-price span { font-size: 12px; font-weight: 500; }
.p-sales {
  font-size: 11px;
  color: var(--text3);
}

/* Filter tabs */
.filter-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}
.filter-tabs::-webkit-scrollbar { display: none; }
.ftab {
  flex-shrink: 0;
  height: 32px;
  padding: 0 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
}
.ftab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* User */
.user-guest {
  padding: 60px 24px;
  text-align: center;
}
.avatar-placeholder {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text3);
}
.user-guest p {
  color: var(--text2);
  margin-bottom: 24px;
  font-size: 14px;
}

.user-logged { padding: 16px; }
.user-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}
.avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e83a4f, #ff7a45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}
.uname { font-size: 16px; font-weight: 600; }
.uid { font-size: 12px; color: var(--text3); margin-top: 2px; }

.order-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.ostat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 8px;
  text-align: center;
}
.ostat-num { font-size: 20px; font-weight: 700; }
.ostat-label { font-size: 12px; color: var(--text3); margin-top: 2px; }

.order-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: relative;
}
.order-status {
  position: absolute;
  top: 14px; right: 14px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}
.order-status.success {
  color: var(--success);
  background: rgba(34,197,94,0.12);
}
.order-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
  padding-right: 60px;
}
.order-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 8px;
}
.order-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}
.order-desc {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.5;
  margin-bottom: 12px;
}

.btn-logout {
  width: 100%;
  margin-top: 24px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-size: 14px;
}
.btn-logout:active { background: var(--surface); }

/* Buttons */
.btn-main {
  height: 46px;
  padding: 0 28px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #e83a4f, #ff5c45);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(232,58,79,0.3);
}
.btn-main:active { opacity: 0.9; transform: scale(0.98); }
.btn-main.full { width: 100%; }

.btn-outline-sm {
  height: 34px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-size: 13px;
}
.btn-outline-sm:active { background: var(--surface2); }

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: calc(56px + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(12,13,18,0.95);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 30;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: none;
  color: var(--text3);
  font-size: 10px;
}
.nav-item.active { color: var(--primary); }
.nav-item svg { stroke: currentColor; }

/* Sheet (bottom modal) */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  visibility: hidden;
  pointer-events: none;
}
.sheet.open {
  visibility: visible;
  pointer-events: auto;
}
.sheet-mask {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  opacity: 0;
  transition: opacity 0.25s;
}
.sheet.open .sheet-mask { opacity: 1; }
.sheet-body {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 12px 20px calc(24px + var(--safe-b));
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 90vh;
  overflow-y: auto;
}
.sheet.open .sheet-body { transform: translateY(0); }
.sheet-handle {
  width: 36px; height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  margin: 0 auto 16px;
}
.sheet-body h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}
.sheet-sub {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 24px;
}

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  height: 46px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 0 14px;
  font-size: 15px;
  outline: none;
}
.field input:focus { border-color: var(--primary); }
.form-error {
  color: var(--primary);
  font-size: 13px;
  min-height: 20px;
  margin-bottom: 8px;
}

/* Order detail */
.order-detail { }
.od-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--success);
  background: rgba(34,197,94,0.12);
  padding: 3px 10px;
  border-radius: 4px;
  margin-bottom: 12px;
}
.order-detail h2 {
  font-size: 18px;
  margin-bottom: 8px;
}
.od-price {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 20px;
}
.od-info {
  background: var(--bg);
  border-radius: 12px;
  padding: 4px 0;
  margin-bottom: 16px;
}
.od-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  font-size: 13px;
}
.od-row span:first-child { color: var(--text3); }
.od-desc h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}
.od-desc p {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
  margin-bottom: 20px;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(80px + var(--safe-b));
  transform: translateX(-50%) translateY(20px);
  background: rgba(30,33,48,0.95);
  color: #fff;
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  z-index: 100;
  max-width: 90%;
  text-align: center;
  border: 1px solid var(--border);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Cover gradients by game */
.cover-ys { background: linear-gradient(145deg, #2a1f3d, #1a2438); }
.cover-wukong { background: linear-gradient(145deg, #3d2a1a, #2a1f14); }
.cover-wzry { background: linear-gradient(145deg, #1a2a3d, #14202e); }
.cover-yjwj { background: linear-gradient(145deg, #1f2a1a, #14201a); }
.cover-delta { background: linear-gradient(145deg, #2a1a1a, #1f1414); }
.cover-default { background: linear-gradient(145deg, #1e2130, #161821); }

/* 补充样式 */
.active-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 10px;
  font-size: 13px;
  color: var(--text2);
}
.active-filter span {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 500;
}
.active-filter button {
  border: none;
  background: none;
  color: var(--text3);
  font-size: 12px;
  padding: 4px 8px;
}

.empty-tip {
  text-align: center;
  color: var(--text3);
  padding: 48px 16px;
  font-size: 14px;
}

.ps-cover {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin-bottom: 16px;
}

.ps-meta {
  display: flex;
  gap: 12px;
  font-size: 13px;
  color: var(--text3);
  margin: 6px 0 12px;
}

.ps-price {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
}

.ps-tip {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.6;
  margin-bottom: 20px;
  padding: 12px;
  background: var(--bg);
  border-radius: 10px;
}

/* 客服加载 */
.cs-loading-body {
  text-align: center;
  padding-top: 40px;
  padding-bottom: 60px;
}

.cs-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 20px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.cs-loading-text {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

.cs-loading-sub {
  font-size: 13px;
  color: var(--text3);
}

.btn-outline-sm.full {
  width: 100%;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 商品真实图片 */
.p-cover.has-img {
  padding: 0;
  overflow: hidden;
}
.p-cover.has-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.p-cover .badge {
  z-index: 2;
}

.ps-cover.has-img {
  padding: 0;
  overflow: hidden;
  width: 100%;
  height: 160px;
  border-radius: 14px;
}
.ps-cover.has-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
