@media (min-width: 900px) {
  .room-lobby:not(.home-layout, .opening-page) {
    margin-top: 82px;
    margin-bottom: 12px;
  }
}

/* Keep the waiting room controls in the first screen at laptop heights. */
@media (min-width: 900px) and (max-height: 1000px) {
  .room-lobby:not(.home-layout) .lobby-card { padding: 15px 24px; }
  .room-lobby:not(.home-layout) .lobby-card h1 { font-size: 27px; margin: 2px 0 9px; }
  .room-lobby .platform-room-invite {
    display: grid;
    grid-template-columns: minmax(200px, .75fr) minmax(0, 1.25fr);
    align-items: center;
    gap: 6px 14px;
    padding: 9px 14px;
    margin: 7px 0;
  }
  .room-lobby .room-invite-copy strong { font-size: 17px; }
  .room-lobby .room-invite-copy p { font-size: 13px; line-height: 1.35; }
  .room-lobby .room-invite-link { flex-basis: auto; font-size: 13px; }
  .room-lobby .room-invite-link input { padding: 6px 9px; font-size: 13px; }
  .room-lobby .platform-room-invite .room-code { grid-column: 1 / -1; margin: 0; }
  .room-lobby .turn-settings { margin: 7px 0; padding: 7px 12px; }
  .room-lobby .turn-settings-summary { font-size: 13px; line-height: 1.3; }
  .room-lobby .turn-settings-fields { margin-top: 5px; gap: 8px 12px; }
  .room-lobby .turn-settings-fields label { font-size: 12px; gap: 2px; }
  .room-lobby .turn-settings-fields select { min-height: 30px; padding: 2px 7px; }
  .room-lobby .turn-settings-fields .button { min-height: 30px; padding: 4px 12px; }
  .room-lobby .turn-settings > .muted { margin-top: 4px; font-size: 12px; }
  .room-lobby .lobby-card .lobby-seats { margin: 10px 0; gap: 12px; }
  .room-lobby .lobby-card .lobby-seat { min-height: 142px; padding: 8px; gap: 4px; }
  .room-lobby .member-avatar { width: 40px; height: 40px; font-size: 26px; }
  .room-lobby .member-name { font-size: 17px; }
  .room-lobby .member-role { font-size: 13px; }
  .room-lobby .member-ready-status { font-size: 13px; padding: 2px 6px; }
  .room-lobby .room-action-reason { margin: 7px 0; padding: 5px 8px; font-size: 14px; }
  .room-lobby .room-start-bar { margin-top: 8px; padding-top: 8px; gap: 8px; }
  .room-lobby .room-start-bar > .button { min-width: 125px; min-height: 39px; font-size: 15px; }
  .room-lobby .lobby-card > .muted { font-size: 13px; line-height: 1.35; }
  .room-lobby .lobby-card:has(.opening-stage) > .room-code { margin: 2px 0; }
}

.room-lobby.opening-page {
  width: min(920px, calc(100% - 32px));
  margin: clamp(18px, 5vh, 52px) auto 12px;
  padding: clamp(14px, 2.1vw, 28px);
  background: #fcf7e9f2;
  border: 1px solid #c9b68f;
  border-top: 3px solid var(--seal);
  box-shadow: 2px 4px 0 #b6a58645, 0 12px 40px #51412616;
}

.opening-page .opening-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid #d9c9a8;
}
.opening-page .opening-status h2 { margin: 0 0 4px; font-size: clamp(20px, 2.5vw, 30px); overflow-wrap: anywhere; }
.opening-page .opening-status p { margin: 0; font-size: 15px; line-height: 1.4; }
.opening-page .turn-clock-bar {
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  width: 148px;
  margin: 0;
  padding: 6px 10px;
}
.opening-page .turn-clock-mode { grid-column: 1; grid-row: 1; justify-self: start; font-size: 12px; }
.opening-page .turn-clock-label { grid-column: 1; grid-row: 2; font-size: 21px; line-height: 1.2; font-variant-numeric: tabular-nums; }

.opening-page .dice-players { gap: 12px; margin: 16px 0; }
.opening-page .dice-player { max-width: 192px; padding: 10px 8px; }
.opening-page .dice-player strong { font-size: 16px; }
.opening-page .dice-player > .opening-account-avatar { --seat-portrait: 52px; }
.opening-page .dice-player .stone-die { margin: 38px auto 25px; }
.opening-page .dice-player > .muted { min-height: 0; font-size: 15px; line-height: 1.35; }
.opening-page .dice-rank { min-height: 0; font-size: 13px; }
.opening-roll-actions { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.opening-page .roll-button { margin: 0; min-height: 44px; padding: 8px 20px; }
.opening-page .dice-replay { margin: 0; min-height: 44px; }
.opening-page .tie-notice { margin: 10px 0 0; }
.opening-page .opening-history { margin-top: 10px; }

.opening-page .choice-queue {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 7px;
  margin: 12px 0;
}
.opening-page .queue-person { display: flex; gap: 5px; align-items: center; min-width: 0; padding: 4px 7px; font-size: 13px; }
.opening-page .queue-person > .opening-account-avatar { --seat-portrait: 26px; }
.queue-person-copy { display: grid; min-width: 0; }
.queue-person-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-person-status { font-size: 12px; line-height: 1.3; }
.opening-page .opening-choice {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 14px;
}
.opening-page .seat-picker,
.opening-page .faction-picker {
  min-width: 0;
  padding: 12px;
  border: 1px solid #d9c9a8;
  background: #fffaf1a6;
}
.opening-page .opening-choice h3 { margin: 0 0 2px; font-size: 18px; }
.opening-page .opening-choice p { margin: 0 0 8px; line-height: 1.3; font-size: 13px; }
.opening-page .seat-table { grid-template-rows: repeat(3, minmax(52px, auto)); gap: 5px; }
.opening-page .seat-choice { min-width: 0; padding: 4px; gap: 2px; line-height: 1.2; text-align: center; }
.opening-page .seat-choice strong { font-size: 16px; }
.opening-page .seat-choice-detail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.opening-page .seat-choice.occupied { grid-template-columns: 28px minmax(0, 1fr); text-align: left; }
.opening-page .seat-choice.occupied .illustrated-avatar { width: 28px; height: 28px; min-width: 28px; }
.opening-page .faction-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.opening-page .faction-card { grid-template-columns: 52px minmax(0, 1fr); min-height: 64px; padding: 4px 6px; }
.opening-page .faction-card .illustrated-avatar { width: 52px; height: 52px; flex-basis: 52px; margin: 0; }
.opening-page .faction-card:not(:has(small)) > strong { grid-row: 1 / -1; align-self: center; }
.opening-page .opening-confirm { margin-top: 12px; padding-top: 10px; gap: 7px; }
.opening-page .opening-confirm .button { min-height: 44px; padding: 6px 18px; white-space: nowrap; }

@media (max-width: 700px) {
  .room-lobby.opening-page { width: calc(100% - 20px); margin-top: 12px; padding: 11px; }
  .opening-page .opening-heading { gap: 7px; padding-bottom: 8px; }
  .opening-page .opening-status p { font-size: 13px; }
  .opening-page .turn-clock-bar { width: 100px; padding: 5px 6px; }
  .opening-page .turn-clock-label { font-size: 17px; }
  .opening-page .dice-players { gap: 8px; margin: 10px 0; }
  .opening-page .dice-player { max-width: none; padding: 7px 4px; }
  .opening-page .dice-player > .opening-account-avatar { --seat-portrait: 40px; }
  .opening-page .dice-player .stone-die { margin: 28px auto 19px; }
  .opening-page .choice-queue { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 8px 0; }
  .opening-page .opening-choice { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .opening-page .seat-picker,
  .opening-page .faction-picker { padding: 8px; }
  .opening-page .seat-table { grid-template-rows: repeat(3, minmax(44px, auto)); }
  .opening-page .faction-card { grid-template-columns: 40px minmax(0, 1fr); min-height: 50px; }
  .opening-page .faction-card .illustrated-avatar { width: 40px; height: 40px; flex-basis: 40px; }
  .opening-page .opening-confirm { flex-wrap: nowrap; font-size: 13px; }
}

@media (max-width: 700px) and (max-height: 740px) {
  .room-lobby.opening-page { margin-top: 8px; }
  .opening-roll-actions { flex-wrap: nowrap; }
  .opening-page .roll-button { min-width: 0; flex: 1; }
  .opening-page .dice-player { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; }
  .opening-page .dice-player strong { grid-column: 2; grid-row: 1; font-size: 14px; line-height: 1.25; text-align: left; }
  .opening-page .dice-player > .opening-account-avatar { --seat-portrait: 32px; }
  .opening-page .dice-player > :is(.stone-die, .muted, .dice-rank) { grid-column: 1 / -1; }
  .opening-page .dice-player .stone-die {
    --die-size: 60px;
    --die-half: 29px;
    width: var(--die-size);
    height: var(--die-size);
    margin: 18px auto 16px;
  }
  .opening-page .die-face { padding: 9px; gap: 4px; }
  .opening-page .die-face .die-pip { width: 8px; height: 8px; }
  .opening-page .stone-die .die-question { inset: 9px; font-size: 35px; }
  .opening-page .queue-person > .opening-account-avatar { --seat-portrait: 20px; }
  .opening-page .queue-person-status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .opening-page .seat-table { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: minmax(44px, auto); }
  .opening-page .seat-choice { grid-area: auto; align-items: stretch; }
  .opening-page .seat-choice.occupied { display: flex; text-align: center; }
  .opening-page .seat-center, .opening-page .seat-choice.occupied .illustrated-avatar { display: none; }
  .opening-page .opening-confirm { margin-top: 6px; padding-top: 6px; }
}

@media (min-width: 1100px) and (min-height: 650px) and (orientation: landscape) {
  #app:has(> .game-layout) > .turn-clock-bar[hidden] {
    display: grid;
    visibility: hidden;
  }
  #app:has(> .game-layout .watch-toolbar):not(:has(> .turn-clock-bar:not([hidden]))) > .game-layout {
    margin-top: 0;
  }
}
