:root {
  --bg: #121212;
  --panel: #1b1b1b;
  --line: #2c2c2c;
  --text: #e9e6e1;
  --muted: #8f8a83;
  --accent: #e0a23a;
  --accent-ink: #1a1408;
  --bad: #e2675a;
  --good: #7fbf7a;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font: 13px ui-monospace, Consolas, monospace; color: var(--text); }
h1, h2 { font-weight: 650; letter-spacing: -0.01em; margin: 0; }
h2 { font-size: 16px; margin-bottom: 10px; color: var(--text); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; padding: 40px 16px; }
.err { color: var(--bad); }
.ok { color: var(--good); }
.nowrap { white-space: nowrap; }

/* top bar */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: 52px; padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.brand { color: var(--text); font-weight: 700; font-size: 17px; }
.brand:hover { text-decoration: none; }
.bar-right { display: flex; align-items: center; gap: 12px; }
.who { font-size: 14px; }
.cloak { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.cloak select { padding: 4px 6px; font-size: 13px; }
.link { color: var(--muted); font-size: 14px; }
.link:hover { color: var(--text); text-decoration: none; }

/* controls */
.btn {
  font: inherit; font-size: 14px; font-weight: 600;
  padding: 7px 14px;
  border: 1px solid var(--accent); border-radius: 5px;
  background: var(--accent); color: var(--accent-ink);
  cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--muted); }
.btn.ghost.on { border-color: var(--accent); color: var(--accent); }
.btn.small { padding: 5px 10px; font-size: 13px; }

input, select {
  font: inherit; color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line); border-radius: 5px;
  padding: 8px 10px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

/* home */
.wrap { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
.tools { display: flex; gap: 10px; }
.tools input { flex: 1; min-width: 0; }
.cats { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 6px; }
.chip {
  font: inherit; font-size: 13px;
  padding: 4px 10px;
  border: 1px solid var(--line); border-radius: 4px;
  background: transparent; color: var(--muted);
  cursor: pointer;
}
.chip:hover { color: var(--text); }
.chip.on { color: var(--text); border-color: var(--accent); }

.shelf { margin-top: 26px; }
.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.tile { display: block; color: var(--text); }
.tile:hover { text-decoration: none; }
.thumb {
  aspect-ratio: 1 / 1;
  border-radius: 6px; overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
}
.tile:hover .thumb { border-color: var(--accent); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fallback {
  display: flex; align-items: center; justify-content: center; text-align: center;
  width: 100%; height: 100%; padding: 10px;
  font-weight: 650; font-size: 15px; color: #f1ede6;
}
.meta { display: flex; flex-direction: column; padding: 6px 2px 0; }
.meta .t { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta .s { font-size: 12px; color: var(--muted); }

.req { display: flex; gap: 10px; max-width: 560px; }
.req input { flex: 1; min-width: 0; }

/* play page */
body.play { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.gamebar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 8px 20px;
  border-bottom: 1px solid var(--line);
}
.gamebar h1 { font-size: 16px; }
.actions { margin-left: auto; display: flex; gap: 8px; }
.stage { flex: 1; min-height: 0; background: #000; }
.stage iframe { width: 100%; height: 100%; border: 0; display: block; }

/* login */
.modal {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  padding: 16px;
}
.panel {
  width: 100%; max-width: 340px;
  background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 18px;
  display: flex; flex-direction: column; gap: 12px;
}
.panel label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.panel p { margin: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1; font: inherit; font-size: 14px; font-weight: 600;
  padding: 8px; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); cursor: pointer;
}
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.row { display: flex; justify-content: flex-end; gap: 8px; }

/* admin */
.addform { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); align-items: end; }
.addform label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; background: var(--panel); }
td input:not([type]) { width: 100%; min-width: 110px; padding: 5px 7px; font-size: 13px; }
td.c { text-align: center; }
td.mini img { width: 36px; height: 36px; object-fit: cover; border-radius: 3px; display: block; }
.reqlist { list-style: none; padding: 0; margin: 0; }
.reqlist li {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}

@media (max-width: 560px) {
  .bar, .gamebar { padding-left: 16px; padding-right: 16px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
  .actions { margin-left: 0; }
  .cloak { font-size: 0; gap: 0; }
}

/* loading placeholders while the game list loads */
.skel .thumb { border-color: transparent; }
.skel .bar1, .skel .bar2 { display: block; height: 10px; border-radius: 3px; background: var(--panel); margin-top: 6px; }
.skel .bar1 { width: 70%; }
.skel .bar2 { width: 45%; height: 8px; }
.skel .thumb, .skel .bar1, .skel .bar2 { animation: skel 1.2s ease-in-out infinite; }
@keyframes skel { 50% { background: #262626; } }
@media (prefers-reduced-motion: reduce) {
  .skel .thumb, .skel .bar1, .skel .bar2 { animation: none; }
}

/* nav */
.nav { display: flex; gap: 16px; margin-right: auto; margin-left: 24px; }

/* chat */
body.chatpage { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.chatwrap { flex: 1; min-height: 0; display: flex; max-width: 1200px; width: 100%; margin: 0 auto; }
.chatmain { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 0 16px; }
.chathead { display: flex; align-items: baseline; gap: 12px; padding: 14px 0 10px; border-bottom: 1px solid var(--line); }
.chathead h1 { font-size: 18px; }
.chathead #modBtn { margin-left: auto; }
.msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 0; }
.loadmore { display: block; margin: 6px auto 10px; }
.msg { position: relative; padding: 6px 8px; border-radius: 5px; }
.msg:hover { background: var(--panel); }
.mhead { display: flex; align-items: baseline; gap: 8px; }
.mhead .name { font-weight: 650; font-size: 14px; }
.msg.mine .name { color: var(--accent); }
.mhead .time { font-size: 12px; color: var(--muted); }
.tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent-ink); background: var(--accent); padding: 1px 5px; border-radius: 3px; }
.mtext { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.macts { position: absolute; top: 4px; right: 6px; display: none; gap: 4px; }
.msg:hover .macts, .msg:focus-within .macts { display: flex; }
.macts button {
  font: inherit; font-size: 12px; padding: 2px 8px; cursor: pointer;
  background: var(--bg); color: var(--muted); border: 1px solid var(--line); border-radius: 4px;
}
.macts button:hover { color: var(--text); border-color: var(--muted); }
.chatstatus { padding: 8px 0 0; display: flex; align-items: center; gap: 10px; }
.sendform { display: flex; gap: 8px; padding: 10px 0 16px; }
.sendform input { flex: 1; min-width: 0; }

.modpanel { width: 320px; flex-shrink: 0; overflow-y: auto; border-left: 1px solid var(--line); padding: 14px 16px 40px; }
.modpanel h2 { font-size: 14px; margin: 18px 0 8px; }
.modpanel h2:first-child { margin-top: 0; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 10px; }
textarea {
  font: 13px ui-monospace, Consolas, monospace; color: var(--text); resize: vertical;
  background: var(--panel); border: 1px solid var(--line); border-radius: 5px; padding: 8px 10px;
}
textarea:focus { outline: none; border-color: var(--accent); }
.modlist { list-style: none; margin: 0; padding: 0; }
.modlist li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; display: flex; flex-direction: column; gap: 4px; overflow-wrap: anywhere; }
.modlist.log li { display: block; padding: 5px 0; }
.row.left { justify-content: flex-start; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.panel h2 { font-size: 16px; margin: 0; }
.panel select, .panel input { width: 100%; }

@media (max-width: 800px) {
  .modpanel { position: fixed; inset: 52px 0 0 auto; width: min(340px, 100%); background: var(--bg); z-index: 5; }
  .nav { margin-left: 12px; gap: 12px; }
  .chathead .muted { display: none; }
}

/* gifs */
.mgif { display: block; max-height: 200px; max-width: min(320px, 100%); border-radius: 5px; margin-top: 4px; }
.gifpanel {
  border: 1px solid var(--line); border-radius: 6px; background: var(--panel);
  padding: 10px; margin-top: 10px; display: flex; flex-direction: column; gap: 8px;
}
.gifpanel[hidden] { display: none; }
.gifgrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px;
  max-height: 260px; overflow-y: auto;
}
.gifgrid .center { grid-column: 1 / -1; padding: 20px 0; }
.gifitem { padding: 0; border: 1px solid transparent; border-radius: 4px; background: var(--bg); cursor: pointer; height: 90px; overflow: hidden; }
.gifitem:hover { border-color: var(--accent); }
.gifitem img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gifnote { text-align: right; }
