/* ---------- theme tokens ---------- */
:root, :root[data-theme="dark"] {
  --bg: #0b0f17; --bg2: #111827; --bg3: #1a2333; --bg4: #243044;
  --border: #283548; --text: #e5e7eb; --muted: #9aa5b8; --faint: #6b7688;
  --accent: #8b5cf6; --accent-soft: rgba(139, 92, 246, .18);
  --ok: #22c55e; --ok-soft: rgba(34, 197, 94, .15);
  --warn: #f59e0b; --warn-soft: rgba(245, 158, 11, .15);
  --danger: #ef4444; --danger-soft: rgba(239, 68, 68, .15);
  --gold: #fbbf24; --gold-soft: rgba(251, 191, 36, .14);
  --shadow: 0 8px 30px rgba(0,0,0,.35);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f6fb; --bg2: #ffffff; --bg3: #eef1f7; --bg4: #e3e8f2;
  --border: #d9dfeb; --text: #111827; --muted: #4b5563; --faint: #8a94a6;
  --accent: #6d4aff; --accent-soft: rgba(109, 74, 255, .12);
  --ok: #16a34a; --ok-soft: rgba(22, 163, 74, .12);
  --warn: #d97706; --warn-soft: rgba(217, 119, 6, .12);
  --danger: #dc2626; --danger-soft: rgba(220, 38, 38, .12);
  --gold: #ca8a04; --gold-soft: rgba(202, 138, 4, .14);
  --shadow: 0 8px 30px rgba(20, 30, 60, .10);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.35rem; } h3 { font-size: 1.1rem; }
p { margin: 0 0 .8rem; }
code { background: var(--bg3); padding: .1em .35em; border-radius: 4px; font-size: .92em; }
pre { background: var(--bg3); padding: .8rem; border-radius: 8px; overflow: auto; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 1rem; }
main.wrap { flex: 1; padding-top: 1.5rem; padding-bottom: 3rem; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: .85rem; }
.right { text-align: right; } .center { text-align: center; }
.row-flex { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }
.mt { margin-top: 1rem; } .mt2 { margin-top: 2rem; } .mb { margin-bottom: 1rem; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.topbar { background: var(--bg2); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; gap: 1.5rem; height: 58px; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; color: var(--text); font-size: 1.05rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 900; }
.brand-tag { font-size: .7rem; font-weight: 600; color: var(--gold); background: var(--gold-soft); border: 1px solid var(--gold); padding: .05rem .45rem; border-radius: 999px; letter-spacing: .02em; }
.nav { display: flex; gap: .25rem; flex: 1; }
.nav a { color: var(--muted); padding: .4rem .7rem; border-radius: 8px; font-weight: 500; }
.nav a:hover { color: var(--text); background: var(--bg3); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--bg3); }
.topbar-right { display: flex; align-items: center; gap: .5rem; }
@media (max-width: 720px) {
  .brand-tag { display: none; }
  .nav a { padding: .35rem .5rem; font-size: .9rem; }
  .topbar-inner { gap: .75rem; }
}

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; user-select: none;
  background: var(--bg3); color: var(--text); border: 1px solid var(--border);
  padding: .45rem .85rem; border-radius: 8px; font: inherit; font-weight: 500; line-height: 1.2;
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--bg4); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: .28rem .6rem; font-size: .84rem; border-radius: 6px; }
.btn.xs { padding: .15rem .45rem; font-size: .78rem; border-radius: 6px; }
.btn.icon { padding: .35rem .5rem; }
.btn.active { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=search], textarea, select {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  padding: .5rem .65rem; border-radius: 8px; font: inherit;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
label.field { display: block; margin-bottom: .8rem; }
label.field > span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .3rem; font-weight: 500; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .8rem; }
.check { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.toggle { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; font-size: .9rem; color: var(--muted); padding: .3rem .6rem; border-radius: 8px; border: 1px solid var(--border); background: var(--bg3); }
.toggle input { accent-color: var(--accent); }
.toggle.on { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }

/* ---------- cards & layout ---------- */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 1.1rem 1.2rem; }
.card + .card { margin-top: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.hero { padding: 2.5rem 1rem 2rem; text-align: center; }
.hero h1 { font-size: 2.4rem; margin-bottom: .4rem; }
.hero p { color: var(--muted); font-size: 1.05rem; max-width: 640px; margin: 0 auto 1.2rem; }
.stats { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; margin-bottom: 2rem; }
.stat { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: .6rem 1.1rem; min-width: 120px; }
.stat b { display: block; font-size: 1.3rem; }
.stat span { color: var(--muted); font-size: .82rem; }
.breadcrumb { color: var(--muted); font-size: .9rem; margin-bottom: .6rem; display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.breadcrumb a { color: var(--muted); }
.page-head { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.page-head h1 { display: flex; align-items: center; gap: .6rem; }
.page-head .actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }
.game-emoji { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; font-size: 1.5rem; background: var(--bg3); border: 1px solid var(--border); flex-shrink: 0; }
.game-emoji.lg { width: 56px; height: 56px; font-size: 1.9rem; }

/* game cards */
.game-card { display: flex; flex-direction: column; gap: .7rem; padding: 1.1rem; border-top: 3px solid var(--accent); color: var(--text); position: relative; }
.game-card:hover { text-decoration: none; border-color: var(--border); box-shadow: var(--shadow); transform: translateY(-2px); transition: all .15s; }
.game-card .title { font-weight: 700; font-size: 1.1rem; }
.game-card .meta { color: var(--muted); font-size: .85rem; }
.game-card .desc { color: var(--muted); font-size: .9rem; flex: 1; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* progress */
.bar { height: 8px; background: var(--bg4); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.bar.lg { height: 14px; }
.bar > i.done { background: var(--ok); }
.progress-line { display: flex; align-items: center; gap: .6rem; font-size: .85rem; color: var(--muted); }
.progress-line .bar { flex: 1; }
.pct { font-weight: 700; color: var(--text); min-width: 3.2em; text-align: right; }
.ring { --p: 0; width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--bg4) 0); }
.ring > div { width: 92px; height: 92px; border-radius: 50%; background: var(--bg2); display: grid; place-items: center; font-weight: 800; font-size: 1.4rem; }
.ring.done { background: conic-gradient(var(--ok) 100%, var(--ok) 0); }

/* hub */
.group-title { margin: 1.4rem 0 .6rem; color: var(--muted); text-transform: uppercase; font-size: .78rem; letter-spacing: .08em; font-weight: 700; }
.cl-card { display: grid; grid-template-columns: 1fr auto; gap: .3rem .8rem; padding: .9rem 1rem; color: var(--text); }
.cl-card:hover { text-decoration: none; border-color: var(--accent); }
.cl-card .name { font-weight: 600; }
.cl-card .count { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.cl-card .desc { grid-column: 1 / -1; color: var(--muted); font-size: .85rem; }
.cl-card .bar { grid-column: 1 / -1; margin-top: .3rem; }
.cl-card.complete { border-color: var(--ok); }
.hub-side .card { padding: .9rem 1rem; }
.hub-layout { display: grid; grid-template-columns: 1fr 300px; gap: 1.5rem; align-items: start; }
@media (max-width: 900px) { .hub-layout { grid-template-columns: 1fr; } }
.linklist a { display: block; padding: .4rem 0; border-bottom: 1px solid var(--border); color: var(--text); }
.linklist a:last-child { border-bottom: 0; }

/* ---------- checklist ---------- */
.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar .search { flex: 1; min-width: 200px; position: relative; }
.toolbar .search input { padding-left: 2rem; }
.toolbar .search::before { content: "⌕"; position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--faint); font-size: 1.1rem; }
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); min-width: 220px; padding: .35rem; z-index: 30; display: none; }
.menu.open .menu-list { display: block; }
.menu-list button { display: flex; width: 100%; text-align: left; background: none; border: 0; color: var(--text); padding: .5rem .7rem; border-radius: 6px; cursor: pointer; font: inherit; gap: .5rem; }
.menu-list button:hover { background: var(--bg3); }
.menu-list button.danger { color: var(--danger); }
.menu-list hr { border: 0; border-top: 1px solid var(--border); margin: .3rem 0; }

.section { margin-bottom: 1rem; border: 1px solid var(--border); border-radius: 12px; background: var(--bg2); overflow: hidden; }
.section-head { display: flex; align-items: center; gap: .7rem; padding: .7rem 1rem; cursor: pointer; user-select: none; background: var(--bg3); }
.section-head:hover { background: var(--bg4); }
.section-head .chev { transition: transform .15s; color: var(--muted); font-size: .8rem; }
.section.collapsed .chev { transform: rotate(-90deg); }
.section.collapsed .section-body { display: none; }
.section-head h3 { margin: 0; flex: 1; font-size: 1rem; }
.section-head .count { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.section-head .count.done { color: var(--ok); font-weight: 700; }
.section-head .mini-bar { width: 90px; }
.section-body { padding: 0; }
.item-head, .item {
  display: grid; align-items: start; gap: .6rem 1rem;
  grid-template-columns: 34px minmax(180px, 1.3fr) minmax(160px, 1.4fr) minmax(110px, .8fr) 88px;
  padding: .6rem 1rem;
}
.item-head { color: var(--faint); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--border); padding-top: .5rem; padding-bottom: .5rem; }
.item { border-bottom: 1px solid var(--border); }
.item:last-child { border-bottom: 0; }
.item:hover { background: var(--bg3); }
.item.checked { opacity: .55; }
.item.checked .name { text-decoration: line-through; text-decoration-color: var(--muted); }
.item input[type=checkbox] { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--ok); cursor: pointer; }
.item .name { font-weight: 600; cursor: pointer; }
.item .desc { color: var(--muted); font-size: .86rem; margin-top: .15rem; }
.item .loc, .item .ft { font-size: .9rem; color: var(--text); }
.item .ft { color: var(--muted); }
.item .col-label { display: none; }
.item .acts { display: flex; gap: .3rem; justify-content: flex-end; }
.item .thumb { width: 44px; height: 32px; object-fit: cover; border-radius: 5px; border: 1px solid var(--border); cursor: zoom-in; }
.item .note-box { grid-column: 2 / -1; }
.item .note-box textarea { min-height: 60px; font-size: .88rem; }
.item .note-text { grid-column: 2 / -1; font-size: .86rem; background: var(--gold-soft); border-left: 3px solid var(--gold); padding: .35rem .6rem; border-radius: 4px; white-space: pre-wrap; }
.badge { display: inline-block; font-size: .7rem; font-weight: 700; padding: .05rem .4rem; border-radius: 999px; vertical-align: middle; margin-left: .35rem; text-transform: uppercase; letter-spacing: .03em; }
.badge.missable { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); }
.badge.tag { background: var(--bg4); color: var(--muted); text-transform: none; font-weight: 500; }
.badge.admin { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent); }
.badge.status { text-transform: capitalize; }
.badge.status.open { background: var(--accent-soft); color: var(--accent); }
.badge.status.planned { background: var(--warn-soft); color: var(--warn); }
.badge.status.done { background: var(--ok-soft); color: var(--ok); }
.badge.status.declined { background: var(--bg4); color: var(--muted); }
.spoiler .desc, .spoiler .loc, .spoiler .ft { filter: blur(5px); transition: filter .15s; cursor: pointer; }
.spoiler .item:hover .desc, .spoiler .item:hover .loc, .spoiler .item:hover .ft, .spoiler .item.reveal .desc, .spoiler .item.reveal .loc, .spoiler .item.reveal .ft { filter: none; }
.compact .item { padding: .3rem 1rem; }
.compact .item .desc { display: none; }
.empty { padding: 2rem; text-align: center; color: var(--muted); }
.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.5rem; }
@media (max-width: 820px) {
  .item-head { display: none; }
  .item { grid-template-columns: 34px 1fr; }
  .item .loc, .item .ft { grid-column: 2; }
  .item .col-label { display: inline; color: var(--faint); font-size: .75rem; text-transform: uppercase; margin-right: .4rem; }
  .item .acts { grid-column: 2; justify-content: flex-start; }
  .item .note-box, .item .note-text { grid-column: 2; }
}

/* ---------- tables (leaderboard, editor) ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .55rem .7rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.table tr.me { background: var(--accent-soft); }
.table .rank { font-weight: 800; font-variant-numeric: tabular-nums; width: 3rem; }
.table .rank.top1 { color: var(--gold); } .table .rank.top2 { color: #c0c8d4; } .table .rank.top3 { color: #cd7f32; }
.table-wrap { overflow-x: auto; }

/* editor */
.ed-section { border: 1px solid var(--border); border-radius: 12px; margin-bottom: 1rem; background: var(--bg2); }
.ed-section-head { display: flex; gap: .6rem; align-items: center; padding: .7rem 1rem; background: var(--bg3); border-radius: 12px 12px 0 0; }
.ed-section-head input { max-width: 340px; }
.ed-items { padding: .5rem 1rem 1rem; }
.ed-item { display: grid; grid-template-columns: 24px 1.2fr 1.2fr .8fr 1.4fr .9fr 70px 96px; gap: .4rem; align-items: center; padding: .3rem 0; border-bottom: 1px dashed var(--border); }
.ed-item input { padding: .35rem .5rem; font-size: .88rem; }
.ed-item .idx { color: var(--faint); font-size: .8rem; text-align: right; }
.ed-item .ctl { display: flex; gap: .2rem; justify-content: flex-end; }
.ed-head { display: grid; grid-template-columns: 24px 1.2fr 1.2fr .8fr 1.4fr .9fr 70px 96px; gap: .4rem; color: var(--faint); font-size: .72rem; text-transform: uppercase; padding: .5rem 0 .2rem; }
@media (max-width: 1000px) {
  .ed-head { display: none; }
  .ed-item { grid-template-columns: 1fr 1fr; }
  .ed-item .idx { display: none; }
}
.sticky-save { position: sticky; bottom: 0; background: var(--bg2); border-top: 1px solid var(--border); padding: .8rem 0; margin-top: 1rem; display: flex; gap: .6rem; justify-content: flex-end; z-index: 5; }

/* markdown */
.md h1 { font-size: 1.7rem; margin-top: 1rem; } .md h2 { font-size: 1.3rem; margin-top: 1.4rem; } .md h3 { font-size: 1.1rem; margin-top: 1.2rem; }
.md ul, .md ol { padding-left: 1.4rem; } .md li { margin: .2rem 0; }
.md blockquote { border-left: 3px solid var(--accent); margin: .8rem 0; padding: .3rem .9rem; color: var(--muted); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
.md img { max-width: 100%; border-radius: 8px; }

/* perks */
.perk { display: flex; gap: .8rem; align-items: flex-start; padding: .8rem 0; border-bottom: 1px solid var(--border); }
.perk:last-child { border-bottom: 0; }
.perk .ic { font-size: 1.3rem; width: 32px; text-align: center; }
.perk b { display: block; }
.perk .muted { font-size: .9rem; }
.unlocked { color: var(--ok); font-weight: 700; font-size: .8rem; margin-left: auto; white-space: nowrap; }

/* proposals */
.proposal { display: grid; grid-template-columns: 64px 1fr; gap: 1rem; align-items: start; }
.vote { display: flex; flex-direction: column; align-items: center; gap: .1rem; background: var(--bg3); border: 1px solid var(--border); border-radius: 10px; padding: .4rem 0; cursor: pointer; color: var(--text); font: inherit; }
.vote:hover { border-color: var(--accent); }
.vote.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.vote b { font-size: 1.15rem; }

/* auth */
.auth { max-width: 420px; margin: 2rem auto; }
.auth h1 { text-align: center; }

/* toasts / modal */
.toasts { position: fixed; bottom: 1rem; right: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 100; }
.toast { background: var(--bg2); border: 1px solid var(--border); border-left: 4px solid var(--accent); padding: .6rem .9rem; border-radius: 8px; box-shadow: var(--shadow); max-width: 340px; animation: slidein .2s ease; }
.toast.ok { border-left-color: var(--ok); } .toast.err { border-left-color: var(--danger); } .toast.warn { border-left-color: var(--warn); }
@keyframes slidein { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 90; padding: 1rem; }
.modal { background: var(--bg2); border: 1px solid var(--border); border-radius: 14px; padding: 1.3rem; max-width: 520px; width: 100%; box-shadow: var(--shadow); }
.modal.img { max-width: min(92vw, 1000px); padding: .5rem; }
.modal.img img { max-width: 100%; max-height: 85vh; display: block; margin: 0 auto; border-radius: 8px; }
.modal .btns { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.footer { border-top: 1px solid var(--border); color: var(--faint); font-size: .82rem; padding: 1rem 0; }
.footer .wrap { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.kbd { font-family: ui-monospace, monospace; background: var(--bg3); border: 1px solid var(--border); border-bottom-width: 2px; padding: 0 .35em; border-radius: 4px; font-size: .8em; }
.loading { text-align: center; padding: 3rem; color: var(--muted); }
.notice { background: var(--warn-soft); border: 1px solid var(--warn); color: var(--text); padding: .6rem .9rem; border-radius: 8px; font-size: .9rem; }
.notice.info { background: var(--accent-soft); border-color: var(--accent); }
.user-chip { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; color: var(--text); }

/* per-item walkthrough panel */
.item .guide-box { grid-column: 2 / -1; background: var(--bg3); border-left: 3px solid var(--accent); border-radius: 6px; padding: .6rem 1rem; font-size: .9rem; max-height: 60vh; overflow: auto; }
.item .guide-box h1, .item .guide-box h2, .item .guide-box h3 { font-size: 1rem; margin: .6rem 0 .3rem; }
.item .guide-box p:last-child { margin-bottom: 0; }
.item .guide-box .attribution { color: var(--faint); font-size: .78rem; border-top: 1px solid var(--border); margin-top: .6rem; padding-top: .4rem; }
.ed-item .ed-guide { grid-column: 1 / -1; min-height: 140px; font-family: ui-monospace, monospace; font-size: .85rem; }
@media (max-width: 820px) { .item .guide-box { grid-column: 2; } }

/* keyboard focus, what's next, profile */
.item.kb { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.next-block { padding: .5rem 0; border-bottom: 1px solid var(--border); }
.next-block:last-child { border-bottom: 0; }
.next-block > .faint { display: block; text-transform: uppercase; letter-spacing: .05em; font-size: .72rem; margin-bottom: .2rem; }
.next-main { display: block; font-weight: 700; font-size: 1.05rem; color: var(--text); }
.miss-area { margin-top: .4rem; }
.miss-area ul { margin: .2rem 0 0; padding-left: 1.1rem; font-size: .88rem; }
.miss-area li { margin: .15rem 0; }
.ok-text { color: var(--ok); }
.item .guide-box .guide-img { float: right; max-width: 40%; max-height: 220px; margin: 0 0 .6rem 1rem; border-radius: 8px; border: 1px solid var(--border); cursor: zoom-in; }
.item .guide-box img:not(.guide-img) { display: block; max-width: min(100%, 640px); border-radius: 8px; margin: .5rem 0; border: 1px solid var(--border); }
.item .guide-box table { border-collapse: collapse; font-size: .86rem; margin: .4rem 0 .8rem; }
.item .guide-box td { padding: .15rem .6rem .15rem 0; vertical-align: top; }
.item .guide-box td:first-child { color: var(--muted); white-space: nowrap; }
@media (max-width: 820px) { .item .guide-box .guide-img { float: none; max-width: 100%; margin: 0 0 .6rem; } }
.md li.nested { margin-left: 1.2rem; list-style-type: circle; }
.md figure { margin: .6rem 0; }
.md figure img { display: block; max-width: min(100%, 640px); border-radius: 8px; border: 1px solid var(--border); }
.md figcaption { color: var(--muted); font-size: .8rem; margin-top: .25rem; }

/* header search, counters, search results, editor flags */
.hsearch { margin-left: auto; }
.hsearch input { width: 200px; padding: .35rem .6rem .35rem .6rem; border-radius: 999px; font-size: .88rem; background: var(--bg3); }
.hsearch input:focus { width: 260px; background: var(--bg); }
@media (max-width: 900px) { .hsearch input { width: 120px; } .hsearch input:focus { width: 160px; } }
.counter { display: inline-flex; align-items: center; gap: .35rem; margin-top: .3rem; }
.counter .cnt { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 3.2em; text-align: center; }
.counter .cnt.done { color: var(--ok); }
.item.sresult { border-bottom: 1px solid var(--border); }
.item.sresult .name { color: var(--text); }
.ed-flags { display: flex; align-items: center; gap: .3rem; }
.ed-flags input[type=number] { width: 58px; padding: .25rem .35rem; font-size: .8rem; }

/* ---------- interactive map ---------- */
.map-layout { display: grid; grid-template-columns: 260px 1fr; gap: 1rem; align-items: start; }
@media (max-width: 900px) { .map-layout { grid-template-columns: 1fr; } }
.map-side { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: .8rem .9rem; display: flex; flex-direction: column; gap: .5rem; max-height: calc(100vh - 160px); overflow: auto; }
.map-tabs { display: flex; flex-wrap: wrap; gap: .3rem; }
.cat-list { display: flex; flex-direction: column; gap: .1rem; }
.cat { display: flex; align-items: center; gap: .45rem; font-size: .85rem; color: var(--muted); padding: .15rem .3rem; border-radius: 6px; cursor: pointer; }
.cat.on { color: var(--text); }
.cat:hover { background: var(--bg3); }
.cat input { accent-color: var(--accent); }
.cat .ic { width: 1.3em; text-align: center; }
.cat .faint { margin-left: auto; font-size: .78rem; }
.map-view { position: relative; height: calc(100vh - 160px); min-height: 480px; overflow: hidden; background: #0a0d13; border: 1px solid var(--border); border-radius: 12px; cursor: grab; touch-action: none; user-select: none; }
.map-view:active { cursor: grabbing; }
.map-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; --inv: 1; }
.map-stage img { width: 100%; height: 100%; display: block; pointer-events: none; user-select: none; }
.mk { position: absolute; transform: translate(-50%, -50%) scale(var(--inv)); width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--faint); background: rgba(17, 24, 39, .92); color: #fff; display: grid; place-items: center; font-size: 13px; line-height: 1; padding: 0; cursor: pointer; transform-origin: center; }
.mk span { pointer-events: none; }
.mk.linked { border-color: var(--accent); }
.mk.miss { border-color: var(--danger); }
.mk.done { opacity: .4; filter: grayscale(1); }
.mk.sel { outline: 3px solid var(--gold); outline-offset: 1px; z-index: 5; }
.mk:hover { z-index: 6; border-color: var(--gold); }
.mk .lbl { display: none; position: absolute; left: 30px; top: 50%; transform: translateY(-50%); white-space: nowrap; font-style: normal; font-size: 12px; background: rgba(17, 24, 39, .9); padding: .1rem .4rem; border-radius: 4px; border: 1px solid var(--border); }
.map-stage.zoomed .mk .lbl { display: block; }
.map-controls { position: absolute; left: 12px; top: 12px; display: flex; flex-direction: column; gap: .3rem; z-index: 8; }
.map-controls .btn { width: 36px; justify-content: center; font-size: 1.1rem; }
.map-hint { position: absolute; left: 12px; bottom: 10px; background: rgba(17, 24, 39, .8); padding: .2rem .5rem; border-radius: 6px; z-index: 8; }
.mpop { position: absolute; right: 12px; top: 12px; width: 300px; max-width: calc(100% - 24px); z-index: 9; padding: .8rem .9rem; box-shadow: var(--shadow); }
:root[data-theme="light"] .map-view { background: #dfe4ee; }
:root[data-theme="light"] .mk { background: rgba(255, 255, 255, .95); color: #111; }
.mk img { width: 18px; height: 18px; object-fit: contain; pointer-events: none; }
.mk span { pointer-events: none; }
.cat img.ic { width: 18px; height: 18px; object-fit: contain; }
.mpop img.pic { width: 22px; height: 22px; object-fit: contain; }

/* map on small screens: filters become a collapsible panel, popup becomes a bottom sheet */
.map-side-toggle { display: none; }
@media (max-width: 900px) {
  .map-side-toggle { display: inline-flex; }
  .map-side { display: none; max-height: 45vh; }
  .map-side.open { display: flex; }
  .map-view { height: 70vh; min-height: 360px; }
  .mpop { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-width: none; max-height: 45vh; overflow: auto; }
  .map-controls .btn { width: 44px; height: 44px; }
  .mk { width: 32px; height: 32px; font-size: 16px; }
  .mk img { width: 22px; height: 22px; }
  .map-hint { display: none; }
}

/* ---------- small screens: header and page heads ---------- */
html, body { overflow-x: hidden; }
.nav-search-mobile { display: none; }
@media (max-width: 720px) {
  .topbar-inner { flex-wrap: wrap; height: auto; min-height: 52px; padding: .35rem 0; gap: .4rem .6rem; }
  .brand { font-size: .98rem; }
  .nav { order: 3; flex: 1 1 100%; justify-content: space-between; gap: 0; }
  .nav a { padding: .3rem .4rem; font-size: .88rem; }
  .nav-search-mobile { display: inline-block; }
  .hsearch { display: none; }
  .topbar-right { margin-left: auto; }
  .topbar-right .user-chip { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .page-head { gap: .6rem; }
  .page-head h1 { display: block; font-size: 1.35rem; line-height: 1.25; }
  .page-head h1 .muted { display: block; font-size: .95rem; }
  .game-emoji { width: 36px; height: 36px; font-size: 1.2rem; }
  .page-head .actions { margin-left: 0; flex: 1 1 100%; }
  .page-head .actions .btn { flex: 1 1 auto; justify-content: center; }
  main.wrap { padding-top: .8rem; }
  .hero h1 { font-size: 1.7rem; }
  .stat { min-width: 90px; padding: .4rem .7rem; }
}

/* ---------- per-game theme ---------- */
#game-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .75; filter: saturate(1.1) brightness(.8); overflow: hidden; }
#game-bg img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; }
#game-bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 40%, transparent) 0%, color-mix(in srgb, var(--bg) 66%, transparent) 45%, color-mix(in srgb, var(--bg) 90%, transparent) 100%); }
:root[data-theme="light"] #game-bg { opacity: .6; filter: saturate(1) brightness(1.05); }
body.themed > .topbar, body.themed > main, body.themed > .footer, body.themed > .toasts, body.themed > #modal-root { position: relative; z-index: 1; }
body.themed > .topbar { position: sticky; z-index: 20; }
body.themed .card, body.themed .section, body.themed .map-side, body.themed .cl-card { background: color-mix(in srgb, var(--bg2) 86%, transparent); backdrop-filter: blur(3px); }
body.themed .topbar { background: color-mix(in srgb, var(--bg2) 90%, transparent); backdrop-filter: blur(6px); }
body.themed .footer { background: color-mix(in srgb, var(--bg2) 80%, transparent); }
body.game-font .page-head h1, body.game-font .section-head h3, body.game-font .group-title, body.game-font .hero h1, body.game-font .card h2, body.game-font .card h3 { font-family: var(--game-font); letter-spacing: .01em; }
.badge.rarity { text-transform: none; font-weight: 700; }
.badge.rarity.common { background: var(--bg4); color: var(--muted); }
.badge.rarity.uncommon { background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok); }
.badge.rarity.rare { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent); }
.badge.rarity.ultra { background: var(--gold-soft); color: var(--gold); border: 1px solid var(--gold); }

/* ---------- restyle: typography, icons, monograms ---------- */
body { font-family: Manrope, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; letter-spacing: .005em; }
h1, h2, .brand, .hero h1, .card h2, .section-head h3, .page-head h1, .next-main { font-family: Fraunces, Georgia, "Times New Roman", serif; letter-spacing: -.01em; font-weight: 600; }
h1 { font-size: 2rem; } .hero h1 { font-size: 2.9rem; font-weight: 700; letter-spacing: -.02em; }
.group-title { font-family: Manrope, system-ui, sans-serif; letter-spacing: .12em; font-size: .72rem; color: var(--faint); }
.ico { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.15em; flex: none; }
.btn .ico { width: 1.05em; height: 1.05em; }
.btn.icon .ico { width: 1.15em; height: 1.15em; }
.nav-search-mobile .ico { width: 1.15em; height: 1.15em; vertical-align: -.2em; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; font-family: Fraunces, Georgia, serif; font-weight: 700; font-size: .78rem; letter-spacing: .02em; background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #000)); }
.game-emoji .mono { font-family: Fraunces, Georgia, serif; font-weight: 700; font-size: 1.15rem; color: var(--text); font-style: normal; }
.game-emoji.lg .mono { font-size: 1.5rem; }
.game-emoji.xs { width: 26px; height: 26px; border-radius: 7px; font-size: .95rem; display: inline-grid; vertical-align: middle; }
.game-emoji.xs .mono { font-size: .8rem; }
.game-emoji .ico { width: 1.2em; height: 1.2em; color: var(--muted); }
.game-emoji.lg .ico { width: 1.5em; height: 1.5em; }
.perk .ic { width: 22px; height: 22px; color: var(--accent); margin-top: .15rem; }
.table .rank .ico { width: 1.25em; height: 1.25em; vertical-align: -.25em; }
.item .acts .btn .ico, .item .acts .ico { width: 1.05em; height: 1.05em; }
.user-chip .ico { color: var(--muted); }
.unlocked .ico { color: var(--ok); }
.ok-text .ico { vertical-align: -.1em; }
.card { border-radius: 14px; }
.btn { font-weight: 600; letter-spacing: .005em; }
.badge { letter-spacing: .05em; }
.bar > i { background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #fff)); }
.bar > i.done { background: linear-gradient(90deg, var(--ok), color-mix(in srgb, var(--ok) 70%, #fff)); }
.topbar { background: linear-gradient(180deg, color-mix(in srgb, var(--bg2) 100%, transparent), color-mix(in srgb, var(--bg2) 96%, var(--accent))); }
.hero p { font-size: 1.1rem; max-width: 560px; }
.stat b { font-family: Fraunces, Georgia, serif; font-size: 1.5rem; }
.footer { letter-spacing: .01em; }

/* ---------- game covers & logos ---------- */
.game-card { padding-top: 0; overflow: hidden; }
.game-card .cover { position: relative; margin: 0 -1.1rem .2rem; aspect-ratio: 460 / 215; background: var(--bg3); overflow: hidden; }
.game-card .cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s; }
.game-card:hover .cover img { transform: scale(1.03); }
.game-card .cover .cover-fallback { display: none; position: absolute; inset: 0; place-items: center; }
.game-card .cover:not(:has(img)) .cover-fallback, .game-card .cover.fallback .cover-fallback { display: grid; }
.game-card .cover-fallback b { font-family: Fraunces, Georgia, serif; font-size: 3rem; color: #fff; opacity: .85; text-shadow: 0 2px 12px rgba(0,0,0,.35); }
.game-card .title { font-family: Fraunces, Georgia, serif; font-size: 1.2rem; }
.game-logo { display: block; max-height: 96px; max-width: min(100%, 420px); width: auto; height: auto; filter: drop-shadow(0 2px 8px rgba(0,0,0,.45)); }
.page-head.has-logo { align-items: center; }
@media (max-width: 720px) { .game-logo { max-height: 56px; } }
.game-logo-mark { display: inline-flex; align-items: center; height: 48px; max-width: 170px; flex-shrink: 0; }
.game-logo-mark img { height: 48px; max-width: 170px; width: auto; object-fit: contain; filter: drop-shadow(0 2px 6px rgba(0,0,0,.45)); }
.game-logo-mark:hover { text-decoration: none; opacity: .9; }
@media (max-width: 720px) { .game-logo-mark, .game-logo-mark img { height: 36px; max-width: 120px; } }

/* platform selector & platform badges */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--bg3); }
.seg button { background: none; border: 0; color: var(--muted); padding: .35rem .7rem; font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent-soft); color: var(--text); }
.badge.trophy { text-transform: capitalize; font-weight: 700; }
.badge.trophy.bronze { background: rgba(205, 127, 50, .18); color: #d99a5b; border: 1px solid #b87333; }
.badge.trophy.silver { background: rgba(192, 200, 212, .18); color: #cfd6e0; border: 1px solid #a8b0bd; }
.badge.trophy.gold { background: var(--gold-soft); color: var(--gold); border: 1px solid var(--gold); }
.badge.trophy.platinum { background: rgba(160, 220, 255, .18); color: #bfe7ff; border: 1px solid #8fd0f5; }
.badge.gs { background: rgba(16, 124, 16, .2); color: #6fd36f; border: 1px solid #2f9e2f; text-transform: none; font-weight: 700; }
.item-head .sortable { cursor: pointer; user-select: none; display: inline-flex; align-items: center; gap: .25rem; }
.item-head .sortable:hover { color: var(--text); }
.item-head .sortable.on { color: var(--accent); }
.item-head .sortable .ico { width: .9em; height: .9em; }

/* Games page backdrop: crossfade gallery of the games' artwork (see mountGallery in games.js) */
#game-bg.gallery { opacity: .9; }
#game-bg.gallery img { position: absolute; inset: 0; opacity: 0; transition: opacity 1.4s ease; transform: scale(1.04); }
#game-bg.gallery img.active { opacity: 1; }
#game-bg.gallery::after { background: radial-gradient(ellipse at 50% 35%, transparent 0%, color-mix(in srgb, var(--bg) 55%, transparent) 55%, color-mix(in srgb, var(--bg) 92%, transparent) 100%), linear-gradient(180deg, color-mix(in srgb, var(--bg) 35%, transparent) 0%, color-mix(in srgb, var(--bg) 60%, transparent) 50%, color-mix(in srgb, var(--bg) 96%, transparent) 100%); }
body.themed .hero h1 { text-shadow: 0 2px 24px rgba(0, 0, 0, .45); }
body.themed .hero p { color: color-mix(in srgb, var(--text) 80%, var(--muted)); }
@media (prefers-reduced-motion: no-preference) {
  #game-bg.gallery img.active { animation: gallery-drift 26s ease-in-out infinite alternate; }
  @keyframes gallery-drift { from { transform: scale(1.04) translate(0, 0); } to { transform: scale(1.1) translate(-1.2%, -1%); } }
}
.badge.pts { background: var(--accent-soft, rgba(124, 92, 255, .18)); color: var(--accent); text-transform: none; letter-spacing: 0; font-weight: 600; }

/* game cards in the grid: identical height and identical layout (equal cover, two-line title area, three-line description) */
.grid > .card.game-card, .grid > .card + .card.game-card { align-self: stretch; height: 100%; margin: 0; box-sizing: border-box; }
.game-card .title { min-height: 2.9em; line-height: 1.45em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.game-card .meta { min-height: 1.3em; }
.game-card .desc { flex: 0 0 auto; max-height: 4.2em; line-height: 1.4em; }
.game-card .progress-line { margin-top: auto; }

/* progress by area (game hub) and search snippets */
.area-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .2rem 1.2rem; }
.area-row { display: flex; align-items: center; gap: .55rem; color: var(--text); padding: .3rem 0; border-bottom: 1px solid var(--border); text-decoration: none; }
.area-row:hover .name { color: var(--accent); }
.area-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: .92rem; }
.area-row .bar { width: 84px; flex: none; }
.area-row.complete .name { color: var(--ok, #4ade80); }
.area-row.more { display: none; }
.area-grid.all .area-row.more { display: flex; }
.desc.snippet { color: var(--muted); font-style: italic; }
mark { background: var(--accent-soft); color: inherit; border-radius: 3px; padding: 0 .12em; }
