/* Rooms (D108): the lobby (room.html), the Live page, and room/watch mode on play.html. */
.rm-main { margin: 0 auto 40px; }
.rm-main h2 { letter-spacing: -0.01em; }

/* cards */
.rm-card { position: relative; background: var(--mc-surface); border: 1px solid var(--mc-border); border-radius: var(--mc-radius); padding: 20px 22px; margin: 0 0 16px; box-shadow: var(--mc-shadow); min-width: 0; }
.rm-card h1 { font-size: 30px; line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 6px; overflow-wrap: anywhere; }
.rm-card h2 { display: flex; align-items: center; gap: 8px; font-size: 19px; margin: 0 0 12px; }
.rm-card > p:last-child { margin-bottom: 0; }
.rm-head { overflow: hidden; padding-top: 24px; }
.rm-head::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--mc-chroma); }
.rm-meta { font-size: 15px; margin: 0; }
.rm-note { font-size: 14px; margin: 8px 0 0; }
.rm-count { font-size: 13px; font-weight: 800; line-height: 1; padding: 4px 9px; border-radius: 999px; background: var(--mc-surface-2); color: var(--mc-violet); }

/* layout: the left column (seats, players) and the chat; cards keep their own height */
.rm-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); grid-template-rows: auto 1fr; grid-template-areas: "seats chat" "players chat"; gap: 16px; align-items: start; }
.rm-seats-card { grid-area: seats; }
.rm-players-card { grid-area: players; }
.rm-chat { grid-area: chat; }
.rm-grid .rm-card { margin: 0; }
.rm-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }

/* invite: room info, a thin line, then the code */
.rm-invite { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--mc-border); }
.rm-code-row { margin: 0; gap: 10px; }
.rm-code { font: 700 24px/1 var(--mc-font-mono); letter-spacing: 3px; padding: 10px 14px; background: var(--mc-surface-2); color: var(--mc-text); border: 1px dashed #c9bdf0; border-radius: var(--mc-radius-sm); user-select: all; }

/* buttons: thinner, calmer; Start (host) and Ready (others) are the main ones */
.rm-main .button { min-height: 44px; padding: 8px 18px; border-width: 1.5px; border-radius: 12px; font-size: 16px; line-height: 1.2;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.15s; }
.rm-main .button:hover { background: var(--mc-surface-2); border-color: var(--mc-violet); color: var(--mc-text); }
.rm-main .button.primary { background: var(--mc-text); border-color: var(--mc-text); color: #fff; box-shadow: 0 4px 14px rgba(29, 22, 48, 0.22); }
.rm-main .button.primary:hover { background: var(--mc-violet); border-color: var(--mc-violet); color: #fff; box-shadow: 0 6px 18px rgba(139, 92, 255, 0.35); }
.rm-main .button.primary:active { transform: translateY(1px); }
.rm-main .button.rm-small, .rm-small { min-height: 34px; padding: 4px 12px; font-size: 14px; border-radius: 10px; }
.rm-main .button.rm-danger { color: #a3122a; }
.rm-main .button.rm-danger:hover { background: #fde0e4; border-color: #a3122a; color: #7a0f20; }
.rm-link { font: inherit; font-size: 14px; font-weight: 700; min-height: 34px; padding: 4px 8px; border: 0; border-radius: 8px; background: none; color: var(--mc-text-muted); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--mc-border); cursor: pointer;
  transition: background-color 0.15s, color 0.15s; }
.rm-link:hover { background: var(--mc-surface-2); color: var(--mc-text); text-decoration-color: currentColor; }
.rm-link.rm-danger { color: #a3122a; }
.rm-link.rm-danger:hover { background: #fde0e4; color: #7a0f20; }
@media (pointer: coarse) { .rm-main .button.rm-small, .rm-small, .rm-link, .rm-main select, .rm-manage > summary, .rm-quick > summary, .rm-main .mc-chat-tool { min-height: 44px; } }
.rm-actions { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--mc-border); }
.rm-actions .rm-note { flex-basis: 100%; margin: 2px 0 0; }
.rm-leave { justify-content: space-between; margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--mc-border); }

/* seats and players: name | status | actions, the host's seat controls on their own line */
.rm-seats, .rm-bench { list-style: none; margin: 0; padding: 0; }
.rm-seat { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--mc-border); }
.rm-seats > li:first-child, .rm-bench > li:first-child, .rm-team + .rm-seat { border-top: 0; }
.rm-seat-name { flex: 1 1 7em; font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.rm-seat-name.rm-open { color: var(--mc-text-muted); font-weight: 600; font-style: italic; }
.rm-tags { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.rm-acts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; margin-left: auto; }
.rm-tags:empty, .rm-acts:empty { display: none; }
.rm-manage { flex: 1 1 100%; }
.rm-manage > summary { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 2px 8px; margin-left: -8px; border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--mc-text-muted); cursor: pointer; list-style: none; transition: background-color 0.15s, color 0.15s; }
.rm-manage > summary::-webkit-details-marker { display: none; }
.rm-manage > summary::before { content: "▸"; transition: transform 0.15s; }
.rm-manage[open] > summary::before { transform: rotate(90deg); }
.rm-manage > summary:hover { background: var(--mc-surface-2); color: var(--mc-text); }
.rm-host-ctl { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 0 2px; }
.rm-team { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--mc-magenta); margin: 12px 0 0; padding: 0; }
.rm-seats > .rm-team:first-child { margin-top: 0; }

/* status chips */
.rm-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 700; line-height: 1.5; padding: 1px 9px; border-radius: 999px; background: #f1eef7; color: var(--mc-text-muted); white-space: nowrap; }
.rm-tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.7; }
.rm-tag.ok { background: #dff5e3; color: #146c3a; }
.rm-tag.wait { background: #fff1dc; color: #8a4a00; }
.rm-tag.host { background: var(--mc-surface-2); color: #5b3fd1; }
.rm-tag.seated { background: #e5ecff; color: #2343b8; }
.rm-tag.muted { background: #fde0e4; color: #7a0f20; }
.rm-tag[title^="Joined from the Live list"] { background: #dcf5fb; color: #0b5c6e; }

/* selects */
.rm-main select { font: inherit; font-size: 15px; min-height: 38px; padding: 6px 10px; border-radius: 10px; border: 1px solid #d6cdea; background: var(--mc-surface); color: var(--mc-text); max-width: 100%; cursor: pointer; transition: border-color 0.15s; }
.rm-main select:hover { border-color: var(--mc-violet); }

/* messages */
.rm-msg { min-height: 1.3em; margin: 8px 0 0; font-size: 14px; }
.rm-msg:empty { min-height: 0; margin: 0; }

/* chat */
.rm-main .mc-chat-lines { min-height: 128px; max-height: 320px; margin: 0 0 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--mc-border); font-size: 15px; }
.rm-main .mc-chat-lines li { margin: 4px 0; }
.rm-chat-empty { color: var(--mc-text-muted); text-align: center; padding: 34px 0 30px; }
.rm-main .mc-chat-text { gap: 8px; margin: 0 0 8px; }
.rm-main .mc-chat-text input { min-height: 44px; padding: 8px 12px; border-radius: 12px; border: 1px solid #d6cdea; transition: border-color 0.15s; }
.rm-main .mc-chat-text input:hover { border-color: var(--mc-violet); }
.rm-main .mc-chat-presets { gap: 6px; }
.rm-main .mc-chat-preset { min-height: 32px; padding: 3px 11px; font-size: 14px; transition: background-color 0.15s, border-color 0.15s; }
.rm-main .mc-chat-preset:hover { background: var(--mc-surface-2); border-color: var(--mc-violet); }
@media (pointer: coarse) { .rm-main .mc-chat-preset { min-height: 44px; } }
.rm-quick { margin: 2px 0 0; }
.rm-quick > summary { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 4px 10px; border-radius: 8px; font-size: 14px; font-weight: 700; color: var(--mc-text-muted); cursor: pointer; list-style: none; transition: background-color 0.15s, color 0.15s; }
.rm-quick > summary::-webkit-details-marker { display: none; }
.rm-quick > summary::before { content: "▸"; transition: transform 0.15s; }
.rm-quick[open] > summary::before { transform: rotate(90deg); }
.rm-quick > summary:hover { background: var(--mc-surface-2); color: var(--mc-text); }
.rm-quick .mc-chat-presets { padding: 6px 0 2px; }
.rm-main .mc-chat-line { font-size: 13px; color: var(--mc-text-muted); margin: 10px 0 0; }

/* the Live page */
.rm-live { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--mc-surface); border: 1px solid var(--mc-border); border-radius: var(--mc-radius); box-shadow: var(--mc-shadow); overflow: hidden; }
.rm-live td, .rm-live th { text-align: left; padding: 12px; border-top: 1px solid var(--mc-border); vertical-align: middle; }
.rm-live th { border-top: 0; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--mc-text-muted); background: #faf8fe; }
.rm-live tbody tr { transition: background-color 0.15s; }
.rm-live tbody tr:hover { background: #fbf9ff; }
.rm-live td:last-child { text-align: right; }
.rm-live .rm-tag { margin-left: 6px; }
.rm-live .button { min-height: 36px; padding: 4px 16px; border-width: 1.5px; border-radius: 10px; font-size: 14px; }
.rm-empty { padding: 22px; border: 1px dashed #d6cdea; border-radius: var(--mc-radius); background: var(--mc-surface); text-align: center; }

@media (max-width: 720px) {
  .rm-grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-template-areas: "seats" "chat" "players"; }
  .rm-live thead { display: none; }
  .rm-live td { display: block; border: 0; padding: 2px 14px; text-align: left; }
  .rm-live td:empty { display: none; }
  .rm-live td:first-child { padding-top: 12px; }
  .rm-live td:last-child { text-align: left; padding: 8px 14px 12px; }
  .rm-live tr { display: block; border-top: 1px solid var(--mc-border); }
  .rm-live tbody tr:first-child { border-top: 0; }
}
@media (max-width: 480px) {
  .wrap { padding: 0 14px; }
  .rm-card { padding: 16px 14px; border-radius: 12px; }
  .rm-head { padding-top: 20px; }
  .rm-card h1 { font-size: 23px; }
  .rm-meta { font-size: 14px; }
  .rm-code { font-size: 20px; letter-spacing: 2px; padding: 8px 10px; }
  .rm-acts { flex: 1 1 100%; justify-content: flex-start; margin-left: 0; }
  .rm-host-ctl select { flex: 1 1 100%; width: 100%; }
  .rm-actions .button { flex: 1 1 auto; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  .rm-main .button, .rm-link, .rm-main select, .rm-main .mc-chat-preset, .rm-main .mc-chat-text input, .rm-quick > summary, .rm-quick > summary::before, .rm-manage > summary, .rm-manage > summary::before, .rm-live tbody tr { transition: none; }
  .rm-main .button.primary:active { transform: none; }
}
/* D118 seat mix: agent seats, the coach toggle. */
.rm-tag.agent { background: #ece6ff; color: #4b2db3; }
.rm-check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
/* D118 C2: seatsUi in the lobby: names and colours on the seat rows, and for cross / table4 (4 seats) or versus (2) a
   small seat map above the list (tokens only; every control stays in the full-width list below). */
.rm-presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 14px; }
.rm-presets-label { flex-basis: 100%; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--mc-text-muted); }
.rm-main .button.rm-preset { max-width: 100%; white-space: normal; text-align: left; }
.rm-main .button.rm-preset.rm-on { background: var(--mc-surface-2); border-color: var(--mc-violet); color: #4b2db3; }
.rm-seat-label { display: inline-flex; align-items: center; gap: 6px; flex: none; min-width: 4.5em; font-weight: 800; font-size: 13px; color: var(--mc-text-muted); }
.rm-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--mc-p0); flex: none; }
.rm-dot.mc-p1 { background: var(--mc-p1); } .rm-dot.mc-p2 { background: var(--mc-green); } .rm-dot.mc-p3 { background: var(--mc-magenta); }
.rm-seat:focus { outline: none; }
.rm-seat:focus-visible { outline: 2px solid var(--mc-violet); outline-offset: 2px; }
.rm-seat:focus-visible, .rm-seat.rm-flash { animation: rm-flash 1.2s ease-out; }
@keyframes rm-flash { from { background: var(--mc-surface-2); } to { background: transparent; } }

.rm-map { display: grid; gap: 8px; max-width: 440px; margin: 0 auto 16px; padding: 12px; border: 1px solid var(--mc-border); border-radius: var(--mc-radius); background: #faf8fe; }
.rm-map-cross, .rm-map-table4 { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-areas: ". p2 ." "p1 mid p3" ". p0 ."; }
.rm-map-cross [data-pid="p0"], .rm-map-table4 [data-pid="p0"] { grid-area: p0; } .rm-map-cross [data-pid="p1"], .rm-map-table4 [data-pid="p1"] { grid-area: p1; }
.rm-map-cross [data-pid="p2"], .rm-map-table4 [data-pid="p2"] { grid-area: p2; } .rm-map-cross [data-pid="p3"], .rm-map-table4 [data-pid="p3"] { grid-area: p3; }
.rm-map-cross .rm-map-mid, .rm-map-table4 .rm-map-mid { grid-area: mid; }
.rm-map-table4 .rm-map-mid { border: 2px dashed var(--mc-border); border-radius: 12px; }
.rm-map-versus { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); grid-template-areas: "a mid b"; }
.rm-map-versus [data-pid="p0"] { grid-area: a; } .rm-map-versus [data-pid="p1"] { grid-area: b; } .rm-map-versus .rm-map-mid { grid-area: mid; }
.rm-map-seat { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 0; min-height: 52px; padding: 6px 4px; font: inherit; color: var(--mc-text);
  background: var(--mc-surface); border: 1.5px solid var(--mc-border); border-radius: 12px; cursor: pointer; transition: border-color 0.15s, background-color 0.15s; }
.rm-map-seat:hover { border-color: var(--mc-violet); background: var(--mc-surface-2); }
.rm-map-seat.rm-mine { border-color: #c9bdf0; }
.rm-map-name { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; font-size: 12px; font-weight: 800; color: var(--mc-text-muted); }
.rm-map-name > span:last-child, .rm-map-who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rm-map-who { max-width: 100%; font-size: 14px; font-weight: 700; }
.rm-map-seat.rm-open .rm-map-who { color: var(--mc-text-muted); font-style: italic; font-weight: 600; }
.rm-map-mid { display: flex; align-items: center; justify-content: center; min-width: 0; padding: 4px; text-align: center; font-size: 12.5px; font-weight: 700; line-height: 1.3; color: var(--mc-text-muted); overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) { .rm-map-seat { transition: none; } .rm-seat:focus-visible, .rm-seat.rm-flash { animation: none; } }
.rm-check { flex-wrap: wrap; min-width: 0; }
.rm-seat-note { flex: 1 1 100%; order: 5; margin: 0; font-size: 13px; line-height: 1.4; }
.rm-manage { order: 6; }

/* D120 one page (docs/PLAN_ONEPAGE.md §3, §11): the room lobby inside play.html (#mc-lobby), the game view next to it,
   the Room drawer over a running game. The lobby rules above apply through .rm-main on the section. */
body.mc-in-lobby .mc-layout { display: block; }
body.mc-in-lobby #mc-view, body.mc-in-lobby .mc-panel, body.mc-in-lobby #mc-full, body.mc-in-lobby #mc-restart, body.mc-in-lobby #mc-seed { display: none; }
.mc-lobby { max-width: 1100px; margin: 0 auto; width: 100%; }
.mc-lobby:focus { outline: none; }
.mc-lobby-top { display: grid; gap: 12px; margin: 0 0 16px; }
.mc-lobby-top > .rm-card { margin: 0; }
.mc-lobby-result h2 { margin: 0 0 6px; font-size: 22px; }
.mc-lobby-result-label { margin: 0 0 4px; text-transform: uppercase; letter-spacing: 0.06em; font-size: 12px; font-weight: 800; }
.mc-lobby-notice { border-color: var(--mc-violet); }
.mc-lobby-notice p { margin: 0 0 8px; font-weight: 700; }
/* the agent panel's slot: shown only while the panel is (the bar element is moved in, not rebuilt) */
.mc-lobby-agents { padding: 0; overflow: visible; border: 0; box-shadow: none; background: none; }
.mc-lobby-agents:not(:has(> .ac-agents:not([hidden]))) { display: none; }
.mc-lobby-agents .ac-agents { position: relative; inset: auto; width: auto; max-width: none; max-height: none; overflow: visible; margin: 0; }
/* the Room drawer: the lobby over the running game, with Close */
body.mc-drawer-open #mc-lobby { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); max-width: none; margin: 0; padding: 16px; overflow-y: auto; overscroll-behavior: contain;
  background: var(--mc-bg, #fffaf3); box-shadow: -12px 0 40px rgba(29, 22, 48, 0.22); z-index: 60; }
body.mc-drawer-open::after { content: ""; position: fixed; inset: 0; background: rgba(29, 22, 48, 0.28); z-index: 55; }
/* The page under the drawer doesn't scroll (phones: only the drawer scrolls, nothing of the game shows through); the
   drawer is the full dynamic viewport height where the browser knows it (mobile toolbars). */
body.mc-drawer-open { overflow: hidden; }
body.mc-drawer-open #mc-lobby { height: 100vh; height: 100dvh; box-sizing: border-box; }
body.mc-drawer-open #mc-lobby .rm-grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-template-areas: "seats" "chat" "players"; }
.rm-drawer-close { float: right; margin: -6px -6px 6px 12px; }
.rm-start-wait { color: var(--mc-text-muted); }
@media (max-width: 767px) {
  body.mc-in-lobby .mc-layout { padding: 10px 16px; }
  .mc-lobby .rm-grid { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-template-areas: "seats" "chat" "players"; }
  body.mc-drawer-open #mc-lobby { width: 100vw; padding: 12px 12px 24px; }
  .mc-lobby .button, .rm-drawer-close { min-height: 44px; }
}
.rm-main .button[disabled], .rm-main .button.primary[disabled] { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
