/* FPSHeaven Meet
   Brand is white on black with a single red accent. No web fonts, no images,
   nothing loaded from anywhere else, so a strict CSP is satisfiable. */

:root {
  --black: #000000;
  --panel: #0d0d0f;
  --panel-2: #141418;
  --line: #232329;
  --white: #ffffff;
  --muted: #9a9aa4;
  --red: #e11d2e;
  --red-dim: #8f0f1c;
  --green: #21c46b;
  --amber: #f0a500;
  --radius: 12px;
  --bar: 64px;
  --sidebar: 320px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--black);
  color: var(--white);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body { overflow: hidden; }

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 100%;
}

/* ---------- bars ---------- */

.bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  min-height: 56px;
}

.bar-bottom {
  border-bottom: 0;
  border-top: 1px solid var(--line);
  justify-content: center;
  gap: 8px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.brand-mark {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--red);
  box-shadow: 0 0 12px rgba(225, 29, 46, 0.6);
}

.brand-name b { color: var(--red); font-weight: 700; }

.bar-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.pill.is-live .dot { background: var(--green); }
.pill.is-warn .dot { background: var(--amber); }
.pill.is-bad .dot { background: var(--red); }
.pill.is-live, .pill.is-warn, .pill.is-bad { color: var(--white); }

.timer { font-variant-numeric: tabular-nums; }

.bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.bars i {
  display: block;
  width: 3px;
  background: #3a3a42;
  border-radius: 1px;
}
.bars i:nth-child(1) { height: 5px; }
.bars i:nth-child(2) { height: 9px; }
.bars i:nth-child(3) { height: 12px; }
.quality.q1 .bars i:nth-child(1) { background: var(--red); }
.quality.q2 .bars i:nth-child(-n+2) { background: var(--amber); }
.quality.q3 .bars i { background: var(--green); }

/* ---------- lobby ---------- */

.lobby {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.lobby-inner {
  width: 100%;
  max-width: 520px;
  text-align: center;
}

.lobby-title { margin: 0 0 6px; font-size: 24px; }
.lobby-sub { margin: 0 0 20px; color: var(--muted); }

.preview {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}

.preview-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.preview-off, .local-off {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #08080a;
  color: var(--muted);
  font-size: 14px;
}

.devices {
  display: grid;
  gap: 10px;
  text-align: left;
  margin-bottom: 14px;
}

.field { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }

.field select {
  width: 100%;
  padding: 9px 10px;
  background: var(--panel-2);
  color: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
}

.field select:focus-visible, .btn:focus-visible, .ctrl:focus-visible,
.icon-btn:focus-visible, input:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

.lobby-toggles { display: flex; gap: 10px; justify-content: center; margin-bottom: 14px; }

.fineprint { color: var(--muted); font-size: 12px; margin-top: 14px; }

.notice {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--red-dim);
  border-left: 3px solid var(--red);
  border-radius: 8px;
  background: rgba(225, 29, 46, 0.08);
  text-align: left;
  font-size: 14px;
}

/* ---------- buttons ---------- */

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--white);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover:not(:disabled) { border-color: #3a3a42; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--red); border-color: var(--red); }
.btn.primary:hover:not(:disabled) { background: #f52a3c; border-color: #f52a3c; }
.btn.big { width: 100%; padding: 14px 18px; font-size: 16px; }
.btn.small { padding: 8px 12px; font-size: 13px; }
.btn.ghost[aria-pressed="false"] { color: var(--muted); border-style: dashed; }

.icon-btn {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}

.ctrl {
  appearance: none;
  min-width: 78px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--white);
  cursor: pointer;
  font-size: 12px;
}

.ctrl:hover { border-color: #3a3a42; }
.ctrl-icon { font-size: 11px; font-weight: 700; letter-spacing: 0.6px; color: var(--muted); }
.ctrl-label { font-size: 12px; position: relative; }
.ctrl[aria-pressed="false"] { background: #1c1216; border-color: var(--red-dim); }
.ctrl[aria-pressed="false"] .ctrl-icon { color: var(--red); }
.ctrl.accent[aria-pressed="true"] { background: var(--red); border-color: var(--red); }
.ctrl.accent[aria-pressed="true"] .ctrl-icon { color: #fff; }
.ctrl.danger { background: var(--red); border-color: var(--red); }
.ctrl.danger .ctrl-icon { color: #fff; }

.badge {
  position: absolute;
  top: -8px;
  right: -14px;
  min-width: 16px;
  padding: 0 4px;
  background: var(--red);
  border-radius: 999px;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
}

/* ---------- stage ---------- */

.stage {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.videos {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  background: #050506;
}

.remote-wrap { position: absolute; inset: 0; }

.remote-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #050506;
}

.remote-badge, .remote-muted {
  position: absolute;
  left: 14px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid var(--line);
  font-size: 12px;
}

.remote-badge { top: 14px; border-color: var(--red-dim); color: var(--red); }
.remote-muted { bottom: 14px; color: var(--muted); }

.local-wrap {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 24%;
  min-width: 130px;
  max-width: 260px;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.6);
}

.local-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.local-wrap.sharing .local-video { transform: none; object-fit: contain; }

.local-tag {
  position: absolute;
  left: 8px;
  bottom: 6px;
  font-size: 11px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.6);
  padding: 2px 6px;
  border-radius: 4px;
}

.waiting {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 24px;
  background: radial-gradient(60% 60% at 50% 45%, #16161a 0%, #050506 100%);
}

.waiting-title { margin: 0; font-size: 17px; font-weight: 600; }
.waiting-sub { margin: 0; color: var(--muted); font-size: 14px; max-width: 420px; }

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid #26262c;
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
}

/* ---------- sidebar ---------- */

.sidebar {
  flex: 0 0 var(--sidebar);
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-left: 1px solid var(--line);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px 10px 14px;
  border-bottom: 1px solid var(--line);
}

.sidebar-head h2 { margin: 0; font-size: 15px; }

.chat-log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg { max-width: 100%; }
.msg .who { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.msg .body {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.msg.mine .who { text-align: right; }
.msg.mine .body { background: #1c0f12; border-color: var(--red-dim); }
.msg.system .body {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 2px;
}

.chat-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
}

.chat-form input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 9px 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--white);
  font-size: 14px;
}

/* ---------- device popover ---------- */

.devices-pop {
  position: fixed;
  right: 12px;
  bottom: calc(var(--bar) + 18px);
  width: min(320px, calc(100vw - 24px));
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  z-index: 30;
}

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  left: 50%;
  top: 70px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 40;
  pointer-events: none;
  width: min(420px, calc(100vw - 24px));
}

.toast {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

/* ---------- fatal ---------- */

.fatal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.9);
}

.fatal-card {
  width: 100%;
  max-width: 460px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--red);
  border-radius: var(--radius);
  padding: 22px;
}

.fatal-card h2 { margin: 0 0 10px; font-size: 19px; }
.fatal-card p { margin: 0 0 10px; color: #d8d8de; }
.fatal-hint { color: var(--muted) !important; font-size: 13px; }
.fatal-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

/* ---------- responsive ---------- */

@media (max-width: 780px) {
  .sidebar {
    position: absolute;
    inset: 0;
    width: 100%;
    flex-basis: auto;
    z-index: 20;
    border-left: 0;
  }
  .stage { position: relative; }
  .local-wrap { width: 34%; min-width: 108px; }
  .ctrl { min-width: 0; flex: 1 1 0; padding: 7px 4px; }
  .ctrl-label { font-size: 11px; }
  .bar-top { flex-wrap: wrap; row-gap: 6px; padding: 8px 12px; }
  .brand { margin-right: 8px; }
}
