:root {
  --bg: #07080b;
  --bg-2: #0d0f14;
  --panel: rgba(255, 255, 255, 0.035);
  --panel-2: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #eef1f6;
  --muted: #8b93a3;
  --dim: #5c6372;
  --accent: #7cf7d4;
  --accent-2: #8ab4ff;
  --accent-ink: #04241c;
  --good: #7cf7d4;
  --bad: #ff8a8a;
  --radius: 18px;
  --radius-sm: 12px;
  --font: "Inter", system-ui, -apple-system, Segoe UI, sans-serif;
  --display: "Space Grotesk", var(--font);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
::selection { background: rgba(124, 247, 212, 0.25); }

/* ---------- Background ---------- */
.bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(600px 400px at 15% -5%, rgba(124, 247, 212, 0.10), transparent 70%),
    radial-gradient(700px 500px at 95% 10%, rgba(138, 180, 255, 0.10), transparent 70%),
    var(--bg);
}
.bg::after {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 65%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 65%);
  opacity: 0.5;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px max(16px, calc((100vw - 1120px) / 2));
  background: rgba(7, 8, 11, 0.72);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 600; letter-spacing: -0.01em; }
.brand-mark {
  width: 22px; height: 14px; border-radius: 4px;
  border: 1.5px solid var(--accent);
  box-shadow: 0 0 14px rgba(124, 247, 212, 0.45);
  position: relative;
}
.brand-mark::after { content: ""; position: absolute; left: 3px; top: 3px; width: 5px; height: 4px; border-radius: 1px; background: var(--accent); }
.nav { display: flex; gap: 4px; }
.nav a {
  padding: 7px 12px; border-radius: 999px; color: var(--muted); font-size: 14px; white-space: nowrap;
  transition: color .15s, background .15s;
}
.nav a:hover { color: var(--text); }
.nav a.active { color: var(--text); background: var(--panel-2); }

main { max-width: 1120px; margin: 0 auto; padding: 0 16px 80px; }

/* ---------- Typography ---------- */
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.025em; margin: 0; font-weight: 600; }
h1 { font-size: clamp(34px, 6vw, 60px); line-height: 1.02; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
.eyebrow { font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.grad {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------- Hero ---------- */
.hero { padding: 64px 0 32px; display: grid; gap: 18px; max-width: 760px; }
.hero p { font-size: 17px; color: var(--muted); margin: 0; max-width: 560px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--panel); cursor: pointer; font-weight: 500; font-size: 14px;
  transition: border-color .15s, background .15s, transform .15s;
}
.btn:hover { border-color: rgba(255,255,255,.28); background: var(--panel-2); }
.btn:active { transform: scale(.98); }
.btn.primary {
  background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600;
  box-shadow: 0 0 0 1px rgba(124,247,212,.3), 0 8px 30px -8px rgba(124,247,212,.55);
}
.btn.primary:hover { background: #a2fbe2; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.on { border-color: var(--accent); color: var(--accent); }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0 22px; }
.chip {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); cursor: pointer; font-size: 14px;
  transition: all .15s;
}
.chip:hover { color: var(--text); border-color: var(--line-2); }
.chip.active { color: var(--text); background: var(--panel-2); border-color: var(--line-2); }
.chip .count { color: var(--dim); margin-left: 6px; font-family: var(--mono); font-size: 12px; }

/* ---------- Card grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.tile {
  display: flex; flex-direction: column; gap: 16px;
  padding: 16px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line);
  transition: border-color .2s, transform .2s, background .2s;
}
.tile:hover { border-color: var(--line-2); background: var(--panel-2); transform: translateY(-2px); }
.tile-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.tile-name { font-family: var(--display); font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.tile-issuer { color: var(--muted); font-size: 13px; }
.fee { font-family: var(--mono); font-size: 13px; text-align: right; white-space: nowrap; }
.fee small { display: block; color: var(--dim); font-family: var(--font); font-size: 11px; }
.tile-best { font-size: 14px; color: var(--muted); margin: 0; }
.rates { display: flex; flex-wrap: wrap; gap: 6px; }
.rate {
  font-size: 12px; padding: 4px 9px; border-radius: 999px;
  background: rgba(255,255,255,.04); border: 1px solid var(--line); color: var(--muted);
}
.rate b { color: var(--text); font-family: var(--mono); font-weight: 500; margin-right: 4px; }
.tile-actions { display: flex; gap: 8px; margin-top: auto; }
.tile-actions .btn { flex: 1; }

/* ---------- Card art ---------- */
.art {
  --c1: #333; --c2: #111;
  position: relative; width: 100%; aspect-ratio: 1.586; border-radius: 14px; overflow: hidden;
  background: linear-gradient(135deg, var(--c1), var(--c2));
  box-shadow: 0 1px 0 rgba(255,255,255,.12) inset, 0 20px 40px -18px rgba(0,0,0,.8);
  color: rgba(255,255,255,.92); padding: 7% 7.5%;
  display: flex; flex-direction: column; justify-content: space-between;
  isolation: isolate;
}
.art::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(255,255,255,.22), transparent 50%),
    linear-gradient(115deg, transparent 40%, rgba(255,255,255,.10) 50%, transparent 60%);
}
.art::after {
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: .18;
  background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.35) 0 1px, transparent 1px 9px);
  mask-image: linear-gradient(90deg, transparent 30%, #000);
  -webkit-mask-image: linear-gradient(90deg, transparent 30%, #000);
}
.art.light { color: rgba(10, 12, 16, .85); }
.art-top { display: flex; justify-content: space-between; align-items: flex-start; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; font-weight: 600; }
.chipset {
  width: 16%; aspect-ratio: 1.3; border-radius: 5px;
  background: linear-gradient(135deg, #f2d89a, #b08a3e);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.2);
}
.art-name { font-family: var(--display); font-size: clamp(14px, 2.4vw, 19px); font-weight: 600; letter-spacing: -0.01em; }
.art-bottom { display: flex; justify-content: space-between; align-items: flex-end; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; opacity: .85; }
.art-num { font-family: var(--mono); letter-spacing: .18em; font-size: 12px; opacity: .8; }

/* ---------- Detail page ---------- */
.back { display: inline-flex; gap: 6px; color: var(--muted); font-size: 14px; margin: 28px 0 8px; }
.back:hover { color: var(--text); }
.detail-hero { display: grid; grid-template-columns: minmax(0, 360px) 1fr; gap: 40px; align-items: center; padding: 16px 0 36px; }
.detail-hero .art { max-width: 360px; }
.detail-hero h1 { font-size: clamp(32px, 5vw, 48px); }
.detail-hero .issuer { color: var(--muted); margin-top: 4px; }
.take {
  margin: 18px 0 0; padding: 14px 16px; border-left: 2px solid var(--accent);
  background: rgba(124,247,212,.05); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 15px;
}
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; margin-top: 20px; }
.stat { background: var(--bg-2); padding: 12px 14px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-family: var(--mono); font-size: 18px; margin-top: 2px; }
.cta-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }

.section { margin-top: 18px; padding: 24px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.section-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.two > .section { margin-top: 0; }

.earn-list { display: grid; gap: 2px; }
.earn-row { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.earn-row:last-child { border-bottom: 0; }
.earn-row .r { font-family: var(--mono); color: var(--accent); white-space: nowrap; }
.earn-row .note { display: block; font-size: 12px; color: var(--dim); }

.list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.list li { position: relative; padding-left: 22px; }
.list li::before { content: ""; position: absolute; left: 2px; top: 9px; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); box-shadow: 0 0 10px rgba(124,247,212,.5); }
.list.cons li::before { background: var(--bad); box-shadow: none; border-radius: 50%; }

/* Offset section */
.credits { display: grid; gap: 8px; }
.credit {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start;
  padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.credit:hover { border-color: var(--line-2); }
.credit.on { border-color: rgba(124,247,212,.4); background: rgba(124,247,212,.04); }
.credit input { position: absolute; opacity: 0; pointer-events: none; }
.box { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--line-2); margin-top: 2px; display: grid; place-items: center; }
.credit.on .box { background: var(--accent); border-color: var(--accent); }
.credit.on .box::after { content: ""; width: 5px; height: 9px; border: solid var(--accent-ink); border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.credit .t { font-weight: 500; }
.credit .n { font-size: 13px; color: var(--muted); }
.credit .val { font-family: var(--mono); white-space: nowrap; }
.credit:focus-within { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.meter { margin-top: 18px; padding: 16px; border-radius: var(--radius-sm); background: var(--bg-2); border: 1px solid var(--line); }
.meter-bar { height: 8px; border-radius: 999px; background: rgba(255,255,255,.06); overflow: hidden; margin: 12px 0 8px; }
.meter-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width .3s; }
.meter-row { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; flex-wrap: wrap; }
.big { font-family: var(--mono); font-size: 26px; letter-spacing: -0.02em; }
.pos { color: var(--good); }
.neg { color: var(--bad); }

/* Spend form */
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg-2); }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 999px; cursor: pointer; color: var(--muted); font-size: 13px; }
.seg button.on { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.toggle input { appearance: none; -webkit-appearance: none; width: 34px; height: 20px; border-radius: 999px; background: rgba(255,255,255,.1); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { transform: translateX(14px); background: var(--accent-ink); }

.spend { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin: 16px 0 6px; }
.field { display: grid; gap: 6px; padding: 12px; border-radius: var(--radius-sm); background: var(--bg-2); border: 1px solid var(--line); transition: border-color .15s; }
.field:focus-within { border-color: var(--accent); }
.field label { font-size: 13px; font-weight: 500; }
.field small { color: var(--dim); font-size: 11px; line-height: 1.3; }
.money { display: flex; align-items: center; gap: 4px; font-family: var(--mono); }
.money span { color: var(--dim); }
.money input { width: 100%; background: transparent; border: 0; outline: 0; font-family: var(--mono); font-size: 18px; padding: 0; }
.money em { font-style: normal; color: var(--dim); font-size: 12px; }
.total-line { font-size: 13px; color: var(--muted); margin-top: 8px; }

/* Results */
.results-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; margin-top: 18px; }
.results-summary .stat .v { font-size: 20px; }
.table-wrap { overflow-x: auto; margin-top: 14px; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
td.num { font-family: var(--mono); }
tfoot td { font-weight: 600; border-bottom: 0; }

/* Compare */
.picker { display: flex; flex-wrap: wrap; gap: 6px; }
.picker .chip.active { border-color: var(--accent); color: var(--accent); background: rgba(124,247,212,.06); }
.picker .chip:disabled { opacity: .5; cursor: not-allowed; }
.cmp-cards { display: grid; gap: 14px; margin-top: 18px; }
.cmp-cards .art { max-width: 220px; }
.cmp-head { display: grid; gap: 10px; }
.cmp th { vertical-align: bottom; }
.cmp td, .cmp th { text-align: left; white-space: normal; min-width: 150px; }
.cmp td:first-child, .cmp th:first-child { min-width: 120px; color: var(--muted); font-size: 13px; position: sticky; left: 0; background: var(--bg-2); z-index: 1; }
.cmp .win { color: var(--accent); }
.cmp .rate-cell b { font-family: var(--mono); font-weight: 500; }
.cmp .rate-cell span { display: block; color: var(--dim); font-size: 12px; font-family: var(--mono); }
.cmp .rate-cell.best b { color: var(--accent); }
.crown { display: inline-block; font-size: 11px; font-family: var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink); background: var(--accent); padding: 2px 8px; border-radius: 999px; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

/* Match ranking */
.rank { display: grid; gap: 8px; margin-top: 16px; }
.rank-row {
  display: grid; grid-template-columns: 28px 64px 1fr auto; gap: 14px; align-items: center;
  padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--bg-2);
  transition: border-color .15s;
}
.rank-row:hover { border-color: var(--line-2); }
.rank-row.top { border-color: rgba(124,247,212,.45); box-shadow: 0 0 30px -12px rgba(124,247,212,.4); }
.rank-row .pos-n { font-family: var(--mono); color: var(--dim); font-size: 13px; }
.rank-row .art { padding: 0; border-radius: 6px; box-shadow: none; }
.rank-row .art:not(.art-photo) > * { display: none; }
.rank-row .nm { font-weight: 500; }
.rank-row .sub { font-size: 12px; color: var(--muted); }
.rank-row .bar { height: 4px; border-radius: 999px; background: rgba(255,255,255,.06); margin-top: 6px; overflow: hidden; }
.rank-row .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: inherit; }
.rank-row .net { font-family: var(--mono); font-size: 18px; text-align: right; }
.rank-row .net small { display: block; font-family: var(--font); font-size: 11px; color: var(--dim); }

/* Compare tray */
.tray {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 30;
  display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px;
  border-radius: 999px; background: rgba(20, 23, 30, .85); border: 1px solid var(--line-2);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 20px 50px -20px rgba(0,0,0,.9); font-size: 14px; max-width: calc(100vw - 32px);
}
.tray[hidden] { display: none; }
.tray .clear { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 13px; }

.footer { max-width: 1120px; margin: 0 auto; padding: 32px 16px 100px; border-top: 1px solid var(--line); color: var(--dim); font-size: 12px; }
.footer p { margin: 0 0 8px; max-width: 760px; }
.footer strong { color: var(--muted); font-weight: 500; }

.fade { animation: fade .35s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .detail-hero { grid-template-columns: 1fr; gap: 24px; }
  .detail-hero .art { max-width: 320px; }
  .two { grid-template-columns: 1fr; }
  .results-summary { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  body { font-size: 14px; }
  .topbar { padding: 12px 16px; }
  .brand span:last-child { display: none; }
  .nav a { padding: 7px 10px; font-size: 13px; }
  .hero { padding: 40px 0 20px; }
  .section { padding: 18px 16px; }
  .grid { grid-template-columns: 1fr; }
  .spend { grid-template-columns: 1fr 1fr; }
  .stats { grid-template-columns: 1fr 1fr 1fr; }
  .stat .v { font-size: 16px; }
  .rank-row { grid-template-columns: 22px 44px 1fr auto; gap: 10px; padding: 10px; }
  .rank-row .net { font-size: 15px; }
}

/* Uploaded card photos */
.art.art-photo { padding: 0; background: #111; }
.art.art-photo::before, .art.art-photo::after { display: none; }
.art.art-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.loading { padding: 120px 0; text-align: center; color: var(--dim); font-family: var(--mono); font-size: 13px; letter-spacing: .1em; }
