:root {
  --bg: #0f1419;
  --bg-card: #1a2332;
  --bg-deep: #0a0f15;
  --accent: #ffd700;
  --text: #e8edf2;
  --text-dim: #8b9bb0;
  --win: #4ade80;
  --neutral: #fbbf24;
  --loss: #f87171;
  --border: #2a3a52;
  --cyan: #38bdf8;
  --violet: #a78bfa;
  --primary: linear-gradient(135deg, #ff6b35, #f72585);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overscroll-behavior: none; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: radial-gradient(circle at top right, rgba(56, 189, 248, 0.14), transparent 22rem), var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow-x: hidden;
  user-select: none;
  touch-action: manipulation;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 10px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.page-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 2px 0 4px;
}
.page-title { text-align: center; font-size: 16px; font-weight: 900; }
.nav-btn {
  min-width: 58px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 11px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-btn:active { transform: scale(0.97); }

.balance-card {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.16), rgba(74, 222, 128, 0.06)), var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.balance-label {
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}
.balance-value {
  font-size: 26px;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
  margin-top: 4px;
  font-family: ui-monospace, monospace;
}
.balance-sub {
  color: var(--text-dim);
  font-size: 11px;
  margin-top: 6px;
}
.balance-pill {
  border: 1px solid rgba(56, 189, 248, 0.36);
  color: var(--cyan);
  background: rgba(56, 189, 248, 0.08);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 10px;
  font-weight: 800;
}

.bag-quick-link {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 11px 14px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
.bag-quick-link:active { transform: scale(0.99); }
.bag-quick-icon {
  font-size: 22px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}
.bag-quick-text {
  font-weight: 800;
  font-size: 14px;
  color: var(--text);
}
.bag-quick-count {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: var(--accent);
  font-weight: 900;
  letter-spacing: 0.4px;
}
.bag-quick-arrow {
  color: var(--text-dim);
  font-size: 18px;
  font-weight: 800;
}

/* 판매 등록 버튼 — bag-quick-link과 동일 패턴, accent 강조 */
.sell-quick-link {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.10), rgba(255, 107, 53, 0.04)), var(--bg-card);
  border: 1px solid rgba(255, 215, 0, 0.4);
  border-radius: 11px;
  padding: 11px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.sell-quick-link:active { transform: scale(0.99); }
.sell-quick-icon { font-size: 22px; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3)); }
.sell-quick-text { font-weight: 800; font-size: 14px; color: var(--text); }
.sell-quick-count {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: var(--accent);
  font-weight: 900;
  letter-spacing: 0.4px;
}
.sell-quick-arrow { color: var(--text-dim); font-size: 18px; font-weight: 800; }

/* 매물 섹션 타이틀 */
.listing-section-title {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 10px 2px 4px;
}
.listing-section-title.mine {
  color: var(--accent);
}

/* 내 매물 row — accent border + 옅은 황금 배경 */
.listing-row.mine {
  border-color: rgba(255, 215, 0, 0.42);
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.08), rgba(255, 107, 53, 0.03)), var(--bg-card);
}
.mine-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 215, 0, 0.18);
  border: 1px solid rgba(255, 215, 0, 0.5);
  color: var(--accent);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.3px;
  vertical-align: middle;
  font-family: inherit;
}
.buy-btn.ghost-btn {
  background: var(--bg-deep);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0 14px;
}

/* 판매 picker — 부위별 섹션 */
.sell-pick-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 12px 0 14px;
  max-height: 360px;
  overflow-y: auto;
}
.sell-pick-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sell-pick-section-title {
  font-size: 10px;
  font-weight: 900;
  color: var(--text-dim);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 0 2px;
}
.sell-pick-row.equipped {
  border-color: rgba(167, 139, 250, 0.5);
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.10), rgba(56, 189, 248, 0.04)), var(--bg-deep);
}
.sell-pick-row.listed {
  border-color: rgba(255, 215, 0, 0.55);
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.10), rgba(255, 215, 0, 0.02)), var(--bg-deep);
  cursor: default;
}
.sell-pick-row.listed:active { transform: none; }
.sell-pick-row.listed .unlist-btn {
  padding: 7px 12px;
  font-size: 11px;
  font-weight: 900;
  border-radius: 8px;
  white-space: nowrap;
}
.equipped-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(167, 139, 250, 0.20);
  border: 1px solid rgba(167, 139, 250, 0.55);
  color: #a78bfa;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.3px;
  vertical-align: middle;
}
.sell-pick-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.sell-pick-row:active { transform: scale(0.99); }
.sell-pick-icon { font-size: 22px; }
.sell-pick-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sell-pick-lv { font-size: 14px; font-weight: 900; color: var(--text); }
.sell-pick-expected { font-size: 11px; color: var(--text-dim); font-family: ui-monospace, monospace; }
.sell-pick-arrow { color: var(--text-dim); font-size: 18px; font-weight: 800; }

/* 판매 가격 입력 폼 */
.sell-price-input {
  width: 100%;
  margin: 8px 0 6px;
  padding: 10px 12px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--accent);
  font-family: ui-monospace, monospace;
  font-size: 18px;
  font-weight: 900;
  text-align: center;
}
.sell-price-input:focus { outline: 1px solid rgba(255, 215, 0, 0.5); border-color: rgba(255, 215, 0, 0.5); }
.sell-price-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.sell-price-meta b { font-family: ui-monospace, monospace; font-size: 13px; }
.sell-price-meta b.gold { color: var(--accent); }

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 2px 0;
  margin-top: 4px;
}
.section-title .sub { font-size: 10px; letter-spacing: 0; text-transform: none; opacity: 0.75; font-weight: 700; }

/* 부위 탭 (스크롤 가능 가로 리스트) */
.slot-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  scrollbar-width: none;
  padding: 0 2px 6px;
  margin: 0 -2px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  cursor: grab;
  scroll-snap-type: x proximity;
}
.slot-tabs.dragging { cursor: grabbing; }
.slot-tabs::-webkit-scrollbar { display: none; }
.slot-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
  scroll-snap-align: start;
  touch-action: manipulation;
}
.slot-tab.active {
  border-color: #ff6b35;
  background: linear-gradient(135deg, rgba(255, 107, 53, 0.18), rgba(247, 37, 133, 0.06)), var(--bg-card);
  color: #ff6b35;
}
.slot-tab-icon { font-size: 14px; }

/* 매물 리스트 */
.listing-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.listing-row {
  display: grid;
  grid-template-columns: 44px 1fr auto auto;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px 12px 10px 10px;
}
.listing-row.disabled { opacity: 0.6; }
.listing-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-deep);
  display: grid;
  place-items: center;
  font-size: 20px;
}
.listing-info { min-width: 0; }
.listing-lv {
  font-size: 18px;
  font-weight: 900;
  color: var(--accent);
  font-family: ui-monospace, monospace;
  line-height: 1;
}
.listing-seller {
  font-size: 10px;
  color: var(--text-dim);
  font-family: ui-monospace, monospace;
  margin-top: 4px;
  letter-spacing: 0.4px;
}
.transcend-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 999px;
  letter-spacing: 0.3px;
  font-family: ui-monospace, monospace;
  margin-left: 6px;
  vertical-align: 2px;
}
.transcend-badge.t1 { color: var(--cyan);   background: rgba(56, 189, 248, 0.12); border: 1px solid rgba(56, 189, 248, 0.4); }
.transcend-badge.t2 { color: var(--violet); background: rgba(167, 139, 250, 0.12); border: 1px solid rgba(167, 139, 250, 0.4); }
.transcend-badge.t3 { color: var(--neutral); background: rgba(251, 191, 36, 0.12); border: 1px solid rgba(251, 191, 36, 0.4); }
.transcend-badge.t4 { color: #ff6b35; background: rgba(255, 107, 53, 0.12); border: 1px solid rgba(255, 107, 53, 0.4); }
.transcend-badge.t5 { color: var(--loss); background: rgba(248, 113, 113, 0.14); border: 1px solid rgba(248, 113, 113, 0.5); box-shadow: 0 0 8px rgba(248, 113, 133, 0.4); }
.listing-price {
  text-align: right;
  white-space: nowrap;
}
.listing-price .price-value {
  font-size: 14px;
  font-weight: 900;
  color: var(--text);
  font-family: ui-monospace, monospace;
}
.listing-price .price-unit {
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
  margin-top: 2px;
}
.buy-btn {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
  min-width: 64px;
}
.buy-btn:active { transform: scale(0.97); }
.buy-btn.cant {
  background: var(--bg-deep);
  color: var(--loss);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 11px;
}
.buy-btn.cant.lower { color: var(--text-dim); }
.buy-btn.cant.poor { color: var(--loss); }

.listing-empty {
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: 11px;
  padding: 18px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
}

.pager {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  padding: 4px 0;
}
.pager-btn {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-card);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}
.pager-btn:active { transform: scale(0.97); }
.pager-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  color: var(--text-dim);
}
.pager-info {
  font-size: 12px;
  color: var(--text-dim);
  font-family: ui-monospace, monospace;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-align: center;
  white-space: nowrap;
}

.market-foot {
  text-align: center;
  color: var(--text-dim);
  font-size: 10px;
  opacity: 0.65;
  margin-top: 8px;
  line-height: 1.5;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  animation: fadeIn 0.18s ease;
}
.overlay.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border-radius: 18px;
  padding: 22px 20px;
  text-align: center;
  border: 1px solid var(--border);
}
.confirm-icon { font-size: 48px; }
.confirm-title { font-size: 20px; font-weight: 800; margin: 14px 0 8px; }
.confirm-sub {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.55;
  margin-bottom: 18px;
}
.confirm-sub b { color: var(--text); font-weight: 800; }

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.close-btn {
  width: 100%;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 12px;
  padding: 13px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.close-btn:active { transform: scale(0.98); }
.close-btn.ghost {
  background: var(--bg-deep);
  color: var(--text);
  border: 1px solid var(--border);
}
