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

body {
  background: #0a0a0a;
  color: #e0e0e0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  overflow: hidden;
}

/* Landing */
.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 16px;
}

.logo {
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -1px;
  color: #fff;
}

.tagline {
  color: #888;
  font-size: 1rem;
  margin-bottom: 24px;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 14px 36px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

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

.btn-primary {
  background: #4f8cff;
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #3a75e6;
}

.btn-secondary {
  background: #2a2a2a;
  color: #e0e0e0;
}

.btn-secondary:hover:not(:disabled) {
  background: #3a3a3a;
}

.join-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.join-row input {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 14px 16px;
  color: #fff;
  font-size: 1rem;
  width: 160px;
  text-align: center;
  letter-spacing: 4px;
  font-weight: 600;
}

.join-row input::placeholder {
  letter-spacing: normal;
  font-weight: 400;
  color: #555;
}

.join-row input:focus {
  outline: none;
  border-color: #4f8cff;
}

.error {
  color: #ff5555;
  font-size: 0.9rem;
  min-height: 1.2em;
}

.active-rooms {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 360px;
}

.rooms-label {
  color: #666;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.btn-room {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 12px 24px;
  color: #e0e0e0;
  font-family: monospace;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 3px;
  cursor: pointer;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.15s, border-color 0.15s;
}

.btn-room:hover {
  background: #222;
  border-color: #4f8cff;
}

.room-peers {
  background: #2a3a5a;
  color: #4f8cff;
  font-size: 0.8rem;
  padding: 2px 10px;
  border-radius: 12px;
  letter-spacing: normal;
}

/* Download */
.desktop-download {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.download-label {
  color: #666;
  font-size: 0.85rem;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #2a3a5a, #1a2a4a);
  border: 1px solid #3a5a8a;
  border-radius: 8px;
  padding: 12px 24px;
  color: #8ab4f8;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-download:hover:not(.unavailable) {
  background: linear-gradient(135deg, #3a4a6a, #2a3a5a);
  border-color: #4f8cff;
  color: #fff;
}

.btn-download.unavailable {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}

.btn-src-download {
  color: #555;
  font-size: 0.8rem;
  text-decoration: underline;
  cursor: pointer;
  transition: color 0.15s;
}

.btn-src-download:hover {
  color: #8ab4f8;
}

/* Room */
.room-view {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  z-index: 10;
}

.room-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.room-code {
  background: #1a1a1a;
  padding: 6px 14px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 3px;
  cursor: pointer;
  transition: background 0.15s;
}

.room-code:hover {
  background: #2a2a2a;
}

.room-code.copied {
  background: #2a5a2a;
}

.peer-count {
  background: #222;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.85rem;
  color: #aaa;
}

.peer-count::before {
  content: '👁 ';
}

/* Tile grid */
.tile-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 400px));
  justify-content: center;
  gap: 10px;
  padding: 0 16px 8px;
  overflow-y: auto;
  align-content: center;
}

.tile {
  position: relative;
  background: #111;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 16/9;
  cursor: pointer;
  transition: all 0.25s ease;
}

.tile.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  z-index: 50;
  aspect-ratio: auto;
  background: #000;
}

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

.tile.fullscreen video,
.tile:fullscreen video {
  object-fit: contain;
}

/* Browser fullscreen API */
.tile:fullscreen {
  background: #000;
}

.tile:-webkit-full-screen {
  background: #000;
}

.tile:-webkit-full-screen video {
  object-fit: contain;
}

.tile audio {
  display: none;
}

.tile.local {
  border: 2px solid #4f8cff;
}

.tile-label {
  position: absolute;
  bottom: 8px;
  left: 10px;
  background: rgba(0, 0, 0, 0.6);
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  color: #ccc;
}

.tile-stats {
  position: absolute;
  top: 8px;
  left: 10px;
  background: rgba(0, 0, 0, 0.7);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-family: monospace;
  color: #0f0;
  white-space: pre;
  pointer-events: none;
}

/* Bottom bar */
.bottom-bar {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 16px;
  z-index: 10;
}

.btn-icon {
  background: #222;
  border: none;
  border-radius: 50%;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #aaa;
  transition: background 0.15s, color 0.15s;
}

.btn-icon:hover {
  background: #333;
  color: #fff;
}

.btn-icon.active {
  background: #2a3a5a;
  color: #4f8cff;
}

.btn-icon.btn-danger {
  background: #3a1a1a;
  color: #ff5555;
}

.btn-icon.btn-danger:hover {
  background: #5a2020;
}

/* Toggle on/off icons */
.btn-icon .off { display: none; }
.btn-icon.active .on { display: block; }
.btn-icon.active .off { display: none; }
.btn-icon:not(.active) .on { display: none; }
.btn-icon:not(.active) .off { display: block; }

/* Screen share button doesn't need on/off toggle */
#screenBtn svg { display: block; }
#nativeShareBtn svg { display: block; }
#statsToggle svg { display: block; }
#leaveBtn svg { display: block; }

/* Native capture stats overlay */
#native-stats {
  position: fixed;
  top: 48px;
  right: 16px;
  background: rgba(0, 0, 0, 0.8);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-family: monospace;
  color: #0f0;
  white-space: pre;
  z-index: 20;
  pointer-events: none;
}
