:root {
  --bg: #0a0c10;
  --panel: #12151c;
  --panel-2: #191d26;
  --line: #242a35;
  --line-soft: #1c212a;
  --text: #eef2f6;
  --muted: #8b95a3;
  --faint: #59616f;
  --accent: #3b82f6;      /* electric blue */
  --accent-2: #22d3ee;    /* cyan */
  --good: #34d399;        /* unlocked = green */
  --bad: #ff5c5c;
  --r: 14px;
  --r-sm: 9px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Pretendard", "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  letter-spacing: -0.01em;
}

a { color: inherit; text-decoration: none; }

.wrap { max-width: 920px; margin: 0 auto; padding: 0 20px; }

/* ── Top bar ─────────────────────────────────────────── */
.nav { display: flex; align-items: center; height: 60px; }
.logo { font-weight: 800; font-size: 18px; letter-spacing: -0.02em; }
.logo b {
  background: linear-gradient(100deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.nav .back { margin-left: auto; color: var(--muted); font-size: 14px; }
.nav .back:hover { color: var(--text); }

/* ── Hero ────────────────────────────────────────────── */
.hero { padding: 46px 0 30px; }
.hero h1 {
  margin: 0;
  font-size: clamp(30px, 6vw, 46px);
  font-weight: 800; letter-spacing: -0.03em; line-height: 1.1;
}
.hero h1 .g {
  background: linear-gradient(100deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.hero p { margin: 14px 0 0; color: var(--muted); font-size: 16px; max-width: 560px; }
.title-row { display: flex; align-items: center; gap: 12px; }
.title-row h1 { margin: 0; }
.title-face {
  width: 46px; height: 46px; border-radius: 8px;
  object-fit: cover; border: 1px solid var(--line);
  flex-shrink: 0;
}
.hero .safe {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 18px; font-size: 13px; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 999px;
}
.hero .safe b { color: var(--text); font-weight: 600; }

/* ── Game grid ───────────────────────────────────────── */
.section-label {
  font-size: 12px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--faint); margin: 34px 0 14px;
}
.games {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.game {
  position: relative; display: block;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden;
  transition: transform .16s ease, border-color .16s ease;
}
.game:hover { transform: translateY(-3px); border-color: #38414f; }
.game .banner {
  width: 100%; aspect-ratio: 460 / 215; overflow: hidden;
  background: var(--panel-2);
}
.game .banner img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .25s ease;
}
.game:hover .banner img { transform: scale(1.04); }
.game .banner.placeholder {
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; font-weight: 800; color: var(--faint);
}
.game .game-body { padding: 14px 18px 18px; }
.game h3 { margin: 0 0 5px; font-size: 16px; font-weight: 700; }
.game p { margin: 0; color: var(--muted); font-size: 13px; }
.game.soon { pointer-events: none; opacity: .5; }
.games { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ── Panels ──────────────────────────────────────────── */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 22px; margin-bottom: 16px;
}
.panel > h2 { margin: 0 0 4px; font-size: 15px; font-weight: 700; }
.panel .step-num {
  display: inline-block; width: 22px; height: 22px; line-height: 22px;
  text-align: center; border-radius: 7px;
  background: rgba(59,130,246,.16); color: var(--accent-2);
  font-size: 12px; font-weight: 700; margin-right: 8px;
}

/* Steps */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.steps li { position: relative; padding: 0 0 14px 34px; color: var(--muted); font-size: 14px; }
.steps li:last-child { padding-bottom: 0; }
.steps li::before {
  counter-increment: s; content: counter(s);
  position: absolute; left: 0; top: 0;
  width: 22px; height: 22px; line-height: 22px; text-align: center;
  border-radius: 7px; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); font-size: 12px; font-weight: 700;
}
.steps li b, .steps b { color: var(--text); font-weight: 600; }

.path {
  display: block; font-family: "Consolas", ui-monospace, monospace;
  background: #06080b; border: 1px solid var(--line); border-radius: 7px;
  padding: 7px 10px; font-size: 12.5px; color: var(--accent-2);
  margin: 6px 0 2px; word-break: break-all;
}
code {
  font-family: "Consolas", ui-monospace, monospace;
  background: #06080b; border: 1px solid var(--line); border-radius: 5px;
  padding: 1px 6px; font-size: 12px; color: var(--accent-2);
}

/* Collapsible help */
details.help { margin-bottom: 16px; }
details.help > summary {
  list-style: none; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 15px 20px; font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
}
details.help > summary::-webkit-details-marker { display: none; }
details.help > summary .chev { margin-left: auto; color: var(--muted); transition: transform .18s; }
details.help[open] > summary { border-radius: var(--r) var(--r) 0 0; border-bottom: none; }
details.help[open] > summary .chev { transform: rotate(180deg); }
details.help .help-body {
  background: var(--panel); border: 1px solid var(--line); border-top: none;
  border-radius: 0 0 var(--r) var(--r); padding: 4px 22px 20px;
}
.note { margin: 14px 0 0; font-size: 12.5px; color: var(--faint);
  border-left: 2px solid var(--line); padding-left: 12px; }

/* ── Dropzone ────────────────────────────────────────── */
.dropzone {
  border: 1.5px dashed var(--line); border-radius: var(--r);
  padding: 32px 20px; text-align: center; cursor: pointer;
  transition: border-color .16s, background .16s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: rgba(59,130,246,.05); }
.dropzone .big { font-size: 15px; font-weight: 600; }
.dropzone .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.dropzone .em { font-size: 26px; display: block; margin-bottom: 10px; }
#fileInput { display: none; }
.file-status { margin-top: 12px; font-size: 13.5px; color: var(--muted); }
.file-status .ok { color: var(--good); }
.file-status .err { color: var(--bad); }
.file-status b { color: var(--text); }

/* ── Lunar coins ─────────────────────────────────────── */
.coins {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--r); padding: 14px 16px; margin-bottom: 16px;
}
.coins .cico {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
  background: radial-gradient(circle at 35% 30%, #3b4a63, #1b2230);
  border: 1px solid var(--line);
}
.coins .lbl { flex: 1; }
.coins .lbl strong { display: block; font-size: 14px; }
.coins .lbl span { font-size: 12px; color: var(--muted); }
.coins input[type="number"] {
  width: 110px; background: #06080b; border: 1px solid var(--line);
  border-radius: var(--r-sm); color: var(--text); padding: 9px 12px;
  font-size: 15px; font-weight: 700; text-align: right; outline: none;
}
.coins input[type="number"]:focus { border-color: var(--accent); }
.coins .max { font-size: 12px; }

/* ── Toolbar ─────────────────────────────────────────── */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar input[type="search"] {
  flex: 1; min-width: 170px; background: #06080b; border: 1px solid var(--line);
  border-radius: var(--r-sm); color: var(--text); padding: 9px 13px; font-size: 14px; outline: none;
}
.toolbar input[type="search"]:focus { border-color: var(--accent); }

/* Legend */
.legend { display: flex; gap: 16px; align-items: center; margin: 0 0 12px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot {
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
  background: transparent; border: 1.5px solid var(--faint);
}
.dot.on { background: var(--good); border-color: var(--good); box-shadow: 0 0 7px rgba(52,211,153,.55); }
.dot.sel { background: var(--accent-2); border-color: var(--accent-2); box-shadow: 0 0 7px rgba(34,211,238,.55); }
.dot.off { background: var(--bad); border-color: var(--bad); box-shadow: 0 0 7px rgba(255,92,92,.55); }

.btn {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 8px 14px; border-radius: var(--r-sm); font-size: 13px; cursor: pointer;
  transition: border-color .15s, background .15s; font-family: inherit;
}
.btn:hover { border-color: #38414f; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none; color: #05141f; font-weight: 700;
}
.btn.primary:disabled { opacity: .35; cursor: not-allowed; }
.chk {
  display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted);
  cursor: pointer; padding: 8px 13px; border: 1px solid var(--line); border-radius: var(--r-sm);
}
.chk input { accent-color: var(--accent); }

/* ── Categories ──────────────────────────────────────── */
.cat { margin-bottom: 8px; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.cat-head {
  display: flex; align-items: center; gap: 10px; padding: 13px 16px;
  background: var(--panel-2); cursor: pointer; user-select: none;
}
.cat-head h3 { margin: 0; font-size: 14.5px; font-weight: 600; flex: 1; }
.cat-head .count { font-size: 12px; color: var(--faint); }
.cat-head .count b { color: var(--good); font-weight: 700; }
.cat-head .chev { color: var(--muted); font-size: 11px; transition: transform .15s; }
.cat.collapsed .chev { transform: rotate(-90deg); }
.cat.collapsed .cat-body { display: none; }
.cat-actions { padding: 8px 14px; border-bottom: 1px solid var(--line-soft); background: var(--panel); }
.cat-actions .btn { padding: 4px 10px; font-size: 12px; }
.grid-items {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(218px, 1fr));
  gap: 1px; padding: 8px; background: var(--panel);
}
.item {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px;
  border-radius: 8px; font-size: 13.5px; cursor: pointer;
  border-left: 2px solid transparent;
}
.item:hover { background: var(--panel-2); }
.item > input { display: none; }               /* hide native checkbox; dot is the control */
.item .name { display: block; }
.item .id { display: block; font-size: 10.5px; color: var(--faint); font-family: ui-monospace, monospace; }
.item .req { display: block; font-size: 11px; color: var(--muted); line-height: 1.35;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.item .txt { flex: 1; min-width: 0; }

/* icon cell: real image if present, else rarity chip */
.ic { position: relative; display: inline-flex; width: 42px; height: 42px; flex-shrink: 0; }
.ic img { width: 42px; height: 42px; object-fit: contain; display: none; border-radius: 6px; }
.ic.has-img img { display: block; }
.ic.has-img .tier { display: none; }

.tier {
  width: 20px; height: 20px; border-radius: 6px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--tc, #667); border: 1px solid rgba(255,255,255,.15);
  box-shadow: 0 0 8px -2px var(--tc);
}
.ic .tier { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 8px; }

/* status via color — four states driven by owned class + checked state */

/* locked + not selected → stays locked (hollow dot) */
.item.locked { border-left-color: transparent; }

/* locked + selected → will unlock (cyan) */
.item.locked:has(> input:checked) { border-left-color: var(--accent-2); background: rgba(34,211,238,.07); }
.item.locked:has(> input:checked) .dot { background: var(--accent-2); border-color: var(--accent-2); box-shadow: 0 0 7px rgba(34,211,238,.55); }

/* unlocked + checked → stays unlocked (green) */
.item.unlocked:has(> input:checked) { border-left-color: var(--good); background: rgba(52,211,153,.06); }
.item.unlocked:has(> input:checked) .dot { background: var(--good); border-color: var(--good); box-shadow: 0 0 7px rgba(52,211,153,.55); }
.item.unlocked:has(> input:checked) .name { color: var(--muted); }

/* unlocked + unchecked → will be re-locked (red, struck through) */
.item.unlocked:not(:has(> input:checked)) { border-left-color: var(--bad); background: rgba(255,92,92,.07); }
.item.unlocked:not(:has(> input:checked)) .dot { background: var(--bad); border-color: var(--bad); box-shadow: 0 0 7px rgba(255,92,92,.55); }
.item.unlocked:not(:has(> input:checked)) .name { text-decoration: line-through; color: var(--muted); }

/* ── Apply bar ───────────────────────────────────────── */
.applybar {
  position: sticky; bottom: 0; z-index: 10; margin-top: 18px;
  background: rgba(10,12,16,.86); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
}
.applybar .inner { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 0; }
.applybar .summary { flex: 1; font-size: 14px; color: var(--muted); }
.applybar .summary b { color: var(--accent-2); }

.hidden { display: none !important; }
footer { text-align: center; color: var(--faint); font-size: 12.5px; padding: 34px 0; }

@media (max-width: 520px) {
  .hero { padding: 34px 0 22px; }
  .applybar .inner { padding: 12px 0; }
  .applybar .btn.primary { flex: 1; }
}
