:root {
  color-scheme: dark;
  --bg: #090807;
  --panel: #15110e;
  --panel2: #201811;
  --line: #4b3825;
  --gold: #d9ad66;
  --text: #f3eadc;
  --muted: #a99d8c;
  font-family: Inter, Pretendard, "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 300px;
  min-height: 100vh;
  color: var(--text);
  font-weight: 700;
  background:
    radial-gradient(circle at 50% -10%, #4b28176e, transparent 35rem),
    linear-gradient(180deg, #0e0b09, var(--bg) 34rem);
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; font-weight: 700; }
button { color: inherit; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid #5a4127;
  background: #090807ef;
  backdrop-filter: blur(16px);
}
.topbar-inner, main { width: min(1440px, calc(100% - 28px)); margin: auto; }
.topbar-inner {
  min-height: 70px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
}
.brand { font-weight: 900; letter-spacing: -.03em; }
.brand small { display: block; color: var(--muted); font-size: 10px; letter-spacing: .14em; }
.home {
  justify-self: end;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: #d7c6ae;
}
.tabs {
  display: flex;
  padding: 4px;
  border: 1px solid #4b3928;
  border-radius: 10px;
  background: #100d0b;
}
.tab {
  min-width: 126px;
  padding: 9px 16px;
  border: 0;
  border-radius: 7px;
  color: #9e9183;
  background: transparent;
  cursor: pointer;
}
.tab:hover { color: #f2d7ae; }
.tab.active {
  color: #18100a;
  background: linear-gradient(135deg, #f3c77f, #b77a39);
  box-shadow: 0 4px 18px #0009;
}
main { padding: 42px 0 70px; }
.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: end;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}
.eyebrow { margin: 0 0 8px; color: var(--gold); font-size: 11px; font-weight: 900; letter-spacing: .2em; }
h1 { margin: 0; font-family: inherit; font-size: clamp(44px, 7vw, 78px); font-weight: 900; line-height: .95; letter-spacing: -.055em; }
.hero p, .market-intro p { max-width: 850px; margin: 16px 0 0; color: #c3b6a4; line-height: 1.75; }
.hero-stat {
  min-width: 190px;
  padding: 16px;
  border: 1px solid #79552f;
  background: linear-gradient(145deg, #271a10, #100d0a);
}
.hero-stat strong { display: block; color: #ffd38c; font-family: inherit; font-size: 36px; font-weight: 900; line-height: 1; }
.hero-stat span { color: var(--muted); font-size: 12px; }
.tab-panel { padding-top: 18px; }
.grade-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.grade {
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--c) 60%, #3b3024);
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 10%, #17130f), #0e0c0a);
}
.grade b { display: block; color: var(--c); }
.grade span { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.toolbar, .market-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(4, minmax(120px, auto));
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #15110ee8;
}
.market-toolbar { grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(140px, auto)); }
input, select {
  min-width: 0;
  padding: 10px;
  color: var(--text);
  border: 1px solid #594630;
  border-radius: 6px;
  background: #0b0a09;
  outline: none;
}
input:focus, select:focus { border-color: var(--gold); }
.catalog {
  display: grid;
  grid-template-columns: minmax(340px, .9fr) minmax(440px, 1.35fr);
  gap: 12px;
  margin-top: 12px;
  align-items: start;
}
.list-panel, .detail {
  border: 1px solid var(--line);
  background: #12100ee8;
  box-shadow: 0 20px 60px #0007;
}
.list-head {
  display: flex;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.list-head strong { color: var(--text); }
.item-list {
  display: grid;
  gap: 1px;
  max-height: 720px;
  overflow: auto;
  background: #2f251c;
}
.item-card {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 11px;
  width: 100%;
  min-width: 0;
  padding: 11px;
  color: var(--text);
  text-align: left;
  border: 0;
  border-left: 3px solid var(--item-color);
  background: #14110f;
  cursor: pointer;
}
.item-card:hover, .item-card.selected { background: #291d13; }
.item-card.selected { box-shadow: inset 0 0 0 1px var(--item-color); }
.item-art, .detail-art, .market-art {
  display: grid;
  place-items: center;
  border: 1px solid #4b3827;
  background:
    radial-gradient(circle, color-mix(in srgb, var(--item-color, #d9ad66) 15%, transparent), transparent 65%),
    #090807;
  image-rendering: pixelated;
}
.item-art { width: 78px; height: 78px; }
.item-art img { width: 72px; height: 72px; object-fit: contain; image-rendering: pixelated; }
.item-copy { min-width: 0; }
.item-kicker { display: block; color: var(--item-color); font-size: 11px; }
.item-copy strong { display: block; margin: 5px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-copy small { display: block; color: #887b6d; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.preview span { padding: 3px 5px; border: 1px solid #3e342a; color: #bdb0a0; font-size: 10px; }
.preview b { color: #70a6ff; }
.detail { position: sticky; top: 86px; min-height: 480px; }
.detail-top {
  display: grid;
  grid-template-columns: 146px 1fr;
  gap: 18px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, color-mix(in srgb, var(--item-color) 10%, #19130f), #0c0a09);
}
.detail-art { width: 140px; height: 140px; }
.detail-art img { width: 128px; height: 128px; object-fit: contain; image-rendering: pixelated; }
.rarity-name { color: var(--item-color); font-size: 12px; font-weight: 800; }
.detail h2 { margin: 8px 0; color: var(--item-color); font-family: inherit; font-size: clamp(22px, 3vw, 34px); font-weight: 900; line-height: 1.15; }
.detail-top p { color: var(--muted); line-height: 1.55; overflow-wrap: anywhere; }
code { color: #d9c7ad; font-size: 11px; }
.eligible { display: flex; flex-wrap: wrap; gap: 5px; }
.eligible span { padding: 3px 7px; border: 1px solid var(--badge); color: var(--badge); font-size: 10px; }
.facts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: #3a2c20;
  border-bottom: 1px solid var(--line);
}
.facts div { padding: 12px; background: #16120f; }
.facts span { display: block; color: var(--muted); font-size: 11px; }
.facts strong { display: block; margin-top: 5px; color: #f0c983; }
.detail-section, .set-effects { padding: 18px 20px 0; }
.detail-section h3, .set-effects h3 { margin: 0 0 10px; color: #e2c08a; font-size: 15px; }
.affix-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; padding: 0; list-style: none; }
.affix-list li { display: flex; justify-content: space-between; gap: 8px; padding: 8px; background: #0d0b0a; border: 1px solid #30271f; }
.affix-list span { color: #c8bcac; font-size: 12px; }
.affix-list b { color: #70a6ff; font-size: 12px; white-space: nowrap; }
.formula, .source-note { color: #968878; font-size: 12px; line-height: 1.65; }
.set-effects { margin: 16px 20px 0; padding: 14px; border: 1px solid #486d42; background: #111b10; }
.set-effects p { margin: 5px 0; color: #82d17f; font-size: 12px; }
.source-note { margin: 18px 20px 22px; padding-top: 14px; border-top: 1px solid #30271f; }
.empty { padding: 60px 20px; color: var(--muted); text-align: center; }
.rules {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  background: #12100e;
}
.rules h2 { margin: 0 0 10px; color: #e5c28d; font-size: 18px; }
.rules p { margin: 5px 0; color: #b8aa98; line-height: 1.65; }
.market-intro {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  padding: 20px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, #24170f, #100d0b);
}
.market-intro h2 { margin: 0; font-family: inherit; font-size: clamp(28px, 5vw, 48px); font-weight: 900; line-height: 1; }
.refresh {
  flex: 0 0 auto;
  padding: 10px 16px;
  border: 1px solid #9b6e3e;
  border-radius: 7px;
  color: #f6d9ac;
  background: #21160f;
  cursor: pointer;
}
.refresh:hover { background: #392315; }
.market-toolbar { margin-top: 12px; }
.market-status {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: #ad9d8a;
  font-size: 12px;
}
.market-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.market-card {
  --item-color: #d6d1c7;
  position: relative;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 14px;
  min-height: 156px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--item-color) 52%, #362b21);
  border-left: 4px solid var(--item-color);
  background: linear-gradient(145deg, color-mix(in srgb, var(--item-color) 7%, #17120f), #0d0b09);
  box-shadow: 0 16px 42px #0005;
}
.market-art { width: 108px; height: 108px; }
.market-art img { width: 96px; height: 96px; object-fit: contain; image-rendering: pixelated; }
.market-art .no-art { max-width: 82px; color: #7f7466; font-size: 11px; text-align: center; }
.market-copy { min-width: 0; }
.market-rarity { color: var(--item-color); font-size: 11px; font-weight: 900; letter-spacing: .08em; }
.market-card h3 {
  margin: 7px 0 8px;
  color: var(--item-color);
  font-family: inherit;
  font-size: 19px;
  font-weight: 900;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.market-meta { display: grid; gap: 4px; color: #a99b8b; font-size: 11px; }
.market-meta b { color: #d9c8af; font-weight: 800; }
.market-price { margin-top: 11px; color: #ffd078; font-family: inherit; font-size: 20px; font-weight: 900; line-height: 1; }
.market-empty, .market-error {
  grid-column: 1 / -1;
  padding: 70px 20px;
  border: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
  background: #12100e;
}
.market-error { color: #f09a82; }

@media (max-width: 1120px) {
  .market-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .topbar-inner { grid-template-columns: 1fr auto; padding: 9px 0; }
  .tabs { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; }
  .tab { flex: 1; min-width: 0; }
  .catalog { grid-template-columns: 1fr; }
  .detail { position: static; }
  .toolbar, .market-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar input, .market-toolbar input { grid-column: 1 / -1; }
}
@media (max-width: 680px) {
  .hero { grid-template-columns: 1fr; }
  .hero-stat { min-width: 0; }
  .grade-strip { display: flex; overflow-x: auto; }
  .grade { min-width: 154px; }
  .market-intro { display: grid; }
  .market-grid { grid-template-columns: 1fr; }
  .facts, .affix-list { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .topbar-inner, main { width: min(100% - 18px, 1440px); }
  .home { font-size: 12px; }
  .toolbar, .market-toolbar { grid-template-columns: 1fr; }
  .toolbar input, .market-toolbar input { grid-column: auto; }
  .item-card { grid-template-columns: 64px 1fr; }
  .item-art { width: 60px; height: 60px; }
  .item-art img { width: 54px; height: 54px; }
  .detail-top { grid-template-columns: 1fr; }
  .detail-art { width: 100%; }
  .facts { grid-template-columns: 1fr 1fr; }
  .market-card { grid-template-columns: 82px minmax(0, 1fr); }
  .market-art { width: 78px; height: 78px; }
  .market-art img { width: 70px; height: 70px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
