.online-room {
  margin: 12px 0 24px;
  min-width: 0;
}
.online-room .actions,
#onlineGuess .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.online-room .status:empty {
  display: none;
}
.online-room-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
#onlineRoomCode {
  font-size: clamp(22px, 4vw, 32px);
  color: var(--yellow, #ffe16b);
  letter-spacing: 0.12em;
  overflow-wrap: anywhere;
}
#onlineCodeWrap {
  display: block;
  margin: 16px 0;
}
#onlineCodeInput {
  display: block;
  max-width: 100%;
  width: 260px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.online-badge,
.online-connection {
  display: block;
  font-size: 11px;
  text-align: center;
  overflow-wrap: anywhere;
}
.online-badge {
  color: var(--yellow, #ffe16b);
}
.online-room .online-kick {
  font-size: 11px;
  padding: 8px;
  min-width: 0;
}
.online-paused {
  border: 2px solid var(--yellow, #ffe16b);
  padding: 12px;
}
#onlineConnect {
  margin-top: 16px;
}
/* Online uses the existing local game structures and CSS. Only ownership,
   room controls and remote-device layout details belong here. */
#onlineGuess, #onlinePlay, #onlineBoards > * { min-width: 0; }
#onlineGuess .online-readonly { cursor: default; }
#onlineGuess .online-readonly:hover { transform: none; }
#onlineGuess :is(.game-header, .secret-selection-header) > div:first-child { min-width: 0; }
#onlineGuess h2, #onlinePlay h2, #onlinePlay h3 { font-family: "Reggae One", "Segoe UI", sans-serif; font-weight: 400; }
#onlinePlay .actions, #onlineGuess .actions { display: flex; flex-wrap: wrap; gap: 12px; }
#onlinePlay input { min-width: 0; max-width: 100%; }
#onlinePlay .auction-status { margin: 8px 0; font-size: 12px; font-weight: 900; color: var(--yellow); line-height: 1.4; }
#onlinePlay .multi-ready { width: fit-content; margin: 14px auto 18px; }
#onlinePlay .section-bottom-action { margin-top: 24px; }
#onlinePlay .multi-answer-list { max-height: 280px; overflow-y: auto; }
#onlinePlay .zoom-touch-grid { height: 55dvh; }
#onlinePlay .multi-position-grid > button { min-height: 0; }
body.online-touch-session { overflow: hidden; }
#onlinePlay.zoom-touch-setup { display: flex; flex-direction: column; gap: 10px; }
#onlinePlay.zoom-touch-setup.hidden { display: none; }
#onlinePlay.zoom-touch-setup .multi-touch-preview { display: flex; flex-direction: column; flex: 1; min-height: 160px; gap: 8px; }
#onlinePlay.zoom-touch-setup .zoom-touch-grid { height: auto; }
#onlinePlay.zoom-touch-setup :is(h2,h3) { font-size: 22px; margin: 0; }
#onlinePlay.zoom-touch-setup .multi-touch-preview > p { font-size: 14px; margin: 0; }
#onlinePlay.zoom-touch-setup > .game-header { padding: 6px; margin: 0; }
#onlinePlay.zoom-touch-setup > .game-header h2 { font-size: 18px; }
#onlinePlay.zoom-touch-setup .game-header .actions button { padding: 6px; font-size: 11px; }
#onlinePlay.zoom-touch-game .game-header { padding: 6px; margin: 0; }
#onlinePlay.zoom-touch-game .game-header h2 { font-size: 18px; margin: 0; }
#onlinePlay.zoom-touch-game .game-header .panel-label { display: none; }
#onlinePlay.zoom-touch-game .game-header .actions button { font-size: 11px; padding: 6px; }
#onlinePlay.zoom-touch-game .multi-answer-list { max-height: 24dvh; }
#onlinePlay.zoom-touch-listening > .game-header { z-index: 4; pointer-events: none; background: none; border: 0; box-shadow: none; }
#onlinePlay.zoom-touch-listening > .game-header button { pointer-events: auto; }
#onlinePlay.zoom-touch-listening .multi-zoom-actions { position: absolute; bottom: max(8px,env(safe-area-inset-bottom)); left: 12px; right: 12px; z-index: 4; margin: 0; }
#onlinePlay.zoom-touch-listening .multi-zoom-hint { position: relative; z-index: 3; pointer-events: none; width: fit-content; background: #15171de6; padding: 5px; }
#onlinePlay.zoom-touch-game[data-touch-phase="answering"] .game-header h2,
#onlinePlay.zoom-touch-game[data-touch-phase="answering"]:not(.zoom-touch-answer-entry) .multi-zoom-points { display: none; }
#onlinePlay.zoom-touch-game[data-touch-phase="answering"] .game-header { flex-shrink: 0; }
#onlinePlay.zoom-touch-game[data-touch-phase="answering"] > .zoom-menu-area { margin-top: 6px; padding-top: 4px; }
@media (max-width: 720px) {
  .online-room .actions > button, #onlineGuess .actions > button { width: 100%; }
  .online-room .player-card { min-width: 0; }
  .online-room-heading { gap: 8px; }
}
/* Individual editor can be slightly wider than .app, just like the local one.
   Center that width explicitly rather than letting overflow anchor it to the left. */
#onlineGuess[data-phase="editor"] { position: relative; left: 50%; margin-inline: 0; transform: translateX(-50%); }

/* One visual group and one kick control per browser/session. */
.online-devices { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 12px; margin-top: 16px; }
.online-device { --device-color: var(--blue); min-width: 0; padding: 10px; border: 2px solid var(--line); border-top: 4px solid var(--device-color); background: var(--panel-2); }
.online-device[data-device="1"] { --device-color: var(--yellow); }
.online-device[data-device="3"] { --device-color: var(--orange); }
.online-device[data-device="4"] { --device-color: #b297ff; }
.online-device[data-device="5"] { --device-color: #68d6a5; }
.online-device[data-device="6"] { --device-color: #ee8db3; }
.online-device-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 8px; }
.online-device-heading h3 { margin: 0; font-size: 12px; color: var(--device-color); }
.online-device-heading .online-connection { margin-left: auto; }
.online-device-players { flex-wrap: wrap; justify-content: center; overflow: visible; gap: 10px; padding-top: 8px; }
.online-device-players .player-card { flex: 0 0 104px; min-width: 0; }
.online-room .online-kick { flex: 0 1 auto; max-width: 100%; min-height: 30px; padding: 5px 7px; font-size: 9px; line-height: 1.3; white-space: normal; overflow-wrap: anywhere; box-shadow: 2px 2px 0 var(--ink); }
.online-device-players .player-remove { width: 24px; height: 24px; padding: 0; min-width: 0; min-height: 0; line-height: 1; }
#onlineConnect { padding: 14px; }
#onlineConnect h3 { margin-top: 0; font-size: 16px; }
@media (max-width: 420px) { .online-devices { grid-template-columns: minmax(0, 1fr); } }

/* Back navigation is secondary to the phase-completion action. */
#onlineGuess .online-menu-action, #onlinePlay .online-menu-action { display: inline-flex; align-items: center; justify-content: center; gap: 7px; width: fit-content !important; max-width: 100%; min-height: 30px; padding: 5px 9px !important; font-size: 11px !important; line-height: 1.3; background: transparent; color: var(--muted); border: 1px solid var(--line); box-shadow: none; letter-spacing: 0; }
.online-menu-action::after { display: none; }
.online-menu-action:hover { color: var(--text) !important; border-color: var(--muted) !important; transform: none; }
.online-back-arrow { font: 18px Arial,sans-serif; }
.online-waiting { margin: 24px auto; padding: 22px 16px; width: min(100%, 760px); text-align: center; font-family: "Reggae One", "Segoe UI", sans-serif; font-size: clamp(18px,3vw,26px); color: var(--yellow); line-height: 1.5; border-block: 1px solid var(--line); }
#onlinePlay .multi-position-grid button.zoom-tested { outline: 3px solid var(--yellow); filter: brightness(1.3); }
#onlinePlay .zoom-suggestion-active { background: var(--yellow); color: var(--ink); outline: 2px solid var(--yellow); }
.online-add-player { font-size: 36px; }
.online-add-player:disabled { opacity: .3; cursor: not-allowed; }
#status:empty { display: none; }
@media (max-width: 720px) { .online-waiting { margin: 12px auto; padding: 14px 10px; } }
/* The shared touch setup hides generic help paragraphs, not the ready/queue state. */
#onlinePlay.zoom-touch-setup > .online-waiting { display: block; flex-shrink: 0; }

/* Compact room during all game phases; lobby keeps the full profile editor. */
.online-player-name { display: none; }
.online-room.online-room-compact { padding: 10px 12px; margin: 10px 0 16px; }
.online-room-compact #onlineActive { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px 14px; align-items: center; }
.online-room-compact .online-room-heading { margin: 0; gap: 6px 12px; font-size: 11px; }
.online-room-compact #onlineRoomCode { font-size: 17px; }
.online-room-compact #onlineActive > .actions { gap: 8px; }
.online-room-compact #onlineActive > .actions > button { width: auto; padding: 6px 9px; font-size: 10px; min-height: 32px; box-shadow: 2px 2px 0 var(--ink); }
.online-room-compact .online-devices { grid-column: 1 / -1; display: flex; flex-wrap: wrap; margin: 0; gap: 6px; }
.online-room-compact .online-device { flex: 1 1 180px; padding: 5px 7px; border-width: 1px; border-left: 3px solid var(--device-color); }
.online-room-compact .online-device-heading { gap: 4px 8px; margin: 0 0 4px; }
.online-room-compact .online-device-heading h3 { font-size: 10px; }
.online-room-compact :is(.online-badge,.online-connection) { font-size: 9px; }
.online-room-compact .online-device-players { gap: 4px 8px; padding: 0; justify-content: flex-start; }
.online-room-compact .online-device-players .player-card { flex: 0 1 auto; width: auto; max-width: 100%; padding: 2px 5px; border: 0; border-left: 2px solid var(--device-color); box-shadow: none; }
.online-room-compact .player-card :is(.player-avatar,input) { display: none; }
.online-room-compact .online-player-name { display: block; font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.online-room-compact .online-paused { margin: 8px 0 0; padding: 7px; font-size: 12px; }
#onlineGuess .online-menu-action, #onlinePlay .online-menu-action { position: relative; display: inline-block; padding-inline: 30px !important; text-align: center; }
.online-back-arrow { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); line-height: 1; pointer-events: none; }
@media (max-width: 720px) {
  .online-room.online-room-compact { padding: 8px; }
  .online-room-compact #onlineActive { grid-template-columns: minmax(0,1fr); gap: 7px; }
  .online-room-compact #onlineActive > .actions { justify-content: flex-end; }
  .online-room-compact .online-devices { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .online-room-compact .online-device { min-width: 0; }
  .online-room-compact .online-device-heading .online-connection { margin-left: 0; }
}

/* Small portraits stay visible without restoring the full lobby profile cards. */
.online-room-compact .online-device-players .player-card {
  display: flex; align-items: center; gap: 5px; flex: 1 1 115px; min-width: 0; padding: 2px 4px;
}
.online-room-compact .player-card .player-avatar {
  display: block; flex: 0 0 26px; width: 26px; height: 34px; min-height: 0; padding: 0;
  border: 1px solid var(--ink); box-shadow: none; opacity: 1; cursor: default;
}
.online-room-compact .online-player-name { min-width: 0; line-height: 1.25; }
.online-room-compact .online-device-heading { align-items: baseline; line-height: 1.3; }
.online-room-compact .online-device-heading h3 { white-space: nowrap; }
.online-room-compact :is(.online-badge,.online-connection) { white-space: nowrap; line-height: 1.3; }
#onlineReady { font-weight: 800; color: var(--yellow); line-height: 1.5; overflow-wrap: anywhere; }
@media (max-width: 720px) {
  .online-room-compact .online-room-heading { align-items: baseline; }
  .online-room-compact #onlineRoomRole, .online-room-compact #onlineRoomCount { white-space: nowrap; }
  .online-room-compact .online-device-heading { gap: 2px 5px; }
  .online-room-compact .online-device-heading h3 { flex-basis: 100%; }
  .online-room-compact :is(.online-badge,.online-connection) { font-size: 8px; }
  .online-room-compact .online-device-players { gap: 3px; }
  .online-room-compact .player-card .player-avatar { flex-basis: 23px; width: 23px; height: 30px; }
  .online-room-compact .online-player-name { font-size: 11px; }
}

#onlineReady { margin: 24px auto 12px; max-width: 900px; text-align: center; font-size: clamp(15px,2vw,20px); }
#onlineReady:not(.hidden) + #onlineBottomActions { margin-top: 8px; }

/* Local/online is a presentation choice until a room is created or joined. */
.play-mode-selector { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0 0 16px; max-width: 560px; }
.play-mode-selector button { min-width: 0; min-height: 46px; padding: 12px 10px; font-size: 13px; overflow-wrap: anywhere; background: var(--panel-2); color: var(--text); }
.play-mode-selector button[aria-pressed="true"] { background: var(--orange); color: var(--ink); border-color: var(--ink); }
.play-mode-selector button:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }
.play-mode-selector button:disabled { opacity: 1; cursor: default; }
.online-room-compact .play-mode-selector { display: none; }
@media (max-width: 480px) {
  .play-mode-selector { gap: 8px; }
  .play-mode-selector button { font-size: 11px; padding: 12px 6px; }
}

#onlineToolbar { justify-content: flex-start; }

/* In the lobby the room replaces the local roster inside Players. */
.players-settings.online-active > :is(#playerList, #playerNameSuggestions, #playerSaveStatus),
#setup.online-guest > :not(.players-settings) { display: none; }

/* Symmetric side tracks keep the secret centered even when its action is visible. */
.online-secret-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) min(102px, 40%) minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  width: 100%;
}
.online-secret-row > .secret-card-wrap { grid-column: 2; min-width: 0; }
.online-secret-row .secret-card { width: 100%; }
.online-secret-row > .online-secret-reveal {
  position: absolute;
  left: calc(50% + min(51px, 20%) + 6px);
  top: 50%;
  translate: 0 -50%;
  width: max-content;
  max-width: calc(50% - min(51px, 20%) - 6px);
  min-width: 0;
  padding: 7px 6px;
  font-size: 10px;
  line-height: 1.2;
  white-space: normal;
  overflow-wrap: anywhere;
}
.online-secret-reveal::after { display: none; }

/* Secret selection only renders players on this device. */
#onlineGuess[data-phase="secret"] #onlineBoards:has(> .secret-selection-player:only-child) {
  grid-template-columns: minmax(0, 600px);
  justify-content: center;
}

.online-departure {
  margin: 8px 0 16px;
  padding: 10px 12px;
  border-left: 3px solid var(--yellow);
  color: var(--yellow);
  font-weight: 800;
  overflow-wrap: anywhere;
}
.online-departure:empty { display: none; }

#onlinePlay.zoom-touch-answer-entry .multi-answer-list { max-height: none; }

.zoom-control-notice { flex-shrink: 0; margin: 4px 0; color: var(--yellow); font-size: 14px; font-weight: 800; text-align: center; }
.zoom-control-notice:empty { display: none; }
