.lobby-chat__backdrop {
  position: fixed;
  inset: 0;
  z-index: 10049;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.35);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.lobby-chat__backdrop[hidden] {
  display: none !important;
}

.lobby-chat {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 10050;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  font-family: Inter, system-ui, sans-serif;
  pointer-events: none;
}

.lobby-chat > * {
  pointer-events: auto;
}

.lobby-chat__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0 1rem;
  border: 1px solid #232833;
  border-radius: 999px;
  background: #0c0b12;
  color: #e8e6e1;
  font-size: 0.8125rem;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.lobby-chat__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #b794ff;
  box-shadow: 0 0 10px rgba(183, 148, 255, 0.75);
}

.lobby-chat__panel {
  width: min(400px, calc(100vw - 2rem));
  max-height: min(560px, calc(100dvh - 7rem));
  height: min(560px, calc(100dvh - 7rem));
  display: none;
  flex-direction: column;
  min-width: 0;
  border: 1px solid #232833;
  border-radius: 14px;
  background: rgba(8, 7, 12, 0.98);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.lobby-chat__panel.is-open {
  display: flex;
  animation: lobby-rise 0.18s ease;
}

.lobby-chat__panel[hidden] {
  display: none !important;
}

@keyframes lobby-rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.lobby-chat__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid #232833;
  flex-shrink: 0;
  background: rgba(8, 7, 12, 0.98);
}

.lobby-chat__head h3 {
  margin: 0;
  font-size: 0.9375rem;
  color: #fff;
}

.lobby-chat__head p {
  margin: 0.2rem 0 0;
  color: #9a9d9a;
  font-size: 0.75rem;
}

.lobby-chat__head-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.lobby-chat__close {
  border: 1px solid #232833;
  background: rgba(255, 255, 255, 0.04);
  color: #e8e6e1;
  font-size: 0.75rem;
  font-weight: 650;
  line-height: 1;
  cursor: pointer;
  min-height: 2rem;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  font-family: inherit;
}

.lobby-chat__close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.12);
}

.lobby-chat__close--icon {
  min-width: 2rem;
  padding: 0.35rem;
  font-size: 1.2rem;
}

.lobby-chat__messages {
  flex: 1 1 auto;
  overflow: auto;
  padding: 0.65rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
}

.lobby-chat__empty {
  margin: auto 0;
  padding: 2rem 0;
  text-align: center;
  color: #9a9d9a;
  font-size: 0.8125rem;
}

.lobby-chat__msg time {
  display: block;
  margin-top: 0.25rem;
  color: #52525b;
  font-size: 0.625rem;
}

.lobby-chat__author {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.lobby-chat__author:hover .lobby-chat__name {
  color: #c4b5fd;
}

.lobby-chat__avatar {
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  overflow: hidden;
  border-radius: 50%;
  background: #181420;
  font-size: 0.65rem;
  font-weight: 700;
  color: #e8e6e1;
}

.lobby-chat__name {
  font-size: 0.8125rem;
  font-weight: 650;
  color: #e8e6e1;
}

.lobby-chat__body {
  margin: 0.25rem 0 0 1.85rem;
  color: #d4d4d8;
  font-size: 0.8125rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.lobby-role {
  display: inline-flex;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.5625rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.lobby-role--gold { background: rgba(245, 158, 11, 0.15); color: #fcd34d; }
.lobby-role--teal { background: rgba(155, 107, 255, 0.14); color: #c4b5fd; }
.lobby-role--discord { background: rgba(88, 101, 242, 0.15); color: #a5b4fc; }
.lobby-role--muted { background: rgba(255, 255, 255, 0.06); color: #9a9d9a; }

.lobby-chat__composer {
  display: flex;
  gap: 0.4rem;
  padding: 0.65rem 0.75rem 0.75rem;
  border-top: 1px solid #232833;
  flex-shrink: 0;
}

.lobby-chat__composer input {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.65rem;
  border: 1px solid #232833;
  border-radius: 8px;
  background: #15121c;
  color: #e8e6e1;
  font: inherit;
  font-size: 0.8125rem;
}

.lobby-chat__send {
  padding: 0.55rem 0.85rem;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(in oklab, #9d6bff 0%, #7c3aed 100%);
  color: #fff;
  font-weight: 650;
  font-size: 0.8125rem;
  cursor: pointer;
}

.lobby-chat__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.lobby-chat__signin {
  margin: 0;
  padding: 0.85rem 0.75rem;
  border-top: 1px solid #232833;
  text-align: center;
  color: #9a9d9a;
  font-size: 0.8125rem;
  flex-shrink: 0;
}

.lobby-chat__signin a {
  color: #a78bfa;
  font-weight: 650;
}

.lobby-chat__error {
  margin: 0;
  padding: 0 0.75rem 0.35rem;
  color: #fca5a5;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.lobby-profile {
  position: relative;
  margin: 0.5rem 0.75rem;
  padding: 0.85rem;
  border: 1px solid #232833;
  border-radius: 10px;
  background: #15121c;
  flex-shrink: 0;
  max-height: 40%;
  overflow: auto;
}

.lobby-profile__close {
  position: absolute;
  top: 0.35rem;
  right: 0.45rem;
  border: 0;
  background: transparent;
  color: #9a9d9a;
  font-size: 1.1rem;
  cursor: pointer;
}

.lobby-profile__head {
  display: flex;
  gap: 0.65rem;
  align-items: center;
}

.lobby-profile__avatar {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  overflow: hidden;
  border-radius: 50%;
  background: #0c0b12;
  font-weight: 700;
}

.lobby-profile__discord {
  margin: 0.15rem 0 0;
  color: #9a9d9a;
  font-size: 0.75rem;
}

.lobby-profile__roles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.65rem;
}

.lobby-profile__bio {
  margin: 0.65rem 0 0;
  color: #d4d4d8;
  font-size: 0.8125rem;
  line-height: 1.45;
}

.lobby-profile__meta {
  margin: 0.5rem 0 0;
  color: #71717a;
  font-size: 0.6875rem;
}

.bv2-app .lobby-chat {
  right: max(1.25rem, env(safe-area-inset-right, 0px));
  bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
}

/* Viewport corner — not the centered content column (avoids sitting on catalog cards) */
html.buynfa-preview .lobby-chat {
  right: max(1.25rem, env(safe-area-inset-right, 0px));
  left: auto;
  bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
  align-items: flex-end;
  width: auto;
  max-width: none;
}

html.buynfa-preview .lobby-chat__toggle {
  align-self: flex-end;
  padding-inline: 1.05rem;
}

.bv2-app .lobby-chat__toggle,
.market .lobby-chat__toggle {
  font-family: inherit;
}

@media (max-width: 480px) {
  .lobby-chat {
    right: max(0.75rem, env(safe-area-inset-right, 0px));
    bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
    left: auto;
    align-items: flex-end;
  }

  html.buynfa-preview .lobby-chat {
    right: max(0.75rem, env(safe-area-inset-right, 0px));
    left: auto;
    bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
    align-items: flex-end;
  }

  html.buynfa-preview .lobby-chat__panel {
    width: min(400px, calc(100vw - 1.5rem));
    max-width: calc(100vw - 1.5rem);
  }

  .lobby-chat__panel {
    width: 100%;
    max-height: calc(100dvh - 7rem);
    height: min(520px, calc(100dvh - 7rem));
  }
}
