:root {
  --bg: #16151d;
  --panel: rgba(28, 26, 38, 0.92);
  --line: #332f45;
  --text: #ecebf3;
  --muted: #9b98ad;
  --accent: #9146ff;
  --accent-2: #b28bff;
  --ok: #3ecf8e;
  --danger: #ff5c6c;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input { font: inherit; }
[hidden] { display: none !important; }

#board { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#board.dragging { cursor: grabbing; }

#topbar { position: fixed; top: 0; left: 0; right: 0; height: 52px; display: flex; align-items: center; gap: 16px;
  padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 5; backdrop-filter: blur(6px); }
.brand { font-weight: 700; font-size: 17px; letter-spacing: .3px; }
.brand::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--accent); margin-right: 8px; }
#progress { flex: 1; display: flex; align-items: center; gap: 10px; max-width: 420px; }
#progress .bar { flex: 1; height: 8px; background: #2a273a; border-radius: 99px; overflow: hidden; }
#progressFill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .3s; }
#progressText { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 90px; }
#userBox { margin-left: auto; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
#userBox img { width: 28px; height: 28px; border-radius: 50%; }
#userBox a { color: var(--muted); text-decoration: none; }
#userBox a:hover { color: var(--text); }
#userBox a.admin { color: var(--accent-2); font-weight: 600; }

#sidebar { position: fixed; top: 64px; right: 12px; width: 240px; max-height: calc(100% - 76px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; z-index: 4; transition: transform .25s; }
#sidebarToggle { position: fixed; top: 64px; right: 262px; width: 26px; height: 32px; border: 1px solid var(--line);
  border-radius: 8px 0 0 8px; background: var(--panel); color: var(--text); cursor: pointer; z-index: 4; transition: right .25s; }
body.sb-collapsed #sidebar { transform: translateX(calc(100% + 12px)); }
body.sb-collapsed #sidebarToggle { right: 12px; }
#sidebar h3 { margin: 14px 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
#sidebar h3 span { color: var(--text); }
.tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.tab { flex: 1; padding: 5px; border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 7px; cursor: pointer; }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
#leaders, #completeLeaders { margin: 0; padding: 0 0 0 22px; }
#leaders li, #completeLeaders li { padding: 3px 0; }
#leaders li b, #completeLeaders li b { float: right; font-variant-numeric: tabular-nums; color: var(--accent-2); }
#leaders li.me { color: var(--accent-2); }
#leaders:empty::after { content: attr(data-empty); color: var(--muted); margin-left: -22px; display: block; }
#players { list-style: none; margin: 0; padding: 0; }
#players li { display: flex; align-items: center; gap: 7px; padding: 3px 0; }
#players img, #players .av { width: 20px; height: 20px; border-radius: 50%; background: #3a3550; flex: none; }
#players .mod { font-size: 10px; background: var(--ok); color: #062; border-radius: 4px; padding: 0 4px; }
.hint { color: var(--muted); font-size: 12px; margin: 14px 0 0; }

#loginBanner { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 6; width: min(420px, calc(100% - 32px)); }
.login-card h2 { margin: 0 0 6px; font-size: 20px; }
.btn.big { padding: 12px 22px; font-size: 16px; width: 100%; }
.muted { color: var(--muted); }
.login-card, .empty-card, .complete-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 20px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.login-card p { margin: 0 0 10px; }
#devForm { display: flex; gap: 6px; margin-top: 10px; }
#devForm input { flex: 1; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: #0f0e14; color: var(--text); }

.btn { display: inline-block; padding: 9px 16px; border-radius: 9px; border: 0; background: #3a3550; color: #fff;
  text-decoration: none; font-weight: 600; cursor: pointer; }
.btn:hover { filter: brightness(1.12); }
.btn.twitch { background: var(--accent); }

#empty, #complete { position: fixed; inset: 0; display: grid; place-items: center; z-index: 7; background: rgba(10,9,14,.55); }
#empty { background: transparent; pointer-events: none; }
.complete-card { min-width: 280px; }
.complete-card h2 { margin: 0 0 12px; font-size: 26px; }
.complete-card ol { text-align: left; margin-bottom: 14px !important; }

#message { position: fixed; inset: 0; display: grid; place-items: center; z-index: 20; background: rgba(10,9,14,.85);
  font-size: 18px; text-align: center; padding: 20px; }
#toast { position: fixed; left: 50%; top: 64px; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 9px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 10; }
#toast.show { opacity: 1; }

/* OBS overlejs: bez saskarnes */
body.overlay #topbar, body.overlay #loginBanner, body.overlay #toast, body.overlay #sidebarToggle, body.overlay .hint { display: none !important; }
body.overlay #sidebar { top: 12px; }

@media (max-width: 640px) {
  #progressText { min-width: 0; font-size: 12px; }
  .brand { display: none; }
  #sidebar { width: 200px; }
  #sidebarToggle { right: 222px; }
}

/* BRB ekrāns */
#brbCard { position: fixed; left: 24px; bottom: 24px; z-index: 6; width: 420px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px; padding: 18px 22px; box-shadow: 0 10px 40px rgba(0,0,0,.45); }
.brb-title { font-size: 26px; font-weight: 800; margin-bottom: 12px; }
.brb-bar { height: 14px; background: #2a273a; border-radius: 99px; overflow: hidden; }
#brbFill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s; }
.brb-row { display: flex; justify-content: space-between; margin: 8px 0 12px; font-size: 18px; font-variant-numeric: tabular-nums; }
#brbPct { font-weight: 800; color: var(--accent-2); }
.brb-join { font-size: 18px; color: var(--muted); }
.brb-join b { color: var(--text); }
body.overlay #sidebar { font-size: 16px; width: 280px; }
body.overlay #players, body.overlay #players + *, body.overlay #sidebar section:nth-child(2) { display: none; }

/* Skaņas poga */
.icon-btn { background: transparent; border: 1px solid var(--line); color: var(--text); border-radius: 8px; width: 34px; height: 32px;
  display: grid; place-items: center; cursor: pointer; margin-left: auto; }
.icon-btn:hover { background: #2a273a; }
.icon-btn .cross { display: none; }
.icon-btn.muted .cross { display: inline; }
.icon-btn.muted .wave { display: none; }
.icon-btn.muted { color: var(--muted); }
#muteBtn + #userBox { margin-left: 0; }

/* Atskaite */
#cdBox { margin: 6px 0 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.cd-label { color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: .6px; }
.cd-num { font-size: 64px; font-weight: 800; line-height: 1.1; color: var(--accent-2); font-variant-numeric: tabular-nums; }
#cdThumb { display: block; max-width: 220px; max-height: 120px; margin: 6px auto; border-radius: 8px; }
body.overlay #completeClose { display: none; }
body.overlay .complete-card { transform: scale(1.35); }

/* Pieslēgšanās lapa */
.cb-wrap { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; }
.cb-card { max-width: 420px; }
.cb-card h2 { margin: 0 0 8px; }

/* Moderatoru pogas spēlētāju sarakstā */
#players li, #bansList li { position: relative; }
.pl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-act { display: none; gap: 3px; }
#players li:hover .pl-act, #bansList .pl-act, .pl-act:focus-within { display: inline-flex; }
.pl-act button { font-size: 11px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line); background: #2a273a; color: var(--text); cursor: pointer; }
.pl-act button:hover { filter: brightness(1.2); }
.pl-act button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
#bansList { list-style: none; margin: 0; padding: 0; }
#bansList li { display: flex; align-items: center; gap: 7px; padding: 3px 0; }

/* Procenti līderu tabulā ("Šī puzle") */
.pct { font-weight: 500; color: var(--muted); margin-right: 8px; font-size: .9em; }
