:root {
  --bg: #141517;
  --bg2: #1c1d21;
  --bg3: #26272c;
  --line: #2e2f35;
  --text: #f3f3f4;
  --muted: #9b9ca3;
  --accent: #ff4655;
  --gold: #ffd166;
  --radius: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
body.modal-open { overflow: hidden; }
a { color: inherit; }
img { display: block; }
button, input, select { font: inherit; }

/* header */
.top { display: flex; align-items: center; gap: 16px; padding: 12px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; background: rgba(20, 21, 23, 0.9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.logo { font-weight: 800; font-size: 21px; letter-spacing: -0.02em; text-decoration: none; color: #fff; white-space: nowrap; }
.logo span { color: var(--accent); }
.search { flex: 1; max-width: 460px; position: relative; }
.search::before { content: ""; position: absolute; left: 12px; top: 50%; width: 15px; height: 15px; transform: translateY(-50%); background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239b9ca3' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat center / contain; pointer-events: none; }
.search input { width: 100%; background: var(--bg3); border: 1px solid var(--line); color: #fff; padding: 9px 12px 9px 36px; border-radius: 9px; font-size: 14px; outline: none; }
.search input:focus { border-color: #5a5b63; }
.search input::-webkit-search-cancel-button { filter: invert(1); }
.updated { margin-left: auto; color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; }

/* game chips */
.chips { display: flex; gap: 8px; padding: 14px 24px 0; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { white-space: nowrap; padding: 7px 13px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 7px; transition: background 0.12s, border-color 0.12s; }
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c, #fff); flex: none; }
.chip:hover { border-color: #55565e; }
.chip.active { background: #fff; color: #111; border-color: #fff; }

/* layout */
main { flex: 1; width: 100%; max-width: 1400px; margin: 0 auto; padding: 18px 24px 60px; }
.loading, .empty, .error { color: var(--muted); padding: 40px 0; text-align: center; }
.error { color: #ff8a93; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 8px 0 14px; }
h1 { font-size: 30px; line-height: 1.1; margin: 0; font-weight: 800; letter-spacing: -0.025em; }
.sub { color: var(--muted); margin: 6px 0 0; font-size: 14px; }
.sub a { color: var(--text); }
.back { display: inline-block; color: var(--muted); text-decoration: none; font-size: 13px; margin-bottom: 10px; }
.back:hover { color: var(--text); }

.toggle { display: inline-flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; flex: none; }
.toggle a { padding: 7px 16px; border-radius: 6px; color: var(--muted); text-decoration: none; font-weight: 700; font-size: 13px; }
.toggle a.active { background: #fff; color: #111; }

.toolbar { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 0 0 16px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.toolbar .spacer { flex: 1; }
.grades { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.grades .lbl { color: var(--muted); font-size: 12px; margin-right: 4px; text-transform: uppercase; letter-spacing: 0.06em; }
.grades button { background: var(--bg2); border: 1px solid var(--line); color: var(--text); padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer; }
.grades button:hover:not(:disabled) { border-color: #55565e; }
.grades button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.grades button:disabled { opacity: 0.38; cursor: not-allowed; }
select, .set-filter { background: var(--bg2); border: 1px solid var(--line); color: var(--text); padding: 7px 10px; border-radius: 8px; font-size: 13px; max-width: 320px; }
.set-filter { min-width: 260px; }
.note { color: var(--muted); font-size: 12px; }

/* ranking */
.ranking { display: flex; flex-direction: column; gap: 6px; }
.row { display: grid; grid-template-columns: 40px 60px 1fr auto; align-items: center; gap: 14px; padding: 8px 14px 8px 8px; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); color: inherit; text-decoration: none; transition: border-color 0.12s, background 0.12s; }
.row:hover { border-color: #5a5b63; background: var(--bg3); }
.rank { color: var(--muted); font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; font-size: 14px; }
.row.r1 .rank { color: var(--gold); }
.row.r2 .rank { color: #d7d7dc; }
.row.r3 .rank { color: #d9a06b; }
.thumb { width: 60px; height: 84px; border-radius: 6px; background: #0e0f11; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.info { min-width: 0; }
.name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.info .sub { margin-top: 2px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--c, #fff); color: #111; margin-right: 6px; vertical-align: 1px; }
.price { font-weight: 800; font-size: 19px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.price .raw { font-size: 12px; color: var(--muted); font-weight: 500; }
.more { display: block; width: 100%; margin: 14px 0 0; padding: 12px; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); cursor: pointer; font-weight: 600; }
.more:hover { border-color: #5a5b63; }

/* sets */
.series { margin: 0 0 8px; }
.series h2 { font-size: 18px; margin: 26px 0 12px; display: flex; align-items: baseline; gap: 10px; }
.series h2 .count { color: var(--muted); font-size: 13px; font-weight: 500; }
.set-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.set-tile { text-decoration: none; color: inherit; display: block; }
.set-tile .thumb { width: 100%; height: auto; aspect-ratio: 16 / 10; border-radius: 10px; background: #0e0f11; border: 1px solid var(--line); transition: border-color 0.12s, transform 0.12s; }
.set-tile .thumb img { object-fit: cover; }
.set-tile:hover .thumb { border-color: #6a6b73; transform: translateY(-2px); }
.set-name { font-weight: 700; margin-top: 9px; font-size: 14px; }
.set-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.set-head { display: flex; gap: 18px; align-items: center; margin: 4px 0 14px; }
.set-thumb { width: 180px; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); flex: none; }

/* card modal */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.72); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal[hidden] { display: none; }
.card-detail { position: relative; background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; max-width: 920px; width: 100%; max-height: 92vh; overflow: auto; display: grid; grid-template-columns: minmax(220px, 360px) 1fr; gap: 24px; padding: 22px; }
.card-detail .close { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg3); color: #fff; font-size: 20px; cursor: pointer; line-height: 1; }
.card-img img { width: 100%; height: auto; border-radius: 10px; background: #0e0f11; }
.card-body h2 { margin: 4px 0 0; font-size: 26px; letter-spacing: -0.02em; line-height: 1.15; padding-right: 36px; }
.eyebrow { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--c, #fff); color: #111; }
.prices { width: 100%; border-collapse: collapse; margin: 16px 0 6px; font-size: 14px; }
.prices td { padding: 8px 6px; border-top: 1px solid var(--line); }
.prices tr:first-child td { border-top: 0; }
.prices .num { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.prices .muted { color: var(--muted); font-weight: 500; font-size: 12px; }
.prices tr.hl td { color: var(--accent); }
.links a { color: var(--text); font-size: 13px; margin-right: 12px; }
.card-body .note { margin-top: 12px; }

.foot { color: var(--muted); font-size: 12px; padding: 18px 24px; border-top: 1px solid var(--line); max-width: 1400px; margin: 0 auto; width: 100%; }
.foot a { color: var(--muted); }

@media (max-width: 720px) {
  .top { padding: 10px 14px; gap: 10px; }
  .updated { display: none; }
  .chips { padding: 12px 14px 0; }
  main { padding: 14px 14px 50px; }
  h1 { font-size: 24px; }
  .row { grid-template-columns: 28px 48px 1fr auto; gap: 10px; }
  .thumb { width: 48px; height: 67px; }
  .price { font-size: 16px; }
  .set-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .card-detail { grid-template-columns: 1fr; padding: 16px; }
  .set-head { flex-direction: column; align-items: flex-start; }
  .set-thumb { width: 100%; max-width: 320px; }
}
