html,
body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #333333;
}

body {
  font-family: system-ui, sans-serif;
}

.popup {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: white;
  user-select: none;
  max-width: 65ch;
  margin: 0 auto;
  padding: 0 30px;
  box-sizing: border-box;
}

.popup h1 {
  font-size: 1.5em;
}

.popup p {
  color: #e1e1e1;
  line-height: 1.3;
}

button {
  font: inherit;
  color: white;
  background-color: #555555;
  border: 1px solid #777777;
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
}

button:hover {
  background-color: #666666;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

button[type="submit"] {
  background-color: #2f6fdb;
  border-color: #2f6fdb;
}

button[type="submit"]:hover {
  background-color: #3c7cea;
}

.toolbar {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  user-select: none;
}

.toolbar button {
  background-color: rgba(51, 51, 51, 0.85);
}

.toolbar button:hover {
  background-color: rgba(85, 85, 85, 0.95);
}

/* The blur strength slider, shown in the toolbar while blurred */
.blur-strength {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  background-color: rgba(51, 51, 51, 0.85);
  font-size: 0.85em;
}

.blur-strength input {
  width: 120px;
}

.blur-strength output {
  min-width: 2ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#viewer-count {
  text-shadow: 1px 1px 3px #333333;
  font-variant-numeric: tabular-nums;
}

/* The presentations, laid out evenly: one fills the page, two side by side, three or four in a 2x2 grid */
.stage {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template: 1fr / 1fr;
  gap: 4px;
  padding: 4px;
  box-sizing: border-box;
}

.stage[data-count="2"] {
  grid-template: 1fr / 1fr 1fr;
}

.stage[data-count="3"],
.stage[data-count="4"] {
  grid-template: 1fr 1fr / 1fr 1fr;
}

.tile {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 6px;
  background-color: #222222;
  cursor: zoom-in;
}

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

/* One enlarged presentation, and the others in a column on the right */
.stage.spotlight {
  grid-template: repeat(var(--others), 1fr) / 1fr minmax(160px, 22%);
}

.stage.spotlight .tile {
  grid-column: 2;
}

.stage.spotlight .tile.spotlighted {
  grid-column: 1;
  grid-row: 1 / -1;
  cursor: zoom-out;
}

.tile-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  pointer-events: none;
}

.tile-status p {
  max-width: 50ch;
  margin: 0;
  padding: 10px 14px;
  border-radius: 8px;
  color: #e1e1e1;
  background-color: rgba(34, 34, 34, 0.85);
  line-height: 1.4;
  text-align: center;
}

.tile-bar {
  position: absolute;
  left: 6px;
  bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tile-name {
  max-width: 24ch;
  overflow: hidden;
  padding: 2px 8px;
  border-radius: 4px;
  color: white;
  background-color: rgba(0, 0, 0, 0.6);
  font-size: 0.85em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-bar button {
  padding: 1px 8px;
  background-color: rgba(0, 0, 0, 0.6);
  border-color: transparent;
}

.status {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 30px;
  pointer-events: none;
}

.status p {
  max-width: 50ch;
  margin: 0;
  padding: 12px 18px;
  border-radius: 8px;
  color: #e1e1e1;
  background-color: rgba(34, 34, 34, 0.85);
  line-height: 1.4;
  text-align: center;
}

.countdown {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* The popover opens in the top layer. Place it below the toolbar instead of in the middle of the screen. */
.menu {
  position: fixed;
  inset: 54px auto auto 10px;
  margin: 0;
  width: min(40ch, calc(100% - 20px));
  max-height: calc(100% - 64px);
  overflow-y: auto;
  box-sizing: border-box;
  padding: 4px 18px 16px;
  border: 1px solid #555555;
  border-radius: 10px;
  color: white;
  background-color: #2a2a2a;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.menu-section {
  padding-top: 12px;
}

.menu-section + .menu-section {
  margin-top: 14px;
  border-top: 1px solid #444444;
}

.menu-section h2 {
  margin: 0 0 10px;
  font-size: 1.05em;
}

.link-row {
  display: flex;
  gap: 8px;
}

.link-row button {
  flex: none;
}

.menu-feedback {
  margin: 8px 0 0;
  color: #b8e0b8;
  font-size: 0.9em;
  line-height: 1.4;
}

#copy-link-failed {
  color: #f0b8b8;
}

.participant-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.participant-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}

.participant-name {
  overflow-wrap: anywhere;
}

.badge {
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.8em;
  color: #e1e1e1;
  background-color: #444444;
}

.menu-section label {
  display: block;
  margin: 10px 0 4px;
  color: #e1e1e1;
}

.menu-section h2 label {
  margin: 0;
  color: inherit;
}

.menu-section input,
.menu-section select {
  width: 100%;
  box-sizing: border-box;
  padding: 5px 8px;
  font: inherit;
  color: white;
  background-color: #1e1e1e;
  border: 1px solid #666666;
  border-radius: 6px;
}

.menu-section input:invalid {
  border-color: #e05555;
}

.menu-note {
  margin: 12px 0 0;
  color: #b8b8b8;
  font-size: 0.85em;
  line-height: 1.4;
}

.stats-entry + .stats-entry {
  margin-top: 12px;
}

/* The heading of a statistics entry: the name and whether it is sent or received */
.stats-heading {
  margin: 0 0 6px;
  font-weight: bold;
  overflow-wrap: anywhere;
}

.stats {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  margin: 0;
  font-size: 0.85em;
}

.stats dt {
  color: #b8b8b8;
}

.stats dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.notices {
  position: fixed;
  bottom: 70px;
  left: 50%;
  z-index: 20;
  width: min(60ch, calc(100% - 20px));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.notice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  border-radius: 8px;
  color: white;
  background-color: rgba(34, 34, 34, 0.95);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.notice p {
  flex: 1;
  margin: 0;
  line-height: 1.4;
}

.notice-close {
  padding: 2px 10px;
  background-color: transparent;
  border-color: transparent;
}

#present-dialog {
  width: min(44ch, calc(100% - 40px));
  box-sizing: border-box;
  padding: 20px 24px;
  border: 1px solid #555555;
  border-radius: 10px;
  color: white;
  background-color: #2a2a2a;
}

#present-dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.6);
}

#present-dialog h1 {
  margin: 0 0 12px;
  font-size: 1.25em;
}

#present-dialog p {
  margin: 0 0 12px;
  color: #e1e1e1;
  line-height: 1.4;
}

#present-dialog label {
  display: block;
  margin-bottom: 6px;
}

#present-name {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  font: inherit;
  color: white;
  background-color: #1e1e1e;
  border: 1px solid #666666;
  border-radius: 6px;
}

#present-replace {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #555555;
  border-radius: 6px;
}

/* A floated legend sits inside the border, so that a long one can wrap */
#present-replace legend {
  float: left;
  width: 100%;
  padding: 0;
  color: #e1e1e1;
  line-height: 1.4;
}

#present-replace-options {
  clear: both;
}

#present-replace-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 0;
  overflow-wrap: anywhere;
}

.dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

@media screen and (min-width: 800px) {
  .popup h1 {
    text-align: center;
  }

  .popup p {
    text-align: justify;
  }
}

/* Last, so that it wins over the display of the rules above with the same specificity */
.hidden {
  display: none;
}
