:root {
  --bg: #f6f4ef; --panel: #ffffff; --ink: #1d211c; --dim: #6b6f66; --line: #dedbd2;
  --accent: #b5651d; --accent-ink: #ffffff; --accent-soft: #f6e7d6;
  --ok: #2f7d32; --ok-soft: #e3f1e3; --bad: #b3261e; --bad-soft: #fbe5e3; --info-soft: #e6eef7; --info: #1f4e79;
  --code: #f0ede5; --radius: 8px; color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #14170f; --panel: #1d2118; --ink: #e7e5dc; --dim: #9a9d90; --line: #33382b;
  --accent: #e0913f; --accent-ink: #1a1206; --accent-soft: #3a2a17;
  --ok: #7cc47f; --ok-soft: #1f3320; --bad: #f08a80; --bad-soft: #3b1d1a; --info-soft: #1b2a3a; --info: #9cc3ea;
  --code: #262b20; color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.7rem; margin: 1.2rem 0 .6rem; line-height: 1.25; }
h2 { font-size: 1.25rem; margin: 1.8rem 0 .6rem; }
h3 { font-size: 1.05rem; margin: 1.2rem 0 .4rem; }
code, pre { font-family: ui-monospace, SFMono-Regular, Consolas, Menlo, monospace; font-size: .88em; }
code { background: var(--code); padding: .05em .3em; border-radius: 4px; }
pre { background: var(--code); padding: .8rem 1rem; border-radius: var(--radius); overflow-x: auto; }
pre code { background: none; padding: 0; }
.hash { word-break: break-all; font-size: .8em; }
.dim { color: var(--dim); }
.count { font-size: .9rem; font-weight: normal; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 440px; }
.wide-ish { max-width: 760px; }

.top { background: var(--panel); border-bottom: 1px solid var(--line); }
.top-in { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1.2rem; min-height: 56px; padding-top: 6px; padding-bottom: 6px; }
.brand { font-weight: 700; color: var(--ink); font-size: 1.05rem; white-space: nowrap; }
.brand-mark { color: var(--accent); }
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem 1rem; }
.nav a { color: var(--ink); }
.nav-user { margin-left: auto; }
.theme-toggle { background: none; border: 0; cursor: pointer; font-size: 1.1rem; padding: .2rem; opacity: .8; }
.theme-toggle:hover { opacity: 1; }
.inline { display: inline; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }

.btn { display: inline-block; background: var(--accent); color: var(--accent-ink) !important; border: 1px solid var(--accent);
  border-radius: 6px; padding: .45rem .9rem; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-small { padding: .2rem .6rem; font-size: .9rem; }
.btn-ghost { background: transparent; color: var(--accent) !important; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff !important; }

.flash { padding: .6rem .9rem; border-radius: var(--radius); margin: .8rem 0; border: 1px solid transparent; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--bad-soft); color: var(--bad); }
.flash-info { background: var(--info-soft); color: var(--info); }
.note { background: var(--accent-soft); padding: .6rem .9rem; border-radius: var(--radius); }

.hero { padding: 1.5rem 0 .5rem; }
.hero h1 { font-size: 2rem; }
.lead { font-size: 1.08rem; color: var(--dim); max-width: 760px; }
.search-big { display: flex; gap: .5rem; max-width: 620px; margin: 1rem 0; }
.search-big input { flex: 1; min-width: 0; }
.stats { display: flex; flex-wrap: wrap; gap: 1.5rem; }
.stats a { color: var(--ink); }
.stats b { font-size: 1.4rem; color: var(--accent); margin-right: .2rem; }
.cols3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem 2rem; margin-top: 2rem; }
.cols2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem 2rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--ink);
  display: flex; flex-direction: column; }
.card:hover { border-color: var(--accent); text-decoration: none; }
.card-img { aspect-ratio: 1 / 1; overflow: hidden; min-height: 0; background: #0c0e09; display: flex; align-items: center; justify-content: center; }
.card-img img { width: 100%; height: 100%; object-fit: contain; }
.noimg { color: #777; font-size: .85rem; }
.card-body { padding: .55rem .7rem .7rem; }
.card-title { font-weight: 600; line-height: 1.3; word-break: break-word; }
.card-meta { font-size: .85rem; }

.badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: .05rem .45rem; border-radius: 999px;
  background: var(--code); color: var(--dim); vertical-align: middle; text-transform: lowercase; white-space: nowrap; }
.b-stock { background: var(--code); }
.b-opu { background: var(--info-soft); color: var(--info); }
.b-comm { background: var(--accent-soft); color: var(--accent); }
.st-published { background: var(--ok-soft); color: var(--ok); }
.st-pending_review { background: var(--accent-soft); color: var(--accent); }
.st-rejected, .st-withdrawn { background: var(--bad-soft); color: var(--bad); }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0 1rem; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; padding: .4rem .55rem; max-width: 100%; }
textarea { width: 100%; }
.filters input[type=search] { flex: 1 1 200px; }
.form { display: flex; flex-direction: column; gap: .7rem; margin: 1rem 0; }
.form label { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; font-size: .92rem; }
.form label.check { flex-direction: row; align-items: center; font-weight: normal; }
.form label small { font-weight: normal; color: var(--dim); }
.form-row { display: flex; flex-wrap: wrap; gap: .7rem; align-items: flex-end; }
.form-row > label { flex: 1 1 200px; }
.narrow-form { max-width: 440px; }
.field-err { color: var(--bad); font-size: .88rem; margin-top: -.4rem; }

.tbl { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  display: block; overflow-x: auto; }
.tbl th, .tbl td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--dim); white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.invalid td { background: var(--bad-soft); }
.thumb-cell img, img.mini { width: 40px; height: 40px; object-fit: contain; background: #0c0e09; vertical-align: middle; }

.pkg-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.pkg-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1.3rem; }
.meta { color: var(--dim); }
.version-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .6rem 0; border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line); margin: .5rem 0 1rem; }
.maps-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.map-tile { display: flex; flex-direction: column; gap: .3rem; color: var(--ink); }
.map-tile img { width: 100%; background: #0c0e09; border-radius: var(--radius); }
.big-preview img { max-width: 100%; border-radius: var(--radius); display: block; margin: .5rem 0 1rem; }
.side-preview { width: 100%; max-width: 420px; border-radius: var(--radius); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.kv dt { color: var(--dim); }
.kv dd { margin: 0; min-width: 0; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: .2rem 0; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; margin: 1rem 0; }
.box summary { cursor: pointer; font-weight: 600; }
.box.danger summary { color: var(--bad); }
.review h3 { margin-top: 0; }
.prose p { max-width: 760px; }
.token { display: inline-block; margin-top: .3rem; word-break: break-all; }
.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin: 1.5rem 0; }
.error-page h1 { font-size: 3rem; margin-bottom: 0; }
.foot { color: var(--dim); font-size: .85rem; padding-top: 2rem; padding-bottom: 2rem; }

@media (max-width: 640px) {
  .nav-user { margin-left: 0; }
  h1 { font-size: 1.4rem; }
  .hero h1 { font-size: 1.6rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

/* ---- Lightbox (app.js) ---------------------------------------------------------------------- */
.big-preview { display: inline-block; cursor: zoom-in; }
body.lightbox-open { overflow: hidden; }
.lightbox { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column;
  background: rgba(8, 9, 6, .94); color: #eee; }
.lightbox-bar { display: flex; align-items: center; gap: .5rem 1rem; padding: .5rem 16px; flex-wrap: wrap; }
.lightbox-caption { flex: 1 1 auto; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.lightbox-bar button, .lightbox-bar a { background: rgba(255, 255, 255, .1); color: #eee; border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 6px; padding: .3rem .7rem; font: inherit; font-size: .9rem; cursor: pointer; text-decoration: none; }
.lightbox-bar button:hover, .lightbox-bar a:hover { background: rgba(255, 255, 255, .2); }
.lightbox-close { font-size: 1.3rem !important; line-height: 1; padding: .15rem .6rem !important; }
.lightbox-stage { flex: 1; min-height: 0; overflow: auto; display: flex; padding: 0 16px 16px; }
/* Fit: fill the window, scaling small maps up with crisp tiles. */
.lightbox-stage img { margin: auto; width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; cursor: zoom-in; }
/* Actual size: the PNG's own pixels, scroll to pan. */
.lightbox.actual .lightbox-stage img { width: auto; height: auto; max-width: none; object-fit: none; cursor: zoom-out; }

/* ---- Header logo ---------------------------------------------------------------------------- */
.brand { display: inline-flex; align-items: center; gap: .6rem; }
.brand-logo { height: 40px; width: auto; display: block; }
.brand-text { font-weight: 700; font-size: 1.15rem; letter-spacing: .01em; color: var(--ink); white-space: nowrap; }
@media (max-width: 640px) {
  .brand-logo { height: 30px; }
  .brand-text { font-size: 1rem; }
}

/* ---- Missions --------------------------------------------------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: .25rem; margin: .3rem 0 .15rem; }
.chip { font-size: .72rem; font-weight: 600; padding: .05rem .45rem; border-radius: 4px; background: var(--code); color: var(--ink); white-space: nowrap; }
.mode-last_one_standing { background: #6b2b25; color: #ffd9d3; }
.mode-land_rush { background: #5a4a1c; color: #ffeab0; }
.mode-space_race { background: #22406b; color: #d6e6ff; }
.mode-resource_race { background: #2f5a2a; color: #d9f5d2; }
.mode-midas { background: #6b5a14; color: #fff2b8; }
.mode-survival { background: #4a2a5e; color: #ecdcff; }
.mode-cooperative { background: #1f5a5a; color: #d2f5f5; }
.mode-convoy { background: #5a3a1f; color: #ffe2c8; }
.crumbs { color: var(--dim); font-size: .9rem; margin: 1rem 0 -.6rem; }
.mission-head { display: grid; grid-template-columns: minmax(0, 360px) 1fr; gap: 1.2rem 1.6rem; align-items: start; margin-top: 1rem; }
.mission-head .map-img img { width: 100%; border-radius: var(--radius); background: #0c0e09; display: block; }
.shots { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.shots a { display: flex; flex-direction: column; width: 84px; font-size: .75rem; color: var(--dim); text-align: center;
  border: 2px solid transparent; border-radius: var(--radius); padding: 2px; }
.shots a.on { border-color: var(--accent); color: var(--ink); }
.shots img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 3px; background: #0c0e09; }
.shots span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.small { font-size: .85rem; }
.tbl td.thumb-cell a { display: inline-block; margin: 0 4px 4px 0; }
.tbl td.thumb-cell img { width: 72px; height: 72px; object-fit: cover; border-radius: 3px; display: block; background: #0c0e09; }
figure.render { margin: 0 0 1rem; }
figure.render figcaption { font-size: .85rem; margin-top: .3rem; }
.lightbox-stage img.smooth { image-rendering: auto; }
.series-nav { display: flex; justify-content: space-between; gap: 1rem; margin: 1rem 0; }
.tbl td.variant { color: var(--dim); }
@media (max-width: 760px) { .mission-head { grid-template-columns: 1fr; } }
