:root {
  --bg: #0d1214;
  --panel: #141b1e;
  --panel-2: #1a2327;
  --line: #26333a;
  --text: #e4ece9;
  --muted: #8fa19b;
  --accent: #3fd0a0;
  --accent-ink: #062018;
  --gold: #e9c46a;
  --danger: #ff6b6b;
  --link: #6fe0b9;
  --radius: 10px;
  --always: #ffffff;
  --common: #3cd23c;
  --uncommon: #ffff00;
  --rare: #ff981f;
  --very-rare: #ff4040;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
a[title="Not written yet"] { color: var(--danger); }
h1, h2, h3, h4 { line-height: 1.25; margin: 1.4em 0 .5em; }
h1 { font-size: 1.9rem; margin-top: .6em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; padding: 0 .3em; font-size: .9em; }
pre { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; overflow-x: auto; }
pre code { border: 0; padding: 0; }
blockquote { margin: 1em 0; padding: .2em 1em; border-left: 3px solid var(--accent); color: var(--muted); background: var(--panel); }
hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
img { max-width: 100%; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
main.wrap { flex: 1; padding-bottom: 48px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hint { color: var(--muted); font-size: .85rem; margin: .4em 0 1em; }
details summary { cursor: pointer; }
.game { position: relative; width: 100%; aspect-ratio: 765 / 503; max-height: calc(100vh - 160px); min-height: 360px;
  background: #000; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.game-status { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; margin: 0;
  padding: 24px; text-align: center; color: var(--muted); z-index: 1; pointer-events: none; }
.checksum { display: block; margin-top: 6px; word-break: break-all; }

/* top bar */
.topbar { background: rgba(13, 18, 20, .92); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(8px); }
.topbar-inner { display: flex; align-items: center; gap: 20px; min-height: 60px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 1.1rem; letter-spacing: .02em; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; }
.nav a { color: var(--muted); padding: 6px 12px; border-radius: 8px; font-weight: 500; }
.nav a:hover, .nav a.active { color: var(--text); background: var(--panel-2); text-decoration: none; }
.search { flex: 1; min-width: 200px; }
.search input { width: 100%; }
.account { display: flex; align-items: center; gap: 10px; }
.account .who { font-weight: 500; }
.account form { margin: 0; }

/* forms */
input[type=text], input[type=search], textarea, select {
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 12px; font: inherit; width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
label { display: block; font-weight: 600; margin: 1em 0 .3em; }
.btn, button.btn {
  display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: 8px; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn-discord { background: #5865f2; color: #fff; }
button.link { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 0; }
button.link:hover { color: var(--text); text-decoration: underline; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 1em 0; }
.inline { display: inline; margin: 0; }

.flash, .notice { background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--gold); padding: 10px 14px; border-radius: 8px; margin: 16px 0; }

/* page heads */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin: 24px 0 12px; }
.page-head h1 { margin: 0; }
.crumbs { color: var(--muted); font-size: .9rem; margin-top: 20px; }
.crumbs a { color: var(--muted); }

/* home */
.hero { padding: 56px 0 32px; text-align: center; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); margin: 0; letter-spacing: .01em; }
.hero h1 span { color: var(--accent); }
.hero p { color: var(--muted); max-width: 640px; margin: 12px auto 24px; font-size: 1.1rem; }
.hero .actions { justify-content: center; }
.wip { display: inline-block; background: rgba(233, 196, 106, .12); color: var(--gold); border: 1px solid rgba(233, 196, 106, .35); border-radius: 999px; padding: 3px 12px; font-size: .85rem; margin-bottom: 18px; }

.grid { display: grid; gap: 16px; }
.grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card h2, .card h3 { margin-top: 0; }
a.card { color: var(--text); display: block; transition: border-color .15s, transform .15s; }
a.card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
a.card .card-sub { color: var(--muted); font-size: .9rem; }
.card-title { font-weight: 700; font-size: 1.05rem; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 36px 0 12px; }
.section-title h2 { margin: 0; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; background: var(--panel); }
table.data th, table.data td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data thead th { background: var(--panel-2); font-size: .85rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--panel-2); }
table.data .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.prose table { border-collapse: collapse; width: 100%; margin: 1em 0; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 8px 12px; }
.prose th { background: var(--panel-2); }

.chance { font-weight: 700; }
.chance.always { color: var(--always); }
.chance.common { color: var(--common); }
.chance.uncommon { color: var(--uncommon); }
.chance.rare { color: var(--rare); }
.chance.very-rare { color: var(--very-rare); }

.tag { display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 1px 7px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); vertical-align: middle; }
.tag.pet { color: var(--gold); border-color: rgba(233, 196, 106, .4); }
.tag.boss { color: var(--danger); border-color: rgba(255, 107, 107, .4); }
.tag.tier-Beginner { color: var(--common); }
.tag.tier-Hard { color: var(--rare); }
.tag.tier-Elite { color: var(--very-rare); }
.tag.donator { color: #c58cff; border-color: rgba(197, 140, 255, .4); }

/* wiki layout */
.wiki-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.infobox { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.infobox h2 { margin: 0; padding: 12px 16px; font-size: 1.05rem; background: var(--panel-2); border-bottom: 1px solid var(--line); }
.infobox dl { margin: 0; display: grid; grid-template-columns: auto 1fr; }
.infobox dt, .infobox dd { margin: 0; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.infobox dt { color: var(--muted); font-size: .9rem; }
.infobox dd { text-align: right; font-weight: 500; }
.infobox dl > :nth-last-child(-n+2) { border-bottom: 0; }
.examine { font-style: italic; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.stats table.data td.num.pos { color: var(--common); }
.stats table.data td.num.neg { color: var(--very-rare); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 16px; }
.filters input { max-width: 320px; }
.filters select { width: auto; }
.prose { max-width: 820px; }
.prose li { margin: .2em 0; }
.page-meta { color: var(--muted); font-size: .85rem; }

/* forums */
.forum-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px 260px; gap: 16px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--panel); }
.forum-row:first-child { border-top-left-radius: var(--radius); border-top-right-radius: var(--radius); }
.forum-row:last-child { border-bottom: 0; border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius); }
.forum-list { border: 1px solid var(--line); border-radius: var(--radius); }
.forum-row .title { font-weight: 600; font-size: 1.02rem; }
.forum-row .desc { color: var(--muted); font-size: .9rem; }
.forum-row .count { text-align: center; color: var(--muted); font-size: .85rem; }
.forum-row .count strong { display: block; color: var(--text); font-size: 1rem; }
.forum-row .last { font-size: .85rem; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.forum-row.pinned { background: linear-gradient(90deg, rgba(63, 208, 160, .07), var(--panel) 40%); }

.post { display: grid; grid-template-columns: 170px minmax(0, 1fr); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin-bottom: 14px; overflow: hidden; scroll-margin-top: 80px; }
.post .side { background: var(--panel-2); padding: 16px; text-align: center; border-right: 1px solid var(--line); }
.post .side .username { display: block; font-weight: 700; margin-top: 8px; word-break: break-word; }
.post .side .meta { color: var(--muted); font-size: .8rem; margin-top: 6px; }
.post .main { padding: 14px 18px; min-width: 0; }
.post .head { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: .85rem; border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.post .body { overflow-wrap: anywhere; }
.post .body > :first-child { margin-top: .5em; }
.post .tools { display: flex; gap: 12px; justify-content: flex-end; font-size: .85rem; margin-top: 10px; }
.post.deleted .body { color: var(--muted); font-style: italic; }
.avatar { border-radius: 50%; background: var(--panel-2); display: inline-block; }
.avatar.sm { width: 28px; height: 28px; }
.avatar.md { width: 40px; height: 40px; }
.avatar.lg { width: 72px; height: 72px; }
.username { color: var(--role, var(--text)); }
.role { display: inline-block; font-size: .72rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; color: var(--role); border: 1px solid var(--role); margin-top: 6px; }
.thread-flags .tag { margin-right: 4px; }
.mod-bar { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 14px; border: 1px dashed var(--line); border-radius: var(--radius); margin-bottom: 16px; align-items: center; }
.mod-bar span { color: var(--muted); font-size: .85rem; margin-right: 4px; }

.preview { border: 1px dashed var(--accent); border-radius: var(--radius); padding: 4px 16px; margin: 16px 0; }

.pager { display: flex; gap: 6px; flex-wrap: wrap; margin: 16px 0; }
.pager a, .pager span { padding: 4px 11px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); }
.pager a:hover { color: var(--text); text-decoration: none; border-color: var(--accent); }
.pager .current { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.pager .gap { border: 0; }

.footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; padding: 20px 0; }
.footer .wrap { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.error-page { text-align: center; padding: 80px 0; }
.error-page .code { font-size: 4rem; font-weight: 800; color: var(--accent); line-height: 1; }

@media (max-width: 900px) {
  .wiki-layout { grid-template-columns: 1fr; }
  .wiki-layout .infobox { order: -1; }
  .forum-row { grid-template-columns: minmax(0, 1fr) 80px; }
  .forum-row .last { display: none; }
}
@media (max-width: 640px) {
  .topbar-inner { gap: 10px; }
  .search { order: 5; flex-basis: 100%; }
  .account .who { display: none; }
  .post { grid-template-columns: 1fr; }
  .post .side { display: flex; gap: 10px; align-items: center; text-align: left; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 14px; }
  .post .side .username { margin-top: 0; }
  .post .side .avatar.lg { width: 36px; height: 36px; }
  .post .side .meta { margin-top: 0; }
  .forum-row { grid-template-columns: 1fr; gap: 4px; }
  .forum-row .count { text-align: left; }
  .forum-row .count strong { display: inline; }
  .grid.cols-2 { grid-template-columns: 1fr; }
}
