:root {
  --bg0: #0c1118;
  --bg1: #141b24;
  --bg2: #1c2633;
  --line: rgba(232, 238, 246, 0.1);
  --text: #e8eef6;
  --muted: #8b9bb0;
  --accent: #3dd6c6;
  --accent-2: #f0b429;
  --danger: #ef6b6b;
  --radius: 18px;
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Syne", "DM Sans", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1000px 500px at 10% -10%, rgba(61, 214, 198, 0.16), transparent 55%),
    radial-gradient(800px 400px at 90% 0%, rgba(240, 180, 41, 0.1), transparent 50%),
    linear-gradient(160deg, #0a0e14, #121821 45%, #0d131b);
}

body {
  min-height: 100vh;
}

h1,
h2 {
  font-family: var(--display);
  letter-spacing: -0.03em;
  margin: 0;
}

.eyebrow {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

.lede {
  color: var(--muted);
  line-height: 1.5;
}

.auth-page {
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.auth-card {
  width: min(420px, 100%);
  padding: 2rem;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 6px);
  background: rgba(20, 27, 36, 0.88);
  backdrop-filter: blur(12px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}

.auth-card h1 {
  font-size: 2.4rem;
  margin-bottom: 0.4rem;
}

.auth-card form {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}

label {
  display: grid;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg0);
  color: var(--text);
  padding: 0.85rem 1rem;
  font: inherit;
  outline: none;
}

input:focus {
  border-color: rgba(61, 214, 198, 0.55);
  box-shadow: 0 0 0 3px rgba(61, 214, 198, 0.12);
}

button,
.btn {
  border: 0;
  border-radius: 12px;
  padding: 0.85rem 1.1rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: var(--accent);
  color: #062a27;
}

button:hover,
.btn:hover {
  filter: brightness(1.05);
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
}

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

.btn.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(239, 107, 107, 0.35);
}

.error {
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
}

.room-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1rem 1.25rem;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}

.room-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
  flex-shrink: 0;
}

.room-header h1 {
  font-size: 2rem;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.you-label {
  font-size: 0.9rem;
  color: var(--muted);
  margin-right: 0.25rem;
}

.btn.sharing-active {
  background: rgba(240, 180, 41, 0.18);
  color: var(--accent-2);
  border: 1px solid rgba(240, 180, 41, 0.45);
}

.screen-stage {
  position: relative;
  flex: 0 1 auto;
  max-height: 42vh;
  min-height: 0;
  margin-bottom: 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(10, 14, 20, 0.92);
  overflow: hidden;
}

.screen-stage.is-empty {
  display: none;
}

.screen-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.55rem;
  padding: 0.55rem;
  height: 100%;
  max-height: 42vh;
}

.screen-tile {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  aspect-ratio: 16 / 9;
  max-height: calc(42vh - 1.1rem);
}

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

.screen-caption {
  position: absolute;
  left: 0.55rem;
  bottom: 0.55rem;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.65);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text);
}

.screen-empty {
  margin: 0;
  padding: 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.screen-stage:not(.is-empty) .screen-empty {
  display: none;
}

.room-grid {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 1rem;
  flex: 1;
  min-height: 0;
}

@media (max-width: 800px) {
  .room-grid {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .screen-stage {
    max-height: 32vh;
  }
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(20, 27, 36, 0.8);
  padding: 1rem 1.1rem 1.15rem;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel h2 {
  font-size: 1.05rem;
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel h2 span {
  display: inline-grid;
  place-items: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: rgba(61, 214, 198, 0.15);
  color: var(--accent);
  font-size: 0.75rem;
}

.peer-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.peer-list li.sharing {
  border-color: rgba(240, 180, 41, 0.4);
}

.peer-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  background: var(--bg2);
  border: 1px solid transparent;
}

.peer-list li.self {
  border-color: rgba(61, 214, 198, 0.35);
}

.peer-list li.speaking {
  border-color: var(--accent);
  background: linear-gradient(
    90deg,
    rgba(61, 214, 198, 0.22),
    var(--bg2) 55%
  );
  box-shadow:
    0 0 0 1px rgba(61, 214, 198, 0.55),
    0 0 22px rgba(61, 214, 198, 0.38);
  animation: speak-glow 1.05s ease-in-out infinite;
}

.peer-list li.speaking .name {
  color: var(--accent);
}

@keyframes speak-glow {
  0%,
  100% {
    box-shadow:
      0 0 0 1px rgba(61, 214, 198, 0.45),
      0 0 14px rgba(61, 214, 198, 0.22);
  }
  50% {
    box-shadow:
      0 0 0 2px rgba(61, 214, 198, 0.85),
      0 0 28px rgba(61, 214, 198, 0.55);
  }
}

.peer-list .name {
  font-weight: 600;
}

.peer-list .badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.peer-list li.muted .badge {
  color: var(--accent-2);
}

.sfx-panel {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.sfx-panel h3 {
  margin: 0 0 0.55rem;
  font-family: var(--display);
  font-size: 0.82rem;
  letter-spacing: -0.02em;
  color: var(--muted);
}

.sfx-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4rem;
}

.sfx-btn {
  appearance: none;
  border: 1px solid color-mix(in srgb, var(--sfx-color, var(--accent)) 45%, transparent);
  border-radius: 10px;
  padding: 0.55rem 0.2rem;
  background: color-mix(in srgb, var(--sfx-color, var(--accent)) 14%, var(--bg0));
  color: var(--text);
  font: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
}

.sfx-btn:hover {
  filter: brightness(1.08);
}

.sfx-btn:active,
.sfx-btn.is-playing {
  transform: scale(0.96);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--sfx-color, var(--accent)) 55%, transparent);
}

.sfx-label {
  display: block;
  line-height: 1.15;
}

.hint {
  margin: 0.75rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  flex-shrink: 0;
}

.chat-panel {
  min-height: 0;
}

.chat-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding-right: 0.25rem;
  margin-bottom: 0.85rem;
}

.chat-item {
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  background: var(--bg0);
  border: 1px solid var(--line);
}

.chat-item .meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.chat-item .meta strong {
  color: var(--accent);
  font-weight: 700;
}

.chat-item .body {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.4;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem;
  flex-shrink: 0;
}

.gate-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.gate-label select {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg0);
  color: var(--text);
  padding: 0.55rem 0.65rem;
  font: inherit;
  font-weight: 600;
}

#remote-audio {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

#remote-audio audio {
  width: 0;
  height: 0;
}
