@font-face {
  font-family: 'Manrope';
  src: url('/fonts/manrope-latin-wght-normal.woff2') format('woff2-variations');
  font-weight: 200 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Manrope';
  src: url('/fonts/manrope-latin-ext-wght-normal.woff2') format('woff2-variations');
  font-weight: 200 800;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #0d1016;
  --bar: #0a0c11;
  --side: #11151c;
  --card: #141922;
  --raised: #1c222c;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.13);
  --text: #e8ecf2;
  --soft: #c3cad5;
  --muted: #8d97a7;
  --faint: #7c8698;
  --accent: #6fe3a3;
  --accent-ink: #06140c;
  --warn: #f2b65a;
  --danger: #f28b7d;
  /* The current game's colour, taken from its cover. */
  --tint: 120, 130, 150;
  --radius: 6px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body {
  color: var(--text);
  font: 500 14px/1.45 Manrope, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
img { display: block; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 28px; min-height: 48px; padding: 0 16px;
  background: var(--bar); border-bottom: 1px solid var(--line); flex-wrap: wrap;
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 15px; }
.nav { display: flex; align-self: stretch; flex-wrap: wrap; }
.nav a {
  display: flex; align-items: center; padding: 0 14px; min-height: 48px; color: var(--muted);
  font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
}
.nav a:hover { color: var(--text); }
.nav a[aria-current='page'] { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.conn { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }
.dot.warn { background: var(--warn); }
.dot.off { background: #5a6475; }

/* ---------- layout ---------- */
.layout { display: flex; flex-wrap: wrap; min-height: calc(100vh - 48px); }
.sidebar {
  flex: 1 1 248px; max-width: 100%; background: var(--side); border-right: 1px solid var(--line);
  padding: 12px 8px; display: flex; flex-direction: column; gap: 2px;
}
@media (min-width: 900px) { .sidebar { max-width: 280px; } }
.content { flex: 999 1 560px; min-width: 0; }
.page { padding: 24px 28px 48px; display: flex; flex-direction: column; gap: 28px; }
.page.narrow { max-width: 980px; }

.search {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; margin: 0 2px 6px;
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius); color: var(--faint);
}
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; font-size: 13px; color: var(--text); }
.search:focus-within { border-color: var(--accent); }
.side-head {
  display: flex; justify-content: space-between; padding: 12px 10px 6px;
  font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--faint);
}
.side-row {
  display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 0 10px; border-radius: var(--radius);
  font-size: 13px; font-weight: 600;
}
.side-row:hover { background: rgba(255, 255, 255, .05); }
.side-row[aria-current='page'] { background: rgba(255, 255, 255, .09); }
.side-row .thumb { width: 22px; height: 22px; border-radius: 4px; flex: none; object-fit: cover; background: var(--raised); }
.side-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-row .note { font-size: 11px; color: var(--faint); }
.side-row.dim .name { color: #9aa3b2; }
.side-empty { padding: 6px 10px; font-size: 12px; color: var(--faint); }

/* ---------- buttons and fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border-radius: var(--radius); border: 1px solid var(--line-strong); background: rgba(255, 255, 255, .05);
  font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, .1); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 800; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { min-height: 52px; padding: 0 30px 0 24px; font-size: 15px; letter-spacing: .05em; text-transform: uppercase; }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 12px; }
.btn.danger { color: var(--danger); }
.btn.link { border: 0; background: none; padding: 0; min-height: 0; color: var(--soft); }
.btn.link:hover { color: var(--text); text-decoration: underline; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 700; color: var(--soft); }
.input, select.input {
  height: 40px; padding: 0 12px; border-radius: var(--radius); border: 1px solid var(--line-strong);
  background: var(--bg); color: var(--text); font-size: 14px; font-weight: 500; min-width: 0;
}
.input:focus { outline: none; border-color: var(--accent); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > .grow { flex: 1 1 260px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  height: 32px; padding: 0 12px; border-radius: var(--radius); border: 1px solid var(--line-strong);
  background: transparent; color: var(--soft); font-size: 12px; font-weight: 700; cursor: pointer;
}
.chip[aria-pressed='true'] { background: var(--text); border-color: var(--text); color: var(--bg); }

.label { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.muted { color: var(--muted); }
.soft { color: var(--soft); }
.error { color: var(--danger); font-size: 13px; font-weight: 600; }
.notice {
  padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, .03); font-size: 13px; color: var(--soft);
}
.notice.warn { border-color: rgba(242, 182, 90, .4); background: rgba(242, 182, 90, .08); color: #f5cf95; }
code { font: 600 12px/1.4 ui-monospace, Consolas, monospace; padding: 1px 5px; border-radius: 4px; background: var(--raised); }

/* ---------- library ---------- */
.hero {
  position: relative; min-height: 280px; border-radius: 8px; overflow: hidden; display: flex; align-items: flex-end;
  background: radial-gradient(70% 120% at 72% 30%, rgba(var(--tint), .9), rgba(var(--tint), .25) 55%, #10131a 90%);
}
.hero > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero .scrim { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(13,16,22,.94) 0%, rgba(13,16,22,.6) 42%, rgba(13,16,22,0) 72%); }
.hero .inner { position: relative; padding: 32px; display: flex; flex-direction: column; gap: 12px; max-width: 560px; }
.hero h1 { font-size: 48px; font-weight: 800; line-height: 1; letter-spacing: -.01em; }
.hero .logo { max-width: 360px; max-height: 120px; object-fit: contain; object-position: left bottom; }
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.75); }

.toolbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.toolbar h2 { font-size: 18px; font-weight: 800; }
.toolbar .end { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px 16px; }
.card { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.cover {
  position: relative; aspect-ratio: 2 / 3; border-radius: var(--radius); overflow: hidden; background: var(--raised);
  box-shadow: inset 0 0 0 1px var(--line); transition: transform .18s ease-out, box-shadow .18s ease-out;
}
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card:hover .cover { transform: translateY(-3px); box-shadow: 0 16px 36px -12px var(--glow, rgba(0,0,0,.6)), inset 0 0 0 1px rgba(255,255,255,.16); }
.cover .placeholder {
  position: absolute; inset: 0; display: flex; align-items: flex-end; padding: 14px 12px;
  font-size: 17px; font-weight: 800; line-height: 1.05; text-transform: uppercase; overflow-wrap: anywhere;
}
.badges { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; gap: 4px; flex-wrap: wrap; }
.badge { padding: 3px 6px; border-radius: 4px; background: rgba(8,10,14,.82); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.badge.warn { color: var(--warn); }
.card .title { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .sub { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); min-width: 0; }
.card .sub span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 48px 24px; border: 1px dashed var(--line-strong); border-radius: 8px; text-align: center; color: var(--muted); display: grid; gap: 12px; justify-items: center; }
.empty h2 { color: var(--text); font-size: 18px; }

/* ---------- game page ---------- */
.game { background: radial-gradient(1100px 620px at 18% 300px, rgba(var(--tint), .16), rgba(13,16,22,0) 70%); min-height: 100%; }
.game-hero {
  position: relative; min-height: 360px; overflow: hidden; display: flex; align-items: flex-end;
  background: radial-gradient(70% 120% at 70% 26%, rgba(var(--tint), .85), rgba(var(--tint), .3) 50%, #10131a 88%);
}
.game-hero > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 35%; }
.game-hero > img.blur { filter: blur(28px) saturate(1.2); transform: scale(1.2); opacity: .7; }
.game-hero .fade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(13,16,22,0) 30%, rgba(13,16,22,.72) 78%, rgba(13,16,22,.97) 100%); }
.game-hero .inner { position: relative; padding: 0 32px 28px; display: flex; flex-direction: column; gap: 10px; }
.game-hero h1 { font-size: 60px; font-weight: 800; line-height: .98; letter-spacing: -.015em; overflow-wrap: anywhere; }
.game-hero .logo { max-width: min(460px, 80%); max-height: 150px; object-fit: contain; object-position: left bottom; }
.crumbs { display: flex; gap: 8px; font-size: 12px; font-weight: 700; color: #c9cfd8; }
.actions { display: flex; align-items: center; gap: 28px; padding: 18px 32px; flex-wrap: wrap; background: rgba(10,12,17,.72); border-bottom: 1px solid var(--line); }
.stats { display: flex; gap: 28px; flex-wrap: wrap; margin: 0; }
.stats div { display: flex; flex-direction: column; gap: 4px; }
.stats dd { margin: 0; font-weight: 700; }
.game-body { display: flex; flex-wrap: wrap; gap: 32px; padding: 28px 32px 48px; align-items: flex-start; }
.game-main { flex: 2 1 480px; min-width: 0; display: flex; flex-direction: column; gap: 32px; }
.game-side { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.section { display: flex; flex-direction: column; gap: 12px; }
.section h2 { font-size: 16px; font-weight: 800; }
.about { font-size: 15px; line-height: 1.6; color: var(--soft); max-width: 70ch; white-space: pre-line; }
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.shots a { border-radius: var(--radius); overflow: hidden; background: var(--raised); }
.shots img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; transition: transform .18s ease-out; }
.shots a:hover img { transform: scale(1.03); }
.panel { padding: 20px; border-radius: 8px; background: var(--card); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px; }
.panel h2, .panel h3 { font-size: 14px; font-weight: 800; }
.panel .head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: rgba(17,21,28,.7); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
tr:last-child td { border-bottom: 0; }
td.wrap { white-space: normal; overflow-wrap: anywhere; }
td.end, th.end { text-align: right; }

/* ---------- server page ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list-item:last-child { border-bottom: 0; }
.list-item .main { flex: 1 1 280px; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.list-item .path { font-weight: 700; overflow-wrap: anywhere; }
.browser { border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--bg); max-height: 320px; overflow: auto; }
.browser button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 12px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer; font-size: 13px; }
.browser button:hover { background: rgba(255,255,255,.05); }
.counts { display: flex; gap: 24px; flex-wrap: wrap; }

/* ---------- sign in ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(900px 500px at 50% 0%, rgba(111,227,163,.08), transparent 70%), var(--bg); }
.auth form { width: min(380px, 100%); display: flex; flex-direction: column; gap: 16px; padding: 28px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); }
.auth h1 { font-size: 22px; font-weight: 800; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); padding: 12px 18px; border-radius: 8px; background: var(--raised); border: 1px solid var(--line-strong); font-weight: 700; z-index: 20; box-shadow: 0 12px 30px rgba(0,0,0,.4); }
.toast.error { color: var(--danger); }

@media (max-width: 700px) {
  .page { padding: 18px 16px 40px; }
  .hero h1 { font-size: 36px; }
  .game-hero h1 { font-size: 40px; }
  .actions, .game-body { padding-left: 16px; padding-right: 16px; }
  .game-hero .inner { padding: 0 16px 22px; }
  .conn { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* A version's place on the server (owner only). */
.v-path { display: flex; max-width: 44ch; font-size: 12px; color: var(--muted); white-space: nowrap; }
.v-path .v-dir { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.v-path span:last-child { flex-shrink: 0; }

/* ---------- desktop app ---------- */
/* The top bar is the window's title bar: drag it to move the window. Windows draws its buttons at the right. */
.desktop .topbar {
  -webkit-app-region: drag; user-select: none; flex-wrap: nowrap;
  padding-right: calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw) + 16px);
}
.desktop .topbar a, .desktop .topbar button, .desktop .topbar input, .desktop .topbar select { -webkit-app-region: no-drag; }
.btn[hidden] { display: none; }
.nav .count {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-left: 7px; padding: 0 5px;
  border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 10px; letter-spacing: 0;
}
.nav .count[hidden] { display: none; }

.progress { display: grid; gap: 7px; flex: 1 1 320px; min-width: 240px; max-width: 620px; }
.progress .track { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.progress .track span, .mini .track span {
  display: block; height: 100%; border-radius: inherit; transition: width .35s ease-out;
  background: linear-gradient(90deg, #4fc98a, var(--accent) 45%, #b5f7d2 50%, var(--accent) 55%, #4fc98a);
  background-size: 300% 100%;
}
.progress.downloading .track span, .progress.unpacking .track span { animation: flow 2.4s linear infinite; }
@keyframes flow { from { background-position: 100% 0; } to { background-position: -50% 0; } }
.progress.paused .track span, .progress.queued .track span, .mini.paused .track span, .mini.queued .track span { background: #5a6475; }
.progress.error .track span, .mini.error .track span { background: var(--danger); }
.progress .pline { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; font-weight: 600; color: var(--soft); }
.progress.error .ptext { color: var(--danger); }
.mini { position: absolute; left: 8px; right: 8px; bottom: 8px; padding: 3px; border-radius: 5px; background: rgba(8, 10, 14, .8); }
.mini .track { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .12); overflow: hidden; }

.desk-buttons { align-items: center; }
.actions > .stats + .desk-buttons { margin-left: auto; }
.setup-text { display: grid; gap: 10px; flex: 1 1 320px; max-width: 640px; font-size: 13px; }
.setup-text .row { align-items: center; }
.desk-note { font-size: 13px; }
.dl-item { align-items: center; }
.dl-item .row { align-items: center; }
.dl-item .progress { flex: none; min-width: 0; max-width: none; margin-top: 6px; }
.dl-thumb { width: 42px; height: 56px; border-radius: 4px; object-fit: cover; flex: none; background: var(--raised); }
@media (prefers-reduced-motion: reduce) { .progress .track span { animation: none !important; } }
/* Pages without the top bar (sign in) still need somewhere to drag the window by. */
.desktop .auth::before { content: ''; position: fixed; inset: 0 0 auto 0; height: 40px; -webkit-app-region: drag; }
