: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 left, rgba(167, 139, 250, 0.12), 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: 9px;
}

.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); }

.capacity-card {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.16), rgba(56, 189, 248, 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;
}
.capacity-label {
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}
.capacity-value {
  font-size: 26px;
  font-weight: 900;
  color: var(--violet);
  font-family: ui-monospace, monospace;
  margin-top: 4px;
  line-height: 1;
}
.capacity-sub {
  color: var(--text-dim);
  font-size: 11px;
  margin-top: 6px;
  line-height: 1.4;
}
.capacity-pill {
  border: 1px solid rgba(167, 139, 250, 0.4);
  color: var(--violet);
  background: rgba(167, 139, 250, 0.10);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 10px;
  font-weight: 800;
}

.slot-sections {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slot-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 10px 10px;
}
.slot-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 4px 8px;
  gap: 8px;
}
.slot-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.slot-section-icon { font-size: 18px; }
.slot-section-name {
  font-size: 13px;
  font-weight: 900;
  color: var(--text);
}
.slot-section-count {
  font-size: 11px;
  color: var(--text-dim);
  font-family: ui-monospace, monospace;
  font-weight: 700;
  margin-left: 4px;
}
.slot-section-count.full { color: var(--loss); }

.add-btn {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 9px;
  padding: 7px 12px;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}
.add-btn:active { transform: scale(0.97); }
.add-btn.cant {
  background: var(--bg-deep);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.bag-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.bag-row {
  display: grid;
  grid-template-columns: 32px 1fr auto auto;
  align-items: center;
  gap: 6px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 10px 8px 8px;
}
.bag-row.equipped {
  grid-template-columns: 32px 1fr auto;
  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);
}
.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;
  font-family: inherit;
}
.bag-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: rgba(255, 107, 53, 0.10);
  display: grid;
  place-items: center;
  font-size: 16px;
}
.bag-info { min-width: 0; }
.bag-lv {
  font-size: 14px;
  font-weight: 900;
  color: var(--accent);
  font-family: ui-monospace, monospace;
  line-height: 1;
}
.bag-meta {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 3px;
  font-family: ui-monospace, monospace;
}

.del-btn {
  background: var(--bg-card);
  color: var(--loss);
  border: 1px solid rgba(248, 113, 113, 0.4);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.del-btn:active { transform: scale(0.97); }

.equip-btn {
  background: var(--bg-card);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.equip-btn:active { transform: scale(0.97); }
.equip-btn.primary {
  color: var(--accent);
  border-color: rgba(255, 215, 0, 0.5);
  background: rgba(255, 215, 0, 0.06);
}

.bag-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 11px;
  padding: 10px;
  background: var(--bg-deep);
  border: 1px dashed var(--border);
  border-radius: 9px;
}

.transcend-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: 2px;
  font-family: ui-monospace, monospace;
}
.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); }

.bag-foot {
  text-align: center;
  color: var(--text-dim);
  font-size: 10px;
  opacity: 0.65;
  margin-top: 6px;
  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: 320px;
  background: var(--bg-card);
  border-radius: 18px;
  padding: 22px 20px;
  text-align: center;
  border: 1px solid var(--border);
}
.confirm-icon { font-size: 48px; }
.confirm-icon.danger { color: var(--loss); }
.confirm-title { font-size: 19px; 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-sub .warn { color: var(--loss); font-weight: 700; }

.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);
}
.close-btn.danger {
  background: var(--loss);
  color: white;
}
