@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap");

:root {
  /* Neutral charcoal surfaces — blue lives only in the accents */
  --bg: #0b0d12;
  --bg-raised: #12151c;
  --bg-panel: #181c25;
  --surface: rgba(18, 21, 28, 0.82);
  --surface-strong: rgba(21, 24, 32, 0.95);
  --border: rgba(255, 255, 255, 0.1);
  --text: #f2f4f8;
  --text-dim: #99a1b0;
  --primary: #3c7bf4;
  --primary-hover: #5b8ffc;
  --secondary: #805cf7;
  --accent: #4f46e5;
  --primary-gradient: linear-gradient(135deg, var(--primary) 0%, #5b8ffc 45%, var(--secondary) 100%);
  --danger: #ef4444;
  --danger-hover: #f55b5b;
  --success: #22c55e;
  --radius: 16px;
  font-family: "Poppins", sans-serif;
}

:root[data-theme="light"] {
  --bg: #f8f9fb;
  --bg-raised: #ffffff;
  --bg-panel: #f1f3f6;
  --surface: rgba(255, 255, 255, 0.85);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --border: #e5e8ee;
  --text: #171b22;
  --text-dim: #68707e;
  --text-strong: #0e1218;
  --primary: #3c7bf4;
  --primary-hover: #245fe2;
  --secondary: #805cf7;
  --accent: #4f46e5;
  --primary-gradient: linear-gradient(135deg, var(--primary) 0%, #4a8cff 45%, var(--secondary) 100%);
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #16a34a;
}

:root[data-theme="light"] .lobby__card {
  background: rgba(255, 255, 255, 0.6);
  border-color: rgba(16, 24, 40, 0.09);
  box-shadow: 0 24px 64px rgba(16, 24, 40, 0.08);
}

:root[data-theme="light"] .option-card {
  background-color: #ffffff;
  border-color: rgba(16, 24, 40, 0.08);
}

:root[data-theme="light"] .panel__title {
  color: var(--text-strong);
}

:root[data-theme="light"] .lobby__card,
:root[data-theme="light"] .panel__title,
:root[data-theme="light"] .hero__pill,
:root[data-theme="light"] .hero__stat,
:root[data-theme="light"] .lobby__features li {
  color: var(--text);
}

:root[data-theme="light"] .panel__title {
  color: var(--text-strong);
}

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

body {
  background:
    radial-gradient(circle at top left, rgba(60, 123, 244, 0.06), transparent 30%),
    radial-gradient(circle at bottom right, rgba(128, 92, 247, 0.07), transparent 34%),
    linear-gradient(135deg, var(--bg), var(--bg-raised));
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.page-shell {
  min-height: 100dvh;
}

.topbar {
  width: min(1120px, calc(100% - 2rem));
  margin: 0.75rem auto 0;
  padding: 0.55rem 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0.75rem;
  z-index: 60;
  /* Glass bar: content scrolling underneath stays visible through it */
  background: rgba(15, 17, 23, 0.4);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  box-shadow: 0 12px 36px rgba(6, 12, 28, 0.25);
}

:root[data-theme="light"] .topbar {
  background: rgba(255, 255, 255, 0.45);
  border-color: rgba(16, 24, 40, 0.08);
  box-shadow: 0 12px 36px rgba(16, 24, 40, 0.06);
}

.brand--nav {
  font-size: 1.05rem;
  text-decoration: none;
}

.topbar__nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar__nav a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  /* Keeps the links readable where the bright hero image passes
     behind the transparent bar */
  text-shadow: 0 1px 10px rgba(7, 17, 31, 0.65);
  transition: background-color 0.18s ease, color 0.18s ease;
}

:root[data-theme="light"] .topbar__nav a {
  text-shadow: none;
}

.topbar__nav a:hover {
  background-color: var(--bg-panel);
  color: var(--text);
}

.btn--nav {
  padding: 0.55rem 1rem;
  font-size: 0.88rem;
  border-radius: 999px;
  margin-left: 0.35rem;
  white-space: nowrap;
}

.theme-toggle {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background-color: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.18s ease, background-color 0.18s ease;
}

.theme-toggle:hover {
  transform: translateY(-1px);
  background-color: var(--bg-panel);
}

.hidden {
  display: none !important;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

.brand i,
.brand__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 0.8rem;
  color: #fff;
  background: var(--primary-gradient);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 10px 24px rgba(60, 123, 244, 0.24);
}

.brand__icon {
  object-fit: cover;
  padding: 0.18rem;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1.5rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.btn--primary {
  background: var(--primary-gradient);
  color: #fff;
  box-shadow: 0 12px 26px rgba(60, 123, 244, 0.22);
}

.btn--primary:hover:not(:disabled) {
  filter: brightness(1.04);
}

.btn--primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---------- Animations ---------- */

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes tilePop {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes tileOut {
  to {
    opacity: 0;
    transform: scale(0.94);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

.btn__spinner {
  display: none;
  width: 15px;
  height: 15px;
  margin-right: 0.55rem;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -2px;
}

.btn:disabled .btn__spinner {
  display: inline-block;
}

/* ---------- Lobby ---------- */

.lobby {
  position: relative;
  min-height: calc(100dvh - 72px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0.25rem 1.5rem 2rem;
  /* No overflow clipping here: the page scrolls via <body>, and the
     corner illustration must extend up beneath the glass topbar
     instead of being cut off with a hard line. */
  background: transparent;
}

@keyframes orbFloat {
  from {
    transform: translate(0, 0) scale(1);
  }
  to {
    transform: translate(70px, 45px) scale(1.18);
  }
}

.lobby__orbs {
  /* Cover the whole viewport (not just the lobby section) so the
     glow fades naturally with no hard edge behind the topbar. */
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.lobby__orbs span {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  animation: orbFloat 16s ease-in-out infinite alternate;
}

.lobby__orbs span:nth-child(1) {
  width: 460px;
  height: 460px;
  top: -140px;
  left: -100px;
  background-color: rgba(47, 128, 236, 0.12);
}

.lobby__orbs span:nth-child(2) {
  width: 420px;
  height: 420px;
  right: -120px;
  bottom: -140px;
  background-color: rgba(139, 92, 246, 0.09);
  animation-delay: -6s;
}

.lobby__orbs span:nth-child(3) {
  width: 300px;
  height: 300px;
  left: 42%;
  top: 55%;
  background-color: rgba(34, 197, 163, 0.12);
  animation-delay: -11s;
}

.lobby__layout {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  width: 100%;
  max-width: 1120px;
  margin: 1.5rem auto 0;
  padding: 0 1rem;
}

.lobby__hero {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  animation: fadeInUp 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Product shot pinned to the top-right corner, floating behind the
   glass card like a modern SaaS hero. Decorative only. */
@keyframes heroFloat {
  from {
    transform: rotate(2.5deg) translateY(0);
  }
  to {
    transform: rotate(2.5deg) translateY(-14px);
  }
}

.lobby__illustration {
  position: absolute;
  top: -96px;
  right: -130px;
  width: min(42vw, 600px);
  z-index: 0;
  pointer-events: none;
  animation: heroFloat 8s ease-in-out infinite alternate;
}

.lobby__illustration::before {
  content: "";
  position: absolute;
  inset: 10% 6%;
  background: radial-gradient(closest-side, rgba(92, 84, 245, 0.18), transparent 75%);
  filter: blur(60px);
  z-index: -1;
}

.lobby__illustration img {
  width: 100%;
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 34px 90px rgba(6, 12, 28, 0.5);
  transition: transform 0.2s ease-out;
  will-change: transform;
}

:root[data-theme="light"] .lobby__illustration img {
  box-shadow: 0 34px 90px rgba(16, 24, 40, 0.14);
  border-color: rgba(16, 24, 40, 0.12);
}

.brand--lg {
  font-size: 1.45rem;
  margin-bottom: 0.4rem;
}

.hero__pill {
  display: inline-flex;
  width: max-content;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(60, 123, 244, 0.14), rgba(128, 92, 247, 0.14));
  color: var(--text);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  backdrop-filter: blur(10px);
}

.hero__pill i {
  color: var(--secondary);
}

.lobby__greeting {
  font-size: clamp(2rem, 3vw, 3rem);
  font-weight: 700;
  line-height: 1.1;
}

.lobby__tagline {
  color: var(--text-dim);
  font-size: 0.98rem;
  line-height: 1.7;
  max-width: 560px;
}

/* Open stat row — values separated by thin dividers, no boxes */
.hero__stats {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  margin-top: 0.3rem;
}

.hero__stat {
  padding: 0;
}

.hero__stat + .hero__stat {
  border-left: 1px solid var(--border);
  padding-left: 1.4rem;
}

.hero__stat strong {
  display: block;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

.hero__stat span {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.hero__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.btn--secondary {
  background-color: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn--secondary:hover:not(:disabled) {
  background-color: var(--bg-panel);
}

.lobby__features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.4rem;
}

/* Plain checklist items — icons carry the accent, no pill boxes */
.lobby__features li {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--text-dim);
  font-size: 0.92rem;
  padding: 0.25rem 0;
  width: fit-content;
  max-width: 100%;
}

.lobby__features i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(60, 123, 244, 0.16), rgba(128, 92, 247, 0.18));
  color: var(--primary);
  font-size: 0.78rem;
}

.lobby__dev {
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-dim);
}

.lobby__dev a {
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
  transition: color 0.18s ease;
}

.lobby__dev a:hover {
  color: var(--primary-hover);
}

.lobby__dev a i {
  color: #0a66c2;
  margin: 0 0.2rem 0 0.3rem;
  font-size: 1rem;
  vertical-align: -1px;
}

.lobby__card {
  grid-column: 2;
  justify-self: end;
  align-self: start;
  /* Sit just below the corner illustration (whose height tracks its
     width) so the card never covers the image. */
  margin-top: calc(min(42vw, 600px) * 0.8 - 72px);
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 440px;
  /* Translucent glass: whatever sits behind (the corner illustration)
     stays visible through the card. */
  background: rgba(17, 19, 26, 0.55);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 24px 64px rgba(6, 12, 28, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: fadeInUp 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.lobby__hero {
  position: relative;
  z-index: 1;
}

/* Open, centered prose section — no container box */
.landing__about {
  width: min(760px, 100%);
  margin-top: 2.5rem;
  padding: 0 1rem;
  text-align: center;
}

.landing__about h3 {
  font-size: 1.35rem;
  margin-bottom: 0.6rem;
}

.landing__about p {
  color: var(--text-dim);
  line-height: 1.75;
  font-size: 0.95rem;
}

.landing__details {
  width: min(1020px, 100%);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2.25rem;
  margin-top: 2.25rem;
}

/* Open feature blocks — icon tiles provide the visual anchor,
   whitespace does the separation instead of borders */
.detail-card {
  padding: 0.25rem;
  text-align: center;
}

.detail-card i {
  margin-left: auto;
  margin-right: auto;
}

.detail-card i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(60, 123, 244, 0.18), rgba(128, 92, 247, 0.2));
  color: var(--primary);
  margin-bottom: 0.75rem;
}

.detail-card h3 {
  font-size: 1rem;
  margin-bottom: 0.35rem;
}

.detail-card p {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-dim);
}

.lobby__subtitle {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.86rem;
  line-height: 1.45;
}

/* ---------- Footer ---------- */

.footer {
  width: min(1120px, calc(100% - 2rem));
  margin: 2.5rem auto 0;
  border-top: 1px solid var(--border);
  padding: 2rem 0 1.25rem;
}

.footer__inner {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 0.7fr);
  gap: 2rem;
}

.footer__brand p {
  margin-top: 0.8rem;
  max-width: 320px;
  color: var(--text-dim);
  font-size: 0.88rem;
  line-height: 1.6;
}

.footer__socials {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
}

.footer__socials a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background-color: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.footer__socials a:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  color: var(--primary);
}

.footer__col h4 {
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 0.85rem;
}

.footer__col a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.88rem;
  padding: 0.3rem 0;
  transition: color 0.18s ease;
}

.footer__col a:hover {
  color: var(--primary);
}

.footer__col a i {
  width: 18px;
  text-align: center;
  color: var(--primary);
}

.footer__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.75rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.82rem;
}

.footer__bottom a {
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
}

.footer__bottom a:hover {
  color: var(--primary);
}

/* ---------- Lobby panels (choice / join link / setup) ---------- */

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateX(46px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes panelInBack {
  from {
    opacity: 0;
    transform: translateX(-46px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.lobby__panel {
  display: none;
  flex-direction: column;
  gap: 1rem;
}

.lobby__panel.active {
  display: flex;
  animation: panelIn 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}

.lobby__panel.active.back {
  animation-name: panelInBack;
}

.panel__head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.panel__title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-strong, var(--text));
}

.panel__back {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background-color: transparent;
  color: var(--text-dim);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.panel__back:hover {
  background-color: var(--bg-panel);
  color: var(--text);
}

.option-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 1rem 1.1rem;
  background-color: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.option-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

.option-card:active {
  transform: scale(0.98);
}

.option-card__icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(60, 123, 244, 0.16), rgba(128, 92, 247, 0.2));
  color: var(--primary);
  font-size: 1.05rem;
}

.option-card__body {
  flex: 1;
  min-width: 0;
}

.option-card__label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
}

.option-card__desc {
  display: block;
  margin-top: 2px;
  color: var(--text-dim);
  font-size: 0.8rem;
}

.option-card__arrow {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.lobby__status {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.83rem;
  line-height: 1.5;
}

.lobby__status--error {
  color: #ffb3ae;
}

/* ---------- Host admit notifications ---------- */

@keyframes admitIn {
  from {
    opacity: 0;
    transform: translateY(-16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.admit-stack {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  z-index: 70;
  width: min(92vw, 440px);
}

.admit-card {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 1rem;
  background-color: rgba(19, 22, 29, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.5);
  animation: admitIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.admit-card__text {
  flex: 1;
  font-size: 0.88rem;
  line-height: 1.35;
}

.admit-card__text b {
  text-transform: capitalize;
}

.admit-card button {
  border: none;
  border-radius: 8px;
  padding: 0.45rem 0.9rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.admit-card button:active {
  transform: scale(0.95);
}

.admit-yes {
  background-color: var(--primary);
  color: #fff;
}

.admit-yes:hover {
  background-color: var(--primary-hover);
}

.admit-no {
  background-color: var(--bg-panel);
  color: var(--text-dim);
}

.admit-no:hover {
  background-color: var(--border);
  color: var(--text);
}

.lobby__preview {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background-color: #000;
}

.lobby__preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.lobby__preview-off {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  color: var(--text-dim);
  background-color: var(--bg-panel);
}

.lobby__preview-off i {
  font-size: 2rem;
}

.lobby__preview-controls {
  position: absolute;
  bottom: 0.75rem;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}

.preview-btn {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background-color: rgba(15, 20, 32, 0.62);
  backdrop-filter: blur(6px);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.18s ease, transform 0.18s ease;
}

.preview-btn:hover {
  background-color: rgba(42, 53, 73, 0.85);
  transform: translateY(-2px);
}

.preview-btn:active {
  transform: scale(0.93);
}

.preview-btn--off {
  background-color: var(--danger);
  border-color: var(--danger);
}

.preview-btn--off:hover {
  background-color: var(--danger-hover);
}

.preview-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.lobby__error {
  color: #ffb3ae;
  font-size: 0.85rem;
  line-height: 1.4;
}

.lobby__card input {
  height: 48px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background-color: var(--bg-panel);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  padding: 0 1rem;
  outline: none;
}

.lobby__card input:focus {
  border-color: var(--primary);
}

/* ---------- App layout ---------- */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  animation: fadeIn 0.35s ease;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 1.25rem;
  background-color: transparent;
  flex-shrink: 0;
}

.header__info {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text-dim);
  font-size: 0.88rem;
}

#participantCount {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  background-color: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease;
}

#participantCount:hover {
  color: var(--text);
  border-color: var(--primary);
}

.participants {
  position: fixed;
  top: 64px;
  right: 16px;
  width: min(92vw, 300px);
  max-height: 55vh;
  display: flex;
  flex-direction: column;
  background-color: var(--surface-strong);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  z-index: 45;
  animation: fadeInUp 0.25s ease;
}

.participants__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1rem;
  font-weight: 600;
  font-size: 0.92rem;
  border-bottom: 1px solid var(--border);
}

.participants__list {
  list-style: none;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.participants__list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 1rem;
  font-size: 0.88rem;
}

.participants__list li span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.participants__remove {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background-color: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.participants__remove:hover {
  background-color: rgba(239, 68, 68, 0.14);
  color: var(--danger);
}

.reconnect-banner {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.75rem 1.1rem;
  background-color: rgba(60, 34, 20, 0.95);
  border: 1px solid rgba(250, 176, 5, 0.35);
  border-radius: 14px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.5);
  font-size: 0.9rem;
  z-index: 80;
  animation: admitIn 0.3s ease;
}

.reconnect-banner i {
  color: #fab005;
}

.reconnect-banner button {
  border: none;
  border-radius: 8px;
  padding: 0.45rem 0.9rem;
  background-color: #fab005;
  color: #201302;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.main {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.stage {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background:
    radial-gradient(ellipse 780px 460px at 50% -12%, rgba(47, 128, 236, 0.09), transparent),
    transparent;
}

/* ---------- Video grid ---------- */

#video-grid {
  flex: 1;
  display: grid;
  /* min(100%, …) lets tiles shrink below 320px on narrow screens
     instead of overflowing horizontally */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 1rem;
  /* extra bottom padding so tiles never hide behind the floating dock */
  padding: 0.5rem 1rem 6.25rem;
  align-content: center;
  overflow-y: auto;
}

.video-tile {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 18px;
  overflow: hidden;
  background-color: #0a0e16;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.4);
  animation: tilePop 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.video-tile:hover {
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.55);
  transform: translateY(-2px);
}

.video-tile--leaving {
  animation: tileOut 0.22s ease forwards;
}

.video-tile {
  cursor: pointer;
}

/* Pinned tile: takes the stage, others shrink into a strip */
#video-grid.grid--pinned {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  align-content: start;
}

#video-grid.grid--pinned .video-tile--pinned {
  grid-column: 1 / -1;
  order: -1;
  aspect-ratio: auto;
  height: calc(100dvh - 320px);
  min-height: 240px;
}

#video-grid.grid--pinned .video-tile--pinned video {
  /* Whole frame visible — important when a screen is being shared */
  object-fit: contain;
  background-color: #000;
}

.video-tile__mic {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: rgba(239, 68, 68, 0.85);
  color: #fff;
  font-size: 0.72rem;
  pointer-events: none;
}

.device-row {
  display: flex;
  gap: 0.5rem;
}

.device-row select {
  flex: 1;
  min-width: 0;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background-color: var(--bg-panel);
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  padding: 0 0.6rem;
  outline: none;
  cursor: pointer;
}

.device-row select:focus {
  border-color: var(--primary);
}

.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-tile video.mirrored {
  transform: rotateY(180deg);
}

.video-tile__name {
  position: absolute;
  left: 12px;
  bottom: 12px;
  max-width: calc(100% - 24px);
  padding: 0.32rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: #fff;
  background-color: rgba(8, 11, 18, 0.55);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

/* ---------- Controls ---------- */

.controls {
  position: absolute;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.85rem;
  background-color: rgba(19, 22, 29, 0.75);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 999px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.5);
  z-index: 20;
  animation: fadeInUp 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.control-btn {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background-color: var(--bg-panel);
  color: var(--text);
  font-size: 1.05rem;
  cursor: pointer;
  transition: background-color 0.18s ease, transform 0.18s ease;
}

.control-btn:hover {
  background-color: var(--border);
  transform: translateY(-2px);
}

.control-btn:active {
  transform: scale(0.92);
}

.control-btn--off {
  background-color: var(--danger);
}

.control-btn--off:hover {
  background-color: var(--danger-hover);
}

.control-btn--active {
  background-color: var(--success);
}

.control-btn--active:hover {
  background-color: #3fbd61;
}

.control-btn--danger {
  background-color: var(--danger);
  width: 62px;
  border-radius: 24px;
}

.control-btn--danger:hover {
  background-color: var(--danger-hover);
}

.control-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---------- Chat ---------- */

.chat {
  width: 330px;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.35);
  flex-shrink: 0;
  margin: 12px -346px 12px 0;
  opacity: 0;
  overflow: hidden;
  /* Slide out of the layout smoothly instead of vanishing */
  transition: margin-right 0.32s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.25s ease;
}

.app.chat-open .chat {
  margin-right: 12px;
  opacity: 1;
}

.chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  font-weight: 500;
  border-bottom: 1px solid var(--border);
}

.chat__close {
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
}

.chat__close:hover {
  color: var(--text);
}

.chat__window {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1rem;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.message {
  animation: messageIn 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  max-width: 88%;
  align-self: flex-start;
}

.message--own {
  align-self: flex-end;
}

.message--own .message__meta {
  justify-content: flex-end;
}

.message--own .message__text {
  background-color: var(--primary);
  border-color: transparent;
  border-radius: 10px 0 10px 10px;
}

.message__meta {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.message__author {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: capitalize;
}

.message__time {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.message__text {
  display: inline-block;
  background-color: var(--bg-raised);
  border: 1px solid var(--border);
  padding: 0.55rem 0.8rem;
  border-radius: 0 10px 10px 10px;
  font-size: 0.9rem;
  line-height: 1.4;
  word-break: break-word;
}

.message--system {
  align-self: center;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.78rem;
  animation: fadeIn 0.3s ease;
}

.control-btn {
  position: relative;
}

.chat-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--danger);
  border: 2px solid var(--bg-raised);
  animation: tilePop 0.25s ease;
}

.chat__composer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}

.chat__composer input {
  flex: 1;
  height: 44px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background-color: var(--bg-raised);
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  padding: 0 1.1rem;
  outline: none;
}

.chat__composer input:focus {
  border-color: var(--primary);
}

.chat__send {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background-color: var(--primary);
  color: #fff;
  font-size: 0.95rem;
  cursor: pointer;
}

.chat__send:hover {
  background-color: var(--primary-hover);
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 104px;
  left: 50%;
  transform: translate(-50%, 12px);
  background-color: var(--bg-raised);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 1.2rem;
  border-radius: 24px;
  font-size: 0.88rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  z-index: 50;
  max-width: 90vw;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast--visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Tablet (chat becomes an overlay) ---------- */

/* ---------- Tablets & below: stacked landing ---------- */

@media (max-width: 1024px) {
  .lobby__layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem 0;
  }

  .lobby__hero {
    order: 1;
    align-items: center;
    text-align: center;
    gap: 0.8rem;
    max-width: 620px;
  }

  .lobby__card {
    order: 2;
    grid-column: auto;
    justify-self: center;
    margin-top: 0;
    max-width: 480px;
    width: 100%;
  }

  /* The corner treatment doesn't fit here — show the product shot as
     a normal block below the join card instead. */
  .lobby__illustration {
    order: 3;
    position: static;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    animation: none;
    pointer-events: auto;
  }

  .lobby__illustration::before {
    display: none;
  }

  .lobby__illustration img {
    transform: none !important;
  }

  .lobby__greeting {
    font-size: clamp(1.6rem, 4.5vw, 2.2rem);
  }

  .lobby__tagline {
    font-size: 0.92rem;
  }

  /* Centered open stat row */
  .hero__stats {
    justify-content: center;
    gap: 1rem;
    width: 100%;
  }

  .hero__stat {
    text-align: center;
  }

  .hero__stat + .hero__stat {
    padding-left: 1rem;
  }

  .hero__stat strong {
    font-size: 0.95rem;
  }

  .hero__stat span {
    font-size: 0.7rem;
  }

  .hero__actions {
    width: 100%;
    max-width: 480px;
    justify-content: center;
  }

  .hero__actions .btn {
    flex: 1;
    min-width: 0;
    padding: 0.75rem 1rem;
  }

  .lobby__features {
    align-items: center;
  }

  .lobby__dev {
    order: 10;
    border-top: none;
    margin-top: 0;
    padding-top: 0;
  }

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

  .landing__details .detail-card:last-child {
    grid-column: 1 / -1;
  }

  .footer__inner {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  }

  .footer__col:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  /* Inputs below 16px make mobile browsers auto-zoom the page when
     the keyboard opens — keep them at 16px so focusing never zooms. */
  .chat__composer input,
  .lobby__card input {
    font-size: 16px;
  }

  .chat {
    position: fixed;
    inset: 56px 0 0 0;
    width: 100%;
    z-index: 40;
    margin: 0;
    border: none;
    border-radius: 16px 16px 0 0;
    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1),
      opacity 0.25s ease;
  }

  .app.chat-open .chat {
    margin: 0;
    transform: translateX(0);
  }

  .chat__composer {
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
  }

  #video-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  }
}

/* ---------- Phones ---------- */

@media (max-width: 640px) {
  /* Keep the glass topbar compact: brand + CTA + theme toggle only */
  .topbar__nav a {
    display: none;
  }

  .btn--nav {
    padding: 0.5rem 0.8rem;
    font-size: 0.8rem;
  }

  .topbar {
    margin-top: 0.5rem;
    width: calc(100% - 1.25rem);
    padding: 0.4rem 0.55rem;
  }

  .footer__inner {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .footer__bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }

  .theme-toggle {
    width: 38px;
    height: 38px;
  }

  .lobby {
    padding: 0.25rem 1rem 1.75rem;
  }

  .lobby__layout {
    gap: 1.25rem;
    padding: 0.75rem 0.25rem;
  }

  .hero__pill {
    font-size: 0.72rem;
    padding: 0.35rem 0.7rem;
  }

  .lobby__tagline {
    font-size: 0.86rem;
    line-height: 1.6;
  }

  .lobby__features {
    display: none;
  }

  .lobby__illustration img {
    border-radius: 18px;
  }

  .landing__about {
    padding: 1rem;
    margin-top: 1rem;
  }

  .landing__details {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .landing__details .detail-card:last-child {
    grid-column: auto;
  }

  .detail-card {
    padding: 0.95rem;
  }
}

@media (max-width: 600px) {
  .header {
    height: 52px;
    padding: 0 0.75rem;
  }

  .brand {
    font-size: 1rem;
  }

  .chat {
    inset: 52px 0 0 0;
  }

  #video-grid {
    grid-template-columns: 1fr;
    gap: 0.6rem;
    padding: 0.5rem 0.6rem 5.5rem;
    align-content: start;
  }

  .video-tile__name {
    font-size: 0.72rem;
    left: 8px;
    bottom: 8px;
  }

  .controls {
    gap: 0.4rem;
    padding: 0.5rem 0.6rem;
    bottom: calc(12px + env(safe-area-inset-bottom));
    max-width: calc(100vw - 16px);
  }

  .control-btn {
    width: 44px;
    height: 44px;
    font-size: 0.95rem;
  }

  .control-btn--danger {
    width: 56px;
  }

  .toast {
    bottom: 82px;
    font-size: 0.8rem;
  }

  .lobby__card {
    padding: 1.25rem;
    gap: 0.85rem;
  }

  .lobby__tagline {
    font-size: 0.85rem;
  }

  .messages {
    padding: 0.75rem;
  }
}

/* ---------- Very small phones ---------- */

@media (max-width: 380px) {
  .header__info {
    font-size: 0.8rem;
  }

  .controls {
    gap: 0.35rem;
  }

  .control-btn {
    width: 40px;
    height: 40px;
    font-size: 0.9rem;
  }

  .control-btn--danger {
    width: 50px;
  }
}

/* ---------- Phones in landscape ---------- */

@media (max-height: 500px) and (orientation: landscape) {
  .header {
    height: 44px;
  }

  .chat {
    inset: 44px 0 0 0;
  }

  #video-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
    gap: 0.5rem;
    padding: 0.4rem 0.6rem 4.6rem;
  }

  .controls {
    padding: 0.4rem 0.55rem;
    gap: 0.4rem;
    bottom: 10px;
  }

  .control-btn {
    width: 40px;
    height: 40px;
    font-size: 0.9rem;
  }

  .control-btn--danger {
    width: 52px;
  }

  .lobby__card {
    padding: 1rem;
    gap: 0.6rem;
  }

  .lobby__preview {
    aspect-ratio: 16 / 7;
  }

  .lobby__layout {
    flex-direction: row;
    gap: 1.5rem;
  }

  .lobby__hero {
    text-align: left;
    align-items: flex-start;
  }

  .lobby__greeting {
    font-size: 1.4rem;
  }

  .toast {
    bottom: 68px;
  }
}
