:root {
  --bg: #14101c;
  --panel: #1e1729;
  --panel2: #261d35;
  --accent: #e8b13a;
  --accent2: #c0392b;
  --text: #f0e9dd;
  --muted: #9a8fb0;
  --ok: #4caf7d;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
}

/* ── верхняя панель ── */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 8px 16px; background: var(--panel);
  border-bottom: 2px solid var(--accent);
  flex-shrink: 0;
}
.logo { font-size: 1.25rem; letter-spacing: .5px; }
.logo b { color: var(--accent); }
.table-select { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.table-select select {
  background: var(--panel2); color: var(--text);
  border: 1px solid #3a2f52; border-radius: 6px; padding: 6px 10px;
}
.controls { margin-left: auto; display: flex; gap: 8px; }
.btn {
  background: var(--panel2); color: var(--text);
  border: 1px solid #3a2f52; border-radius: 8px;
  padding: 8px 14px; cursor: pointer; font-size: .9rem;
  transition: all .15s;
}
.btn:hover { border-color: var(--accent); }
.btn.on { background: var(--accent); color: #1a1208; border-color: var(--accent); font-weight: 600; }
.btn.off { background: var(--accent2); color: #fff; border-color: var(--accent2); }
.btn.small { padding: 8px 12px; }

/* ── основная область ── */
.layout { display: flex; flex: 1; min-height: 0; }
.game-pane { flex: 1; min-width: 0; }
.game-pane iframe { width: 100%; height: 100%; border: 0; background: #fff; }

.video-pane {
  width: 320px; flex-shrink: 0;
  background: var(--panel); border-left: 1px solid #3a2f52;
  display: flex; flex-direction: column; padding: 10px; gap: 10px;
}
.pane-title { font-size: .95rem; color: var(--muted); }
.video-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  align-content: start; overflow-y: auto; flex: 1;
}
.tile {
  position: relative; aspect-ratio: 4/3;
  background: var(--panel2); border-radius: 10px; overflow: hidden;
  border: 1px solid #3a2f52;
}
.tile video { width: 100%; height: 100%; object-fit: cover; }
.tile .name {
  position: absolute; bottom: 4px; left: 6px;
  font-size: .75rem; background: rgba(0,0,0,.55);
  padding: 2px 6px; border-radius: 4px;
}
.tile.muted-cam::after {
  content: '🎥'; position: absolute; top: 4px; right: 6px; opacity: .8;
}
.placeholder {
  grid-column: 1 / -1; aspect-ratio: auto; height: 100px;
  display: flex; align-items: center; justify-content: center;
  text-align: center; color: var(--muted); font-size: .8rem;
}

/* ── чат ── */
.chat-box { display: flex; flex-direction: column; height: 180px; flex-shrink: 0; }
.chat-log {
  flex: 1; overflow-y: auto; background: var(--panel2);
  border-radius: 8px 8px 0 0; padding: 8px; font-size: .8rem;
}
.chat-log b { color: var(--accent); }
.chat-log div { margin-bottom: 4px; }
.chat-form { display: flex; gap: 6px; }
.chat-form input {
  flex: 1; background: var(--panel2); border: 1px solid #3a2f52;
  border-radius: 0 0 0 8px; color: var(--text); padding: 8px 10px; outline: none;
}
.chat-form input:focus { border-color: var(--accent); }
.chat-form .btn { border-radius: 0 0 8px 0; }

/* ── статус-бар ── */
.statusbar {
  display: flex; gap: 20px; align-items: center;
  padding: 6px 16px; background: var(--panel);
  border-top: 1px solid #3a2f52; font-size: .8rem; color: var(--muted);
  flex-shrink: 0;
}
.statusbar .hint { margin-left: auto; opacity: .6; }
#stConn.ok { color: var(--ok); }

/* ── мобильный ── */
@media (max-width: 760px) {
  .layout { position: relative; }
  .video-pane {
    position: absolute; right: 0; bottom: 0; width: 100%;
    height: 42%; border-left: 0; border-top: 1px solid #3a2f52;
    border-radius: 14px 14px 0 0; z-index: 10;
  }
  .game-pane iframe { height: 58%; }
}
