/* Player-only surfaces. The official cover stays the focal point; the room is a quieter writing surface. */
.arena-player {
  --bout-deck: #131116;
  --bout-inset: #19171e;
  --bout-msg: #231e2a;
  --bout-line: #3b3442;
  --gut: clamp(16px, 3vw, 36px);
  --reading-pad: max(var(--gut), calc((100% - 51.25rem) / 2));
  --bout-stage: min(100%, 51.25rem);
  --room-height: 100vh;
  --visible-room: var(--player-visual-height, var(--room-height));
}
@supports (height: 100dvh) { .arena-player { --room-height: 100dvh; } }
:root[data-theme=light] .arena-player {
  --bout-deck: #efebf2;
  --bout-inset: #fdfbff;
  --bout-msg: #f0e8f5;
  --bout-line: #d9cfdf;
}

.arena-player .arena-mast .arena-brand .product-lockup { display: block; width: auto; max-width: 10rem; height: 24px; object-fit: contain; }
@media (max-width: 690px) {
  .arena-player .arena-mast .arena-brand .product-lockup { height: 18px; max-width: 7rem; }
}

/* This is also the unenhanced first paint and the pagehide snapshot. */
.player-boot {
  min-height: calc(100svh - var(--bar-size)); display: grid; place-items: center;
  padding: 24px var(--pad); text-align: center;
  background: radial-gradient(ellipse at 50% 45%, var(--bout-inset), transparent 65%);
}
.boot-panel { max-width: 32rem; overflow-wrap: anywhere; }
.boot-mark { display: block; margin: 0 auto 20px; }
.boot-panel h1 { font: 580 clamp(1.75rem,4vw,2.75rem)/1.1 Space,var(--sans); letter-spacing: -.05em; }
.boot-panel p { color: var(--muted); line-height: 1.55; margin: 8px auto 0; }
.boot-panel .btn { margin-top: 20px; }

/* First-login setup is a page surface, not a mobile keyboard-sized overlay. */
.player-name-setup {
  display: grid; justify-items: center; align-items: center;
  min-height: calc(100svh - var(--bar-size));
  padding: clamp(14px, 4vh, 44px) max(var(--pad), env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(var(--pad), env(safe-area-inset-left));
}
.name-setup-card {
  width: min(100%, 32rem); min-width: 0; padding: clamp(16px, 4vw, 32px);
  background: var(--bout-inset); border: 1px solid var(--bout-line); border-radius: 8px;
  overflow-wrap: anywhere;
}
.name-setup-confirmed { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--muted); font-size: .85rem; font-weight: 600; }
.name-setup-confirmed::before { content: ''; width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--signal); }
.name-setup-card h1 { font: 600 clamp(1.6rem, 5vw, 2.45rem)/1.1 Space, var(--sans); letter-spacing: -.05em; text-wrap: balance; }
#name-description, #name-rules { color: var(--muted); line-height: 1.5; text-wrap: pretty; }
#name-description { margin-top: 8px; }
#name-form { margin-top: 16px; }
#name-form label { display: block; margin-bottom: 5px; font-size: .92rem; font-weight: 600; }
#new-username { min-height: 44px; font-size: 1rem; }
#name-rules { margin-top: 6px; font-size: .85rem; }
.name-setup-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
#name-status:empty { display: block; margin: 0; } /* Keep the live region present before its first message. */
@media (max-width: 400px) { .name-setup-actions .btn { flex: 1 1 100%; justify-content: center; } }
@media (max-height: 480px) { .player-name-setup { align-items: start; } }

/* A closed card has a second explanatory line. At phone heights give that
   line the space of the generic sign-in hint; both fields keep their labels. */
@media (max-height: 650px) {
  #target-admission:not(:empty) + #gate-description { display: none; }
  .arena-entry:has(#target-admission:not(:empty)) #target-admission { font-size: .82rem; line-height: 1.35; margin-top: 4px; }
}


/* The workspace owns the whole viewport. The masthead only frames boot, entry and name setup. */
body[data-surface=workspace] .arena-mast { display: none; }
.arena-player:has(#workspace:not([hidden])) { display: flex; flex-direction: column; height: var(--visible-room); }
.arena-player:has(#workspace:not([hidden])) #main { display: grid; flex: 1 0 0; min-height: 0; }
.arena-player #workspace {
  width: 100%; max-width: none; height: auto; min-height: 0; margin: 0; padding: 0; border: 0;
  display: grid; grid-template: minmax(0, 1fr) / var(--side) minmax(0, 1fr) var(--rail);
}
.arena-player .brief-scope { margin-top: 10px; font-size: .85rem; line-height: 1.5; color: var(--ink); }
.brief-flag-goal { margin-block: 10px; font-size: .85rem; line-height: 1.5; color: var(--ink); text-wrap: pretty; }
#bout-identity { padding-block: 10px; margin: 0 0 8px; font-size: .85rem; overflow-wrap: anywhere; border-top: 1px solid var(--rule); }

#workspace .turns { position: relative; isolation: isolate; flex: 1 1 0; min-height: 0; padding-block: clamp(14px, 2.75vh, 28px); gap: clamp(14px, 2.5vh, 24px); scrollbar-width: thin; }
#workspace :is(.turns, .thread-foot) { padding-inline: var(--reading-pad); }
#workspace .turns > * { flex: none; }
#workspace .turns article { flex: none; max-width: min(69ch, 100%); }
#workspace .turns .mine { max-width: min(66ch, 92%); }
#workspace .turns article.mine p { background: var(--surface); border: 1px solid var(--rule); border-radius: 12px 12px 3px 12px; padding: 10px 16px; }
#workspace .turns article p { font-size: 1rem; line-height: 1.57; }
#workspace .turns article.withheld p { color: var(--muted); font-style: italic; border-inline-start: 2px solid var(--rule); padding: 4px 0 4px 12px; }
#workspace .turn-byline { gap: 10px; margin-bottom: 5px; }
#workspace .mine .turn-byline { align-items: center; flex-wrap: wrap; row-gap: 0; margin-bottom: 0; }
#workspace .turn-edit {
  display: inline-flex; align-items: center; min-height: 44px; margin-block: -12px; padding: 4px 8px;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted);
  font: 600 .78rem/1.2 var(--sans); text-align: start;
  text-decoration: underline; text-underline-offset: .2em;
}
#workspace .turn-edit:hover:not(:disabled), #workspace .turn-edit:focus-visible { background: var(--bout-inset); color: var(--ink); }
#workspace .turn-byline small { font-weight: 630; font-size: .82rem; overflow-wrap: anywhere; }
#workspace .reply .turn-byline::before { content: ''; flex: none; width: 1.1rem; height: 1.1rem; align-self: center; background: url('assets/arena/arena-mark.svg') center/contain no-repeat; }
#workspace .turn-byline time { flex: none; }
#workspace .turns pre { padding: 12px 16px; border: 1px solid var(--bout-line); background: var(--bout-deck); font-size: .86rem; line-height: 1.6; }
#workspace .empty-chat { max-width: 31rem; padding-block: 8px; text-wrap: pretty; }
#workspace .empty-chat::before {
  width: 58px; height: 58px; margin-bottom: 14px; border-radius: 11px; border: 1px solid var(--bout-line);
  background: url('assets/arena/arena-mark.svg') center/36px 36px no-repeat, var(--bout-deck);
}
#workspace .empty-chat h2 { font-size: clamp(1.28rem, 2.6vw, 1.9rem); line-height: 1.1; letter-spacing: -.047em; }
#workspace .empty-chat p { max-width: 42ch; margin: 7px auto 0; line-height: 1.5; }

#workspace .thread-foot { --composer-max: 51.25rem; flex: none; display: grid; grid-template-columns: minmax(0,1fr); min-width: 0; }
#workspace .compose { display: grid; padding: 0 0 max(14px, env(safe-area-inset-bottom)); border: 0; }
.thread-foot .chat-error { inline-size: min(100%,var(--composer-max)); margin-inline: auto; color: var(--ink); font-size: .85rem; overflow-wrap: anywhere; }
.thread-foot .chat-error:not(:empty) { margin-block-end: 4px; border-inline-start: 2px solid var(--blue); padding-inline-start: 8px; }
.hold-note { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; padding-block: 14px; border-top: 1px solid var(--rule); }
.hold-note strong { font-size: .95rem; }.hold-note p { color: var(--muted); font-size: .85rem; }
.hold-note a { display: inline-flex; align-items: center; min-height: 44px; font-size: .88rem; }
#workspace .composer { inline-size: min(100%,var(--composer-max)); margin-inline: auto; }
#workspace .composer .box { border: 1px solid var(--rule-strong); border-radius: 12px; background: var(--surface); overflow: hidden; }
#workspace .composer .box:focus-within { border-color: var(--blue); }
#workspace .compose #message {
  --message-pad: 6px;
  --message-rows: 3;
  display: block; width: 100%; min-width: 0; min-height: 52px;
  max-height: calc(var(--message-rows) * 1.5em + 2 * var(--message-pad) + 14px);
  padding: 14px 16px var(--message-pad);
  border: 0; border-radius: 0; background: transparent; outline: none;
  font: 400 max(16px,.95rem)/1.5 var(--sans); color: var(--ink);
  field-sizing: content; resize: none; overflow: auto; overflow-wrap: anywhere;
}
#workspace .compose textarea::placeholder { color: var(--faint); }
#workspace .compose textarea[aria-invalid=true] { color: var(--bad); }
#workspace .box-bar { display: flex; align-items: center; gap: 8px; padding: 6px 8px 8px 10px; }
#workspace .box-bar .grow { flex: 1; }
#workspace #send { display: grid; place-items: center; width: 38px; min-height: 38px; padding: 0; background: var(--solid); color: #fff; border: 1px solid transparent; border-radius: 8px; }
#workspace #send:hover:not(:disabled) { background: #9406c8; }
#workspace #send:disabled { opacity: 1; color: var(--faint); background: var(--base-raised); border-color: var(--bout-line); }
#workspace #send svg { width: 17px; height: 17px; }
#workspace #send:not([data-sending]) .send-wait, #workspace #send[data-sending] .send-arrow { display: none; }
#workspace .composer-limit { display: block; margin: 0; font: 500 .74rem/1.25 var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
#workspace .composer-limit:empty { display: none; }
#workspace .composer-limit[data-level=warn] { color: var(--warn); }
#workspace .composer-limit[data-level=over] { color: var(--bad); font-weight: 650; }
#workspace .compose .hint { margin: 7px auto 0; inline-size: min(100%,var(--composer-max)); color: var(--faint); font-size: .74rem; text-align: center; }
#workspace .edit-resend {
  display: flex; align-items: center; flex-wrap: wrap; gap: 2px 10px;
  margin-bottom: 4px; padding-inline: 4px;
}
#workspace .edit-resend p { flex: 1 1 9rem; min-width: 0; font-size: .82rem; line-height: 1.4; text-wrap: pretty; overflow-wrap: anywhere; }
#workspace .edit-resend strong { display: block; font-weight: 650; }
#workspace .edit-resend span { color: var(--muted); }
#workspace #cancel-edit { flex: none; margin-inline-start: auto; padding-inline: 10px; font-size: .8rem; background: transparent; }
@media (max-width: 600px), (max-height: 520px) {
  #workspace .edit-resend span { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
.arena-player :is(#transcript, #boot-title, #chat-title):focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
@media (pointer: coarse), (max-width: 760px) {
  #workspace .compose #message { --message-pad: 10px; min-height: 44px; }
  #workspace #send { width: 44px; min-height: 44px; }
}
@media (pointer: coarse) { #workspace .compose .hint .keys { display: none; } }
@media (max-width: 600px) { #workspace .turns article.mine { max-width: 95%; } }

/* Applies both to a resized layout viewport and to a keyboard overlaid on it.
   Keep Send next to the field; if chrome and text still cannot fit, allow page scroll. */
.arena-player[data-room-compact]:has(#workspace:not([hidden])) { height: auto; min-height: var(--visible-room); }
.arena-player[data-room-compact] #main { flex: 1 0 auto; }
.arena-player[data-room-compact] #workspace .turns { flex: 1 1 0; min-height: 5rem; max-height: min(8rem, calc(var(--visible-room) * .29)); padding-block: 10px; }
.arena-player[data-room-compact] #workspace .topbar { padding-block: 5px; }
.arena-player[data-room-compact] #workspace :is(.banner, .strip, .hint) { display: none; }
.arena-player[data-room-compact] #workspace .empty-chat::before { display: none; }
.arena-player[data-room-compact] #workspace .compose { padding-block: 0 max(8px, env(safe-area-inset-bottom)); }
.arena-player[data-room-compact] #workspace .compose #message { --message-rows: 1; }

/* With an overlay keyboard the larger layout viewport cannot scroll the short
   room into view. Give the visible room its own scroll fallback instead. */
:root:has(.arena-player[data-room-overlay]) { overflow: clip; }
.arena-player[data-room-overlay]:has(#workspace:not([hidden])) {
  position: fixed; inset: var(--player-visual-top) 0 auto;
  height: var(--visible-room); min-height: 0; overflow: auto; overscroll-behavior: contain;
}
