:root {
  --bg: #16181d;
  --panel: #23262e;
  --text: #eceef2;
  --muted: #9aa0ac;
  --accent: #4f8cff;
  --danger: #e5484d;
  --speaking: #3ecf8e;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, sans-serif;
}

button {
  font: inherit;
  padding: 0.6em 1.1em;
  border: 0;
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
button:hover { filter: brightness(1.25); }
button:disabled { opacity: 0.5; cursor: default; }
button.off { background: #4a3a1e; }          /* mic or camera is turned off */
button.danger { background: var(--danger); }

.msg { color: var(--muted); min-height: 1.4em; margin: 0; }

/* ---------- Lobby ---------- */
#lobby {
  max-width: 360px;
  margin: 12vh auto 0;
  padding: 0 16px;
}
#lobby h1 { font-size: 1.6rem; }
#join-form { display: grid; gap: 14px; }
#join-form label { display: grid; gap: 4px; color: var(--muted); }
#join-form input {
  font: inherit;
  padding: 0.6em;
  border-radius: 8px;
  border: 1px solid #3a3e48;
  background: var(--panel);
  color: var(--text);
}
#join-btn { background: var(--accent); }

/* ---------- Call ---------- */
#call {
  display: flex;
  flex-direction: column;
  height: 100vh;
}
#call[hidden] { display: none; }
#call header, #call footer {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 16px;
}
#call footer { justify-content: center; }
#room-title { font-weight: 600; }

/* The video grid: as many 280px+ columns as fit, each tile 16:9 */
#grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  align-content: center;
  gap: 10px;
  padding: 0 16px;
}

.tile {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--panel);
  border-radius: 12px;
  overflow: hidden;
  outline: 3px solid transparent;
  transition: outline-color 0.2s;
}
.tile.speaking { outline-color: var(--speaking); }

/* "contain" = always show the WHOLE picture, with dark bars if its shape
   doesn't match the tile (e.g. a phone held upright). "cover" would fill
   the tile but cut off the top/bottom, which looks zoomed in. */
.tile video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
/* Your own video is mirrored, like looking in a mirror */
.tile.local video { transform: scaleX(-1); }

/* Big initial letter shown when someone's camera is off */
.tile .avatar {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  font-size: 3rem;
  color: var(--muted);
}
.tile.camera-off video { display: none; }
.tile.camera-off .avatar { display: grid; }

.tile .label {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgb(0 0 0 / 0.55);
  font-size: 0.9rem;
}
