.room-dialog {
  width: min(490px, calc(100% - 18px));
  max-height: calc(100dvh - 18px);
  overflow: hidden;
}

.room-entry,
.room-lobby {
  max-height: calc(100dvh - 20px);
  overflow-y: auto;
  padding: 22px 18px calc(18px + env(safe-area-inset-bottom));
}

.room-entry h2,
.room-lobby h2 {
  margin: 0 0 16px;
  font-family: "SimSun", "Songti SC", serif;
  font-size: 22px;
  line-height: 1.3;
}

.room-modes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 17px;
  border: 1px solid #a89f90;
  border-radius: 3px;
}

.room-modes button {
  min-width: 0;
  min-height: 38px;
  padding: 5px 3px;
  border: 0;
  border-right: 1px solid #a89f90;
  background: transparent;
  color: #494b45;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.room-modes button:last-child {
  border-right: 0;
}

.room-modes button.is-active {
  background: var(--green);
  color: #fff;
}

.room-entry form > label,
.room-code-field label,
.character-picker legend {
  display: block;
  margin-bottom: 6px;
  color: #5d5d55;
  font-size: 12px;
  font-weight: 800;
}

.room-entry input[type="text"],
.room-entry input[name="nickname"] {
  width: 100%;
  height: 44px;
  padding: 0 11px;
  border: 1px solid #a89f90;
  border-radius: 3px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  text-transform: none;
}

.room-code-field {
  margin-top: 12px;
}

#roomCodeInput,
#recoveryCodeInput {
  letter-spacing: 0;
  text-transform: uppercase;
}

.character-picker {
  min-width: 0;
  margin: 17px 0 0;
  padding: 0;
  border: 0;
}

.character-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.character-option {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 78px;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 1px solid #bcb3a4;
  border-radius: 3px;
  background: #f8f4eb;
  cursor: pointer;
}

.character-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.character-option img {
  width: 38px;
  height: 52px;
  object-fit: cover;
  object-position: center top;
  border: 1px solid #c7bdac;
  background: #ddd5c7;
}

.character-option span {
  min-width: 0;
}

.character-option strong,
.character-option small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-option strong {
  font-size: 12px;
}

.character-option small {
  margin-top: 3px;
  color: #79746b;
  font-size: 10px;
}

.character-option.is-selected {
  border: 2px solid var(--brick);
  padding: 5px;
  background: #fff;
}

.character-option.is-disabled {
  cursor: not-allowed;
  filter: grayscale(0.8);
  opacity: 0.46;
}

.form-error {
  min-height: 18px;
  margin: 8px 0 2px;
  color: #a02f29;
  font-size: 12px;
}

.room-submit {
  width: 100%;
  min-height: 46px;
  border-radius: 3px;
  cursor: pointer;
  font-weight: 800;
}

.room-submit:disabled,
.lobby-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.lobby-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.lobby-heading h2 {
  margin-bottom: 12px;
}

.lobby-heading h2 button,
.private-brief button {
  padding: 0;
  border: 0;
  border-bottom: 1px dashed currentColor;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
}

.room-lobby .close-button {
  flex: none;
  margin: -8px -8px 0 0;
  color: var(--ink);
}

.seat-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.seat-row {
  display: grid;
  min-width: 0;
  min-height: 58px;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  padding: 5px;
  border: 1px solid #c8beae;
  background: #f8f4eb;
}

.seat-row.is-me {
  border-left: 4px solid var(--brick);
  padding-left: 2px;
}

.seat-row img {
  width: 38px;
  height: 46px;
  object-fit: cover;
  object-position: center top;
  background: #ddd5c7;
}

.seat-row span,
.seat-row strong,
.seat-row small {
  display: block;
  min-width: 0;
}

.seat-row strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seat-row small {
  margin-top: 3px;
  color: #747168;
  font-size: 9px;
  line-height: 1.3;
}

.private-brief {
  margin: 12px -18px 0;
  padding: 13px 18px;
  background: #293b33;
  color: #f4efe3;
}

.private-brief > p {
  margin: 0 0 3px;
  color: #e7c878;
  font-size: 10px;
  font-weight: 800;
}

.private-brief > strong {
  font-family: "SimSun", "Songti SC", serif;
  font-size: 18px;
}

.private-brief dl {
  display: grid;
  gap: 8px;
  margin: 10px 0;
}

.private-brief dl div {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 7px;
}

.private-brief dt {
  color: #e7c878;
  font-size: 11px;
  font-weight: 800;
}

.private-brief dd {
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
}

.private-brief small {
  color: #cbd3cd;
  font-size: 10px;
}

.lobby-status {
  min-height: 32px;
  margin: 11px 0;
  color: #68665f;
  font-size: 11px;
  line-height: 1.45;
}

.lobby-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.lobby-actions button {
  min-width: 0;
  min-height: 43px;
  padding: 6px 4px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.choice-list button.is-voted {
  border-color: #e9c776;
  background: rgba(233, 199, 118, 0.16);
}

.choice-list button.is-voted::after {
  content: "✓";
  font-size: 17px;
}

.choice-label {
  display: block;
  padding-right: 38px;
}

.vote-count {
  position: absolute;
  top: 50%;
  right: 38px;
  color: #e9c776;
  font-size: 10px;
  transform: translateY(-50%);
}

.vote-footer {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #d7d3ca;
  font-size: 11px;
}

.vote-footer .resolve-vote-button {
  min-height: 30px;
  padding: 4px 9px;
  border-color: #e9c776;
  color: #e9c776;
  font-size: 11px;
  text-align: center;
}

.vote-footer .resolve-vote-button::after {
  content: none;
}

@media (max-width: 430px) {
  .stage-header {
    gap: 5px;
    padding-right: 7px;
    padding-left: 9px;
  }

  .header-actions {
    gap: 0;
  }

  .header-button {
    width: 36px;
    height: 40px;
  }
}

@media (max-width: 350px) {
  .character-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .room-modes button {
    font-size: 11px;
  }
}

@media (max-height: 690px) {
  .room-entry,
  .room-lobby {
    padding-top: 14px;
  }

  .character-option {
    min-height: 64px;
  }

  .character-option img {
    height: 44px;
  }
}
