:root {
  --bg: #0b0b0f;
  --panel: #15151c;
  --border: #2a2a36;
  --accent: #6d5efc;
  --danger: #ff4d4f;
  --text: #f3f3f7;
  --muted: #9a9ab0;
  --ok: #34d399;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
}
.hidden { display: none !important; }

/* --------------------------------- Лобби --------------------------------- */
#lobby {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  padding-top: calc(24px + env(safe-area-inset-top));
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}
.brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 6px; }
.brand img { width: 84px; height: 84px; border-radius: 22px; }
.brand h1 { font-size: 24px; margin: 0; font-weight: 650; letter-spacing: -0.02em; }
.brand p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; text-align: center; }

.btn {
  appearance: none;
  border: none;
  border-radius: 14px;
  padding: 16px 20px;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  width: 100%;
  max-width: 340px;
  cursor: pointer;
  transition: transform .06s ease, opacity .15s ease;
}
.btn.secondary { background: var(--panel); color: var(--text); border: 1px solid var(--border); }
.btn:active { transform: scale(.98); }

.divider { width: 100%; max-width: 340px; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.field { display: flex; gap: 8px; width: 100%; max-width: 340px; }
.field input {
  flex: 1; min-width: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--text);
  font-size: 16px;
}
.field input::placeholder { color: var(--muted); }
.field input:focus { outline: none; border-color: var(--accent); }
.field .btn { width: auto; padding: 14px 18px; }

.hint { color: var(--muted); font-size: 13px; line-height: 1.5; text-align: center; max-width: 340px; }

/* --------------------------------- Звонок -------------------------------- */
#call { position: fixed; inset: 0; background: #000; }

#remoteVideo {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  background: #000;
}
#localVideo {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  width: 104px; height: 150px;
  object-fit: cover;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, .25);
  background: #111;
  z-index: 3;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
}
#localVideo.mirror { transform: scaleX(-1); }

.status {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  left: 50%; transform: translateX(-50%);
  background: rgba(0, 0, 0, .45);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  padding: 7px 14px; border-radius: 999px;
  font-size: 13px; color: #fff; z-index: 4;
  display: flex; align-items: center; gap: 8px;
  max-width: calc(100% - 150px);
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status.connected::before { background: var(--ok); }

.stats {
  position: absolute;
  top: calc(52px + env(safe-area-inset-top));
  left: 50%; transform: translateX(-50%);
  background: rgba(0, 0, 0, .5);
  padding: 6px 12px; border-radius: 10px;
  font-size: 12px; color: #cfcfe0; z-index: 4;
  font-variant-numeric: tabular-nums;
}

.share-row {
  position: absolute;
  left: 50%; transform: translateX(-50%);
  bottom: calc(112px + env(safe-area-inset-bottom));
  z-index: 5;
  width: calc(100% - 40px); max-width: 340px;
}

.controls {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center; gap: 14px;
  padding: 20px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 5;
  background: linear-gradient(to top, rgba(0, 0, 0, .6), transparent);
}
.ctrl {
  width: 58px; height: 58px; border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, .16);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform .06s ease, background .15s ease;
}
.ctrl svg { width: 26px; height: 26px; }
.ctrl:active { transform: scale(.92); }
.ctrl.off { background: #fff; color: #111; }
.ctrl.danger { background: var(--danger); }
