:root {
  --bg: #0e1014;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e7e9ee;
  --muted: #8b93a3;
  --accent: #f5b73d;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 14px 20px;
  background: rgba(14,16,20,.9); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; }
.logo { font-size: 22px; font-weight: 700; letter-spacing: -.5px; }
.logo .accent { color: var(--accent); }
.tagline { font-size: 12px; color: var(--muted); }
.search {
  flex: 1; min-width: 220px; max-width: 720px; margin-left: 28px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 18px; font-size: 16px; outline: none;
}
.floor-grid { margin-top: 14px; }
.search:focus { border-color: var(--accent); }

/* layout: persistent filter sidebar + swappable content (ladder / catalog) */
.app { display: grid; grid-template-columns: 244px minmax(0, 1fr); align-items: start; }
.content { min-width: 0; }
.filters {
  position: sticky; top: var(--header-h, 64px); align-self: start;
  height: calc(100vh - var(--header-h, 64px)); overflow-y: auto;
  padding: 6px 14px 40px; border-right: 1px solid var(--line);
}
.filters-head { display: none; align-items: center; justify-content: space-between; padding: 10px 2px 4px; font-weight: 700; }
.filters-close { background: none; border: none; color: var(--muted); font-size: 26px; line-height: 1; cursor: pointer; }
.fsec { border-bottom: 1px solid var(--line); }
.fsec:last-child { border-bottom: none; }
.fsec-sum { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 11px 2px; font-size: 13px; font-weight: 600; color: var(--text); user-select: none; }
.fsec-sum::-webkit-details-marker { display: none; }
.fsec-title { flex: 1; }
.fsec-count { font-size: 11px; font-weight: 700; color: var(--muted); }
.fsec-count.on { color: var(--accent); }
.fsec-sum::after { content: "▸"; color: var(--muted); font-size: 10px; transition: transform .15s ease; }
.fsec[open] > .fsec-sum::after { transform: rotate(90deg); }
.fsec-body { padding: 2px 2px 12px; }
.fsec-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 2px 12px; }
.fchip {
  background: var(--panel); color: var(--muted);
  border: 1px solid var(--line); border-radius: 7px;
  padding: 5px 10px; font-size: 12.5px; line-height: 1.15; cursor: pointer; user-select: none;
}
.fchip:hover { color: var(--text); border-color: var(--muted); }
.fchip.on { background: var(--accent); border-color: var(--accent); color: #14171d; font-weight: 700; }
.fchip.block { display: block; width: 100%; text-align: left; margin-bottom: 4px; }
.fsec-search, .fsec-num {
  background: var(--panel); color: var(--text); width: 100%;
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; font-size: 13px; outline: none;
}
.fsec-search:focus, .fsec-num:focus { border-color: var(--accent); }
.fsec-list { max-height: 210px; overflow-y: auto; margin-top: 8px; }
.coll-wrap { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.coll-label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 6px; }
.coll-search { margin-bottom: 8px; }
.coll-hint { color: var(--muted); font-size: 12px; font-style: italic; padding: 2px; }
.fsec-range { display: flex; align-items: center; gap: 8px; padding: 2px 2px 12px; }
.fsec-num { -moz-appearance: textfield; }
.fsec-dash { color: var(--muted); }

/* toolbar above the grid */
.toolbar {
  position: sticky; top: var(--header-h, 64px); z-index: 4;
  display: flex; align-items: center; gap: 14px; padding: 12px 20px;
  background: rgba(14,16,20,.9); backdrop-filter: blur(8px);
}
.count { color: var(--muted); font-size: 13px; }
.clear-btn {
  margin-left: auto; background: none; border: 1px solid var(--line); color: var(--muted);
  border-radius: 7px; padding: 5px 12px; font-size: 12.5px; cursor: pointer;
}
.clear-btn:hover { color: var(--text); border-color: var(--muted); }
.filter-toggle {
  display: none; background: var(--panel); border: 1px solid var(--line); color: var(--text);
  border-radius: 7px; padding: 6px 12px; font-size: 13px; cursor: pointer;
}

/* view tabs */
.tabs { display: flex; gap: 4px; }
.tab { background: none; border: none; color: var(--muted); font-size: 15px; font-weight: 600; padding: 6px 13px; border-radius: 8px; cursor: pointer; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); background: var(--panel); }
.view[hidden] { display: none; }

/* the ladder (price guide) */
.ladder-intro { padding: 20px 20px 6px; }
.ladder-intro h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.ladder-intro p { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.ladder-intro .chain { color: var(--text); }
.tier { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.tier-head { position: relative; display: flex; align-items: baseline; gap: 14px; margin-bottom: 12px; width: max-content; max-width: 100%; }
.tier-name { font-size: 18px; font-weight: 800; }
.tier-unit { font-size: 11px; color: var(--accent); text-transform: uppercase; letter-spacing: .07em; margin-left: 8px; font-weight: 700; }
.tier-meta { color: var(--muted); font-size: 13px; }
.tier-val { color: var(--text); }
.tier-ratio {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 6; display: none;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; font-size: 13px; white-space: nowrap; box-shadow: 0 10px 26px rgba(0,0,0,.5);
}
.tier-ratio div { padding: 2px 0; }
.tier-head:hover .tier-ratio { display: block; }
.tier-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.tier-empty { color: var(--muted); font-size: 13px; padding: 2px 0 4px; }
.tier.floor .tier-name { color: var(--muted); }
.tier-floor-list { display: flex; flex-wrap: wrap; gap: 8px; }
.floor-item { background: var(--panel); border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 6px 12px; font-size: 12.5px; cursor: pointer; }
.floor-item:hover { color: var(--text); border-color: var(--muted); }

/* price guide head + table of contents */
.guide-head { padding: 20px 20px 8px; }
.guide-head h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }
.toc a {
  display: inline-flex; align-items: center; gap: 7px; text-decoration: none;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 6px 13px; font-size: 13px; font-weight: 600;
}
.toc a:hover { border-color: var(--accent); }
.toc a span { color: var(--muted); font-size: 11px; font-weight: 700; }
.guide-note { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.admin-flag { color: var(--accent); }
.tier[id] { scroll-margin-top: calc(var(--header-h, 64px) + 58px); }

/* admin controls */
.admin-btn { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 7px; padding: 5px 12px; font-size: 12.5px; cursor: pointer; }
.admin-btn:hover { color: var(--text); border-color: var(--muted); }
.admin-btn.on { color: var(--accent); border-color: var(--accent); }
.price.admin .level-pick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.price.admin .level-pick button { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 7px; padding: 7px 13px; font-size: 14px; font-weight: 700; cursor: pointer; }
.price.admin .level-pick button:hover { border-color: var(--muted); }
.price.admin .level-pick button.on { background: var(--accent); color: #14171d; border-color: var(--accent); }
.price.admin .level-pick button.untag { color: var(--muted); font-weight: 400; }
.price-hint { display: block; margin-top: 7px; color: var(--muted); font-size: 12px; }

.grid {
  display: grid; gap: 16px; padding: 0 20px 28px;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.card { position: relative; cursor: pointer; transition: transform .12s ease; }
.card:hover { transform: translateY(-4px); }

/* ---------- the full card face (scales via container units) ---------- */
.cardface {
  --frame: #3a4150;
  container-type: inline-size;
  position: relative; display: flex; flex-direction: column;
  aspect-ratio: 5 / 7; overflow: hidden;
  border-radius: 0.7cqw;
  background: linear-gradient(180deg, #1b1f27, #101319);
  box-shadow: 0 3cqw 7cqw rgba(0,0,0,.4);
}
.cf-art { position: relative; height: 57%; overflow: hidden; background: #0c0e12; }
.cf-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* cost (top) stacked over power (below), top-left corner */
.cf-corner {
  position: absolute; top: 2cqw; left: 2cqw;
  display: flex; flex-direction: column;
  border-radius: 1.2cqw; overflow: hidden;
  box-shadow: 0 1cqw 2cqw rgba(0,0,0,.45);
}
.cf-cost, .cf-pow {
  min-width: 11cqw; padding: 1.3cqw 2.2cqw;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 6.8cqw; line-height: 1; color: #fff;
}
.cf-cost { background: rgba(31,95,208,.95); }   /* energy cost */
.cf-pow  { background: rgba(192,52,26,.95); }    /* power */
.cf-body {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  gap: 1.4cqw; padding: 3cqw 3.6cqw 3.4cqw;
}
.cf-name {
  font-weight: 800; font-size: 9.5cqw; line-height: 1.02; letter-spacing: -.02em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cf-tags { display: flex; gap: 2.5cqw; align-items: baseline; margin-top: 1cqw; }
.cf-rar { font-size: 4cqw; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--frame); }
.cf-type { font-size: 3.8cqw; color: var(--muted); }
.cf-price {
  margin-top: auto; padding-top: 2cqw;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 6px;
}
.cf-price-val { font-size: 8.5cqw; font-weight: 800; letter-spacing: -.01em; color: var(--accent); line-height: 1; }
/* up / adjust / down vote control (fixed px so it also works in the modal) */
.vote { display: inline-flex; flex-direction: column; align-items: center; gap: 1px; line-height: 1; user-select: none; flex: 0 0 auto; }
.vote button { background: none; border: none; cursor: pointer; padding: 3px 12px; color: var(--muted); font-size: 20px; line-height: .7; border-radius: 8px; }
.vote button:hover { color: var(--text); background: var(--panel-2); }
.vote .v-up.on { color: #4ec77a; }
.vote .v-dn.on { color: #ef5470; }
.v-cap { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.price-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
/* ability now lives only in the detail modal */
.modal-ability { margin-top: 16px; color: #ccd2de; font-size: 14px; line-height: 1.45; }
.modal-ability strong { color: #fff; }
.modal-ability .trg {
  display: inline-block; vertical-align: baseline; font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .04em; padding: 1px 7px; margin: 0 5px 3px 0;
  border-radius: 5px; background: var(--accent); color: #14171d;
}
.modal-ability .cref { font-weight: 700; color: #fff; }

/* rarity frames */
.cardface.r-common     { --frame: #8b93a3; }
.cardface.r-rare       { --frame: #4a90d9; --glow: rgba(74,144,217,.18); }
.cardface.r-epic       { --frame: #a367e6; --glow: rgba(163,103,230,.20); }
.cardface.r-legendary  { --frame: #f5b73d; --glow: rgba(245,183,61,.22); }
.cardface.r-mythic     { --frame: #ef5470; --glow: rgba(239,84,112,.24); }
.cardface.r-fusion     { --frame: #3fc7a8; --glow: rgba(63,199,168,.20); }
.cardface[class*="limited"], .cardface[class*="limleg"] { --frame: #e7c66b; --glow: rgba(231,198,107,.22); }

.sentinel { height: 40px; }
.foot { padding: 24px 20px 40px; color: var(--muted); font-size: 12px; text-align: center; }

/* ---------- detail modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 20; display: none;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,.72); padding: 24px;
}
.modal.on { display: flex; }
.sheet {
  position: relative;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  max-width: 720px; width: 100%; max-height: 90vh; overflow: auto;
  display: grid; grid-template-columns: 300px 1fr; gap: 0; padding: 24px;
}
.facewrap { width: 300px; }
.sheet .info { padding: 4px 6px 6px 26px; }
.sheet h2 { margin: 0 0 14px; font-size: 24px; letter-spacing: -.02em; }
.price {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 18px;
}
.price-label { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.price-val { font-size: 20px; font-weight: 700; }
.price-val em { font-size: 13px; font-weight: 400; font-style: normal; color: var(--muted); }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 14px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.close {
  position: absolute; top: 12px; right: 16px;
  background: none; border: none; color: var(--muted);
  font-size: 28px; line-height: 1; cursor: pointer; z-index: 2;
}
.close:hover { color: var(--text); }
/* filters collapse to a slide-in drawer on narrow screens */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .filter-toggle { display: inline-block; }
  .filters {
    position: fixed; top: 0; left: 0; bottom: 0; height: 100vh;
    width: 284px; max-width: 86vw; z-index: 40;
    background: var(--bg); border-right: 1px solid var(--line);
    transform: translateX(-100%); transition: transform .22s ease;
  }
  body.filters-open .filters { transform: translateX(0); }
  .filters-head { display: flex; }
  body.filters-open::before {
    content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 39;
  }
}

@media (max-width: 600px) {
  .sheet { grid-template-columns: 1fr; justify-items: center; }
  .facewrap { width: min(70vw, 260px); }
  .sheet .info { padding: 18px 4px 4px; width: 100%; }
}
