:root {
  color-scheme: dark;
  --bg: #09090f;
  --bg-deep: #050509;
  --surface: #14151d;
  --surface-2: #1b1d28;
  --surface-3: #0f1017;
  --line: #303243;
  --line-soft: #222433;
  --text: #f7f7fb;
  --muted: #a8adbd;
  --quiet: #747b8f;
  --accent: #52a8ff;
  --accent-2: #ff4ecd;
  --accent-3: #ffcf5c;
  --ok: #35e4ad;
  --danger: #ff5c7a;
  --warn: #ffb84d;
  --shadow: 0 24px 72px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(82, 168, 255, 0.12), transparent 34%),
    linear-gradient(225deg, rgba(255, 78, 205, 0.1), transparent 38%),
    linear-gradient(180deg, rgba(255, 207, 92, 0.045), transparent 46%),
    var(--bg);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 18px);
  background-size: 84px 84px, 84px 84px, auto;
  opacity: 0.54;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.92), rgba(0, 0, 0, 0.36) 64%, transparent);
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--text);
  background: linear-gradient(180deg, #222432, #161821);
  cursor: pointer;
  font-weight: 850;
  letter-spacing: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease,
    opacity 140ms ease;
}

button:hover:not(:disabled) {
  border-color: rgba(82, 168, 255, 0.72);
  background: linear-gradient(180deg, #282a3a, #1a1c27);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 10px 30px rgba(82, 168, 255, 0.12);
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  color: var(--text);
  background: rgba(6, 7, 12, 0.82);
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

input::placeholder {
  color: #6f7688;
}

input:focus {
  outline: 3px solid rgba(82, 168, 255, 0.18);
  border-color: var(--accent);
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(255, 78, 205, 0.24);
  outline-offset: 2px;
}

.chat-form input {
  font-weight: 750;
}

.is-hidden {
  display: none !important;
}

.primary {
  border-color: transparent;
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 950;
  box-shadow:
    0 16px 42px rgba(82, 168, 255, 0.18),
    0 10px 34px rgba(255, 78, 205, 0.13);
}

.primary:hover:not(:disabled) {
  border-color: transparent;
  background: linear-gradient(135deg, #69b6ff, #ff65d5);
}

.lobby {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 30px 16px;
}

.lobby-shell {
  position: relative;
  z-index: 1;
  width: min(1100px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 26px;
  align-items: center;
}

.lobby-hero {
  padding: 18px 0;
}

.lobby-hero h1 {
  max-width: 760px;
  margin: 16px 0 0;
  font-size: clamp(2.7rem, 7vw, 6.15rem);
  line-height: 0.9;
  letter-spacing: 0;
  text-wrap: balance;
}

.lobby-copy {
  max-width: 520px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.5;
  font-weight: 760;
}

.lobby-card {
  padding: 18px;
}

.lobby-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.big-action {
  min-height: 64px;
  font-size: 1rem;
}

.setup-form {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}

.lobby-status {
  min-height: 22px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 850;
}

.app {
  position: relative;
  z-index: 1;
  width: min(1540px, calc(100vw - 28px));
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr) 250px;
  gap: 16px;
  padding: 18px 0;
}

.sidebar,
.rightbar {
  display: grid;
  align-content: start;
  gap: 14px;
}

.sidebar,
.rightbar {
  position: sticky;
  top: 18px;
  max-height: calc(100dvh - 36px);
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.rightbar {
  grid-template-rows: auto auto;
}

.sidebar {
  height: calc(100dvh - 36px);
  grid-template-rows: auto auto minmax(220px, 1fr) auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
}

.brand.compact {
  padding: 0 2px;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  color: #ffffff;
  background:
    linear-gradient(135deg, rgba(82, 168, 255, 0.95), rgba(255, 78, 205, 0.95)),
    var(--surface-2);
  font-size: 1.35rem;
  font-weight: 1000;
  box-shadow:
    0 16px 42px rgba(82, 168, 255, 0.16),
    0 10px 34px rgba(255, 78, 205, 0.12);
}

.brand h1,
.brand h2,
.stage-header h2,
.panel-heading h3 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 1.65rem;
  line-height: 1;
}

.brand h2 {
  max-width: 240px;
  overflow: hidden;
  font-size: 1.22rem;
  line-height: 1.08;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-3);
  font-size: 0.71rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(26, 28, 39, 0.96), rgba(14, 15, 22, 0.96)),
    var(--surface);
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3));
  opacity: 0.86;
}

.profile-panel,
.room-panel,
.voice-panel,
.members-panel,
.chat-panel {
  padding: 16px;
}

.section-title {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 850;
}

.room-code {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(82, 168, 255, 0.08), rgba(255, 78, 205, 0.06)),
    rgba(5, 6, 10, 0.74);
}

.room-code span,
label {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 780;
}

.room-code strong {
  color: var(--accent-3);
  font-size: 2rem;
  line-height: 1;
  letter-spacing: 0.08em;
  text-shadow: 0 0 24px rgba(255, 207, 92, 0.25);
}

.profile-name {
  display: block;
  overflow: hidden;
  color: var(--accent);
  font-size: 1.08rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.split-actions,
.join-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 10px;
}

.stage {
  min-width: 0;
  min-height: calc(100dvh - 36px);
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr) auto;
  gap: 14px;
}

.stage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 13px 15px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(12, 13, 20, 0.82);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.stage-header h2 {
  overflow: hidden;
  max-width: min(680px, 54vw);
  font-size: clamp(1.4rem, 3vw, 2.75rem);
  line-height: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.status {
  flex: 0 0 auto;
  max-width: 48%;
  overflow: hidden;
  padding: 8px 11px;
  border: 1px solid rgba(82, 168, 255, 0.34);
  border-radius: 999px;
  color: var(--accent);
  background: rgba(82, 168, 255, 0.1);
  font-size: 0.82rem;
  font-weight: 950;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.screen-frame {
  position: relative;
  min-height: 360px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(82, 168, 255, 0.08), rgba(255, 78, 205, 0.06) 42%, transparent),
    linear-gradient(180deg, #090a10, #020306);
  box-shadow:
    0 26px 90px rgba(0, 0, 0, 0.44),
    inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.screen-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.28;
  z-index: 1;
}

.screen-frame:fullscreen {
  border: 0;
  border-radius: 0;
  background: #000;
}

#screenVideo {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 360px;
  background: transparent;
  object-fit: contain;
}

.screen-frame:fullscreen #screenVideo {
  width: 100vw;
  height: 100vh;
}

.fullscreen-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 4;
  min-height: 36px;
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(8, 9, 14, 0.7);
  backdrop-filter: blur(14px);
  color: var(--text);
  font-size: 0.74rem;
  text-transform: uppercase;
}

.fullscreen-btn:hover:not(:disabled) {
  border-color: rgba(255, 78, 205, 0.55);
}

.stream-audio-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 4;
  display: grid;
  grid-template-columns: 36px auto 36px auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(8, 9, 14, 0.74);
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
}

.stream-audio-controls button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.78rem;
}

#streamVolumeDown,
#streamVolumeUp {
  width: 34px;
  padding: 0;
  font-size: 1rem;
}

#streamVolumeLevel {
  min-width: 44px;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 900;
  text-align: center;
}

.screen-empty {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.screen-empty strong {
  color: var(--text);
  font-size: clamp(1.35rem, 3vw, 2.6rem);
  letter-spacing: 0;
  text-wrap: balance;
}

.screen-empty small {
  color: var(--muted);
  font-weight: 760;
}

.screen-frame.has-stream .screen-empty {
  display: none;
}

.pulse-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--accent-2);
  box-shadow:
    0 0 0 8px rgba(255, 78, 205, 0.09),
    0 0 30px rgba(255, 78, 205, 0.58);
}

.stage-actions,
.voice-actions {
  display: grid;
  gap: 10px;
}

.stage-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.panel-heading h3 {
  font-size: 1.12rem;
}

.dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 999px;
  background: #555b6d;
  box-shadow: 0 0 0 6px rgba(85, 91, 109, 0.12);
}

.dot.live {
  background: var(--ok);
  box-shadow:
    0 0 0 6px rgba(53, 228, 173, 0.12),
    0 0 24px rgba(53, 228, 173, 0.45);
}

.voice-actions {
  margin-top: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.member-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  overflow: visible;
}

.chat-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(160px, 1fr) auto;
}

.chat-messages {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 160px;
  max-height: none;
  margin-top: 14px;
  padding-right: 4px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.chat-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 760;
}

.chat-message {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(5, 6, 10, 0.62);
}

.chat-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--quiet);
  font-size: 0.74rem;
  font-weight: 900;
}

.chat-name {
  overflow: hidden;
  color: var(--accent);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chat-text {
  margin: 0;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.36;
  overflow-wrap: anywhere;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 12px;
}

.member {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 32px;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(18, 20, 29, 0.74);
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.member.not-in-voice {
  border-color: rgba(255, 255, 255, 0.06);
  background: linear-gradient(180deg, rgba(30, 32, 42, 0.72), rgba(16, 17, 24, 0.72));
}

.member.in-voice {
  border-color: rgba(82, 168, 255, 0.42);
  background:
    linear-gradient(135deg, rgba(82, 168, 255, 0.18), rgba(255, 78, 205, 0.12)),
    rgba(10, 12, 20, 0.86);
  box-shadow:
    inset 3px 0 0 var(--ok),
    0 10px 28px rgba(82, 168, 255, 0.08);
}

.member.in-voice .member-name {
  color: #ffffff;
}

.member.not-in-voice .avatar {
  background: linear-gradient(135deg, rgba(93, 98, 114, 0.86), rgba(56, 60, 74, 0.86));
  color: #d9dce6;
}

.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(135deg, rgba(82, 168, 255, 0.82), rgba(255, 78, 205, 0.72));
  font-weight: 1000;
}

.member-main {
  min-width: 0;
}

.member-name {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-weight: 900;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
}

.badge {
  padding: 3px 6px;
  border: 1px solid rgba(82, 168, 255, 0.3);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(82, 168, 255, 0.08);
  font-size: 0.7rem;
  font-weight: 900;
}

.badge.live {
  border-color: rgba(53, 228, 173, 0.38);
  color: var(--ok);
  background: rgba(53, 228, 173, 0.08);
}

.badge.owner {
  border-color: rgba(255, 207, 92, 0.38);
  color: var(--accent-3);
  background: rgba(255, 207, 92, 0.08);
}

.badge.danger {
  border-color: rgba(255, 92, 122, 0.34);
  color: var(--danger);
  background: rgba(255, 92, 122, 0.08);
}

.member-menu-wrap {
  position: relative;
  justify-self: end;
}

.member-menu-button {
  display: grid;
  place-items: center;
  width: 32px;
  min-height: 32px;
  padding: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
}

.member-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 8;
  display: none;
  width: 178px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(9, 10, 15, 0.96);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.42);
}

.member-menu-wrap.is-open .member-menu {
  display: grid;
  gap: 7px;
}

.member-menu button {
  justify-content: start;
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.78rem;
}

.member-volume-row {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  align-items: center;
  gap: 6px;
}

.member-volume-row button {
  justify-content: center;
  padding: 0;
}

.member-volume-row span,
.member-menu-note {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-align: center;
}

.member-menu-note {
  display: block;
  padding: 7px 4px;
  text-align: left;
}

@media (max-width: 1100px) {
  .app {
    grid-template-columns: 310px minmax(0, 1fr);
  }

  .lobby-shell {
    grid-template-columns: 1fr;
    max-width: 720px;
  }

  .rightbar {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }

  .chat-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  body::before {
    background-size: 56px 56px, 56px 56px, auto;
  }

  .lobby {
    padding: 18px 12px;
  }

  .lobby-shell {
    gap: 18px;
  }

  .lobby-hero h1 {
    font-size: clamp(2.35rem, 15vw, 4.15rem);
  }

  .app {
    width: min(100% - 20px, 680px);
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 10px 0;
  }

  .sidebar,
  .rightbar {
    position: static;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .stage {
    order: 1;
  }

  .rightbar {
    order: 2;
  }

  .sidebar {
    order: 3;
  }

  .rightbar {
    grid-template-columns: 1fr;
  }

  .stage {
    min-height: auto;
    grid-template-rows: auto minmax(320px, 56vh) auto;
  }

  .stage-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .stage-header h2,
  .status {
    max-width: 100%;
  }

  .screen-frame,
  #screenVideo {
    min-height: 320px;
  }

  .stage-actions,
  .voice-actions,
  .split-actions,
  .join-form,
  .lobby-actions,
  .chat-form {
    grid-template-columns: 1fr;
  }

  .stream-audio-controls {
    left: 12px;
    right: 12px;
    grid-template-columns: 36px 1fr 36px;
  }

  #streamMute {
    grid-column: 1 / -1;
  }
}
