:root {
  --bg: #0e1117;
  --bg2: #151a23;
  --card: #1a202b;
  --card2: #222a37;
  --line: #2c3544;
  --text: #e8ecf3;
  --muted: #8d98ab;
  --accent: #34d399;      /* Delta-Smaragd */
  --accent2: #10b981;
  --accent-ink: #052e22;
  --gold: #f5c84c;
  --red: #ef4444;
  --cm: #60a5fa;
  --tp: #f59e0b;
  --est: #9ca3af;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
  --radius: 14px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f5f8; --bg2: #ffffff; --card: #ffffff; --card2: #f0f3f7; --line: #dde3eb;
    --text: #141a24; --muted: #5f6b7d; --accent: #059669; --accent2: #047857; --accent-ink: #ffffff;
    --gold: #c99a10; --cm: #2563eb; --tp: #c2410c; --est: #6b7280;
    --shadow: 0 6px 20px rgba(20,30,50,.10);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  background-image: radial-gradient(1200px 500px at 80% -200px, rgba(52,211,153,.10), transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
.wrap { max-width: 1400px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
button, select, input { font: inherit; color: inherit; }

/* Header */
.top { position: sticky; top: 0; z-index: 20; backdrop-filter: blur(10px); background: color-mix(in srgb, var(--bg) 82%, transparent); border-bottom: 1px solid var(--line); }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand h1 { margin: 0; font-size: 20px; letter-spacing: .2px; }
.ball { width: 38px; height: 38px; border-radius: 50%; flex: none; border: 3px solid #111;
  background: linear-gradient(#ef4444 0 46%, #111 46% 54%, #fff 54%); position: relative; box-shadow: var(--shadow); }
.ball::after { content: ""; position: absolute; inset: 50% auto auto 50%; width: 12px; height: 12px; transform: translate(-50%,-50%); border-radius: 50%; background: #fff; border: 3px solid #111; }
.set-line { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.set-line select { background: transparent; border: 0; padding: 0; font-weight: 600; color: var(--accent); cursor: pointer; }
.set-line select option { background: var(--bg2); color: var(--text); }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 10px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); border: 1px solid transparent; font-weight: 600; font-size: 14px; }
.btn:hover { background: var(--accent2); }
.btn.ghost { background: var(--card); color: var(--text); border-color: var(--line); font-weight: 500; }
.btn.ghost:hover { background: var(--card2); }
.btn[disabled] { opacity: .6; cursor: progress; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin: 22px 0 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .lbl { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.stat .val { font-size: 26px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .val small { font-size: 14px; color: var(--muted); font-weight: 500; }
.stat .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.bar { height: 6px; background: var(--card2); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #5eead4); border-radius: 99px; transition: width .3s; }
.stat.highlight .val { color: var(--accent); }

/* Toolbar */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar input[type=search] { flex: 1 1 260px; min-width: 200px; }
.toolbar input, .toolbar select { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; outline: none; }
.toolbar input:focus, .toolbar select:focus { border-color: var(--accent); }
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 7px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--card2); color: var(--text); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0 6px; }
.chip { border: 1px solid var(--line); background: var(--card); padding: 4px 11px; border-radius: 99px; font-size: 13px; cursor: pointer; color: var(--muted); user-select: none; }
.chip b { color: var(--text); font-weight: 600; margin-right: 4px; }
.chip.on { border-color: var(--accent); color: var(--text); background: color-mix(in srgb, var(--accent) 16%, var(--card)); }
.result-info { font-size: 13px; margin: 8px 0 12px; }

/* Rarity badge */
.rb { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 6px; letter-spacing: .3px; background: var(--card2); color: var(--muted); border: 1px solid var(--line); }
.rb.R { color: #93c5fd; } .rb.RR { color: #c4b5fd; }
.rb.IR { color: #f9a8d4; } .rb.UR { color: #fde68a; } .rb.SIR { color: #fda4af; border-color: #fda4af55; }
.rb.MHR { color: #1a1200; background: linear-gradient(135deg, #fde68a, #f5c84c 50%, #fff3c4); border-color: transparent; }
@media (prefers-color-scheme: light) {
  .rb.R { color: #1d4ed8; } .rb.RR { color: #6d28d9; } .rb.IR { color: #be185d; } .rb.UR { color: #a16207; } .rb.SIR { color: #be123c; }
}

/* Grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; transition: transform .15s, border-color .15s; }
.tile:hover { transform: translateY(-2px); }
.tile.some { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.tile.all { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.tile .imgbox { position: relative; aspect-ratio: 245 / 342; background: var(--card2); cursor: zoom-in; overflow: hidden; }
.tile .imgbox img { width: 100%; height: 100%; object-fit: cover; display: block; transition: filter .2s, opacity .2s; }
.tile.none .imgbox img { filter: grayscale(.85) brightness(.75); opacity: .85; }
.tile .imgbox:hover img { filter: none; opacity: 1; }
.tile .no { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.7); color: #fff; font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 6px; font-variant-numeric: tabular-nums; }
.tile .check { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; font-size: 14px; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.tile .meta { padding: 10px 12px 4px; }
.tile .name { font-weight: 650; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .sub { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; margin-top: 3px; white-space: nowrap; overflow: hidden; }
.tile .sub .en { overflow: hidden; text-overflow: ellipsis; }
.variants { padding: 6px 8px 10px; display: flex; flex-direction: column; gap: 4px; margin-top: auto; }

.vrow { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 9px; cursor: pointer; user-select: none; border: 1px solid transparent; }
.vrow:hover { background: var(--card2); }
.vrow.on { background: color-mix(in srgb, var(--accent) 14%, transparent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.vrow .box { width: 18px; height: 18px; border-radius: 5px; border: 2px solid var(--muted); flex: none; display: grid; place-items: center; font-size: 12px; font-weight: 900; color: transparent; }
.vrow.on .box { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.vrow .vl { flex: 1; font-size: 13px; }
.vrow .pr { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; }
.dot.cardmarket { background: var(--cm); } .dot.tcgplayer { background: var(--tp); } .dot.estimate { background: var(--est); } .dot.manual { background: var(--gold); }
.vtag-reverse { background: linear-gradient(90deg, #93c5fd, #c4b5fd, #f9a8d4, #fde68a); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 600; }
.vtag-holo { color: #a5b4fc; font-weight: 600; }
@media (prefers-color-scheme: light) { .vtag-holo { color: #4f46e5; } .vtag-reverse { background: linear-gradient(90deg,#2563eb,#7c3aed,#db2777); -webkit-background-clip: text; background-clip: text; } }

/* List */
.list { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list th, .list td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; }
.list th { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); background: var(--bg2); }
.list .vrow .pr { display: none; }
.list tr:last-child td { border-bottom: 0; }
.list tr.on td { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.list td.num, .list th.num { text-align: right; font-variant-numeric: tabular-nums; }
.list img { width: 34px; height: 47px; object-fit: cover; border-radius: 3px; display: block; cursor: zoom-in; background: var(--card2); }
.list .vrow { padding: 4px 6px; display: inline-flex; }
.list .nm { font-weight: 600; } .list .en { color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.65); backdrop-filter: blur(3px); }
.modal-box { position: relative; background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; max-width: 860px; width: 100%; max-height: calc(100vh - 40px); overflow: auto; box-shadow: var(--shadow); }
.modal-x { position: absolute; top: 10px; right: 12px; border: 0; background: var(--card2); width: 34px; height: 34px; border-radius: 50%; font-size: 22px; line-height: 1; cursor: pointer; z-index: 2; }
.modal-body { display: grid; grid-template-columns: minmax(0, 330px) 1fr; gap: 24px; padding: 24px; }
.modal-body .big { width: 100%; border-radius: 14px; box-shadow: var(--shadow); display: block; background: var(--card2); aspect-ratio: 245/342; }
.modal-body h2 { margin: 0 0 2px; font-size: 24px; padding-right: 30px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14px; margin: 12px 0 16px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.mvar { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; background: var(--card); }
.mvar-head { display: flex; align-items: center; gap: 10px; }
.mvar-head .vrow { flex: 1; padding: 4px 6px; }
.mvar-head .big-price { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mvar-src { font-size: 12.5px; color: var(--muted); margin: 6px 0 0 6px; display: grid; gap: 2px; }
.mvar-src .row { display: flex; gap: 6px; align-items: center; }
.ovr { display: flex; align-items: center; gap: 8px; margin: 8px 0 0 6px; font-size: 13px; color: var(--muted); }
.ovr input { width: 100px; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; }
.links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.links a { text-decoration: none; }
.nav-btns { display: flex; gap: 8px; margin-top: 12px; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--card2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); z-index: 60; font-size: 14px; }
.foot { font-size: 12.5px; margin: 40px 0 30px; border-top: 1px solid var(--line); padding-top: 14px; }
.empty { text-align: center; padding: 60px 0; color: var(--muted); }

@media (max-width: 700px) {
  .wrap { padding: 0 12px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .modal-body { grid-template-columns: 1fr; padding: 16px; }
  .modal-body .big { max-width: 300px; margin: 0 auto; }
  .stat .val { font-size: 22px; }
}
