/* The host page: rooms, the room form, and (later) the game and its board. */

main.host-main {
  display: block;
  max-width: 900px;
  margin: 0 auto;
  padding: 16px 16px 32px;
}

.host-main h2 {
  margin: 8px 0;
  font-size: 20px;
}

.room-list {
  list-style: none;
  margin: 12px 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.room {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  padding: 10px 14px;
  display: grid;
  gap: 6px;
}

.room h3 {
  margin: 0;
  font-size: 17px;
  overflow-wrap: anywhere;
}

.room .buttons {
  flex-wrap: wrap;
}

.room-form,
.incoming {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  padding: 12px 16px;
  margin: 12px 0;
  display: grid;
  gap: 10px;
}

.field {
  display: grid;
  gap: 4px;
  font-weight: 600;
}

.field input,
.field select {
  font: inherit;
  font-weight: 400;
  max-width: 100%;
}

#room-topics {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px 18px;
}

.problems {
  margin: 0;
  padding-left: 20px;
}

.problems:empty {
  display: none;
}

.host-game {
  display: grid;
  gap: 8px;
}

/* A game is shown on a class screen: use the width, and larger text. */
main.host-main.playing {
  max-width: 1400px;
}

.join-how {
  margin: 4px 0;
  font-size: 18px;
}

.join-how a {
  font-weight: 600;
}

.game-status {
  margin: 4px 0;
  font-size: 18px;
  font-weight: 600;
}

/* After the end: the code no longer lets anyone in. */
.join.ended .join-code {
  text-decoration: line-through;
  opacity: 0.45;
}

.join.ended .live-only {
  display: none;
}

.lobby-box > summary {
  cursor: pointer;
  font-size: 17px;
  font-weight: 700;
  margin: 8px 0 4px;
}

.board li.left {
  opacity: 0.5;
}

.join {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  padding: 12px 16px;
  text-align: center;
}

.join-code {
  margin: 4px 0;
  font: 700 clamp(48px, 12vw, 96px) / 1.1 ui-monospace, monospace;
  letter-spacing: 0.12em;
  overflow-wrap: anywhere;
}

.join a {
  overflow-wrap: anywhere;
}

/* End sits apart from Start, so a click meant for one never lands on the other. */
#game-end {
  margin-left: auto;
}

.host-game h3 {
  margin: 8px 0 0;
  font-size: 17px;
}

.lobby {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px;
}

.lobby li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 4px 4px 4px 10px;
  overflow-wrap: anywhere;
}

/* The rows share the board's columns (subgrid), so the bars line up. */
.board {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 2em minmax(0, 1fr) minmax(0, 2fr) auto;
  gap: 4px 0.5em;
  /* At least 24 px on a 1920 px projector, and smaller on a phone. */
  font-size: clamp(16px, 1.6vw, 40px);
}

.board li {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  align-items: center;
}

.board .place {
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.board .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.bar-track {
  height: 0.6em;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.bar-track > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
}

.board li.finished .bar-track > span {
  background: #3ccf7e;
}

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

/* On a phone the bar takes its own line, so nothing scrolls sideways. */
@media (max-width: 480px) {
  .board {
    grid-template-columns: 2em minmax(0, 1fr) auto;
  }

  .board .bar-track {
    grid-column: 2 / -1;
    grid-row: 2;
  }
}

.link-dialog {
  max-width: min(560px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
}

.link-dialog textarea {
  width: 100%;
  box-sizing: border-box;
  font: 13px/1.4 ui-monospace, monospace;
  overflow-wrap: anywhere;
}
