.lobby {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
  width: 100%;
  max-width: 360px;
}
.lobby[hidden] { display: none; }
.lobby-title {
  font-size: 22px;
  font-weight: 500;
  margin: 0 0 8px;
}
.lobby-btn {
  padding: 12px 20px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  font: inherit;
  font-size: 16px;
  color: var(--link-color);
  text-decoration: none;
  cursor: pointer;
}
.lobby-btn:hover { background: #f0f0f0; }
.lobby-or {
  margin: 4px 0;
  color: #888;
  font-size: 13px;
}
.join-form {
  display: flex;
  gap: 8px;
  width: 100%;
}
.join-code {
  flex: 1;
  padding: 12px;
  font: inherit;
  font-size: 18px;
  font-family: 'Courier New', monospace;
  letter-spacing: 4px;
  text-align: center;
  text-transform: uppercase;
  border: 1px solid #ccc;
  border-radius: 6px;
}
.join-code:focus { outline: 2px solid var(--link-color); outline-offset: -2px; }
.lobby-error {
  color: #c5302d;
  font-size: 14px;
  margin: 4px 0 0;
}

.online-game[hidden] { display: none; }
.room-line {
  font-size: 14px;
  color: #666;
  margin: 0 0 4px;
}
/* When the share button is showing, stretch the row to reach the grid's
   visual right edge. The grid is 3.5 × cell wide but uses margin-left: -cell/4
   to shift left inside .online-game, so its right edge lands at 3.25 × cell
   from .online-game's left. We match that width here so the share icon is
   flush with the grid's right edge, while still leaving room-line's left edge
   inside .online-game (not off-screen on narrow viewports). */
.room-line:has(.share-link:not([hidden])) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: calc(var(--grid-cell) * 3.25);
}
.room-line strong {
  font-family: 'Courier New', monospace;
  font-size: 18px;
  letter-spacing: 4px;
  color: #1c1c1c;
}
.share-link {
  padding: 4px 0 4px 6px;
  background: none;
  border: none;
  color: var(--link-color);
  cursor: pointer;
  border-radius: 6px;
  vertical-align: middle;
  line-height: 0;
}
.share-link:hover { background: rgba(0, 0, 0, 0.05); }
.share-link[hidden] { display: none; }
.share-icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81 1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9c-1.66 0-3 1.34-3 3s1.34 3 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.16c-.05.21-.08.43-.08.65 0 1.61 1.31 2.92 2.92 2.92s2.92-1.31 2.92-2.92-1.31-2.92-2.92-2.92z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81 1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9c-1.66 0-3 1.34-3 3s1.34 3 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.16c-.05.21-.08.43-.08.65 0 1.61 1.31 2.92 2.92 2.92s2.92-1.31 2.92-2.92-1.31-2.92-2.92-2.92z'/%3E%3C/svg%3E") center / contain no-repeat;
  vertical-align: middle;
}
.share-link.copied .share-icon {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E");
  color: #1f8a3a;
}
.role-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  margin: 0 0 4px;
}
.role-line .muted { color: #666; }
.status-line {
  font-size: 14px;
  color: #666;
  margin: 0 0 12px;
  min-height: 20px;
}
.status-line.peer-missing { color: #c5302d; }
.status-line.your-turn { color: var(--link-color); font-weight: 500; }

/* Online rematch lives behind a real <button> (sends a server message,
   doesn't navigate) but should read like the link-styled "Play again" on
   the other game pages. */
.result-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--link-color);
  text-decoration: underline;
  cursor: pointer;
}
.result-link:hover { text-decoration: none; }
.result-link[disabled] { color: #888; cursor: default; text-decoration: none; }
