.room-screen { color: #242237; padding-block: 1.2rem .25rem; }
.room-screen [hidden] { display: none !important; }
.room-nav, .room-invite-group, .room-panel-heading, .room-cover-text p, .room-player-meta {
  display: flex; align-items: center;
}
.room-nav { justify-content: space-between; flex-wrap: wrap; gap: .65rem; margin-bottom: 1rem; }
.room-invite-group { flex-wrap: wrap; gap: .75rem; }
.room-nav .btn { min-height: 2.4rem; font-size: .84rem; }
.room-code { color: #696577; font-size: .8rem; }
.room-code strong { margin-left: .2rem; font: 700 .9rem ui-monospace, monospace; color: #403657; letter-spacing: .07em; }
.room-cover {
  position: relative; isolation: isolate; display: flex; align-items: flex-end; min-height: 11.6rem; padding: 1.6rem 2rem;
  overflow: hidden; color: #fff; background: #20203c; border-radius: .65rem; border: 1px solid #302744;
}
.room-cover-art { position: absolute; z-index: -2; inset: 0 0 0 auto; height: 100%; width: 74%; object-fit: cover; object-position: 50% 44%; }
.room-cover::before {
  content: ''; position: absolute; z-index: -1; inset: 0;
  background: linear-gradient(90deg, #25203f 15%, #25203ff2 30%, #25203f58 66%, #17122110);
}
.room-cover-text { min-width: 0; max-width: 75%; }
.room-badges { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; }
.room-private {
  display: inline-flex; align-items: center; gap: .28rem; padding: .1rem .45rem;
  border: 1px solid #9185ac; border-radius: .3rem; background: #34294d; color: #eee7fa;
  font-size: .7rem; font-weight: 650;
}
.room-phase { display: inline-flex; gap: .4rem; align-items: center; color: #dbfce3; font-size: .72rem; font-weight: 700; }
.room-phase i { width: .46rem; height: .46rem; background: #a3efb5; border-radius: 50%; }
.room-screen[data-phase="playing"] .room-phase { color: #fff0be; }
.room-screen[data-phase="playing"] .room-phase i { background: #f6cf71; }
.room-screen[data-phase="finished"] .room-phase { color: #dbd7f2; }
.room-screen[data-phase="finished"] .room-phase i { background: #b0a3cb; }
.room-cover h1 {
  margin: .62rem 0 .55rem; color: #fff; font: 750 clamp(1.75rem, 4vw, 3.1rem)/1.12 var(--ui-font);
  overflow-wrap: anywhere; text-shadow: 0 2px 0 #27203f;
}
.room-cover-text p { margin: 0; flex-wrap: wrap; gap: .45rem; color: #ece8f8; font-size: .86rem; }
.room-map-separator { color: #ada6c4; margin-inline: .08rem; }
.room-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 1.15rem; margin-top: 1.2rem; align-items: start; }
.room-read-only .room-layout { grid-template-columns: minmax(0, 1fr); }
.room-seat-panel, .room-control, .room-game-panel, .room-chat {
  min-width: 0; padding: clamp(1rem, 2.4vw, 1.65rem);
  background: #fff; border: 1px solid #dfdce7; border-radius: .65rem;
}
.room-screen .section-title { margin: 0; font: 730 clamp(1.2rem, 2vw, 1.55rem)/1.3 var(--ui-font); }
.room-panel-heading { gap: .6rem; margin-bottom: .9rem; }
.room-seat-count { color: #6f6686; font-size: .82rem; }
.room-seats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; margin: 0; padding: 0; list-style: none; }
.room-seat {
  min-width: 0; min-height: 4.2rem; display: flex; align-items: center; gap: .7rem; padding: .65rem .7rem;
  border: 1px solid #e2dfeb; border-radius: .45rem; background: #fcfbff;
}
.room-avatar { flex: 0 0 auto; display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: .4rem; }
.room-avatar .invader { width: 1.65rem; height: 1.35rem; }
.room-avatar.avatar-0 { background: #e9e3ff; color: #7158bc; }
.room-avatar.avatar-1 { background: #def3e7; color: #3f8464; }
.room-avatar.avatar-2 { background: #ffe6cf; color: #a45f37; }
.room-avatar.avatar-3 { background: #e1edf9; color: #557eaa; }
.room-player { min-width: 0; }
.room-player strong { display: block; font-size: .92rem; overflow-wrap: anywhere; }
.room-player small { margin-left: .3rem; color: #6e638c; font-weight: 500; font-size: .7rem; }
.room-player-meta { flex-wrap: wrap; gap: .32rem; margin-top: .2rem; }
.room-player-meta > span:first-child:not([class]) { font-size: .69rem; color: #746e7f; }
.room-player-meta:empty { display: none; }
.room-host, .room-player-state { color: #655d71; font-weight: 550; font-size: .69rem; }
.room-host { color: #7050ae; }
.room-player-state.ready { color: #327755; }
.room-player-state.offline { color: #9c653b; }
.room-seat-empty { background: #faf9fc; border-style: dashed; color: #817b8d; font-size: .82rem; }
.room-seat-empty .room-avatar { color: #9991aa; background: #f0eef4; }
.room-slot-item { min-width: 0; }
.room-slot-toggle { width: 100%; height: 100%; text-align: left; }
.room-slot-toggle:hover:not(:disabled), .room-slot-toggle:focus-visible {
  border-color: #9173c7; background: #f6f2fd;
}
.room-slot-label { display: grid; gap: .12rem; overflow-wrap: anywhere; }
.room-slot-label strong { color: #554e64; font-size: .83rem; }
.room-slot-label small { font-size: .72rem; font-weight: 600; color: #6843a4; }
.room-seat-closed { background: #eeedf2; border-style: solid; border-color: #e3dfe9; color: #716d7b; }
.room-seat-closed .room-avatar { background: #e2dfe9; color: #716c80; }
.room-slot-toggle:disabled { opacity: 1; }
.room-slot-toggle:disabled small { color: #78717f; font-weight: 400; }
.room-seats[aria-busy=true] .room-slot-toggle { cursor: progress; }
.room-hint { margin: .85rem 0 1rem; color: #635d70; font-size: .9rem; line-height: 1.55; }
.room-control .room-action { width: 100%; justify-content: center; }
.room-chat { color: var(--ink); text-align: left; }
.room-chat .section-title { margin: 0 0 .85rem; font: 730 clamp(1.2rem, 2vw, 1.55rem)/1.3 var(--ui-font); }
.room-chat-stage { position: relative; }
.room-chat-log {
  height: clamp(12rem, 26vh, 18rem); padding: .55rem .7rem; overflow-y: auto; overflow-anchor: none;
  overscroll-behavior: contain; border: 1px solid var(--line); border-radius: .45rem; background: #faf9fc;
}
.room-chat-empty {
  position: absolute; inset: 0; display: grid; place-items: center; margin: 0;
  pointer-events: none; color: var(--muted); font-size: .86rem;
}
.room-chat-empty[hidden] { display: none; }
.room-chat-message { margin: 0; padding: .33rem .2rem; font-size: .88rem; line-height: 1.5; overflow-wrap: anywhere; }
.room-chat-message strong { color: #493d68; }
.room-chat-message.from-self strong { color: var(--purple-dark); }
.room-chat-message.from-bot { color: #255d52; background: #e8f4ed; border-radius: .3rem; padding-inline: .48rem; }
.room-chat-message.from-bot strong { color: #316b5e; }
.room-chat-message.from-bot + .from-bot { margin-top: .18rem; }
.room-chat-compose { display: flex; align-items: stretch; gap: .5rem; margin-top: .65rem; }
.room-chat-compose input {
  flex: 1; min-width: 0; padding: .6rem .7rem; border: 1px solid #b9b4c8; border-radius: .4rem;
  color: var(--ink); background: #fff; font-size: .9rem;
}
.room-chat-compose button { min-height: 2.5rem; }
.room-chat-status { margin: .5rem 0 0; color: #8b422e; font-size: .8rem; }
.room-chat-status:empty { margin: 0; }
.room-action:disabled { cursor: not-allowed; opacity: .55; }
.room-board-title { padding-bottom: .7rem; }
.room-has-game .room-layout { grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); grid-template-rows: auto 1fr; }
.room-has-game .room-game-panel { grid-column: 1; grid-row: 1 / 3; }
.room-has-game .room-seat-panel, .room-has-game .room-control { grid-column: 2; }
.room-has-game .room-seats { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 760px) {
  .room-layout, .room-has-game .room-layout { grid-template-columns: 1fr; grid-template-rows: auto; gap: .8rem; }
  .room-has-game .room-game-panel, .room-has-game .room-seat-panel, .room-has-game .room-control { grid-column: auto; grid-row: auto; }
  .room-has-game .room-seats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .room-cover { min-height: 10rem; padding: 1.35rem; }
}
@media (max-width: 470px) {
  .room-screen { padding-top: .6rem; }
  .room-invite-group { gap: .35rem; }
  .room-nav .btn { padding-inline: .5rem; }
  .room-code { font-size: .72rem; }
  .room-code strong { letter-spacing: 0; font-size: .75rem; }
  .room-cover { min-height: 9.5rem; }
  .room-cover-text { max-width: 94%; }
  .room-seats, .room-has-game .room-seats { gap: .45rem; }
  .room-seat { gap: .43rem; padding: .5rem; }
  .room-avatar { width: 1.9rem; height: 1.9rem; }
}

/* The member lobby pairs each activity on the left with its context or actions on the right. */
.room-lobby {
  container: waiting-room / inline-size;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center;
  gap: .8rem 1rem; padding-top: 0;
}
.room-lobby .room-cover {
  grid-area: 1 / 1; min-height: 2.5rem; padding: 0; align-items: center;
  background: transparent; color: var(--ink); border: 0; border-radius: 0;
}
.room-lobby .room-cover::before, .room-lobby .room-cover-art, .room-lobby .room-cover-text > p { display: none; }
.room-lobby .room-cover-text { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .7rem; max-width: 100%; }
.room-lobby .room-cover h1 {
  order: -1; margin: 0; font-size: clamp(1.45rem, 2.2vw, 1.9rem); color: var(--ink); text-shadow: none;
}
.room-lobby .room-badges { gap: .35rem; }
.room-lobby .room-phase, .room-lobby .room-private { padding: .15rem .48rem; border-radius: .3rem; }
.room-lobby .room-phase { background: #e7f3ef; color: #256b61; }
.room-lobby .room-phase i { background: #389568; }
.room-lobby .room-private { border: 0; background: var(--lavender); color: var(--purple-dark); }
.room-lobby .room-nav { grid-area: 1 / 2; margin: 0; justify-content: flex-end; }
.room-lobby .room-layout {
  grid-column: 1 / -1; margin: 0; align-items: stretch; gap: .8rem;
  grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr);
  grid-template-areas: "seats info" "chat controls";
}
.room-lobby .room-seat-panel { grid-area: seats; }
.room-lobby .room-game-info { grid-area: info; }
.room-lobby .room-chat { grid-area: chat; }
.room-lobby .room-control { grid-area: controls; display: flex; flex-direction: column; }
.room-lobby .room-layout > section { min-width: 0; padding: clamp(.85rem, 1.25vw, 1.15rem); }
.room-lobby .section-title { font-size: 1.3rem; }
.room-lobby .room-panel-heading, .room-lobby .room-chat .section-title { margin-bottom: .55rem; }
.room-lobby .room-seat-count { margin-left: auto; font-variant-numeric: tabular-nums; }
.room-lobby .room-seats { grid-template-columns: minmax(0, 1fr); gap: .26rem; }
.room-lobby .room-seat { min-height: 2.25rem; padding: .25rem .65rem; gap: .65rem; }
.room-seat-number {
  display: grid; place-items: center; flex: 0 0 1.55rem; min-height: 1.45rem;
  color: var(--purple-dark); background: var(--lavender); border-radius: .3rem;
  font: 700 .9rem/1 var(--ui-font);
}
.room-seat-empty .room-seat-number { background: #efedf3; color: #766e81; }
.room-lobby .room-player, .room-lobby .room-slot-label {
  display: flex; align-items: center; flex: 1; min-width: 0; gap: .45rem;
}
.room-lobby .room-player-meta, .room-lobby .room-slot-label small { margin: 0 0 0 auto; flex-shrink: 0; }
.room-lobby .room-player-meta { justify-content: flex-end; }
.room-lobby .room-player-meta > span { font-size: .73rem; }
.room-game-info { display: grid; align-content: start; gap: .4rem; }
.room-info-art {
  display: block; width: 100%; height: clamp(6.25rem, 16vh, 9rem); object-fit: contain;
  background: var(--page); border-radius: .4rem;
}
.room-info-title { font: 730 1.2rem/1.3 var(--ui-font); overflow-wrap: anywhere; }
.room-info-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .55rem; color: var(--muted); font-size: .75rem; }
.room-info-meta span:first-child { padding: .1rem .4rem; border-radius: .3rem; background: var(--lavender); color: var(--purple-dark); }
.room-info-description { font-size: .83rem; color: var(--muted); line-height: 1.55; overflow-wrap: anywhere; }
.room-map-briefing { white-space: pre-wrap; overflow-wrap: anywhere; background: #15191d; padding: .6rem .7rem; font-size: .82rem; }
.room-map-briefing p { margin: 0; }
.room-lobby .room-chat-log { height: clamp(6.5rem, 16vh, 9.5rem); }
.room-lobby .room-chat-compose { margin-top: .5rem; }
.room-lobby .room-control-buttons { display: grid; gap: .45rem; margin-top: auto; }
.room-lobby .room-control-buttons .room-back { background: white; border-color: var(--line); color: var(--muted); }
.room-lobby .room-control-buttons .room-back:hover { background: var(--page); color: var(--ink); }
.room-lobby .room-hint { margin: .45rem 0 .85rem; font-size: .85rem; }
@container waiting-room (max-width: 41rem) {
  .room-lobby .room-cover { grid-area: 1 / 1 / 2 / -1; }
  .room-lobby .room-nav { grid-area: 2 / 1 / 3 / -1; justify-content: flex-start; }
  .room-lobby .room-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "seats" "controls" "chat" "info"; }
  .room-lobby .room-control-buttons { grid-template-columns: repeat(auto-fit, minmax(min(100%, 8rem), 1fr)); }
}
@media (max-height: 700px) {
  .page-frame:has(.room-lobby) { padding-top: .7rem; }
  .room-lobby, .room-lobby .room-layout { row-gap: .6rem; }
  .room-lobby .room-layout > section { padding: .7rem .85rem; }
  .room-lobby .room-seat { min-height: 2.1rem; }
}

/* Only a joined, running (or just finished) match takes over the viewport. */
body.room-immersive { background: #edf2f4; }
body.room-immersive .site-header,body.room-immersive .ad-slot,body.room-immersive .ad-wrap,
body.room-immersive .footer { display: none !important; }
body.room-immersive .page-frame,
body.room-immersive #main { display: block; width: 100%; max-width: none; margin: 0; padding: 0; }
body.room-immersive .room-screen {
  display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh;
  padding: 0; background: #edf2f4; color: #263d4d;
}
body.room-immersive .room-cover,body.room-immersive .room-nav,body.room-immersive .room-seat-panel,
body.room-immersive .room-control,body.room-immersive .room-board-title { display: none !important; }
body.room-immersive .room-layout { display: block; margin: 0; flex: 1; }
body.room-immersive .room-game-panel {
  width: min(1280px,100%); margin: 0 auto; padding: clamp(.55rem,1.5vw,1.3rem);
  background: transparent; border: 0; border-radius: 0; box-shadow: none;
}
.match-bar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: .5rem; padding: max(.5rem,env(safe-area-inset-top)) max(1rem,env(safe-area-inset-right)) .5rem max(1rem,env(safe-area-inset-left));
  background: #1d3547; color: #f3f8f7; border-bottom: 1px solid #526977;
}
.match-bar > div { display: flex; gap: .7rem; align-items: center; }
.match-bar h1 { margin: 0; font: 750 clamp(.95rem,2vw,1.15rem)/1.35 var(--ui-font); letter-spacing: -.035em; }
.match-bar h1:focus { outline: 0; }
.match-symbol { display: grid; place-items: center; width: 2rem; height: 2rem; color: #aad9ce; border: 1px solid #577883; border-radius: .45rem; }
.match-bar button { display: inline-flex; align-items: center; gap: .38rem; min-height: 2.1rem; padding: .35rem .65rem; border-radius: .35rem; border: 1px solid #687e89; background: #2b4658; color: #f0f5f6; font-size: .78rem; font-weight: 700; }
.match-bar button:hover { background: #3b5b6c; }
body.room-immersive .rtd .rtd-stats { margin-top: 0; }
@media(min-width:800px) {
  body.room-immersive .rtd { width: min(100%,max(850px,calc(137.5dvh + 30px))); margin-inline: auto; }
}
dialog.match-report {
  width: min(455px,calc(100% - 28px)); max-height: calc(100dvh - 22px); overflow: auto;
  padding: clamp(1.15rem,3vw,1.7rem); color: #23394a; border-radius: .65rem; border: 1px solid #91aaa9;
  border-top: 4px solid #53988b; background: #f8faf9; box-shadow: 0 15px 65px #172c4277;
}
.match-report::backdrop { background: #101e2a9a; backdrop-filter: blur(2px); }
dialog.match-report[data-outcome=lost] { border-top-color: #b38363; }
.match-report-head { display: flex; gap: .8rem; align-items: center; }
.match-report-mark { display: grid; place-items: center; width: 3rem; height: 3rem; flex: none; border-radius: .5rem; border: 1px solid #a8c9c0; color: #34756c; background: #e1f0eb; }
.match-report[data-outcome=lost] .match-report-mark { border-color: #d6bbab; color: #9b6549; background: #f6e9e0; }
.match-report-head p,.match-report-head h2,.match-report dl,.match-report dd { margin: 0; }
.match-report-head p { color: #5c6d77; font-size: .76rem; font-weight: 650; }
.match-report-head h2 { margin-top: .15rem; font: 800 clamp(1.4rem,4vw,1.8rem)/1.25 var(--ui-font); letter-spacing: -.055em; }
.match-close { margin-left: auto; align-self: flex-start; display: grid; place-items: center; width: 2rem; height: 2rem; padding: 0; border: 1px solid #d6dfe1; border-radius: .4rem; background: #fff; color: #4c626d; }
.match-report .match-statistics { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); margin-block: 1.2rem 1rem; border-block: 1px solid #d5dfe0; padding: .85rem 0; }
.match-statistics > div { padding-inline: .7rem; border-left: 1px solid #d5dfe0; }
.match-statistics > div:first-child { border: 0; padding-left: 0; }
.match-statistics dt { color: #586b76; font-size: .72rem; }
.match-statistics dd { margin-top: .25rem; font: 750 1.1rem/1.35 ui-monospace,monospace; color: #274351; }
.match-receipt { display: grid; gap: .25rem; font-size: .84rem; color: #52656b; }
.match-receipt strong { color: #236f60; }
.match-receipt strong:empty { display: none; }
.match-choices { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1.2rem; }
.match-choices .btn { flex: 1; min-height: 2.5rem; }
.match-choices .primary { background: #256566; color: #fff; }
.match-choices .secondary { border: 1px solid #cdD9DB; color: #3b5460; background: #fff; }
@media(max-width:470px) {
  .match-bar { padding-inline: .6rem; }
  .match-bar > div { gap: .35rem; }
  .match-bar button { padding-inline: .45rem; font-size: .73rem; }
  .match-symbol { width: 1.65rem; height: 1.65rem; }
  body.room-immersive .room-game-panel { padding: .45rem; }
}
@media(max-height:500px) and (orientation:landscape) {
  .match-bar { padding-block: .25rem; }
  body.room-immersive .room-game-panel { padding-block: .4rem; }
  body.room-immersive .rtd-play { grid-template-columns: minmax(0,1fr) minmax(180px,.7fr); }
  body.room-immersive .rtd-stats { margin-bottom: .45rem; }
  body.room-immersive .rtd-field { max-width: max(320px,calc(137.5dvh - 145px)); }
}
body.hosting-match .site-header, body.hosting-match .ad-slot, body.hosting-match .footer { display: none; }
body.hosting-match .page-frame, body.hosting-match #main { display: block; width: 100%; max-width: none; margin: 0; padding: 0; }
.match-notice, .play-wait {
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; padding: 1rem; gap: .9rem;
}
.match-notice h1, .play-wait h1 { margin: 0 0 .5rem; font-size: clamp(1.25rem, 4vw, 2rem); }
.play-wait { background: #14222a; color: #e7f4ee; }
