.room-shell {
  padding-block: clamp(1.15rem, 3vw, 2.4rem) 2.5rem;
}

.room-page:has(#room-entry:not([hidden])) {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100svh;
}

.room-page:has(#room-entry:not([hidden])) .room-shell {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: min(calc(100% - 2rem), 28rem);
  padding-block: 1.5rem;
}

.room-header-actions,
.room-results-actions,
.room-lobby-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .65rem;
}

.room-header-actions {
  flex-wrap: nowrap;
  justify-content: flex-end;
}

.room-page .brand-mark { flex: none; }

#room-header-exit-slot:empty,
#room-header-exit-slot:has(> button[hidden]) { display: none; }

.room-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: .52rem .95rem;
  border: 1px solid #b8d2c1;
  border-radius: .67rem;
  background: #e8f4e9;
  color: #265541;
  text-align: center;
  text-decoration: none;
  font-size: .9rem;
  font-weight: 780;
  white-space: nowrap;
}

.room-button:hover:not(:disabled) {
  border-color: #89b39b;
  background: #dceddf;
}

.room-button:disabled { opacity: .58; }
.room-button.room-plain { background: #f9fcf8; }
.room-button.room-plain:hover:not(:disabled) { background: #eaf4eb; }

.room-intro {
  margin-block-end: clamp(.85rem, 2.4vw, 1.35rem);
  text-align: center;
}

.room-intro h1 {
  color: #142d23;
  font-size: clamp(1.9rem, 4.5vw, 2.8rem);
  font-weight: 860;
  letter-spacing: -.035em;
  line-height: 1.18;
  text-wrap: balance;
}

#room-lobby {
  max-width: 56rem;
  margin-inline: auto;
}

.room-lobby-grid {
  display: grid;
  gap: .9rem;
  grid-template-columns: minmax(0, .72fr) minmax(0, 1.28fr);
}

.room-panel,
.room-scoring,
.room-invite {
  min-width: 0;
  padding: clamp(1rem, 3.1vw, 1.7rem);
  border: 1px solid #d9e7dc;
  border-radius: 1.08rem;
  background: #f9fcf8;
  box-shadow: var(--shadow);
}

.room-panel h2,
.room-scoring h3,
.room-invite h2 {
  font-size: clamp(1.15rem, 2.35vw, 1.35rem);
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.25;
}

.room-entry-form {
  display: grid;
  align-content: start;
  gap: .85rem;
  padding: clamp(1.1rem, 4vw, 2rem);
}

.room-entry-heading {
  display: grid;
  gap: .4rem;
  margin-block-end: .25rem;
  text-align: center;
}

.room-entry-heading h1 {
  color: #142d23;
  font-size: clamp(1.35rem, 5vw, 1.8rem);
  font-weight: 850;
  line-height: 1.25;
}

.room-entry-heading p {
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.55;
  text-wrap: balance;
}

.room-field {
  display: grid;
  gap: .3rem;
  min-width: 0;
  align-content: start;
}

.room-field label {
  color: #37594a;
  font-size: .86rem;
  font-weight: 760;
}

.room-field :is(input, select) {
  width: 100%;
  min-width: 0;
  min-height: 2.75rem;
  padding: .58rem .72rem;
  border: 1px solid #c7dacc;
  border-radius: .62rem;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.room-field :is(input, select):focus-visible {
  outline: 2px solid #2e875e;
  outline-offset: 2px;
}

.room-field :is(input, select):disabled {
  border-color: #d8e4da;
  background: #edf4ee;
  color: #405d50;
  opacity: 1;
}

.room-field input::placeholder { color: #6f887b; }
.room-field input.room-code-input { text-transform: uppercase; }

.room-create { width: 100%; }

.room-entry-form .primary-button {
  min-width: 0;
  min-height: 2.75rem;
  padding-inline: clamp(.7rem, 3vw, 1.1rem);
}

.room-join-field {
  padding-block-start: .72rem;
  border-block-start: 1px solid #dce9df;
}

.room-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: .48rem;
}

.room-scoring,
.room-invite,
.room-countdown {
  border-color: #305643;
  background: radial-gradient(ellipse at 90% 0%, #1e4e36, transparent 75%), #112f26;
  color: #f0f8ee;
}

.room-scoring > p,
.room-invite > p {
  margin-block-start: .52rem;
  color: #cedfd1;
  font-size: .9rem;
  text-wrap: pretty;
}

.room-multipliers {
  display: grid;
  margin: .85rem 0 0;
  padding: 0;
  list-style: none;
}

.room-multipliers > li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .55rem;
  padding-block: .34rem;
  border-block-end: 1px solid rgb(197 228 204 / .17);
  color: #dfecde;
  font-size: .9rem;
}

.room-multipliers strong {
  color: var(--figure-ink);
  font-size: 1.14rem;
  font-variant-numeric: tabular-nums;
  font-weight: 840;
  letter-spacing: -.035em;
}

.room-scoring > .room-solo-note { margin-block-start: .75rem; font-size: .82rem; }

.room-manual {
  position: fixed;
  inset: 0;
  width: min(calc(100% - 2rem), 36rem);
  max-width: none;
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #cbded0;
  border-radius: 1.08rem;
  background: #f9fcf8;
  color: var(--ink);
  box-shadow: 0 14px 48px rgb(16 47 38 / .2);
}

.room-manual::backdrop { background: rgb(16 47 38 / .55); }
.room-preferences:has(+ #room-manual[open])::backdrop { background: transparent; }

.room-manual-header {
  position: sticky;
  inset-block-start: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .7rem;
  padding: .75rem clamp(.9rem, 4vw, 1.45rem);
  border-block-end: 1px solid #d9e7dc;
  background: #f9fcf8;
}

.room-manual-header h2 {
  font-size: clamp(1.18rem, 4vw, 1.5rem);
  line-height: 1.25;
}

.room-manual-content {
  display: grid;
  gap: 1rem;
  padding: clamp(.9rem, 4vw, 1.45rem);
}

.room-preferences { width: min(calc(100% - 2rem), 25rem); }

.room-preferences-content {
  display: grid;
  gap: 1.15rem;
  padding: clamp(.9rem, 4vw, 1.45rem);
}

.room-preferences-content .room-manual-open {
  justify-content: flex-start;
}

.room-manual-rules {
  display: grid;
  gap: .52rem;
  color: #38594b;
  font-size: .93rem;
  text-wrap: pretty;
}

.room-manual-rules h3 { color: var(--ink); font-size: 1.15rem; }

.room-invite {
  display: grid;
  align-content: center;
  justify-items: start;
  min-height: 12.5rem;
}

.room-invite h2 { color: #d5e6d8; font-size: .96rem; }

.room-code {
  margin-block-start: .18rem;
  color: var(--figure-ink);
  font-family: ui-monospace, Consolas, monospace;
  font-size: clamp(1.85rem, 5.6vw, 3.55rem);
  font-weight: 820;
  line-height: 1.05;
  letter-spacing: .09em;
  overflow-wrap: anywhere;
}

.room-invite-copy {
  margin-block-start: .85rem;
  border-color: #b9ddc2;
  background: #e3f6e6;
}

.room-muted { color: var(--muted); font-size: .86rem; }

.room-roster,
.room-scores {
  display: grid;
  gap: .4rem;
  margin: .8rem 0 0;
  padding: 0;
  list-style: none;
}

.room-roster {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .58rem;
}

.room-lobby-panel {
  grid-column: 1 / -1;
}

.room-roster > li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .12rem .5rem;
  min-width: 0;
  min-height: 3.05rem;
  padding: .53rem .67rem;
  border: 1px solid #dce9df;
  border-radius: .55rem;
  background: #f1f7f0;
  overflow-wrap: anywhere;
}

.room-person-name { min-width: 0; color: #244b3c; font-size: 1.02rem; font-weight: 760; }
.room-person-detail { color: #557064; font-size: .83rem; }

.room-settings-panel {
  display: grid;
  align-content: center;
  padding: clamp(.85rem, 3vw, 1.15rem);
}

.room-settings-panel h2 { font-size: 1.12rem; }

.room-settings {
  display: grid;
  grid-template-columns: 1.15fr repeat(2, minmax(0, 1fr));
  gap: .48rem .65rem;
  min-width: 0;
  margin: .48rem 0 0;
  padding: 0;
  border: 0;
}

.room-settings :is(input, select) { padding-block: .35rem; }

.room-field-unit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: .38rem;
}

.room-field-unit > span { color: #597164; font-size: .86rem; }

.room-lobby-actions {
  justify-content: space-between;
  margin-block-start: .6rem;
}

.room-lobby-actions .primary-button {
  min-width: 0;
  min-height: 2.75rem;
  padding-inline: 1rem;
}

.room-lobby-exit {
  display: flex;
  justify-content: center;
  margin-block-start: .75rem;
}

.room-lobby-exit:empty { display: none; }

.room-message,
.room-notice {
  min-width: 0;
  margin-block-end: .85rem;
  padding: .5rem .75rem;
  border: 1px solid #d6e5d9;
  border-radius: .58rem;
  background: #f6fbf5;
  color: #365b48;
  font-size: .86rem;
  overflow-wrap: anywhere;
}

.room-message {
  border-color: #e5b6ad;
  background: var(--bad-bg);
  color: var(--bad);
}

.room-message:empty,
.room-notice:empty,
#room-review-score:empty { display: none; }

.room-hud { margin-block-end: .8rem; min-height: 4.2rem; }
.room-progress { color: var(--muted); font-size: .9rem; text-align: end; }
.room-board { gap: .85rem; }
.room-board .target-panel { min-height: 0; }
.room-board .target-plot { min-height: 13rem; }
.room-board .target-plot > svg { max-width: 100%; }
.room-board .option-card { min-height: 8.25rem; }
.room-board .option-card:disabled { opacity: 1; }

.room-countdown {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: .45rem;
  min-height: min(48vh, 19rem);
  padding: 1rem;
  border: 1px solid #305643;
  border-radius: 1.05rem;
  box-shadow: var(--shadow);
  text-align: center;
}

.room-countdown > p { color: #d6e7d8; font-size: 1rem; font-weight: 740; }
.room-countdown > strong {
  color: var(--figure-ink);
  font-size: clamp(2.5rem, 9vw, 5.4rem);
  font-variant-numeric: tabular-nums;
  font-weight: 870;
  line-height: 1.05;
}

.room-countdown:not([hidden]) + .room-board { display: none; }
.room-round-scores { margin-block-start: .85rem; }
.room-results-panel { max-width: 56rem; }
.room-results-actions { margin-block-start: 1.1rem; }

.room-score-row {
  display: grid;
  grid-template-columns: minmax(2rem, auto) minmax(0, 1fr) minmax(2.5rem, auto);
  align-items: baseline;
  column-gap: .65rem;
  row-gap: .13rem;
  min-width: 0;
  padding: .58rem .75rem;
  border: 1px solid #dce9df;
  border-radius: .57rem;
  background: #f2f8f1;
}

.room-place {
  color: #436653;
  font-size: .86rem;
  font-variant-numeric: tabular-nums;
  font-weight: 780;
}

.room-score-name { color: #244a3b; font-weight: 790; overflow-wrap: anywhere; }
.room-score-points {
  grid-column: 3;
  grid-row: 1;
  color: #1e5a41;
  text-align: end;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-weight: 830;
}

.room-score-detail {
  grid-column: 2 / -1;
  color: var(--muted);
  font-size: .82rem;
  white-space: normal;
  overflow-wrap: anywhere;
}

.room-score-time,
.room-score-factor { white-space: nowrap; font-variant-numeric: tabular-nums; }
.room-final-scores .room-score-row:first-child { border-color: #a8ccb3; background: #e7f4e8; }

.room-review-rounds { grid-template-columns: repeat(auto-fit, minmax(4rem, 1fr)); }
#room-review-score { margin-block-start: .38rem; }
#room-review-status { color: #d2e9d8; text-align: end; font-size: .85rem; }

@media (max-width: 48rem) {
  .room-page:has(#room-match:not([hidden])) .room-shell { padding-block-start: .72rem; }
  .room-board .target-plot { min-height: 0; }
  .room-board .target-plot > svg { max-height: clamp(7.3rem, 24vh, 12rem); }
  .room-board .option-card { min-height: 6.7rem; }
  .room-board .option-plot > .chart-svg { max-height: 6.2rem; }
}

@media (max-width: 39rem) {
  .room-lobby-grid { grid-template-columns: minmax(0, 1fr); gap: .7rem; }
  .room-invite { min-height: 0; }
  .room-hud { align-items: stretch; flex-direction: column; margin-block-end: .58rem; }
  .room-hud .stats { justify-content: space-between; }
  .room-hud .stat { flex: 1; }
  .room-progress:empty { display: none; }
  .room-progress { font-size: .8rem; text-align: start; }
  .room-board { gap: .65rem; }
  .room-board .target-plot > svg { max-height: clamp(6.8rem, 20vh, 9.4rem); }
  .room-board .option-card { min-height: 6rem; }
  .room-board .option-plot > .chart-svg { max-height: 5.65rem; }
  .room-results-actions > * { min-height: 2.58rem; }
}

@media (max-width: 30rem) {
  .room-page .masthead-inner { gap: .5rem; }
  .room-header-actions { gap: .35rem; }
  .room-header-actions .room-button { padding-inline: .62rem; font-size: .83rem; }
  .room-settings { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .room-settings > .room-field:first-of-type { grid-column: 1 / -1; }
  .room-score-row { padding-inline: .48rem; column-gap: .4rem; }
  .room-review-rounds { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (max-width: 22rem) {
  .room-page .brand { font-size: .85rem; letter-spacing: 0; }
  .room-header-actions .room-button { padding-inline: .43rem; font-size: .79rem; }
}
