:root {
  --bg: #0e0f13;
  --panel: rgba(22, 23, 29, 0.92);
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f4f5;
  --muted: #9ca3af;
  --accent: #7cfc4a;
  --warn: #fbbf24;
  --bad: #f87171;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Rubik', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

canvas#arena {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

/* ---------- Lobby panel ---------- */

.lobby {
  position: fixed;
  top: 20px;
  left: 20px;
  width: 300px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  backdrop-filter: blur(10px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  padding: 18px;
}

.lobby[hidden] { display: none; }

.lobby-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.01em;
}

.mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 5px solid var(--accent);
  box-shadow: 0 0 14px rgba(124, 252, 74, 0.5);
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
button.ghost:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.2); }

.menu-btn {
  width: 100%;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.menu-btn:hover { background: rgba(255, 255, 255, 0.12); }
.menu-btn[hidden] { display: none; }

.games {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: auto;
  gap: 2px;
  padding: 4px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}
.games button {
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 10px;
  padding: 8px 8px;
  white-space: nowrap;
  cursor: pointer;
}
.games button:hover { color: var(--text); }
.games button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.blurb {
  margin: 8px 2px 16px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.step {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
}

.qr {
  background: #fff;
  border-radius: 14px;
  padding: 10px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}
.qr svg { width: 100%; height: 100%; display: block; }

.code-block {
  margin-top: 14px;
  display: grid;
  gap: 4px;
  justify-items: start;
}
.label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.url {
  color: var(--text);
  font-size: 13px;
  word-break: break-all;
  text-decoration: none;
  border-bottom: 1px dashed var(--line);
  margin-bottom: 6px;
}
.code {
  font-size: 52px;
  font-weight: 800;
  letter-spacing: 0.14em;
  line-height: 1;
  color: var(--accent);
  text-shadow: 0 0 24px rgba(124, 252, 74, 0.35);
}

.remote {
  margin-top: 16px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(77, 171, 247, 0.08);
  border: 1px solid rgba(77, 171, 247, 0.18);
}
.remote p {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}
.remote a {
  color: #8cc8ff;
  word-break: break-all;
  text-decoration: none;
  border-bottom: 1px dashed rgba(140, 200, 255, 0.4);
}

.status {
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}
.status.ok::before { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.status.warn::before { background: var(--warn); }
.status.bad::before { background: var(--bad); }

.roster {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.roster li {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 14px;
}
.roster .dot { width: 14px; height: 14px; border-radius: 50%; }
.roster .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster .meta { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.roster .btns {
  grid-column: 2 / 4;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  min-height: 16px;
}
.roster .btns span {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.3);
}
.roster .btns span.on { background: var(--text); color: var(--bg); }

.hint {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}
kbd {
  font-family: inherit;
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
}

/* ---------- Collapsed chip ---------- */

.chip {
  position: fixed;
  top: 16px;
  left: 16px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
}
.chip[hidden] { display: none; }

@media (max-width: 520px) {
  .lobby { width: calc(100vw - 24px); left: 12px; top: 12px; }
}
