:root {
  --coral: #FF758C;
  --cyan: #56CFE1;
  --lime: #B8E986;
  --bg: #12101a;
  --surface: #1e1a2c;
  --surface-2: #2a2540;
  --text: #F0EFF5;
  --muted: #9B97AD;
  --danger: #e85d6a;
  --radius: 16px;
  --font: 'Golos Text', system-ui, sans-serif;
  --gradient: linear-gradient(135deg, var(--coral) 0%, var(--cyan) 55%, var(--lime) 100%);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

#app { min-height: 100%; }

/* ── Lobby ── */
.lobby {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem 3rem;
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(255, 117, 140, 0.18), transparent 55%),
    radial-gradient(ellipse 70% 45% at 90% 10%, rgba(86, 207, 225, 0.16), transparent 50%),
    var(--bg);
}

.lobby-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.15rem;
  margin-bottom: 1.75rem;
}

.lobby-brand img { border-radius: 10px; }

.lobby-card {
  width: min(420px, 100%);
  background: rgba(30, 26, 44, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  padding: 1.75rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.lobby-card--center { text-align: center; }

.lobby-card h1 {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.lobby-lead {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 1.25rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.field input {
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  background: var(--surface-2);
  border: 1.5px solid transparent;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  outline: none;
}

.field input:focus { border-color: rgba(86, 207, 225, 0.55); }

.preview-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  overflow: hidden;
  background: #0a0810;
  margin-bottom: 1rem;
}

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

.preview-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.9rem;
  pointer-events: none;
}

.preview-wrap.has-video .preview-placeholder { display: none; }

.lobby-toggles {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.toggle, .ctrl {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
}

.toggle svg, .ctrl svg { width: 22px; height: 22px; }
.toggle .icon-off, .ctrl .icon-off { display: none; }
.toggle[aria-pressed="false"], .ctrl[aria-pressed="false"] {
  background: rgba(232, 93, 106, 0.2);
  color: var(--danger);
}
.toggle[aria-pressed="false"] .icon-on,
.ctrl[aria-pressed="false"] .icon-on { display: none; }
.toggle[aria-pressed="false"] .icon-off,
.ctrl[aria-pressed="false"] .icon-off { display: block; }

.toggle:hover, .ctrl:hover { transform: scale(1.05); }

.lobby-error {
  color: var(--danger);
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}

.btn {
  display: inline-flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.95rem 1.25rem;
  border-radius: 14px;
  font: inherit;
  font-weight: 600;
  font-size: 1rem;
  border: none;
  cursor: pointer;
  text-decoration: none;
  margin-bottom: 0.65rem;
}

.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 8px 24px rgba(86, 207, 225, 0.25);
}

.btn-primary:disabled { opacity: 0.5; cursor: wait; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.lobby-back {
  display: block;
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
  text-decoration: none;
  margin-top: 0.5rem;
}

.lobby-back:hover { color: var(--cyan); }

/* ── Room ── */
.room {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #0c0a12;
}

.room-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: rgba(18, 16, 26, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
}

.room-bar__left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.room-bar__left img { border-radius: 8px; flex-shrink: 0; }

.room-bar__left strong {
  display: block;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-bar__left span {
  font-size: 0.75rem;
  color: var(--muted);
}

.btn-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-chip:hover { border-color: rgba(86, 207, 225, 0.45); }

.tiles {
  display: grid;
  gap: 0.65rem;
  padding: 0.75rem;
  align-content: center;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
}

.tiles[data-count="1"] {
  grid-template-columns: 1fr;
  max-width: 960px;
  margin-inline: auto;
  width: 100%;
}

.tiles[data-count="2"] {
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 700px) {
  .tiles[data-count="2"] { grid-template-columns: 1fr; }
}

.tile {
  position: relative;
  background: var(--surface);
  border-radius: 18px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  min-height: 180px;
}

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

.tile.is-local video { transform: scaleX(-1); }
.tile.is-local.is-sharing video { transform: none; }

.tile__label {
  position: absolute;
  left: 0.75rem;
  bottom: 0.75rem;
  padding: 0.3rem 0.65rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.55);
  font-size: 0.8rem;
  font-weight: 600;
  backdrop-filter: blur(6px);
}

.tile__avatar {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #2a2540, #1a1726);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--cyan);
}

.tile.cam-off .tile__avatar { display: flex; }
.tile.cam-off video { opacity: 0; }

.controls {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 1rem 1rem calc(1.25rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55), transparent);
}

/* Демонстрация экрана: pressed=true = идёт трансляция */
.ctrl--share .icon-off { display: none; }
.ctrl--share[aria-pressed="false"] {
  background: var(--surface-2);
  color: var(--text);
}
.ctrl--share[aria-pressed="false"] .icon-on { display: block; }
.ctrl--share[aria-pressed="false"] .icon-off { display: none; }
.ctrl--share[aria-pressed="true"] {
  background: rgba(86, 207, 225, 0.22);
  color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(86, 207, 225, 0.35);
}
.ctrl--share[aria-pressed="true"] .icon-on { display: none; }
.ctrl--share[aria-pressed="true"] .icon-off { display: block; }

.ctrl--hang {
  width: 64px;
  height: 52px;
  border-radius: 26px;
  background: var(--danger);
  color: #fff;
}

.ctrl--hang:hover { background: #d44a58; }

.toast {
  position: fixed;
  bottom: 5.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(37, 34, 53, 0.95);
  color: var(--text);
  padding: 0.65rem 1.1rem;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 50;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
