.identity-dialog {
  width: min(480px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 18px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 60px #000b;
}
.identity-dialog::backdrop { background: #01040bb0; }
.identity-dialog form { display: grid; gap: 9px; }
.identity-dialog h2 { margin-bottom: 3px; font-size: 19px; text-align: center; }
.identity-dialog input[type=text] { min-height: 36px; padding: 7px 9px; }
.identity-banner { display: grid; justify-items: center; gap: 7px; padding: 4px 0; }
.identity-banner button { min-height: 32px; }
.identity-colors { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.identity-colors label { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 3px 7px; border: 1px solid var(--line); border-radius: 5px; }
.identity-colors input { min-width: 36px; min-height: 30px; padding: 1px; }
.identity-dialog fieldset { margin: 0; min-width: 0; border: 1px solid var(--line); border-radius: 5px; padding: 5px; }
.identity-dialog legend { padding: 0 4px; color: var(--muted); font-size: 11px; }
.identity-choices, .identity-crests { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.identity-choices label, .identity-crests label { position: relative; }
.identity-choices input, .identity-crests input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.identity-choices label > span, .identity-crests label > span { display: grid; place-content: center; min-height: 38px; padding: 3px; text-align: center; font-size: 11px; border: 1px solid transparent; border-radius: 4px; background: #0b1523; }
.identity-crests label > span { font-size: 16px; line-height: 1.1; }
.identity-crests small { font-size: 10px; color: var(--muted); }
.identity-dialog input:hover + span { background: #152536; }
.identity-dialog input:checked + span { border-color: var(--cyan); color: var(--cyan); }
.identity-dialog input:focus-visible + span { outline: 2px solid var(--cyan); outline-offset: 1px; }
.identity-actions { display: flex; justify-content: end; gap: 8px; }
.identity-actions button { min-height: 34px; }
.identity-dialog [data-error]:empty { display: none; }
.identity-dialog [data-error] { color: var(--warning); }

.player-banner {
  display: inline-block;
  position: relative;
  width: 44px;
  aspect-ratio: 2 / 1;
  overflow: hidden;
  isolation: isolate;
  flex: none;
  vertical-align: middle;
  background: var(--banner-primary);
  border-radius: 2px;
  outline: 1px solid #a2bbd140;
}
.player-banner::before, .player-banner::after { content: ""; position: absolute; inset: 0; }
.player-banner::before { background: var(--banner-secondary); }
.player-banner::after { z-index: 2; background: linear-gradient(105deg, #0005, #fff1 18%, #0002 34%, #fff2 48%, transparent 70%, #0006); pointer-events: none; }
.banner-fields::before { clip-path: inset(0 0 0 50%); }
.banner-sash::before { clip-path: polygon(58% 0, 100% 0, 100% 40%, 39% 100%, 0 100%, 0 79%); }
.banner-canton::before { clip-path: inset(0 56% 45% 0); }
.banner-standard::before { clip-path: inset(0 30%); }
.banner-crest { position: absolute; z-index: 1; left: 25%; top: 50%; transform: translate(-50%, -50%); color: #fff4d5; text-shadow: 0 1px 2px #060b14, 0 0 2px #060b14; font-size: 13px; line-height: 1; }
.banner-sash .banner-crest { left: 68%; top: 29%; }
.banner-canton .banner-crest { left: 22%; top: 28%; font-size: 10px; }
.banner-standard .banner-crest { left: 50%; }
.identity-preview { width: min(100%, 300px); border-radius: 4px; }
.identity-preview .banner-crest { font-size: 58px; }
.identity-preview.banner-canton .banner-crest { font-size: 40px; }
#room-banner { width: 25px; margin-inline: 4px 2px; }
#room-banner .banner-crest { font-size: 8px; }
#room-seat { display: inline-block; max-width: 90px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }

.workspace-dock:not(.is-stacked) > [data-window-id="chat"] { height: min(430px, 100%); }
[data-window-id="chat"].is-mobile-sheet { height: min(440px, 78%); }
.room-chat {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: minmax(156px, 1fr);
  container-type: inline-size;
}
.workspace-window:not(.is-mobile-sheet) > .room-chat { padding-bottom: 31px; }
.chat-main { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.chat-header { position: relative; display: grid; align-items: center; grid-template-columns: minmax(0, 1fr) auto auto; gap: 5px; }
.chat-header h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.chat-header button { min-height: 32px; padding-inline: 7px; white-space: nowrap; }
.chat-header button[aria-expanded="true"] { color: var(--cyan); border-color: #4d7b86; background: #173340; }
.chat-roster { position: absolute; z-index: 1; inset: calc(100% + 5px) 0 auto auto; width: min(100%, 300px); padding: 9px; background: var(--panel); border: 1px solid var(--line); border-radius: 5px; box-shadow: 0 8px 24px #0008; }
.chat-roster h4 { margin: 0 0 4px; font-size: 12px; }
.chat-roster ul { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.chat-roster li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 7px; min-height: 32px; border-top: 1px solid var(--line-soft); }
.chat-roster strong { font-size: 12px; overflow-wrap: anywhere; }
.chat-roster .player-banner { width: 31px; }
.chat-presence { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11px; }
.chat-presence::before { content: ''; width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--presence-color); }
.chat-presence[data-presence="online"] { --presence-color: #79dca4; }
.chat-presence[data-presence="recent"] { --presence-color: #f4ce75; }
.chat-presence[data-presence="offline"] { --presence-color: #ef8b83; }
.chat-channels { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 7px; min-height: 0; width: clamp(112px, 31cqw, 168px); margin-inline-start: 10px; padding-inline-start: 10px; border-inline-start: 1px solid var(--line); }
.chat-group-list { display: grid; align-content: start; gap: 5px; min-height: 0; overflow: auto; }
.chat-channel { display: grid; align-content: center; gap: 3px; width: 100%; min-height: 49px; padding: 6px 7px; text-align: start; background: #0b1725; }
.chat-channel strong { line-height: 1.2; overflow-wrap: anywhere; }
.chat-channel small { color: var(--muted); font-size: 10px; line-height: 1.25; overflow-wrap: anywhere; }
.chat-channel[aria-current="true"] { border-color: #4d7b86; color: var(--cyan); background: #173340; }
.chat-group-list .chat-channel:focus-visible { outline-offset: -3px; }
.chat-create { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding-inline: 4px; white-space: nowrap; }
.chat-create span { display: inline-grid; place-items: center; width: 16px; height: 16px; border: 1px solid #4d7b86; border-radius: 50%; color: var(--cyan); font-size: 13px; line-height: 1; }
.chat-messages { flex: 1 1 0; min-height: 0; overflow-y: auto; display: grid; align-content: start; gap: 7px; overscroll-behavior-y: contain; }
.chat-messages:focus-visible { outline: 2px solid var(--cyan); outline-offset: -2px; }
.chat-message { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 7px; padding-block: 4px; }
.chat-message p { overflow-wrap: anywhere; white-space: pre-wrap; }
.chat-message time { color: var(--muted); white-space: nowrap; font: 9px var(--mono); padding-top: 3px; }
.chat-message strong { font-weight: 700; }
.chat-compose { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px; }
.chat-compose input, .chat-compose button { min-height: 34px; }
.chat-compose input { min-width: 0; padding: 5px 7px; }
[data-chat-status]:empty, #chat-create-error:empty { display: none; }
#chat-create-error { color: var(--warning); }
.chat-create-dialog fieldset { padding: 6px; }
.chat-invitees { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.chat-invitees label { position: relative; min-width: 0; }
.chat-invitees input { position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; }
.chat-invitees input:enabled { cursor: pointer; }
.chat-invitees label > span { display: grid; justify-items: center; align-content: center; gap: 5px; min-height: 86px; padding: 8px 5px; text-align: center; overflow-wrap: anywhere; border: 1px solid var(--line); border-radius: 4px; background: #0b1725; }
.chat-invitees label .player-banner { width: 56px; }
.chat-invitees small { color: var(--muted); font-size: 10px; }
@container (width < 420px) {
  .room-chat:has(.chat-channels:not([hidden])) .chat-header h3 { grid-column: 1 / -1; }
  .room-chat:has(.chat-channels:not([hidden])) [data-chat-players] { grid-column: 2; }
  .room-chat:has(.chat-channels:not([hidden])) .chat-message { grid-template-columns: auto minmax(0, 1fr); }
  .room-chat:has(.chat-channels:not([hidden])) .chat-message time { grid-column: 2; padding-top: 0; }
  .chat-header button { min-height: 36px; }
  .chat-create { min-height: 36px; }
}

.identity-choices label > span { gap: 4px; justify-items: center; }
.identity-template-swatch { width: 36px; }
.identity-template-swatch .banner-crest { font-size: 9px; }
.identity-template-swatch.banner-canton .banner-crest { font-size: 7px; }

.crest-outline { display: inline-block; width: 1em; height: 1em; background: currentColor; }
.identity-crest-icon { justify-self: center; }
