/* ============================================================
   Silver Palace — Fan Database
   Design system shared with the "Sea Of Deceit" fan-site family
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Barlow:wght@500;600;700;800;900&family=Barlow+Condensed:wght@600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg-color: #080c14;
  --card-bg: #111826;
  --card-bg2: #161f30;
  --border-color: #232f45;
  --text-color: #e7ecf4;
  --text-muted: #8993a8;
  --gold: #d4a843;
  --gold-soft: rgba(212, 168, 67, 0.14);
  --accent-color: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.14);
  --danger: #e2574c;
  --radius: 12px;
  --radius-sm: 8px;

  /* Attribute (element) accent colors — matched to in-game icon art */
  --el-gravitas: #9b8cf2;
  --el-ignis: #ef6a4c;
  --el-glacies: #4fd3e6;
  --el-radiatio: #45c17a;
  --el-fulmen: #f0c14e;
  --el-alba: #7c8ce8;

  /* Rarity accent colors (character cards) */
  --rarity-5: #d4a843;
  --rarity-4: #9b8cf2;
  --rarity-3: #38bdf8;

  /* Identity accent colors */
  --id-hero: #e2574c;
  --id-witness: #38bdf8;
  --id-guardian: #4fae6a;
  --id-outlaw: #b06de0;
  --id-saviour: #d4a843;
  --id-victim: #8993a8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-color);
  color: var(--text-color);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(circle at 15% 0%, rgba(212, 168, 67, 0.06), transparent 45%),
    radial-gradient(circle at 85% 10%, rgba(56, 189, 248, 0.06), transparent 45%);
  background-attachment: fixed;
  min-height: 100vh;
}

a { color: var(--accent-color); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
  font-family: 'Barlow', sans-serif;
  font-weight: 800;
  letter-spacing: 0.01em;
  margin: 0;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-color); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 8px; }

:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

[x-cloak] { display: none !important; }

/* ---------- Layout shell ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar / icon rail */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: rgba(8, 12, 20, 0.9);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: width 0.2s ease;
}

.sidebar.collapsed { width: 72px; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 20px 8px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border-color);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  overflow: hidden;
  white-space: nowrap;
}

.brand-text strong {
  font-family: 'Barlow', sans-serif;
  font-weight: 800;
  font-size: 15px;
  color: var(--text-color);
}

.brand-text span {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}

.sidebar.collapsed .brand-text { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  border: 1px solid transparent;
  background: none;
}

.nav-item svg { flex-shrink: 0; width: 18px; height: 18px; }

.nav-item:hover {
  background: var(--card-bg2);
  color: var(--text-color);
}

.nav-item.active {
  background: var(--gold-soft);
  border-color: rgba(212, 168, 67, 0.35);
  color: var(--gold);
}

.sidebar.collapsed .nav-item span.label { display: none; }

.sidebar-toggle {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  border-radius: var(--radius-sm);
  background: none;
  border: 1px solid var(--border-color);
}
.sidebar-toggle:hover { color: var(--text-color); }

/* Main content */
.main {
  flex: 1;
  min-width: 0;
  padding: 28px 40px 60px;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.page-header h1 { font-size: 26px; }
.page-header p { color: var(--text-muted); margin: 4px 0 0; font-size: 14px; }

.count-pill {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--card-bg2);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 4px 12px;
}

/* ---------- Filter bar ---------- */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 22px;
  padding: 12px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
}

.filter-bar-columns {
  flex-direction: column;
  align-items: stretch;
}
.filter-bar-columns > .search-input {
  flex: none;
  align-self: stretch;
  width: 100%;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 0;
  border-top: 1px solid var(--border-color);
}
.filter-row:first-of-type { border-top: 1px solid var(--border-color); }

.filter-label {
  flex-shrink: 0;
  width: 76px;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.filter-row .clear-btn { margin-left: auto; }

.search-input {
  background: var(--card-bg2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-color);
  padding: 8px 12px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  min-width: 180px;
  flex: 1 1 180px;
}
.search-input:focus { border-color: var(--accent-color); outline: none; }

.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--card-bg2);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.chip img { width: 14px; height: 14px; object-fit: contain; }
.chip:hover { color: var(--text-color); border-color: #34405a; }
.chip.active {
  background: var(--accent-soft);
  border-color: rgba(56, 189, 248, 0.4);
  color: var(--accent-color);
}

.clear-btn {
  font-size: 12.5px;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  cursor: pointer;
}
.clear-btn:hover { color: var(--danger); border-color: var(--danger); }

/* ---------- Sub tabs (slot / identity switches) ---------- */

.subtabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.subtab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.subtab img { width: 18px; height: 18px; object-fit: contain; }
.subtab:hover { color: var(--text-color); }
.subtab.active {
  background: var(--gold-soft);
  border-color: rgba(212, 168, 67, 0.4);
  color: var(--gold);
}

/* ---------- Grids & cards ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 16px;
}

.char-card {
  background: var(--card-bg);
  border: 3px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
  position: relative;
}
.char-card:hover {
  transform: translateY(-3px);
  border-color: rgba(212, 168, 67, 0.4);
}

.char-card .portrait-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  background: linear-gradient(160deg, var(--card-bg2), #0c1220);
  overflow: hidden;
}
.char-card .portrait-wrap img.portrait {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

/* Colored attribute icons: source PNGs are white silhouettes, tinted via CSS mask */
.attr-icon-mask {
  display: inline-block;
  flex-shrink: 0;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}

/* Rarity-tinted backgrounds */
.portrait-wrap.rarity-5 {
  background:
    radial-gradient(circle at 32% 18%, rgba(212, 168, 67, 0.5), transparent 62%),
    linear-gradient(160deg, var(--card-bg2), #0c1220);
}
.portrait-wrap.rarity-4 {
  background:
    radial-gradient(circle at 32% 18%, rgba(155, 140, 240, 0.42), transparent 62%),
    linear-gradient(160deg, var(--card-bg2), #0c1220);
}
.portrait-wrap.rarity-3 {
  background:
    radial-gradient(circle at 32% 18%, rgba(56, 189, 248, 0.32), transparent 62%),
    linear-gradient(160deg, var(--card-bg2), #0c1220);
}

.char-card.rarity-5 { border-color: rgba(212, 168, 67, 0.55); }
.char-card.rarity-4 { border-color: rgba(155, 140, 240, 0.5); }
.char-card.rarity-3 { border-color: rgba(56, 189, 248, 0.45); }
.char-card.rarity-5:hover { border-color: rgba(212, 168, 67, 0.85); }
.char-card.rarity-4:hover { border-color: rgba(155, 140, 240, 0.8); }
.char-card.rarity-3:hover { border-color: rgba(56, 189, 248, 0.75); }

.rarity-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  display: flex;
  gap: 1px;
  background: rgba(8, 12, 20, 0.72);
  border-radius: 999px;
  padding: 3px 6px;
}
.rarity-badge img { width: 11px; height: 11px; }

.attr-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(8, 12, 20, 0.72);
  border: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
}
.attr-badge img { width: 16px; height: 16px; object-fit: contain; }

.char-card .card-footer {
  padding: 9px 10px 11px;
}

.char-card .char-name {
  font-family: 'Barlow', sans-serif;
  font-weight: 800;
  font-size: 14.5px;
  color: var(--text-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
}
.tag-row img { width: 13px; height: 13px; object-fit: contain; opacity: 0.9; }
.tag-row span {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state strong { color: var(--text-color); display: block; margin-bottom: 4px; font-family:'Barlow',sans-serif; }

/* ---------- Item cards (case implements / motives) ---------- */

.item-list { display: flex; flex-direction: column; gap: 10px; }

.item-card {
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 12px 16px;
  cursor: pointer;
}
.item-card:hover { border-color: rgba(56,189,248,0.35); }

.item-icon {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--card-bg2);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
}
.item-icon img { width: 30px; height: 30px; object-fit: contain; }

.item-icon.motive-icon {
  width: 52px;
  height: 52px;
  padding: 0;
  overflow: hidden;
}
.item-icon.motive-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.item-main { flex: 1; min-width: 0; }
.item-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item-name { font-family: 'Barlow', sans-serif; font-weight: 800; font-size: 15px; }
.item-sub { color: var(--text-muted); font-size: 12.5px; margin-top: 3px; }
.item-effect { color: var(--text-muted); font-size: 12.5px; margin-top: 6px; line-height: 1.5; }
.item-stats-mini { display: flex; gap: 12px; flex-shrink: 0; }
.item-stats-mini .stat-mini { text-align: center; }
.item-stats-mini .stat-mini .v { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 14px; color: var(--text-color); }
.item-stats-mini .stat-mini .l { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

.rarity-inline { display: flex; gap: 1px; }
.rarity-inline img { width: 12px; height: 12px; }

.identity-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px 3px 6px;
  border-radius: 999px;
  background: var(--card-bg2);
  border: 1px solid var(--border-color);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}
.identity-pill img { width: 13px; height: 13px; }

/* ---------- Character detail page (full-width, two columns) ---------- */

.char-page-wrap {
  width: 100%;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  margin-bottom: 16px;
  cursor: pointer;
}
.back-btn svg { width: 16px; height: 16px; }
.back-btn:hover { color: var(--text-color); border-color: #34405a; }

.char-page-grid {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 20px;
  align-items: start;
}

.char-splash-col {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: linear-gradient(160deg, var(--card-bg2), #0c1220);
  min-height: 460px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.char-splash-col.rarity-5 {
  background: radial-gradient(circle at 40% 15%, rgba(212, 168, 67, 0.45), transparent 62%), linear-gradient(160deg, var(--card-bg2), #0c1220);
}
.char-splash-col.rarity-4 {
  background: radial-gradient(circle at 40% 15%, rgba(155, 140, 240, 0.4), transparent 62%), linear-gradient(160deg, var(--card-bg2), #0c1220);
}
.char-splash-col.rarity-3 {
  background: radial-gradient(circle at 40% 15%, rgba(56, 189, 248, 0.32), transparent 62%), linear-gradient(160deg, var(--card-bg2), #0c1220);
}

.char-splash-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.char-splash-fallback {
  width: 200px;
  height: 200px;
  border-radius: 14px;
  background: rgba(8, 12, 20, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.char-splash-fallback img { width: 100%; height: 100%; object-fit: contain; }

.char-splash-gender {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
}

.char-info-col { min-width: 0; }

.char-info-header { margin-bottom: 14px; }
.char-info-header h2 { font-size: 26px; color: var(--text-color); margin-bottom: 10px; }

.gender-toggle {
  display: flex;
  gap: 4px;
}
.gender-toggle button {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(8,12,20,0.55);
  color: var(--text-muted);
  cursor: pointer;
}
.gender-toggle button.active { background: var(--gold-soft); color: var(--gold); border-color: var(--gold); }

@media (max-width: 900px) {
  .char-page-grid { grid-template-columns: 1fr; }
  .char-splash-col { min-height: 320px; }
}

/* ---------- Stat roster comparison ---------- */

.build-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 8px;
}

.build-card { position: relative; }

.build-tag {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 10px;
  border-radius: 999px;
}
.build-tag-bis { background: var(--gold); color: #14100a; }
.build-tag-alt { background: var(--card-bg2); color: var(--text-muted); border: 1px solid var(--border-color); }

@media (max-width: 700px) {
  .build-pair { grid-template-columns: 1fr; }
}

.rank-section { margin-top: 20px; }

.rank-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.rank-row {
  display: grid;
  grid-template-columns: 130px 1fr 60px;
  align-items: center;
  gap: 10px;
}

.rank-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-color);
}
.rank-head img { width: 16px; height: 16px; object-fit: contain; }

.rank-badge {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--gold);
  background: var(--gold-soft);
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 2px;
}

.rank-bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--card-bg2);
  border: 1px solid var(--border-color);
  overflow: hidden;
}
.rank-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent-color);
  transition: width 0.3s ease;
}
.rank-bar-fill.rarity-5 { background: linear-gradient(90deg, #9c7a2c, var(--gold)); }
.rank-bar-fill.rarity-4 { background: linear-gradient(90deg, #6f5fc0, var(--el-gravitas)); }
.rank-bar-fill.rarity-3 { background: linear-gradient(90deg, #1c8fc0, var(--accent-color)); }

.rank-value {
  text-align: right;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text-color);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}
.stat-box {
  background: var(--card-bg2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 6px;
  text-align: center;
}
.stat-box img { width: 16px; height: 16px; margin-bottom: 4px; }
.stat-box .val { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 14px; }
.stat-box .lab { font-size: 9.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.badge-row { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }

.accordion { border-top: 1px solid var(--border-color); }
.accordion-item { border-bottom: 1px solid var(--border-color); }
.accordion-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 4px;
  font-family: 'Barlow', sans-serif;
  font-weight: 700;
  font-size: 14.5px;
}
.accordion-head .skill-name { color: var(--gold); font-weight: 600; font-size: 12.5px; margin-left: 8px; }
.accordion-panel {
  padding: 0 4px 16px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-line;
}

.persona-list { display: flex; flex-direction: column; gap: 10px; }
.persona-item {
  background: var(--card-bg2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.persona-item .p-name { font-weight: 700; font-size: 13px; color: var(--text-color); display: flex; gap: 8px; align-items: center; }
.persona-item .p-num {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--gold-soft); color: var(--gold);
  font-size: 10.5px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.persona-item .p-desc { font-size: 12.5px; color: var(--text-muted); margin-top: 5px; line-height: 1.5; }

.tba { color: var(--text-muted); font-style: italic; font-size: 13px; }

/* Case implement set piece list inside modal */
.set-piece-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.set-piece-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--card-bg2); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); padding: 8px 12px; font-size: 12.5px;
}

/* ---------- Case Implements: full set overview ---------- */

.ci-set-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(560px, 1fr));
  gap: 16px;
}

.ci-set-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px 18px 18px;
}

.ci-set-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.ci-piece-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.ci-piece {
  background: var(--card-bg2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  height: 100%;
}

.ci-piece-art {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: linear-gradient(160deg, #0f1524, #0a0f1a);
  margin-bottom: 8px;
}
.ci-piece-art img { width: 100%; height: 100%; object-fit: cover; }

.ci-piece-slot {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold);
  font-weight: 700;
}

.ci-piece-name {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-color);
  margin: 2px 0 8px;
  line-height: 1.3;
  min-height: 2.6em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ci-piece-stats {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
}

.ci-stat-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 50px;
  font-size: 10.5px;
  color: var(--text-muted);
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  text-align: left;
}
.ci-stat-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex-shrink: 0;
}
.ci-stat-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.ci-stat-name {
  line-height: 1.2;
}
.ci-stat-chip .gold-num { font-size: 12.5px; }

.ci-set-effect {
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}
.ci-set-effect-label {
  display: block;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  margin-bottom: 5px;
}

@media (max-width: 880px) {
  .ci-set-grid { grid-template-columns: 1fr; }
  .ci-piece-row { grid-template-columns: repeat(2, 1fr); }
}

.motive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.motive-card {
  background: var(--card-bg);
  border: 3px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s ease;
}
.motive-card.rarity-5 { border-color: rgba(212, 168, 67, 0.55); }
.motive-card.rarity-4 { border-color: rgba(155, 140, 240, 0.5); }
.motive-card.rarity-3 { border-color: rgba(56, 189, 248, 0.45); }
.motive-card.rarity-5:hover { border-color: rgba(212, 168, 67, 0.85); }
.motive-card.rarity-4:hover { border-color: rgba(155, 140, 240, 0.8); }
.motive-card.rarity-3:hover { border-color: rgba(56, 189, 248, 0.75); }

.motive-art-wrap {
  position: relative;
  aspect-ratio: 16 / 10;
  background: linear-gradient(160deg, var(--card-bg2), #0c1220);
  overflow: hidden;
}
.motive-art-wrap.rarity-5 {
  background:
    radial-gradient(circle at 32% 18%, rgba(212, 168, 67, 0.5), transparent 62%),
    linear-gradient(160deg, var(--card-bg2), #0c1220);
}
.motive-art-wrap.rarity-4 {
  background:
    radial-gradient(circle at 32% 18%, rgba(155, 140, 240, 0.42), transparent 62%),
    linear-gradient(160deg, var(--card-bg2), #0c1220);
}
.motive-art-wrap.rarity-3 {
  background:
    radial-gradient(circle at 32% 18%, rgba(56, 189, 248, 0.32), transparent 62%),
    linear-gradient(160deg, var(--card-bg2), #0c1220);
}
.motive-art-wrap > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
}

.motive-body { padding: 12px 14px 14px; }
.motive-body .item-name { font-size: 15.5px; }
.motive-body .item-sub { color: var(--gold); font-weight: 600; margin-top: 2px; }
.motive-body .item-effect { margin-top: 6px; }

.motive-stats { justify-content: flex-start; gap: 20px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border-color); }

.gold-num { color: var(--gold); font-weight: 700; }

/* ---------- Footer / credits ---------- */

.credits-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 16px;
}
.credits-card h3 { font-size: 16px; margin-bottom: 10px; color: var(--gold); }
.credits-card p { color: var(--text-muted); font-size: 13.5px; line-height: 1.6; margin: 0 0 8px; }

.social-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.social-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13.5px;
  text-decoration: none;
  color: #fff;
  transition: filter 0.15s ease, transform 0.15s ease;
}
.social-btn:hover { filter: brightness(1.08); transform: translateY(-1px); text-decoration: none; }
.social-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

.kofi-btn { background: #ff5e5b; }
.discord-btn { background: #5865f2; }

.disclaimer {
  text-align: center;
  color: var(--text-muted);
  font-size: 11.5px;
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  line-height: 1.6;
}

/* ---------- Mobile ---------- */

.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(8,12,20,0.95);
  position: sticky;
  top: 0;
  z-index: 50;
}
.mobile-topbar .burger {
  background: none; border: 1px solid var(--border-color); border-radius: 8px;
  color: var(--text-color); width: 36px; height: 36px; display:flex; align-items:center; justify-content:center;
}

@media (max-width: 880px) {
  .sidebar {
    position: fixed;
    left: -240px;
    top: 0;
    height: 100vh;
    z-index: 60;
    width: 220px;
    transition: left 0.2s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
  }
  .sidebar.mobile-open { left: 0; }
  .sidebar.collapsed { width: 220px; }
  .mobile-topbar { display: flex; }
  .main { padding: 18px 16px 50px; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .char-splash-col { min-height: 260px; }
  .char-splash-fallback { width: 150px; height: 150px; }
  .rank-row { grid-template-columns: 90px 1fr 50px; gap: 6px; }
  .item-stats-mini { display: none; }
}

.mobile-scrim {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 55;
}
.mobile-scrim.show { display: block; }
