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

:root {
  --bg: #101418;
  --panel: #1a2129;
  --border: #2c3540;
  --text: #e8edf2;
  --dim: #8b98a5;
  --accent: #4da3ff;
  --danger: #e5534b;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  padding-bottom: 2rem;
}

header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.brand { margin-right: auto; min-width: 0; }
h1 { font-size: 1.15rem; font-weight: 600; }
.tagline {
  color: var(--dim);
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 480px) { .tagline { display: none; } }

#faq-btn {
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border-radius: 50%;
  font-weight: 700;
  color: var(--dim);
  flex-shrink: 0;
}

#faq, #invite-gate, #splash {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
}

.faq-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 640px;
  width: 100%;
  padding: 1.25rem 1.5rem;
  line-height: 1.55;
}

.faq-head { display: flex; align-items: center; justify-content: space-between; }
.faq-head h2 { font-size: 1.1rem; }
.faq-card h3 { margin: 1.1rem 0 0.35rem; font-size: 0.95rem; color: var(--accent); }
.faq-card p, .faq-card ul { color: var(--text); font-size: 0.9rem; margin: 0.35rem 0; }
.faq-card ul { padding-left: 1.2rem; }
.faq-card li { margin: 0.35rem 0; }
#invite-gate { align-items: center; z-index: 300; background: var(--bg); }
#invite-gate h2 { font-size: 1.05rem; margin-bottom: 0.5rem; }
#invite-gate input {
  flex: 2;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  min-width: 0;
}

.faq-card code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 0.3rem;
  font-size: 0.85em;
}

.status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status.online { background: #3fb950; }
.status.offline { background: var(--danger); }

button {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:active { transform: scale(0.97); }
button.primary { background: var(--accent); border-color: var(--accent); color: #06121f; font-weight: 600; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }

.hidden { display: none !important; }

/* ---------- share panel ---------- */

#share-panel {
  max-width: 480px;
  margin: 1rem auto;
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
}

#share-panel label { display: block; color: var(--dim); font-size: 0.85rem; margin: 0.75rem 0 0.25rem; }
#share-panel label:first-child { margin-top: 0; }

#share-panel input[type="text"],
#share-panel select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
}

.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  color: var(--text) !important;
  font-size: 1rem !important;
  cursor: pointer;
}

.button-row { display: flex; gap: 0.75rem; margin-top: 1rem; }
.button-row button { flex: 1; }

.hint { color: var(--dim); font-size: 0.85rem; margin-top: 0.75rem; text-align: center; }

/* ---------- video grid ---------- */

#grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0.75rem;
  padding: 1rem;
}

@media (max-width: 400px) {
  #grid { grid-template-columns: 1fr; }
}

.tile {
  position: relative;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  border: 1px solid var(--border);
}

.tile video {
  width: 100%;
  height: 100%;
  object-fit: cover; /* fill the tile/screen; crop edges on aspect mismatch */
  display: block;
  transition: transform 0.25s ease;
}

/* Per-tile "fit" mode: letterbox instead of crop, shows the whole frame. */
.tile.fit-contain video { object-fit: contain; }

.tile-label {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tile-label .spacer { margin-left: auto; }

.tile button.icon {
  background: rgba(0, 0, 0, 0.45);
  border: none;
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  font-size: 0.95rem;
}

.tile.expanded {
  position: fixed;
  inset: 0;
  z-index: 100;
  border-radius: 0;
  border: none;
  aspect-ratio: auto;
}

body.has-expanded { overflow: hidden; }

.tile .connecting {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
  font-size: 0.9rem;
}

.self-tile { margin-top: 1rem; }

#empty-state {
  text-align: center;
  color: var(--dim);
  padding: 3rem 1rem;
  line-height: 1.6;
}

#splash { align-items: center; }
#splash h2 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.brand { cursor: pointer; }

.faq-card a { color: var(--accent); }
