:root {
  --bg: #0f1115;
  --panel: #181b22;
  --panel-2: #20242d;
  --border: #2b303b;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --accent: #8ab4f8;
  --accent-ink: #0b1d3a;
  --danger: #ea4335;
  --ok: #34a853;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

/* ---------- forms ---------- */

label { display: block; margin: 0 0 14px; color: var(--muted); font-size: 13px; }
label > input, label > select, label > textarea { margin-top: 6px; }
input, select, textarea {
  display: block;
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; min-height: 80px; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); }
label.check input { width: auto; margin: 0; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none !important;
  white-space: nowrap;
}
button:disabled { opacity: .6; cursor: default; }
button.secondary, .button.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
button.danger { background: var(--danger); color: #fff; }
button.small, .button.small { padding: 6px 12px; font-size: 13px; }
button.block { width: 100%; }

.error { color: #f28b82; min-height: 1.5em; margin: 8px 0 0; font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; }

/* ---------- layout ---------- */

.brand { font-weight: 800; font-size: 20px; color: var(--text); letter-spacing: -.02em; }
.brand span { color: var(--accent); }
.brand:hover { text-decoration: none; }

.center-page { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 22px; margin: 18px 0 20px; }
.auth-card .foot { margin: 18px 0 0; text-align: center; color: var(--muted); font-size: 14px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--panel);
}
.topbar nav { display: flex; align-items: center; gap: 14px; color: var(--muted); }
.container { max-width: 900px; margin: 0 auto; padding: 28px 24px 60px; }
.container h2 { font-size: 18px; margin: 0 0 14px; }
section + section { margin-top: 28px; }

.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > label { flex: 1 1 200px; margin-bottom: 0; }
.row > label.check { flex: 0 0 auto; padding-bottom: 10px; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 0; border-top: 1px solid var(--border);
}
.list > li:first-child { border-top: 0; }
.list .grow { flex: 1 1 240px; min-width: 0; }
.list .title { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.list .sub { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.list .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.list .empty { color: var(--muted); justify-content: center; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted);
}
.badge.live { background: rgba(52,168,83,.15); color: #81c995; }
.badge.pending { background: rgba(251,188,4,.15); color: #fdd663; }

#toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px);
  background: #e8eaed; color: #202124; padding: 10px 18px; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 100; font-size: 14px; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; width: min(440px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { margin: 0 0 18px; font-size: 18px; }
dialog .actions { display: flex; justify-content: flex-end; margin-top: 8px; }

/* ---------- video tiles ---------- */

.tile {
  position: relative; overflow: hidden; background: #202124;
  border-radius: var(--radius); min-width: 0; min-height: 0;
}
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.tile.self video { transform: scaleX(-1); }
.tile .avatar {
  position: absolute; inset: 0; display: none; place-items: center; background: #202124;
}
.tile .avatar span {
  width: 30%; max-width: 96px; min-width: 44px; aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center; font-size: clamp(18px, 4vw, 40px); font-weight: 600; color: #fff;
}
.tile.no-video .avatar { display: grid; }
.tile.no-video video { visibility: hidden; }
.tile .nameplate {
  position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px);
  display: flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 6px; background: rgba(0,0,0,.55); font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile .nameplate .mic-off { display: none; color: #f28b82; }
.tile.muted .nameplate .mic-off { display: inline-flex; }
.tile .status {
  position: absolute; top: 8px; left: 8px; font-size: 12px; color: var(--muted);
  background: rgba(0,0,0,.55); padding: 2px 8px; border-radius: 6px;
}

/* ---------- room page ---------- */

.room-page { overflow: hidden; }

.lobby {
  min-height: 100%; display: flex; align-items: center; justify-content: center;
  gap: 32px; padding: 24px; flex-wrap: wrap; align-content: center; overflow: auto; height: 100%;
}
.lobby-preview { width: min(640px, 100%); }
.lobby-preview .tile { aspect-ratio: 16 / 9; }
.lobby-preview .preview-controls { display: flex; justify-content: center; gap: 12px; margin-top: 14px; }
.lobby-form { width: min(360px, 100%); }
.lobby-form h1 { margin: 16px 0 4px; font-size: 24px; overflow-wrap: anywhere; }
.lobby-form .meta { color: var(--muted); margin: 0 0 20px; font-size: 14px; }

.ctl {
  width: 48px; height: 48px; padding: 0; border-radius: 50%;
  background: #3c4043; color: #fff; border: 0;
}
.ctl:hover { filter: brightness(1.15); }
.ctl.off { background: var(--danger); }
.ctl.active { background: var(--accent); color: var(--accent-ink); }
.ctl.leave { width: 64px; border-radius: 999px; background: var(--danger); }

.call { height: 100%; display: flex; flex-direction: column; }
.call-header {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 16px; color: var(--muted); font-size: 14px;
}
.call-header .room-title { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-header .count { display: inline-flex; align-items: center; gap: 4px; }
.grid {
  flex: 1; min-height: 0; display: grid; gap: 8px; padding: 0 12px;
  grid-template-columns: 1fr; grid-auto-rows: 1fr; position: relative;
}
.grid .waiting {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
  color: var(--muted); gap: 12px; pointer-events: none;
}
.grid .waiting button { pointer-events: auto; justify-self: center; }
.controls {
  display: flex; justify-content: center; align-items: center; gap: 12px;
  padding: 14px 12px 18px; flex-wrap: wrap;
}

.left-page { height: 100%; display: grid; place-items: center; text-align: center; padding: 24px; }
.left-page .actions { display: flex; gap: 12px; justify-content: center; margin-top: 18px; }

/* ---------- board game wall (landing background) ---------- */
/* Layout/overlay styles are set inline by public/js/board-wall.js; these are cosmetic. */

.board-wall-track img {
  border-radius: 6px; background: #1b1e25;
  opacity: 0; transition: opacity .8s ease;
}
.board-wall-track img.loaded { opacity: 1; }
.board-wall ~ .center-page .card { box-shadow: 0 20px 60px rgba(0,0,0,.55); }
.bg-credit {
  position: fixed; right: 12px; bottom: 8px; z-index: 1;
  font-size: 12px; color: rgba(232,234,237,.55);
}
.bg-credit a { color: inherit; text-decoration: underline; }

.credits h1 { margin: 18px 0 8px; }
.credits ul { padding-left: 18px; font-size: 13px; color: var(--muted); }
.credits li { margin: 3px 0; overflow-wrap: anywhere; }
