/*
 * ROOT Student / multiplayer room layer
 * All selectors are namespaced so the legacy ROOT and NULL CITY styles stay intact.
 */

#rootRoomPanel.room-panel {
  --room-black: #07080d;
  --room-navy: #0d1020;
  --room-panel: #12162a;
  --room-panel-2: #181d36;
  --room-white: #f7f8ff;
  --room-muted: #a8aec7;
  --room-line: #343a59;
  --room-purple: #8b5cff;
  --room-purple-deep: #5d32d6;
  --room-lime: #dfff57;
  --room-mint: #6ff3c1;
  --room-coral: #ff718d;
  --room-cyan: #69d7ff;
  --room-tap: 44px;
  --room-radius: 14px;
  --room-hard-shadow: 5px 5px 0 var(--room-black);
  position: absolute;
  z-index: 56;
  top: 0;
  right: calc(var(--rail-width, 76px) + env(safe-area-inset-right));
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: clamp(340px, 32vw, 400px);
  height: var(--visual-height, 100dvh);
  min-height: 0;
  overflow: hidden;
  border-left: 3px solid var(--room-white);
  background:
    linear-gradient(135deg, rgba(139, 92, 255, .12), transparent 34%),
    var(--room-navy);
  color: var(--room-white);
  box-shadow: -7px 0 0 var(--room-black), -30px 0 70px rgba(0, 0, 0, .42);
  font-family: Inter, ui-rounded, "Hiragino Sans", "Yu Gothic UI", system-ui, -apple-system, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  color-scheme: dark;
  isolation: isolate;
  opacity: 0;
  pointer-events: none;
  transform: translate3d(calc(100% + 12px), 0, 0);
  visibility: hidden;
  transition:
    transform .28s cubic-bezier(.2, .82, .2, 1),
    opacity .18s ease,
    visibility 0s linear .28s;
}

#rootRoomPanel.room-panel::before {
  content: "";
  position: absolute;
  z-index: -2;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, .022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .022) 1px, transparent 1px);
  background-size: 22px 22px;
  pointer-events: none;
}

#rootRoomPanel.room-panel::after {
  content: "";
  position: absolute;
  z-index: 20;
  inset: 0;
  background: repeating-linear-gradient(
    180deg,
    transparent 0 3px,
    rgba(255, 255, 255, .012) 3px 4px
  );
  mix-blend-mode: screen;
  opacity: .42;
  pointer-events: none;
}

#rootRoomPanel.room-panel.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translate3d(0, 0, 0);
  visibility: visible;
  transition:
    transform .3s cubic-bezier(.2, .82, .2, 1),
    opacity .18s ease,
    visibility 0s;
}

.room-panel,
.room-panel *,
.room-chat-peek,
.room-chat-peek *,
.room-toast,
.room-modal,
.room-modal * {
  box-sizing: border-box;
}

.room-panel button,
.room-panel input,
.room-panel textarea,
.room-panel select,
.room-chat-peek button,
.room-chat-peek input,
.room-modal button,
.room-modal input,
.room-modal textarea {
  font: inherit;
}

.room-panel button,
.room-panel a,
.room-chat-peek button,
.room-modal button {
  -webkit-tap-highlight-color: transparent;
}

.room-panel button:not(:disabled),
.room-panel a,
.room-chat-peek button:not(:disabled),
.room-modal button:not(:disabled) {
  cursor: pointer;
}

.room-panel :is(button, a, input, textarea, select):focus-visible,
.room-chat-peek :is(button, a, input):focus-visible,
.room-modal :is(button, a, input, textarea):focus-visible {
  outline: 3px solid var(--room-lime, #dfff57);
  outline-offset: 2px;
}

.room-panel :is(button, input, select),
.room-chat-peek :is(button, input),
.room-modal :is(button, input) {
  min-height: var(--room-tap, 44px);
}

.room-panel [hidden],
.room-chat-peek[hidden],
.room-toast[hidden],
.room-modal[hidden] {
  display: none !important;
}

/* ---------- shared room typography and surfaces ---------- */

.room-panel h1,
.room-panel h2,
.room-panel h3,
.room-panel p {
  margin-top: 0;
}

.room-panel h1,
.room-panel h2,
.room-panel h3 {
  color: var(--room-white);
  line-height: 1.08;
  letter-spacing: -.035em;
}

.room-panel h1 {
  margin-bottom: 8px;
  font-size: clamp(26px, 3vw, 38px);
  font-weight: 1000;
}

.room-panel h2 {
  margin-bottom: 7px;
  font-size: 19px;
  font-weight: 950;
}

.room-panel h3 {
  margin-bottom: 5px;
  font-size: 14px;
  font-weight: 900;
}

.room-panel p {
  margin-bottom: 10px;
  color: var(--room-muted);
}

.room-kicker,
.room-eyebrow {
  margin: 0 0 6px;
  color: var(--room-lime);
  font-size: 9px;
  font-weight: 1000;
  letter-spacing: .18em;
  line-height: 1.2;
  text-transform: uppercase;
}

.room-caption,
.room-help,
.room-meta {
  color: var(--room-muted);
  font-size: 10px;
  line-height: 1.55;
}

.room-header {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 62px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  border-bottom: 3px solid var(--room-black);
  background: rgba(13, 16, 32, .96);
}

.room-header::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: -3px;
  height: 3px;
  background: linear-gradient(90deg, var(--room-purple) 0 67%, var(--room-lime) 67% 78%, transparent 78%);
  pointer-events: none;
}

.room-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.room-brand > span,
.room-mark {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 2px solid var(--room-white);
  background: var(--room-purple);
  color: var(--room-white);
  box-shadow: 3px 3px 0 var(--room-black);
  font-size: 15px;
  font-weight: 1000;
  letter-spacing: -.08em;
  transform: rotate(-2deg);
}

.room-brand strong {
  display: block;
  overflow: hidden;
  color: var(--room-white);
  font-size: 14px;
  font-weight: 1000;
  letter-spacing: -.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-brand small {
  display: block;
  margin-top: 1px;
  color: var(--room-muted);
  font-size: 8px;
  font-weight: 850;
  letter-spacing: .1em;
}

.room-scroll,
.room-entry,
.room-lobby,
.room-game,
.room-chat {
  min-width: 0;
  min-height: 0;
}

.room-scroll {
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 16px 15px max(20px, env(safe-area-inset-bottom));
  overscroll-behavior: contain;
  scrollbar-color: var(--room-purple) transparent;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

#roomPanelContent.room-scroll {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

#roomPanelContent > .room-lobby {
  gap: 12px;
  padding: 16px 15px max(20px, env(safe-area-inset-bottom));
  overflow-x: hidden;
  overflow-y: auto;
}

#roomPanelContent > .room-chat { flex: 1 1 auto; }

.room-scroll::-webkit-scrollbar,
.room-chat-log::-webkit-scrollbar {
  width: 5px;
}

.room-scroll::-webkit-scrollbar-thumb,
.room-chat-log::-webkit-scrollbar-thumb {
  border-radius: 0;
  background: var(--room-purple);
}

.room-card,
.room-entry-card,
.room-lobby-card,
.room-game-card,
.room-safety,
.room-reveal {
  position: relative;
  border: 2px solid var(--room-line);
  border-radius: var(--room-radius);
  background: rgba(24, 29, 54, .94);
  box-shadow: var(--room-hard-shadow);
}

.room-card::before,
.room-entry-card::before,
.room-lobby-card::before,
.room-game-card::before,
.room-reveal::before {
  content: "";
  position: absolute;
  top: -2px;
  left: 13px;
  width: 46px;
  height: 4px;
  background: var(--room-purple);
}

.room-section {
  padding: 14px;
}

.room-stack {
  display: grid;
  gap: 12px;
}

.room-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.room-row > :is(div, span, p) {
  min-width: 0;
}

.room-divider {
  height: 2px;
  margin: 14px 0;
  border: 0;
  background: var(--room-line);
}

.room-field {
  display: grid;
  gap: 6px;
}

.room-field > label,
.room-label {
  color: var(--room-white);
  font-size: 11px;
  font-weight: 900;
}

.room-input,
.room-field :is(input, textarea, select),
.room-chat-form input,
.room-modal :is(input, textarea) {
  width: 100%;
  border: 2px solid var(--room-line);
  border-radius: 10px;
  background: var(--room-black);
  color: var(--room-white);
  caret-color: var(--room-lime);
}

.room-input,
.room-field :is(input, select),
.room-chat-form input,
.room-modal input {
  min-height: 46px;
  padding: 10px 12px;
}

.room-field textarea,
.room-modal textarea {
  min-height: 92px;
  padding: 11px 12px;
  line-height: 1.55;
  resize: vertical;
}

.room-input::placeholder,
.room-field :is(input, textarea)::placeholder,
.room-chat-form input::placeholder,
.room-modal :is(input, textarea)::placeholder {
  color: #747a98;
  opacity: 1;
}

.room-input:focus,
.room-field :is(input, textarea, select):focus,
.room-chat-form input:focus,
.room-modal :is(input, textarea):focus {
  border-color: var(--room-purple);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(139, 92, 255, .2);
}

/* ---------- actions, status and tabs ---------- */

.room-action,
.room-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 44px;
  min-height: var(--room-tap);
  padding: 9px 13px;
  border: 2px solid var(--room-white);
  border-radius: 10px;
  background: var(--room-purple);
  color: var(--room-white);
  box-shadow: 4px 4px 0 var(--room-black);
  font-size: 12px;
  font-weight: 950;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
  touch-action: manipulation;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}

.room-action:active,
.room-button:active {
  box-shadow: 1px 1px 0 var(--room-black);
  transform: translate(3px, 3px);
}

.room-action:disabled,
.room-button:disabled {
  border-color: #4a4f68;
  background: #2b3047;
  color: #777d98;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.room-button.is-primary,
.room-action.is-primary,
.room-button-primary {
  border-color: var(--room-black);
  background: var(--room-lime);
  color: var(--room-black);
  box-shadow: 4px 4px 0 var(--room-purple);
}

.room-button.is-secondary,
.room-action.is-secondary,
.room-button-secondary {
  border-color: var(--room-purple);
  background: var(--room-black);
  color: var(--room-white);
}

.room-button.is-quiet,
.room-action.is-quiet,
.room-button-quiet {
  border-color: var(--room-line);
  background: transparent;
  color: var(--room-muted);
  box-shadow: none;
}

.room-button.is-danger,
.room-action.is-danger,
.room-button-danger {
  border-color: var(--room-coral);
  background: #2b101b;
  color: #ffb4c2;
}

.room-button.is-wide,
.room-action.is-wide,
.room-wide {
  width: 100%;
}

.room-icon-button,
.room-close {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid var(--room-line);
  border-radius: 10px;
  background: var(--room-black);
  color: var(--room-white);
  box-shadow: 3px 3px 0 var(--room-purple-deep);
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
}

.room-status,
.room-chip,
.room-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  padding: 4px 8px;
  border: 1.5px solid var(--room-line);
  border-radius: 999px;
  background: var(--room-black);
  color: var(--room-muted);
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.room-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #70758d;
}

.room-status.is-online::before,
.room-status.is-ready::before {
  background: var(--room-lime);
  box-shadow: 0 0 0 3px rgba(223, 255, 87, .13);
}

.room-status.is-live {
  border-color: var(--room-coral);
  color: #ffc2cf;
}

.room-status.is-live::before {
  background: var(--room-coral);
  box-shadow: 0 0 0 3px rgba(255, 113, 141, .13);
}

.room-tabs {
  position: relative;
  z-index: 5;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 4px;
  padding: 7px 9px;
  border-bottom: 2px solid var(--room-black);
  background: rgba(7, 8, 13, .92);
  backdrop-filter: blur(14px);
}

.room-tabs button,
.room-tabs a {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 44px;
  place-items: center;
  padding: 6px 5px;
  border: 1.5px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--room-muted);
  font-size: 10px;
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
}

.room-tabs :is(button, a)[aria-selected="true"],
.room-tabs :is(button, a)[aria-current="page"],
.room-tabs :is(button, a).is-active {
  border-color: var(--room-purple);
  background: rgba(139, 92, 255, .17);
  color: var(--room-white);
}

.room-tabs :is(button, a)[aria-selected="true"]::after,
.room-tabs :is(button, a)[aria-current="page"]::after,
.room-tabs :is(button, a).is-active::after {
  content: "";
  position: absolute;
  right: 7px;
  bottom: 5px;
  left: 7px;
  height: 2px;
  background: var(--room-lime);
}

/* A compact world-side switcher. It also works as a regular rail inside the panel. */
.room-rail {
  position: absolute;
  z-index: 58;
  top: 50%;
  right: calc(var(--rail-width, 76px) + env(safe-area-inset-right) + 10px);
  display: grid;
  gap: 5px;
  width: 54px;
  padding: 6px;
  border: 2px solid var(--room-white);
  border-radius: 12px;
  background: rgba(7, 8, 13, .91);
  box-shadow: 5px 5px 0 rgba(0, 0, 0, .72);
  backdrop-filter: blur(12px);
  transform: translateY(-50%);
}

.room-rail button,
.room-rail a {
  position: relative;
  display: grid;
  min-width: 42px;
  min-height: 44px;
  place-items: center;
  padding: 4px;
  border: 1.5px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #aeb3cb;
  font-size: 9px;
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
  text-decoration: none;
}

.room-rail :is(button, a).is-active,
.room-rail :is(button, a)[aria-current="page"],
.room-rail :is(button, a)[aria-pressed="true"] {
  border-color: var(--room-lime);
  background: var(--room-purple);
  color: var(--room-white);
}

.room-panel .room-rail {
  position: static;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  width: auto;
  padding: 6px 9px;
  border: 0;
  border-bottom: 2px solid var(--room-black);
  border-radius: 0;
  box-shadow: none;
  transform: none;
}

/* ---------- entry and room code ---------- */

.room-entry {
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  padding: clamp(18px, 4vh, 34px) 17px max(24px, env(safe-area-inset-bottom));
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.room-entry-hero {
  position: relative;
  margin-bottom: 18px;
  padding: 18px 16px 16px;
  border: 3px solid var(--room-white);
  background:
    linear-gradient(135deg, rgba(139, 92, 255, .48), transparent 58%),
    var(--room-black);
  box-shadow: 6px 6px 0 var(--room-purple);
  overflow: hidden;
}

.room-entry-hero::after {
  content: "ROOT";
  position: absolute;
  right: -6px;
  bottom: -18px;
  color: rgba(255, 255, 255, .05);
  font-size: 62px;
  font-weight: 1000;
  letter-spacing: -.09em;
  pointer-events: none;
}

.room-entry-card {
  display: grid;
  gap: 12px;
  padding: 15px;
}

.room-entry-actions,
.room-host-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 9px;
}

.room-code {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .16em;
  min-height: 58px;
  padding: 9px 12px;
  border: 2px dashed var(--room-lime);
  border-radius: 10px;
  background: #080a12;
  color: var(--room-lime);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: clamp(20px, 3vw, 28px);
  font-weight: 900;
  letter-spacing: .15em;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  text-shadow: 2px 0 var(--room-purple), -1px 0 var(--room-cyan);
  user-select: all;
}

/* ---------- lobby and players ---------- */

.room-lobby {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  overflow: hidden;
}

.room-lobby > .room-scroll {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.room-lobby-card {
  padding: 14px;
}

.room-lobby-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.room-player-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.room-player {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 58px;
  padding: 7px 9px;
  border: 2px solid var(--room-line);
  border-radius: 11px;
  background: var(--room-black);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, .55);
  overflow: hidden;
}

.room-player::after {
  content: "WAIT";
  align-self: center;
  padding: 4px 6px;
  border: 1px solid #575d76;
  border-radius: 999px;
  color: #858ba5;
  font-size: 7px;
  font-weight: 1000;
  letter-spacing: .08em;
}

.room-player.is-ready {
  border-color: var(--room-lime);
  background: linear-gradient(90deg, rgba(223, 255, 87, .08), var(--room-black) 45%);
}

.room-player.is-ready::after {
  content: "READY";
  border-color: var(--room-lime);
  color: var(--room-lime);
}

.room-player.is-host {
  box-shadow: inset 4px 0 var(--room-purple), 3px 3px 0 rgba(0, 0, 0, .55);
}

.room-player.is-host::before {
  content: "HOST";
  position: absolute;
  top: 0;
  right: 8px;
  padding: 2px 5px;
  background: var(--room-purple);
  color: #fff;
  font-size: 6px;
  font-weight: 1000;
  letter-spacing: .08em;
}

.room-player-avatar,
.room-avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 2px solid var(--room-white);
  border-radius: 9px;
  background: var(--room-purple);
  color: #fff;
  box-shadow: 2px 2px 0 var(--room-black);
  font-size: 13px;
  font-weight: 1000;
  text-transform: uppercase;
}

.room-player > div,
.room-player-info {
  min-width: 0;
}

.room-player strong,
.room-player-name {
  display: block;
  overflow: hidden;
  color: var(--room-white);
  font-size: 12px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-player small,
.room-player-meta {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  color: var(--room-muted);
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-ready-toggle {
  width: 100%;
  border-color: var(--room-lime);
  background: rgba(223, 255, 87, .07);
  color: var(--room-lime);
}

.room-ready-toggle[aria-pressed="true"],
.room-ready-toggle.is-ready {
  background: var(--room-lime);
  color: var(--room-black);
  box-shadow: 4px 4px 0 var(--room-purple);
}

/* ---------- game, prompt, progress and reveal ---------- */

.room-game {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  overflow: hidden;
}

.room-game > .room-scroll {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.room-game-hud {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 2px solid var(--room-black);
  background: rgba(7, 8, 13, .94);
}

.room-progress {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--room-muted);
  font-size: 9px;
  font-weight: 900;
}

.room-progress > :is(i, span:first-child, .room-progress-track) {
  position: relative;
  display: block;
  min-width: 0;
  height: 7px;
  border: 1px solid #444a66;
  border-radius: 0;
  background: #080910;
  overflow: hidden;
}

.room-progress > :is(i, span:first-child, .room-progress-track)::after,
.room-progress-fill {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  display: block;
  width: var(--room-progress, 0%);
  background: linear-gradient(90deg, var(--room-purple), var(--room-lime));
}

.room-timer {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  justify-content: center;
  gap: 3px;
  min-width: 64px;
  min-height: 44px;
  padding: 6px 9px;
  border: 2px solid var(--room-lime);
  background: var(--room-black);
  color: var(--room-lime);
  box-shadow: 3px 3px 0 var(--room-purple);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 19px;
  font-weight: 1000;
  line-height: 1;
}

.room-timer small {
  color: var(--room-muted);
  font-size: 7px;
  letter-spacing: .08em;
}

.room-timer.is-low {
  border-color: var(--room-coral);
  color: var(--room-coral);
  box-shadow: 3px 3px 0 #641a32;
  animation: room-timer-alert .7s steps(2, end) infinite;
}

@keyframes room-timer-alert {
  50% { transform: translateX(2px); }
}

.room-game-card {
  padding: 15px;
}

.room-question,
.room-prompt {
  position: relative;
  padding: 15px;
  border: 3px solid var(--room-white);
  background:
    linear-gradient(135deg, rgba(139, 92, 255, .31), transparent 60%),
    var(--room-black);
  box-shadow: 5px 5px 0 var(--room-purple);
}

.room-question h2,
.room-prompt h2 {
  margin: 0;
  font-size: clamp(19px, 2.2vw, 25px);
  line-height: 1.25;
}

.room-answer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.room-answer-grid button,
.room-answer-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 54px;
  padding: 9px 10px;
  border: 2px solid var(--room-line);
  border-radius: 10px;
  background: var(--room-panel-2);
  color: var(--room-white);
  box-shadow: 3px 3px 0 var(--room-black);
  font-size: 11px;
  font-weight: 850;
  line-height: 1.35;
  text-align: left;
}

.room-answer-grid button:hover,
.room-answer-grid button[aria-pressed="true"],
.room-answer-grid button.is-selected {
  border-color: var(--room-lime);
  background: rgba(139, 92, 255, .24);
}

.room-answer-grid button[aria-pressed="true"]::after,
.room-answer-grid button.is-selected::after {
  content: "✓";
  position: absolute;
  top: 5px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--room-lime);
  color: var(--room-black);
  font-size: 10px;
  font-weight: 1000;
}

.room-reveal {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-color: var(--room-purple);
  background:
    linear-gradient(135deg, rgba(139, 92, 255, .17), transparent 50%),
    var(--room-panel-2);
}

.room-reveal.is-highlight {
  border-color: var(--room-lime);
  box-shadow: 5px 5px 0 var(--room-purple);
}

.room-reveal-list,
.room-scoreboard {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.room-reveal-item,
.room-score-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 45px;
  padding: 7px 8px;
  border: 1.5px solid var(--room-line);
  border-radius: 9px;
  background: var(--room-black);
}

/* ---------- public room chat ---------- */

.room-chat {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(139, 92, 255, .05), transparent 30%);
}

.room-chat-log {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 9px;
  min-height: 0;
  margin: 0;
  padding: 14px 13px 18px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  scrollbar-color: var(--room-purple) transparent;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.room-message {
  align-self: flex-start;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 7px;
  width: min(92%, 310px);
}

.room-message.is-me {
  align-self: flex-end;
  grid-template-columns: minmax(0, 1fr);
}

.room-message-avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1.5px solid var(--room-white);
  border-radius: 8px;
  background: var(--room-purple);
  color: #fff;
  font-size: 9px;
  font-weight: 1000;
}

.room-message-body {
  min-width: 0;
}

.room-message-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 0 0 3px;
  color: var(--room-muted);
  font-size: 8px;
}

.room-message-meta strong {
  color: var(--room-white);
  font-size: 9px;
}

.room-message-text,
.room-message-body > p {
  margin: 0;
  padding: 8px 10px;
  border: 1.5px solid var(--room-line);
  border-radius: 4px 11px 11px 11px;
  background: var(--room-panel-2);
  color: var(--room-white);
  font-size: 11px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.room-message.is-me .room-message-text,
.room-message.is-me .room-message-body > p {
  border-color: var(--room-purple);
  border-radius: 11px 4px 11px 11px;
  background: rgba(139, 92, 255, .22);
}

.room-message.is-system {
  align-self: center;
  display: block;
  width: auto;
  max-width: 90%;
  padding: 5px 9px;
  border: 1px dashed var(--room-line);
  border-radius: 999px;
  color: var(--room-muted);
  font-size: 8px;
  text-align: center;
}

.room-chat-form {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  flex: 0 0 auto;
  padding: 9px 10px max(9px, env(safe-area-inset-bottom));
  border-top: 3px solid var(--room-black);
  background: rgba(13, 16, 32, .98);
  box-shadow: 0 -12px 30px rgba(0, 0, 0, .18);
}

.room-chat-form input {
  min-width: 0;
}

.room-chat-form button {
  width: 48px;
  min-width: 48px;
  padding-inline: 8px;
}

.room-chat-peek {
  --room-black: #07080d;
  --room-white: #f7f8ff;
  --room-purple: #8b5cff;
  --room-lime: #dfff57;
  --room-muted: #a8aec7;
  position: absolute;
  z-index: 57;
  right: calc(var(--rail-width, 76px) + env(safe-area-inset-right) + 18px);
  bottom: max(16px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: min(304px, calc(100vw - var(--rail-width, 76px) - env(safe-area-inset-right) - 40px));
  min-height: 58px;
  padding: 7px 8px;
  border: 2px solid var(--room-white);
  border-radius: 11px;
  background: rgba(7, 8, 13, .9);
  color: var(--room-white);
  box-shadow: 5px 5px 0 rgba(0, 0, 0, .72), 0 16px 36px rgba(0, 0, 0, .28);
  backdrop-filter: blur(13px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity .18s ease, transform .18s ease;
}

.room-chat-peek.is-visible,
.room-chat-peek.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.room-chat-peek::before {
  content: "CHAT";
  position: absolute;
  top: -8px;
  left: 9px;
  padding: 2px 6px;
  background: var(--room-purple);
  color: #fff;
  font-size: 7px;
  font-weight: 1000;
  letter-spacing: .12em;
}

.room-chat-peek-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1.5px solid #fff;
  border-radius: 8px;
  background: var(--room-purple);
  font-size: 10px;
  font-weight: 1000;
}

.room-chat-peek > div {
  min-width: 0;
}

.room-chat-peek strong,
.room-chat-peek p {
  display: block;
  overflow: hidden;
  margin: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-chat-peek strong {
  font-size: 9px;
}

.room-chat-peek p {
  margin-top: 2px;
  color: var(--room-muted);
  font-size: 10px;
}

.room-chat-peek button {
  display: grid;
  min-width: 44px;
  min-height: 44px;
  place-items: center;
  padding: 6px 9px;
  border: 1.5px solid var(--room-lime);
  border-radius: 8px;
  background: rgba(223, 255, 87, .09);
  color: var(--room-lime);
  font-size: 9px;
  font-weight: 950;
}

.room-chat-peek-form {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 7px;
  min-width: 0;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, .14);
}

.room-chat-peek-form input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 8px 10px;
  border: 1.5px solid #343a59;
  border-radius: 8px;
  background: #0d1020;
  color: #f7f8ff;
  caret-color: var(--room-lime);
}

.room-chat-peek-form input:focus {
  border-color: var(--room-purple);
  outline: 0;
}

.room-chat-peek-form button {
  width: 44px;
  min-width: 44px;
  padding: 4px;
}

.room-chat-peek.is-full-chat {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
}

.game-shell.room-panel-open .room-chat-peek.is-open {
  right: calc(var(--rail-width, 76px) + env(safe-area-inset-right) + 8px);
}

.game-shell.room-panel-open #roomPanelContent > :is(.room-lobby, .room-entry) {
  padding-bottom: calc(148px + env(safe-area-inset-bottom));
}

.game-shell.room-chat-active:not(.room-game-active) .emote-dock {
  bottom: max(146px, calc(env(safe-area-inset-bottom) + 138px));
}

.game-shell.room-game-active .emote-dock {
  opacity: 0;
  pointer-events: none;
}

/* ---------- safety, toast and modal ---------- */

.room-safety {
  padding: 12px;
  border-color: #5b4050;
  background: linear-gradient(135deg, rgba(255, 113, 141, .09), rgba(24, 29, 54, .96));
  box-shadow: 4px 4px 0 #29111a;
}

.room-safety strong {
  display: block;
  color: #ffc4d0;
  font-size: 11px;
}

.room-safety p {
  margin: 4px 0 0;
  color: #c6a9b2;
  font-size: 9px;
  line-height: 1.5;
}

.room-safety-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.room-safety-actions button,
.room-safety-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 7px 10px;
  border: 1.5px solid #8b4b60;
  border-radius: 8px;
  background: #241018;
  color: #ffb8c7;
  font-size: 9px;
  font-weight: 900;
  text-decoration: none;
}

.room-toast {
  --room-black: #07080d;
  --room-white: #f7f8ff;
  --room-purple: #8b5cff;
  --room-lime: #dfff57;
  position: fixed;
  z-index: 360;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  width: min(390px, calc(100vw - 28px));
  min-height: 46px;
  padding: 11px 14px;
  border: 2px solid var(--room-white);
  border-radius: 9px;
  background: var(--room-black);
  color: var(--room-white);
  box-shadow: 5px 5px 0 var(--room-purple), 0 18px 42px rgba(0, 0, 0, .4);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.45;
  text-align: center;
  transform: translateX(-50%);
}

.room-toast.is-success {
  border-color: var(--room-lime);
  box-shadow: 5px 5px 0 var(--room-purple);
}

.room-toast.is-error {
  border-color: #ff718d;
  box-shadow: 5px 5px 0 #62172a;
}

.room-modal {
  --room-black: #07080d;
  --room-navy: #0d1020;
  --room-panel-2: #181d36;
  --room-white: #f7f8ff;
  --room-muted: #a8aec7;
  --room-line: #343a59;
  --room-purple: #8b5cff;
  --room-lime: #dfff57;
  --room-coral: #ff718d;
  position: fixed;
  z-index: 350;
  inset: 0;
  display: grid;
  place-items: center;
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  background: rgba(3, 4, 9, .78);
  backdrop-filter: blur(8px);
  color: var(--room-white);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity .18s ease, visibility 0s linear .18s;
}

.room-modal.is-open,
.room-modal[open] {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transition: opacity .18s ease, visibility 0s;
}

.room-modal-card,
.room-modal > :is(section, article, form, div):first-child {
  width: min(430px, 100%);
  max-height: min(620px, calc(var(--visual-height, 100dvh) - 32px));
  padding: 17px;
  overflow-x: hidden;
  overflow-y: auto;
  border: 3px solid var(--room-white);
  border-radius: 13px;
  background:
    linear-gradient(135deg, rgba(139, 92, 255, .16), transparent 38%),
    var(--room-navy);
  box-shadow: 7px 7px 0 var(--room-purple);
  overscroll-behavior: contain;
}

.room-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.room-modal h2 {
  margin: 0;
  color: var(--room-white);
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: -.035em;
}

.room-modal p {
  color: var(--room-muted);
  font-size: 11px;
  line-height: 1.6;
}

/* ---------- live game layer shared with the 3D city ---------- */

#rootRoomGameHud.room-game-overlay {
  --room-black: #07080d;
  --room-navy: #0d1020;
  --room-panel-2: #181d36;
  --room-white: #f7f8ff;
  --room-muted: #a8aec7;
  --room-line: #343a59;
  --room-purple: #8b5cff;
  --room-lime: #dfff57;
  --room-coral: #ff718d;
  --room-tap: 44px;
  --room-radius: 14px;
  --room-hard-shadow: 5px 5px 0 var(--room-black);
  position: absolute;
  z-index: 54;
  top: max(64px, calc(env(safe-area-inset-top) + 54px));
  left: calc((100% - var(--rail-width, 76px)) / 2);
  width: min(470px, calc(100% - var(--rail-width, 76px) - 32px));
  max-height: calc(var(--visual-height, 100dvh) - max(82px, calc(env(safe-area-inset-top) + 72px)) - max(14px, env(safe-area-inset-bottom)));
  overflow: auto;
  border: 3px solid var(--room-white);
  border-radius: 14px;
  background: rgba(13, 16, 32, .96);
  color: var(--room-white);
  box-shadow: 7px 7px 0 var(--room-purple), 0 24px 70px rgba(0, 0, 0, .52);
  font-family: Inter, ui-rounded, "Hiragino Sans", "Yu Gothic UI", system-ui, -apple-system, sans-serif;
  transform: translateX(-50%);
  backdrop-filter: blur(13px);
  overscroll-behavior: contain;
}

#rootRoomGameHud.room-game-overlay[hidden] { display: none !important; }

#rootRoomGameHud #roomGameContent {
  display: grid;
  gap: 11px;
  padding: 12px;
}

.room-countdown-card {
  display: grid;
  min-height: 190px;
  place-items: center;
  text-align: center;
}

.room-countdown {
  color: var(--room-lime);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: clamp(70px, 14vw, 118px);
  font-weight: 1000;
  line-height: .9;
  text-shadow: 6px 6px 0 var(--room-purple);
}

.room-submitted {
  display: grid;
  gap: 7px;
  min-height: 120px;
  place-content: center;
  padding: 16px;
  text-align: center;
}

.room-submitted strong { color: var(--room-lime); font-size: 18px; }
.room-submitted p { margin: 0; color: var(--room-white); font-size: 14px; }
.room-submitted small { color: var(--room-muted); }

.room-chat-public {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 13px;
  border-bottom: 2px solid var(--room-black);
  background: rgba(139, 92, 255, .12);
}

.room-chat-public > span {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 2px solid var(--room-lime);
  border-radius: 50%;
  color: var(--room-lime);
}

.room-chat-public strong,
.room-chat-public small { display: block; }
.room-chat-public strong { font-size: 10px; letter-spacing: .08em; }
.room-chat-public small { color: var(--room-muted); font-size: 9px; }

.room-compact-chat {
  display: grid;
  gap: 7px;
  max-height: 150px;
  padding: 8px 0;
  overflow-y: auto;
}

.room-compact-chat .room-message { width: 100%; }
.room-compact-chat .room-message-text { padding-block: 6px; font-size: 10px; }
.room-score-row span,
.room-score-row small { overflow-wrap: anywhere; }
.room-score-row small { max-width: 130px; color: var(--room-lime); text-align: right; }

body.keyboard-open #rootRoomGameHud.room-game-overlay {
  top: max(4px, var(--visual-top, 0px));
  max-height: calc(var(--visual-height, 100dvh) - 8px);
}

/* ---------- compact landscape, keyboard and portrait ---------- */

@media (max-height: 430px) and (orientation: landscape) {
  #rootRoomPanel.room-panel {
    width: clamp(320px, 38vw, 380px);
    font-size: 12px;
  }

  .room-header {
    min-height: 53px;
    padding-top: max(6px, env(safe-area-inset-top));
    padding-bottom: 6px;
  }

  .room-brand > span,
  .room-mark {
    width: 34px;
    height: 34px;
  }

  .room-scroll,
  .room-entry {
    padding-top: 12px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .room-panel h1 {
    font-size: 27px;
  }

  .room-entry-hero {
    margin-bottom: 12px;
    padding: 13px;
  }

  .room-entry-hero::after {
    font-size: 48px;
  }

  .room-tabs {
    padding-block: 4px;
  }

  .room-tabs button,
  .room-tabs a {
    min-height: 44px;
  }

  .room-player-list {
    gap: 6px;
  }

  .room-player {
    min-height: 52px;
  }

  .room-game-hud {
    padding-block: 6px;
  }

  .room-question,
  .room-prompt,
  .room-game-card {
    padding: 11px;
  }

  .room-answer-grid button,
  .room-answer-card {
    min-height: 48px;
  }

  .room-chat-form {
    padding-top: 6px;
  }

  .room-chat-peek {
    right: calc(var(--rail-width, 70px) + env(safe-area-inset-right) + 10px);
    bottom: max(9px, env(safe-area-inset-bottom));
    min-height: 52px;
  }
}

@media (max-width: 760px) and (orientation: landscape) {
  #rootRoomPanel.room-panel {
    width: min(340px, calc(100vw - var(--rail-width, 70px) - env(safe-area-inset-right) - 72px));
    min-width: 300px;
  }

  .room-rail {
    display: none;
  }

  .room-answer-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 660px) and (orientation: landscape) {
  #rootRoomPanel.room-panel {
    width: min(300px, calc(100vw - var(--rail-width, 64px) - env(safe-area-inset-right) - 10px));
    min-width: 0;
  }

  .room-entry-actions,
  .room-host-actions {
    grid-template-columns: 1fr;
  }

  .room-player {
    grid-template-columns: 38px minmax(0, 1fr) auto;
  }

  .room-player-avatar,
  .room-avatar {
    width: 36px;
    height: 36px;
  }

  .room-chat-peek {
    width: min(240px, calc(100vw - var(--rail-width, 64px) - env(safe-area-inset-right) - 22px));
  }
}

/* ---------- v10 standalone ROOT Student / CHAT mode ---------- */

.game-shell.mode-chat #rootRoomPanel.room-panel {
  --room-tap: 48px;
  --room-radius: 16px;
  position: fixed;
  z-index: 60;
  inset: 0;
  display: flex;
  width: 100vw;
  max-width: none;
  height: var(--visual-height, 100dvh);
  max-height: var(--visual-height, 100dvh);
  border: 0;
  background:
    radial-gradient(circle at 12% 8%, rgba(139, 92, 255, .16), transparent 31%),
    radial-gradient(circle at 88% 88%, rgba(223, 255, 87, .06), transparent 27%),
    var(--room-navy);
  box-shadow: none;
  font-size: 15px;
  opacity: 1;
  pointer-events: auto;
  transform: none;
  visibility: visible;
}

.game-shell.mode-game #rootRoomPanel.room-panel {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.game-shell.mode-chat #rootRoomPanel .room-header { order: 1; }
.game-shell.mode-chat #rootRoomPanel #roomPanelContent { order: 2; }
.game-shell.mode-chat #rootRoomPanel .room-tabs { order: 3; }

.game-shell.mode-chat #rootRoomPanel .room-header {
  min-height: 66px;
  padding:
    max(9px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    9px
    max(16px, env(safe-area-inset-left));
  background: rgba(7, 8, 13, .95);
}

.game-shell.mode-chat #rootRoomPanel .room-header::before {
  content: "CHAT MODE";
  position: absolute;
  right: max(16px, env(safe-area-inset-right));
  bottom: 8px;
  color: var(--room-muted);
  font-size: 7px;
  font-weight: 1000;
  letter-spacing: .16em;
}

.game-shell.mode-chat #rootRoomPanel .room-brand > span {
  width: 42px;
  height: 42px;
  font-size: 17px;
}

.game-shell.mode-chat #rootRoomPanel .room-brand strong { font-size: 16px; }
.game-shell.mode-chat #rootRoomPanel .room-brand small { font-size: 9px; }
.game-shell.mode-chat #rootRoomPanel .room-close { display: none; }

.game-shell.mode-chat #rootRoomPanel .room-tabs {
  flex: 0 0 auto;
  gap: 6px;
  padding:
    7px
    max(10px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
  border-top: 3px solid var(--room-black);
  border-bottom: 0;
  background: rgba(7, 8, 13, .98);
  box-shadow: 0 -12px 32px rgba(0, 0, 0, .23);
}

.game-shell.mode-chat #rootRoomPanel .room-tabs button {
  min-height: 54px;
  gap: 2px;
  border-radius: 10px;
  font-size: 10px;
}

.game-shell.mode-chat #rootRoomPanel .room-tabs button::before { display: block; font-size: 17px; line-height: 1; }
.game-shell.mode-chat #rootRoomPanel .room-tabs button[data-room-view="room"]::before { content: "▦"; }
.game-shell.mode-chat #rootRoomPanel .room-tabs button[data-room-view="chat"]::before { content: "✉"; }
.game-shell.mode-chat #rootRoomPanel .room-tabs button[data-room-view="players"]::before { content: "●"; }
.game-shell.mode-chat #rootRoomPanel .room-tabs button[data-room-view="safety"]::before { content: "!"; }

.game-shell.mode-chat #rootRoomPanel #roomPanelContent.room-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, .018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .018) 1px, transparent 1px);
  background-size: 28px 28px;
}

.game-shell.mode-chat #rootRoomPanel h1 {
  font-size: clamp(34px, 5vw, 52px);
  letter-spacing: -.055em;
}

.game-shell.mode-chat #rootRoomPanel h2 { font-size: 22px; }
.game-shell.mode-chat #rootRoomPanel h3 { font-size: 16px; }
.game-shell.mode-chat #rootRoomPanel p { font-size: 14px; line-height: 1.65; }
.game-shell.mode-chat #rootRoomPanel :is(.room-kicker, .room-eyebrow) { font-size: 10px; }
.game-shell.mode-chat #rootRoomPanel :is(.room-caption, .room-help, .room-meta) { font-size: 12px; }
.game-shell.mode-chat #rootRoomPanel :is(.room-button, .room-action, .room-ready-toggle) { min-height: 48px; font-size: 14px; }
.game-shell.mode-chat #rootRoomPanel .room-field > label { font-size: 13px; }
.game-shell.mode-chat #rootRoomPanel .room-field :is(input, textarea, select),
.game-shell.mode-chat #rootRoomPanel .room-chat-form input { font-size: 16px; }

.game-shell.mode-chat #rootRoomPanel #roomPanelContent > .room-entry {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 18px;
  width: min(880px, 100%);
  margin: 0 auto;
  padding:
    clamp(24px, 5vh, 48px)
    max(22px, env(safe-area-inset-right))
    28px
    max(22px, env(safe-area-inset-left));
}

.game-shell.mode-chat #rootRoomPanel #roomPanelContent > .room-entry > .room-entry-hero,
.game-shell.mode-chat #rootRoomPanel #roomPanelContent > .room-entry > #roomNicknameForm,
.game-shell.mode-chat #rootRoomPanel #roomPanelContent > .room-entry > .room-player-list,
.game-shell.mode-chat #rootRoomPanel #roomPanelContent > .room-entry > .room-button.is-wide {
  grid-column: 1 / -1;
}

.game-shell.mode-chat #rootRoomPanel #roomNicknameForm {
  justify-self: center;
  width: min(560px, 100%);
}

.game-shell.mode-chat #rootRoomPanel .room-entry-hero {
  margin-bottom: 2px;
  padding: clamp(20px, 4vw, 34px);
  box-shadow: 8px 8px 0 var(--room-purple);
}

.game-shell.mode-chat #rootRoomPanel .room-entry-hero::after { font-size: clamp(68px, 12vw, 128px); }
.game-shell.mode-chat #rootRoomPanel .room-entry-card,
.game-shell.mode-chat #rootRoomPanel .room-lobby-card { padding: 20px; }

.game-shell.mode-chat #rootRoomPanel #roomPanelContent > .room-lobby {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 18px;
  width: min(1040px, 100%);
  margin: 0 auto;
  padding:
    24px
    max(22px, env(safe-area-inset-right))
    28px
    max(22px, env(safe-area-inset-left));
  overflow-x: hidden;
  overflow-y: auto;
}

.game-shell.mode-chat #rootRoomPanel #roomPanelContent > .room-lobby > .room-lobby-summary,
.game-shell.mode-chat #rootRoomPanel #roomPanelContent > .room-lobby > .room-help {
  grid-column: 1 / -1;
}

.game-shell.mode-chat #rootRoomPanel .room-lobby-summary { padding: 20px; }
.game-shell.mode-chat #rootRoomPanel .room-player-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.game-shell.mode-chat #rootRoomPanel .room-player { min-height: 66px; padding: 9px 11px; }
.game-shell.mode-chat #rootRoomPanel .room-player strong { font-size: 14px; }
.game-shell.mode-chat #rootRoomPanel .room-player small { font-size: 10px; }

.game-shell.mode-chat #rootRoomPanel #roomPanelContent > .room-chat {
  width: min(780px, 100%);
  margin: 0 auto;
  border-right: 2px solid rgba(52, 58, 89, .6);
  border-left: 2px solid rgba(52, 58, 89, .6);
  background: rgba(7, 8, 13, .35);
}

.game-shell.mode-chat #rootRoomPanel .room-chat-public { padding: 14px 18px; }
.game-shell.mode-chat #rootRoomPanel .room-chat-public strong { font-size: 12px; }
.game-shell.mode-chat #rootRoomPanel .room-chat-public small { font-size: 11px; }
.game-shell.mode-chat #rootRoomPanel .room-chat-log { gap: 13px; padding: 20px 18px 26px; }
.game-shell.mode-chat #rootRoomPanel .room-message { width: min(82%, 560px); grid-template-columns: 38px minmax(0, 1fr); gap: 10px; }
.game-shell.mode-chat #rootRoomPanel .room-message.is-me { grid-template-columns: minmax(0, 1fr); }
.game-shell.mode-chat #rootRoomPanel .room-message-avatar { width: 38px; height: 38px; font-size: 12px; }
.game-shell.mode-chat #rootRoomPanel .room-message-meta { font-size: 10px; }
.game-shell.mode-chat #rootRoomPanel .room-message-meta strong { font-size: 11px; }
.game-shell.mode-chat #rootRoomPanel .room-message-text,
.game-shell.mode-chat #rootRoomPanel .room-message-body > p { padding: 11px 13px; font-size: 14px; }
.game-shell.mode-chat #rootRoomPanel .room-message.is-system { font-size: 10px; }
.game-shell.mode-chat #rootRoomPanel .room-chat-form {
  padding:
    11px
    max(14px, env(safe-area-inset-right))
    11px
    max(14px, env(safe-area-inset-left));
}

.game-shell.mode-chat.room-panel-open #roomPanelContent > :is(.room-lobby, .room-entry) { padding-bottom: 28px; }
.game-shell.mode-chat .room-chat-peek { display: none !important; }

.game-shell.mode-game.room-game-active #rootRoomGameHud.room-game-overlay,
.game-shell.mode-game.room-panel-open #rootRoomGameHud.room-game-overlay {
  left: 50%;
  width: min(520px, calc(100% - 32px));
}

.game-shell.mode-chat #rootRoomGameHud.room-game-overlay { visibility: hidden; }

body.keyboard-open .game-shell.mode-chat #rootRoomPanel.room-panel {
  top: var(--visual-top, 0px);
  bottom: auto;
  height: var(--visual-height, 100dvh);
  max-height: var(--visual-height, 100dvh);
}

body.keyboard-open .game-shell.mode-chat #rootRoomPanel .room-header {
  min-height: 49px;
  padding-top: 5px;
  padding-bottom: 5px;
}

body.keyboard-open .game-shell.mode-chat #rootRoomPanel .room-brand > span {
  width: 36px;
  height: 36px;
}

body.keyboard-open .game-shell.mode-chat #rootRoomPanel .room-tabs { display: none; }
body.keyboard-open .root-mode-switch {
  top: calc(var(--visual-top, 0px) + 3px);
  min-height: 42px;
  padding: 2px;
}
body.keyboard-open .root-mode-button { min-height: 38px; }

/* The answer keyboard already consumes most of a landscape phone. Keep the
   round timer unobstructed; the mode switch returns as soon as the keyboard
   closes. */
body.keyboard-open .game-shell.mode-game.room-game-active .root-mode-switch {
  display: none;
}

@media (max-height: 520px) and (orientation: landscape) {
  .game-shell.mode-chat #rootRoomPanel .room-header { min-height: 58px; padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: 6px; }
  .game-shell.mode-chat #rootRoomPanel .room-brand > span { width: 38px; height: 38px; }
  .game-shell.mode-chat #rootRoomPanel .room-tabs button { min-height: 48px; }
  .game-shell.mode-chat #rootRoomPanel #roomPanelContent > .room-entry,
  .game-shell.mode-chat #rootRoomPanel #roomPanelContent > .room-lobby { padding-top: 16px; padding-bottom: 18px; }
  .game-shell.mode-chat #rootRoomPanel .room-entry-hero { padding: 18px; }
  .game-shell.mode-chat #rootRoomPanel h1 { font-size: clamp(31px, 5vw, 44px); }
}

@media (max-width: 700px), (orientation: portrait) {
  .game-shell.mode-chat #rootRoomPanel .room-header::before { display: none; }
  .game-shell.mode-chat #rootRoomPanel .room-brand > div { display: none; }
  .game-shell.mode-chat #rootRoomPanel #roomPanelContent > .room-entry,
  .game-shell.mode-chat #rootRoomPanel #roomPanelContent > .room-lobby {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .game-shell.mode-chat #rootRoomPanel #roomPanelContent > .room-lobby > *,
  .game-shell.mode-chat #rootRoomPanel #roomPanelContent > .room-entry > * { grid-column: 1; }
  .game-shell.mode-chat #rootRoomPanel #roomPanelContent > .room-entry > #roomNicknameForm,
  .game-shell.mode-chat #rootRoomPanel #roomPanelContent > .room-entry > .room-player-list,
  .game-shell.mode-chat #rootRoomPanel #roomPanelContent > .room-entry > .room-button.is-wide { grid-column: 1; }
  .game-shell.mode-chat #rootRoomPanel .room-player-list { grid-template-columns: 1fr; }
  .game-shell.mode-chat #rootRoomPanel #roomPanelContent > .room-chat { border-right: 0; border-left: 0; }
}

@media (orientation: portrait) {
  .game-shell.mode-chat #rootRoomPanel.room-panel,
  .game-shell.mode-chat #rootRoomPanel.room-panel.is-open {
    inset: 0;
    width: 100vw;
    transform: none;
  }
  .game-shell.mode-chat #rootRoomPanel #roomPanelContent > .room-entry,
  .game-shell.mode-chat #rootRoomPanel #roomPanelContent > .room-lobby {
    padding-right: max(16px, env(safe-area-inset-right));
    padding-left: max(16px, env(safe-area-inset-left));
  }
  .game-shell.mode-chat #rootRoomPanel h1 { font-size: clamp(34px, 11vw, 46px); }
}

body.keyboard-open #rootRoomPanel.room-panel,
#rootRoomPanel.room-panel.is-keyboard-open {
  height: var(--visual-height, 100dvh);
  max-height: var(--visual-height, 100dvh);
}

body.keyboard-open .room-chat-peek {
  bottom: calc(100dvh - var(--visual-top, 0px) - var(--visual-height, 100dvh) + 6px);
}

body.keyboard-open .room-chat-peek > :not(.room-chat-peek-form) {
  display: none;
}

body.keyboard-open .room-chat-peek-form {
  padding-top: 0;
  border-top: 0;
}

body.keyboard-open .room-panel .room-header,
.room-panel.is-keyboard-open .room-header {
  min-height: 49px;
  padding-top: 5px;
  padding-bottom: 5px;
}

body.keyboard-open .room-panel .room-chat-log,
.room-panel.is-keyboard-open .room-chat-log {
  padding-top: 8px;
  padding-bottom: 8px;
}

body.keyboard-open .room-panel .room-chat-form,
.room-panel.is-keyboard-open .room-chat-form {
  padding-bottom: 6px;
}

@media (orientation: portrait) {
  #rootRoomPanel.room-panel {
    position: fixed;
    z-index: 340;
    inset: 0;
    width: 100vw;
    max-width: none;
    height: var(--visual-height, 100dvh);
    border: 0;
    border-top: max(0px, env(safe-area-inset-top)) solid var(--room-black);
    box-shadow: none;
    transform: translate3d(0, 102%, 0);
  }

  #rootRoomPanel.room-panel.is-open {
    transform: translate3d(0, 0, 0);
  }

  .room-header {
    padding-right: max(14px, env(safe-area-inset-right));
    padding-left: max(14px, env(safe-area-inset-left));
  }

  .room-scroll,
  .room-entry {
    padding-right: max(15px, env(safe-area-inset-right));
    padding-left: max(15px, env(safe-area-inset-left));
  }

  .room-tabs,
  .room-chat-form {
    padding-right: max(9px, env(safe-area-inset-right));
    padding-left: max(9px, env(safe-area-inset-left));
  }

  .room-rail {
    position: fixed;
    z-index: 345;
    top: auto;
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    left: max(10px, env(safe-area-inset-left));
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    width: auto;
    transform: none;
  }

  .room-panel .room-rail {
    position: static;
  }

  .room-chat-peek {
    position: fixed;
    z-index: 330;
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    left: max(12px, env(safe-area-inset-left));
    width: auto;
  }

  .room-modal {
    align-items: end;
    padding-right: max(10px, env(safe-area-inset-right));
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    padding-left: max(10px, env(safe-area-inset-left));
  }

  .room-modal-card,
  .room-modal > :is(section, article, form, div):first-child {
    width: 100%;
    max-height: min(82dvh, calc(var(--visual-height, 100dvh) - 20px));
    border-radius: 14px 14px 4px 4px;
  }
}

@media (max-width: 390px) and (orientation: portrait) {
  .room-entry-actions,
  .room-host-actions,
  .room-answer-grid {
    grid-template-columns: 1fr;
  }

  .room-code {
    font-size: 20px;
  }

  .room-player {
    grid-template-columns: 38px minmax(0, 1fr) auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  #rootRoomPanel.room-panel,
  .room-panel *,
  .room-panel *::before,
  .room-panel *::after,
  .room-chat-peek,
  .room-toast,
  .room-modal {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
  }
}

@media (forced-colors: active) {
  #rootRoomPanel.room-panel,
  .room-card,
  .room-entry-card,
  .room-lobby-card,
  .room-game-card,
  .room-player,
  .room-question,
  .room-prompt,
  .room-chat-peek,
  .room-modal-card {
    border-color: CanvasText;
  }

  .room-action,
  .room-button,
  .room-tabs button,
  .room-tabs a {
    forced-color-adjust: auto;
  }
}

@media (orientation: landscape) {
  .game-shell { --room-panel-visible-width: clamp(340px, 32vw, 400px); }
  #rootRoomGameHud.room-game-overlay { left: 50%; }
  .game-shell.room-game-active #rootRoomGameHud.room-game-overlay {
    left: calc((100% - 320px) / 2);
    width: min(470px, calc(100% - 344px));
  }
  .game-shell.room-panel-open #rootRoomGameHud.room-game-overlay {
    left: calc((100% - var(--room-panel-visible-width)) / 2);
    width: min(470px, calc(100% - var(--room-panel-visible-width) - 24px));
  }
}

@media (max-height: 430px) and (orientation: landscape) {
  .game-shell { --room-panel-visible-width: clamp(320px, 38vw, 380px); }
}

@media (max-width: 760px) and (orientation: landscape) {
  .game-shell { --room-panel-visible-width: min(340px, calc(100vw - var(--rail-width, 70px) - env(safe-area-inset-right) - 72px)); }
}

@media (max-width: 660px) and (orientation: landscape) {
  .game-shell { --room-panel-visible-width: min(300px, calc(100vw - var(--rail-width, 64px) - env(safe-area-inset-right) - 10px)); }
  .game-shell.room-game-active #rootRoomGameHud.room-game-overlay {
    left: calc((100% - 256px) / 2);
    width: min(470px, calc(100% - 280px));
  }
}
