/* Styles for the admin and gameplay UIs: an 8-bit Halloween look. Square
   corners, solid borders, shadows with no blur, and a pixel font for
   headings and controls. Colours follow the system's light or dark setting.

   The colours come from a pixel-art picture of a witch's study at night: the
   dark theme takes them as they are, and the light theme darkens the same
   hues for a pale lilac page. Every text colour is at least 4.5:1 on --bg
   and --surface. */

/* Pixelify Sans (SIL Open Font License, fonts/OFL.txt), cut down to Latin
   letters and punctuation. One variable file for weights 400 to 700. Its
   digits are not all one width, so times and counts stay in the system
   font. */
@font-face {
  font-family: "Pixelify Sans";
  src: url("fonts/PixelifySans.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --bg: #f6eefa;
  --surface: #fdf8fe;
  --text: #1d0734;
  --muted: #66295b;
  /* The dropdown chevron, drawn in --muted (a data URL can't use variables). */
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2366295b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --border: #d9c3e3;
  --accent: #7a2f8c;
  --accent-text: #ffffff;
  --danger: #b8323d;
  --ok: #2f7a1f;
  /* The pumpkins' glow: the ring around whatever has keyboard focus. */
  --warm: #b4532a;
  /* Other people's chat bubbles. */
  --bubble: #ece0f3;
  /* The hard shadow under cards and buttons. */
  --shadow: #b9a1c7;
  --radius: 0;
  --font-body: system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-pixel: "Pixelify Sans", ui-monospace, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14073a;
    --surface: #241647;
    --text: #f3e6f7;
    --muted: #b579b6;
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23b579b6' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --border: #402e95;
    --accent: #c76be0;
    --accent-text: #14073a;
    --danger: #ec6068;
    --ok: #7bd85a;
    --warm: #f2aa7d;
    --bubble: #33215e;
    --shadow: #07021a;
  }
}

/* A user's own font, which an admin sets (users.font); the gameplay UI puts
   it on the page (gameplay/js/play.js). Papyrus has no file here to load:
   the browser uses the one installed on the device, and a device without it
   shows the usual fonts. */
:root[data-font="papyrus"] {
  --font-body: Papyrus, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-pixel: Papyrus, "Pixelify Sans", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

/* Display rules below would otherwise override the hidden attribute. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font-body);
}

/* Clerk's impersonation badge, shown while an admin plays as someone, is a
   white pill in either theme. Clerk colours its text with light-dark(),
   which follows the color-scheme above, so in dark mode the text turned
   white on that white pill. Keep the badge in light mode, and give text
   that Clerk doesn't colour itself the light theme's --text. */
.cl-impersonationFab {
  color-scheme: light;
  color: #1c1c21;
}

a {
  color: var(--accent);
}

/* Keyboard focus: a square ring in the pumpkins' glow. Clerk's sign-in form
   draws its own. */
:where(a, button, input, select, textarea, summary):where(:not(.cl-rootBox *)):focus-visible {
  outline: 2px solid var(--warm);
  outline-offset: 2px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 20px;
  border-bottom: 2px solid var(--border);
  background: var(--surface);
}

/* The pumpkin sprite, then the name. */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-pixel);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
  text-decoration: none;
}

/* On phones the admin bar says only "Admin": the buttons beside it need the
   room. */
@media (max-width: 640px) {
  .brand-game {
    display: none;
  }
}

.topbar nav {
  display: flex;
  gap: 16px;
}

/* The links and the account, laid out in the bar on wider screens. */
.menu {
  display: flex;
  align-items: center;
  gap: 24px;
  flex: 1;
}

.menu-toggle {
  display: none;
}

.account {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 4px;
}

h2 {
  font-size: 1.1rem;
  margin: 0 0 12px;
}

h1,
h2,
h3 {
  font-family: var(--font-pixel);
  font-weight: 600;
}

.muted {
  color: var(--muted);
}

/* The pixel-art sprites (shared/sprites/, dom.js's sprite()). A row never
   squeezes them. */
img.sprite {
  flex: none;
}

/* A sprite that stands for a word after a name (the skull for eliminated),
   in line with the text. */
img.status-mark {
  margin-left: 4px;
  vertical-align: -3px;
}

/* A one-colour icon (dom.js's icon()): the sprite in --icon is the mask,
   and the text's colour fills it, so it follows the button's colour in both
   themes. 24px, twice the sprite's 12, so every pixel is the same size. */
.icon {
  display: inline-block;
  flex: none;
  width: var(--icon-size, 24px);
  height: var(--icon-size, 24px);
  background: currentColor;
  mask: var(--icon) center / var(--icon-size, 24px) no-repeat;
}

/* A button that shows only an icon; its aria-label and title name it. As
   tall as a button with one line of text. */
button.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
}

/* Phones: icon buttons keep their own width, side by side, where buttons
   with words fill the width of their card or table cell. */
@media (max-width: 640px) {
  section.card .row > button.icon-button,
  table.responsive td .row > button.icon-button {
    width: auto;
  }
}

/* An empty list: the ghost sprite, then the words. */
.empty {
  display: flex;
  align-items: center;
  gap: 10px;
}

.empty::before {
  content: "";
  flex: none;
  width: 32px;
  height: 32px;
  background: url("sprites/ghost.svg") center / contain no-repeat;
}

.small {
  font-size: 0.85rem;
}

/* A page's heading, with a button at the right. */
.page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

/* Under a list shown a page at a time (the Users page): which items and page
   are shown at the left; the page-size choice and the previous and next
   buttons at the right. On a narrow screen the controls wrap under the
   text. */
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

.pager p {
  margin: 0;
}

/* The arrows as tall as the page-size list beside them, and wide enough to
   hit easily on a phone. */
.pager-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
}

.pager-controls button.icon-button {
  min-width: 44px;
  padding: 0 12px;
}

/* A page's tabs (a game's, a stage's or a template's page): a row of
   buttons over a line, the chosen one underlined. On a narrow screen the
   row scrolls sideways. */
.tabs {
  display: flex;
  gap: 4px;
  margin-top: 16px;
  overflow-x: auto;
  /* The cut-off tab at the edge shows there are more. */
  scrollbar-width: none;
  box-shadow: inset 0 -2px var(--border);
}

.tabs button {
  padding: 8px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
  box-shadow: none;
}

.tabs button:hover {
  color: var(--text);
}

.tabs button[aria-selected="true"] {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

.crumbs {
  margin-bottom: 12px;
  color: var(--muted);
}

section.card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 4px 4px 0 var(--shadow);
  padding: 16px;
  margin: 16px 0;
  /* A table wider than the card scrolls inside it instead of spilling out. */
  overflow-x: auto;
}

/* A part of an admin page that is built again on its own (admin/js/live.js):
   it holds its content without boxing it, so the layout is as without it. */
.live {
  display: contents;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

/* Columns of at least 320px, or one column as wide as the container when it
   is narrower (a phone's open row on a game's Players tab), so nothing in it
   sticks out. */
.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
}

/* The grid spaces its cards; their own margins would double the gap. */
.grid {
  margin: 16px 0;
}

.grid > section.card {
  margin: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

/* Every row at least as tall as one holding a button or a dropdown, so rows
   with and without one are the same height. */
td {
  height: 48px;
}

/* Names in bold (a power's, in the first column) stay on one line. */
td strong {
  white-space: nowrap;
}

/* Buttons in tables are compact, to fit that height. */
td button {
  padding: 4px 10px;
  font-size: 0.9rem;
}

/* A form in a table cell (a dropdown and its button) sits on one line,
   centred like the rest of the row. */
td .row {
  flex-wrap: nowrap;
  align-items: center;
}

/* Dropdowns in tables share one width, so whatever follows them (a Give
   button, the next column) lines up from row to row. */
td select {
  width: 10rem;
}

th {
  font-family: var(--font-pixel);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

/* Rules for bare form elements leave out Clerk's sign-in form (.cl-rootBox),
   which styles its own: a full-width button there squeezed the phone number
   field. :where() adds no specificity, so more specific rules here still win
   as before. */
label:where(:not(.cl-rootBox *)) {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

label.inline {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  color: var(--text);
}

input:where(:not(.cl-rootBox *)),
select:where(:not(.cl-rootBox *)),
textarea:where(:not(.cl-rootBox *)),
button:where(:not(.cl-rootBox *)) {
  font: inherit;
  color: var(--text);
}

input:where(:not(.cl-rootBox *)),
select:where(:not(.cl-rootBox *)),
textarea:where(:not(.cl-rootBox *)) {
  padding: 6px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  min-width: 0;
}

textarea {
  min-height: 70px;
  width: 100%;
}

/* The browser's own chevron sits against the right border; this one is drawn
   10px in from it, with room for it after the text. A choice too long for the
   box ends in an ellipsis rather than being cut off. */
select:where(:not(.cl-rootBox *)) {
  appearance: none;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding-right: 32px;
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 8px;
}

/* A form straight after a table (such as a stage's "New options" below its
   options) keeps its distance, as a heading between them would. */
table + form:where(:not(.cl-rootBox *)) {
  margin-top: 16px;
}

/* A button straight after a form (such as "Add one option per active player"
   after "Add options") keeps its distance. */
form:where(:not(.cl-rootBox *)) + button,
form:where(:not(.cl-rootBox *)) + .row {
  margin-top: 12px;
}

/* A fieldset only groups controls (to disable them together); no frame. */
fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

fieldset.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* A stage timer's options (admin/js/forms.js timerFields) sit a little
   apart from its time limit above them. */
.timer-status > label:not(.inline) + label.inline {
  margin-top: 10px;
}

/* Everything in a disabled fieldset looks unavailable. */
fieldset:disabled {
  opacity: 0.5;
}

/* Buttons under a card's content, such as Leave game. */
.actions {
  margin-top: 12px;
}

form.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Buttons sit on a hard shadow and press down into it when clicked, at once
   rather than in a smooth slide. */
button:where(:not(.cl-rootBox *)) {
  padding: 6px 12px;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  font-family: var(--font-pixel);
  box-shadow: 3px 3px 0 var(--shadow);
  cursor: pointer;
}

/* A link that looks like a button, for one that goes to another page. */
a.button {
  display: inline-block;
  padding: 6px 12px;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  font-family: var(--font-pixel);
  box-shadow: 3px 3px 0 var(--shadow);
  text-decoration: none;
}

button:where(:not(.cl-rootBox *)):not(:disabled):active,
a.button:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--shadow);
}

button.secondary {
  background: transparent;
  color: var(--accent);
}

button.danger {
  border-color: var(--danger);
  background: transparent;
  color: var(--danger);
}

button:where(:not(.cl-rootBox *)):disabled {
  opacity: 0.5;
  cursor: default;
}

/* A person's profile photo, or their initials without one (shared/photo.js). */
.avatar {
  flex: none;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border);
}

.avatar.initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-weight: 600;
}

/* In a table: the photo and its buttons, centred on each other. */
/* A row's detail (a player's character info on a game's Players tab): one
   cell across the table, under its row, on the bubble colour so it reads as
   part of that row. */
tr.detail-row > td {
  height: auto;
  padding: 12px;
  background: var(--bubble);
}

tr.detail-row .grid {
  margin: 0;
}

/* Which info a player has, then the button that shows or hides it. */
.info-cell {
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
}

.photo-cell {
  align-items: center;
  flex-wrap: nowrap;
}

/* The player's own card: room between their photo and name, and the photo
   buttons under them, which are otherwise flush when there is no hint text
   between the two. */
.photo-cell + .row {
  margin-top: 12px;
}

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  font-family: var(--font-pixel);
  font-size: 0.8rem;
  /* The same everywhere: a badge in a heading would otherwise be bold, and
     sit on the heading's larger line. */
  font-weight: 400;
  line-height: 1.45;
  vertical-align: middle;
}

/* A tag with an x that takes it away, such as a user's admin role: the x is
   inside the tag's border, after a line and with no gap, like deleting a
   tag. A + in the same place gives the tag instead. */
.badge.tag {
  display: inline-flex;
  align-items: stretch;
  padding-right: 0;
}

.badge.tag > button {
  display: inline-flex;
  align-items: center;
  min-height: 0;
  margin-left: 6px;
  padding: 0 5px;
  border: 0;
  /* The tag's own border colour, so the line matches it on a tag that is
     not lit too. */
  border-left: 2px solid;
  border-left-color: inherit;
  background: transparent;
  color: inherit;
  box-shadow: none;
}

.badge.tag > button:hover:not(:disabled) {
  background: color-mix(in srgb, currentColor 20%, transparent);
}

/* A row of tags, such as the holders of a power, that wraps between tags and
   keeps each name on one line. */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tags .badge {
  white-space: nowrap;
}

.badge.removed {
  border-color: var(--danger);
  color: var(--danger);
}

.badge.on {
  border-color: var(--ok);
  color: var(--ok);
}

/* A stage timer's time left (shared/countdown.js). Digits of one width, so
   the time doesn't shift as it changes. */
.countdown {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* The candle sprite, its flame moving, before the time. */
.countdown::before {
  content: "";
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-right: 0.3em;
  vertical-align: -0.15em;
  background: url("sprites/candle.svg") center / contain no-repeat;
}

.countdown.paused {
  color: var(--muted);
}

/* The last seconds, and once the time is up. */
.countdown.ending,
.countdown.up {
  color: var(--danger);
}

.message {
  /* Room below too, so a button after the message doesn't touch it. */
  margin: 8px 0 16px;
  font-size: 0.9rem;
}

/* An empty message (no error yet) takes no room, and in a row of form
   controls doesn't wrap onto a line of its own. */
.message:empty {
  display: none;
}

.message.error {
  color: var(--danger);
}

.message.ok {
  color: var(--ok);
}

/* An error's details for a developer (errorNodes in dom.js): in the page's
   text colour under the red message, and the report wrapped, so the page
   never scrolls sideways. */
.error-details {
  margin-top: 6px;
  color: var(--text);
}

.error-details summary {
  cursor: pointer;
}

.error-details pre {
  margin: 6px 0;
  padding: 8px;
  border-radius: var(--radius);
  background: var(--bg);
  font: 0.8rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 240px;
  overflow-y: auto;
}

/* A success: the potion sprite before the words. */
.message.ok::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 6px;
  vertical-align: -3px;
  background: url("sprites/potion.svg") center / contain no-repeat;
}

/* The note that something worked (toast() in dom.js): a card at the bottom
   of the screen, over the page, that clicks pass through. It pops up in
   steps, as the buttons press down. The popover's own styles put it in the
   middle of the screen, so these replace them. */
.toast {
  position: fixed;
  inset: auto 16px calc(16px + env(safe-area-inset-bottom)) 16px;
  z-index: 30;
  width: fit-content;
  max-width: 480px;
  margin: 0 auto;
  padding: 10px 14px;
  border: 2px solid var(--ok);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ok);
  font-family: var(--font-pixel);
  font-size: 1rem;
  box-shadow: 3px 3px 0 var(--shadow);
  pointer-events: none;
  animation: toast-in 0.2s steps(2);
}

/* A warning (toast(text, { kind: "warning" })): something was not done. */
.toast.warning {
  border-color: var(--warm);
  color: var(--warm);
}

@keyframes toast-in {
  from {
    transform: translateY(8px);
  }
}

/* A button whose request is on its way (setBusy() in dom.js): dots after
   its label, appearing one by one. Not faded, as a disabled button is: it
   is working, not unavailable. */
button[aria-busy="true"]:disabled {
  opacity: 1;
  cursor: progress;
}

button[aria-busy="true"]::after {
  content: "...";
  display: inline-block;
  margin-left: 2px;
  clip-path: inset(0 100% 0 0);
  animation: busy-dots 1.2s steps(4, jump-none) infinite;
}

@keyframes busy-dots {
  to {
    clip-path: inset(0 -10% 0 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    animation: none;
  }

  button[aria-busy="true"]::after {
    clip-path: none;
    animation: none;
  }
}

.sign-in {
  display: flex;
  justify-content: center;
  margin: 60px 0;
}

/* Clerk's card is 400px wide; the test sign-in form gets the same width. */
.sign-in > div {
  min-width: min(400px, 100%);
}

.center {
  max-width: 420px;
  margin: 60px auto;
}

code,
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
}

@media (max-width: 640px) {
  .topbar {
    flex-wrap: wrap;
    gap: 12px;
  }
  main {
    padding: 16px;
  }
}

/* Gameplay UI. Players use phones, so the page is narrow and the vote
   buttons are large. */
main.narrow {
  max-width: 640px;
}

/* Admin: a deleted game's page starts with this (deletedNotice in
   admin/js/views/game.js). */
.card.deleted-game {
  border-color: var(--danger);
}

.card.deleted-game h2 {
  color: var(--danger);
}

.banner {
  padding: 10px 20px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  text-align: center;
}

/* A warning about this computer, such as a clock that is off (clock.js). */
.banner.warning {
  background: var(--warm);
}

.options {
  display: grid;
  gap: 8px;
  margin: 8px 0 12px;
}

/* An option's photo, when it stands for a player, sits left of its name. */
button.option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  font-size: 1.05rem;
  text-align: left;
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

button.option.chosen {
  border-color: var(--ok);
  color: var(--ok);
  font-weight: 600;
}

/* The chosen option stays fully visible although its button is disabled. */
button.option.chosen:disabled {
  opacity: 1;
}

/* One recorded use of a power: its inputs and a Take back button. */
.row.use {
  align-items: center;
  margin-bottom: 12px;
}

/* A power use's notes: keep the line breaks the writer typed. */
.notes {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.power + .power {
  border-top: 1px solid var(--border);
  margin-top: 12px;
  padding-top: 12px;
}

h3 {
  font-size: 1rem;
  margin: 0 0 4px;
}



/* Uploads (shared/upload.js): one row per file, with its progress. */
.uploads:empty {
  display: none;
}

.uploads {
  display: grid;
  gap: 10px;
}

.upload-row {
  display: grid;
  gap: 4px;
  padding: 8px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
}

.upload-name {
  overflow-wrap: anywhere;
}

.upload-row progress {
  width: 100%;
  height: 8px;
  accent-color: var(--accent);
}

.upload-status {
  justify-content: space-between;
  align-items: center;
}

.upload-status .message {
  margin: 0;
}

/* A Resume button and the progress of what it sends. */
.resume {
  display: grid;
  gap: 8px;
}

/* An asset's picture or video: as wide as there is room, never taller than
   most of the screen. */
.preview {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  border-radius: var(--radius);
}

/* Name and value pairs, such as an asset's details. */
dl.details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin: 0;
}

dl.details dt {
  color: var(--muted);
}

dl.details dd {
  margin: 0;
  overflow-wrap: anywhere;
}

dialog.card {
  max-width: min(560px, calc(100vw - 32px));
  color: var(--text);
}

dialog::backdrop {
  background: rgb(0 0 0 / 0.45);
}

/* Player view: assets (ui/gameplay/js/assets.js). One block per file, so
   a player sees each picture or video at a glance on a phone. */
.asset-list {
  display: grid;
  gap: 12px;
  margin: 8px 0 12px;
}

.asset-item {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
}

.asset-item .preview {
  max-height: 60vh;
}

.asset-item audio {
  width: 100%;
}

.asset-item p {
  margin: 0;
}

.asset-name {
  overflow-wrap: anywhere;
}

/* What the uploader says a file is, under its name, line breaks kept. */
.asset-description {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* A file name being changed: the box for the name, then its extension,
   fixed, as plain text. */
.filename-input {
  display: flex;
  align-items: center;
  gap: 4px;
}

.filename-input input {
  flex: 1;
}

.filename-input .extension {
  color: var(--muted);
}

/* Changing a file's name and description, under its actions. */
.asset-editor {
  margin-top: 8px;
}

/* A file's actions (Resume or Hide, Edit, Delete) share the width
   equally: a grid of equal columns, since flex would add each button's
   padding on top of its share. */
.asset-actions {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  margin-top: 4px;
}

.asset-actions button {
  width: 100%;
}

h2.subhead {
  margin-top: 16px;
}

/* Phones. Tables become a stack of cards, one per row, each value beside
   its column's name (from the data-label dom.js's table() sets); fields take
   the full width; controls are big enough to tap. */
@media (max-width: 640px) {
  section.card {
    padding: 12px;
  }

  table.responsive,
  table.responsive tbody,
  table.responsive tr,
  table.responsive td {
    display: block;
    width: 100%;
  }

  table.responsive thead {
    display: none;
  }

  table.responsive tr {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 12px;
    margin-bottom: 10px;
  }

  table.responsive td {
    height: auto;
    border: none;
    padding: 6px 0;
  }

  /* A labelled cell: the column name on the left, the value on the right,
     the name level with the value's first line. */
  table.responsive td[data-label] {
    display: grid;
    grid-template-columns: 5.75rem 1fr;
    gap: 10px;
    align-items: baseline;
  }

  table.responsive td[data-label]::before {
    content: attr(data-label);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
  }

  /* The order in a card: the labelled cells, then a description, then the
     actions. A description takes the card's whole width, under its name,
     rather than the narrow value column. */
  table.responsive tr {
    display: flex;
    flex-direction: column;
  }

  table.responsive td[data-label="Description"] {
    order: 1;
    grid-template-columns: 1fr;
    gap: 4px;
  }

  table.responsive td:not([data-label]) {
    order: 2;
  }

  /* A row's detail joins the card of its row: no gap or line between. */
  table.responsive tr.detail-row {
    margin-top: -12px;
    border-top: none;
    padding: 0;
  }

  table.responsive tr.detail-row > td {
    padding: 12px;
  }

  /* An announcement or a post: its own text, under its name, across the
     card's width. "Announcement" is also too long for the name column. */
  table.responsive td[data-label="Announcement"],
  table.responsive td[data-label="Post"] {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  /* The access code's buttons fill each line they wrap onto. */
  .code-buttons > button {
    flex: 1 1 auto;
  }

  /* A cell holding nothing (no power held, say) is left out of the card. */
  table.responsive td:has(> .cell:empty) {
    display: none;
  }

  /* Dropdowns in a card fill their column; a dropdown with its button
     (Give to) keeps them side by side. */
  td select {
    width: 100%;
  }

  td .row,
  td form.row {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
  }

  td .row button {
    width: auto;
  }

  /* Cells without a column name hold actions, such as Impersonate or
     Delete: full-width buttons at the bottom of the card. */
  table.responsive td:not([data-label]) button {
    width: 100%;
  }

  /* Several actions in one cell (Resume and Delete) share its width
     equally: a grid of equal columns, since flex would add each button's
     padding on top of its share. */
  table.responsive td:not([data-label]) .row {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
  }

  /* Fields in a row stack, each across the whole width, whether the row is
     inside a form or is the form. */
  form .row,
  form.row {
    flex-direction: column;
    align-items: stretch;
  }

  /* Buttons of forms and cards span the width, so they line up and are easy
     to hit. */
  form:where(:not(.cl-rootBox *)) button,
  section.card > button,
  section.card > .row > button {
    width: 100%;
  }

  form .row > label,
  label:where(:not(.cl-rootBox *)) input,
  label:where(:not(.cl-rootBox *)) select {
    width: 100%;
  }

  label.inline {
    width: auto;
  }

  /* An asset's details: each name above its value. */
  dl.details {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  dl.details dd {
    margin-bottom: 8px;
  }

  label.inline input {
    width: auto;
  }

  /* The header: the title and the menu button; the menu opens below. */
  .topbar {
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0;
  }

  .menu-toggle:not([hidden]) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 40px;
    padding: 0;
    background: transparent;
    color: var(--text);
    border-color: var(--border);
  }

  .menu {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding-top: 12px;
  }

  .menu.open {
    display: flex;
  }

  .menu nav {
    flex-direction: column;
    gap: 0;
  }

  .menu nav a,
  .menu .account > span {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
  }

  .menu .account {
    margin-left: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .menu .account button {
    width: 100%;
  }

  /* Big enough to tap. */
  button:where(:not(.cl-rootBox *)),
  input:where(:not(.cl-rootBox *)),
  select:where(:not(.cl-rootBox *)) {
    min-height: 40px;
  }

  td button {
    padding: 8px 12px;
  }

  /* Rows that hold buttons let them wrap rather than overflow. */
  .row {
    flex-wrap: wrap;
  }
}

/* Message board and announcements (the player view's posts). */
.posts {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.post {
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

/* The player's own posts stand out a little. */
.post.own {
  border-left: 4px solid var(--accent);
}

.post h3 {
  margin: 0 0 2px;
}

.post-meta,
.post .small {
  margin: 0 0 4px;
}

/* Keep the line breaks the writer typed, and wrap long words and links. */
.post-body {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Under a search box, whose own margin spaces the posts from it. */
.player-search + .posts {
  margin-top: 0;
}

/* The board's search, under the form for a new post. */
.composer + .player-search {
  margin-top: 16px;
}

.composer .row {
  justify-content: space-between;
}

.composer p {
  margin: 0;
}

/* A game's 6-digit access code, typed in (the player page's game choice;
   the dashboard has a larger one of its own). */
.code-input {
  width: calc(6 * (1ch + 0.3em) + 1.6em);
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3em;
  text-align: center;
}

/* Choosing players (shared/picker.js, in the admin's and the players' forms
   to start a conversation): the chosen ones as tags at the top, a search
   box, then a list of players that scrolls on its own, each row a photo, a
   name and a checkbox. */
.picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.picker-chosen {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.picker-chosen p {
  margin: 0;
}

/* A chosen player's name stays on one line, also on a phone. */
.picker-chosen .badge {
  white-space: nowrap;
}

.picker-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 320px;
  overflow-y: auto;
  /* Room for the outline of a focused row. */
  padding: 2px;
}

label.picker-row {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border: 2px solid transparent;
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
}

label.picker-row:hover {
  border-color: var(--border);
}

label.picker-row:has(input:checked) {
  border-color: var(--accent);
  background: var(--bg);
}

label.picker-row input {
  width: auto;
}

/* For long lists such as every user (picker.js): a grid of cards that
   fills the width, one column on a phone, each with the username below
   the name. */
.picker.compact .picker-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  max-height: 420px;
}

.picker.compact label.picker-row {
  gap: 10px;
  padding: 8px 10px;
  border-color: var(--border);
}

.picker.compact label.picker-row:has(input:checked) {
  border-color: var(--accent);
}

.picker.compact label.picker-row input {
  /* The whole card is the target, so the box needn't be tall on a phone. */
  min-height: 0;
}

.picker-name,
.player-name {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.picker-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Side by side, also on a phone, where buttons are otherwise full width. */
.picker-actions > button {
  width: auto;
  flex: 1 1 auto;
}

@media (min-width: 641px) {
  .picker-actions > button {
    flex: 0 0 auto;
  }
}

.picker.compact > p {
  margin: 0;
}

/* Conversations (player view and admin UI; shared/conversations.js). */

.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* One conversation in the list: a full-width row rather than a button. */
button.conversation-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  font-family: var(--font-body);
  font-weight: normal;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
}

button.conversation-row:hover {
  border-color: var(--accent);
}

/* Who a conversation is with, in its row: one photo, or up to three
   overlapping, each in a ring of the row's colour. */
.member-photos {
  display: inline-flex;
  flex: none;
}

.member-photos.stacked .avatar {
  position: relative;
  box-shadow: 0 0 0 2px var(--bg);
}

/* Each photo over the next, so the first person's initials stay whole. */
.member-photos.stacked .avatar:nth-child(1) {
  z-index: 3;
}

.member-photos.stacked .avatar:nth-child(2) {
  z-index: 2;
}

.member-photos.stacked .avatar + .avatar {
  margin-left: -6px;
}

/* The name takes the room left, and long lists of names are cut short. */
.conversation-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-row.unread .conversation-title {
  font-weight: 700;
}

/* The player view's screens (list, new, open conversation): a column with
   room between its parts, such as the back button and the title. */
.conversations .stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.conversations .stack > :where(p, h3, h4) {
  margin: 0;
}

/* An open conversation's title row: back, who it is with, the title, and
   the "i" that opens its people and settings. The info screen has the same
   row, with back and the title. */
.thread-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.thread-head .thread-title {
  flex: 1;
  min-width: 0;
}

/* On the card, not in a list row: the ring takes the card's colour. */
.thread-head .member-photos.stacked .avatar {
  box-shadow: 0 0 0 2px var(--surface);
}

/* A conversation's people, on its info screen: photo, name, status. */
.member-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.member-list li {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* The Players tab: each player's photo, name and status, then their powers. */
.player-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* The search box above a list of the player page (the Players tab's players,
   the Vote card's options, the announcements, the board's posts), on its own
   line. */
.player-search {
  display: block;
  width: 100%;
  margin-bottom: 16px;
}

/* A line between the players that show: the search hides some. */
.player-list li:not([hidden]) ~ li:not([hidden]) {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.player-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

/* Under the name, not under the photo: the photo (36px) and the gap (10px). */
.player-list .power,
.player-list .character-info,
.player-list .player-note {
  margin-left: 46px;
}

.player-list .character-info {
  margin-bottom: 8px;
}

/* "No character info…" and "No powers shown.": as close as the Character
   section, not a paragraph's space apart. */
.player-list .player-note {
  margin-top: 0;
  margin-bottom: 8px;
}

/* A power's description and its uses: as close as the name is to them. */
.player-list .power p {
  margin: 0 0 4px;
}

/* The Your character card's private info, under the public info. */
details + .private-info {
  margin-top: 12px;
}

.private-info h3 {
  margin: 0 0 8px;
}

.private-info-controls {
  align-items: center;
}

.thread-title {
  margin: 0;
}

/* The line under a title row (who started it, on the info screen), close
   under it. */
.conversations .thread-head + p {
  margin-top: -8px;
}

/* Chats (shared/chat.js): the conversations and the admins' assistant. Like
   a phone's messages app, but with square text boxes: the writer's own
   messages on the right in the accent colour, others' on the left in
   --bubble, each under a line with who wrote it. In a conversation, messages
   from one writer close together form a group under one name and time.

   An open conversation's messages scroll on their own, so the box to write
   in stays in view under them. */
.chat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 4px 2px;
}

.chat-message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 80%;
}

/* A new group starts a little lower than the one before. (The assistant's
   log has its own gap.) */
.chat > .chat-message:not(.continued, :first-child) {
  margin-top: 10px;
}

.chat-message.own {
  align-self: flex-end;
  align-items: flex-end;
}

/* The line above a bubble and the links under it line up with the
   bubble's square edge. */
.chat-meta {
  margin: 0 0 2px;
}

/* Someone else's message with their photo (CHAT_AVATAR_PX, 28px) beside the
   bubble. The name above and the links under it line up with the bubble. */
.chat-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.chat-avatar-space {
  flex: none;
  width: 28px;
}

.chat-message.with-avatar > .chat-meta,
.chat-message.with-avatar > .chat-links {
  margin-left: calc(28px + 8px);
}

/* Keep the line breaks the writer typed, and wrap long words and links. */
.bubble {
  margin: 0;
  padding: 7px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bubble);
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.own .bubble {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

.chat-message.removed .bubble {
  font-style: italic;
  color: var(--muted);
  background: transparent;
  border: 2px dashed var(--border);
}

/* A long, formatted reply (the assistant's): across the whole width, not in
   a bubble. */
.chat-message.reply {
  align-items: stretch;
  max-width: 100%;
  overflow-wrap: anywhere;
}

/* Small text buttons under a message (Undo, Retry; Remove, Put back), so a
   long chat is not a wall of buttons. */
.chat-links {
  display: flex;
  gap: 12px;
  margin: 2px 0 0;
}

.chat-links button {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  color: var(--accent);
  font-size: 0.85rem;
  cursor: pointer;
}

.chat-links button.danger {
  color: var(--danger);
}

.chat-links button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Admin: the assistant's panel (ui/admin/js/assistant/panel.js). A drawer on
   the right on wider screens, a full-screen sheet on phones. It sits outside
   <main>, so it stays open while pages change. */
/* The crystal ball sprite, then the word. */
.assistant-toggle:not([hidden]) {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.assistant {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: min(420px, 100vw);
  padding: 16px;
  gap: 10px;
  border-left: 2px solid var(--border);
  background: var(--surface);
  box-shadow: -4px 0 0 var(--shadow);
}

.assistant[hidden] {
  display: none;
}

/* Wide enough for both: the page leaves room for the drawer. */
@media (min-width: 1200px) {
  body.assistant-open main {
    margin-right: 440px;
  }
}

/* The header: back to the chats, the title in the room left, then icons. */
.assistant-head {
  display: flex;
  align-items: center;
  gap: 4px;
}

.assistant-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assistant-head-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 2px;
}

/* Clear all, on the list of chats: a text button before the icons, as in
   the notification panel's head. */
.assistant .assistant-clear {
  margin-right: 6px;
}

.assistant .assistant-clear[hidden] {
  display: none;
}

/* Icon-only buttons (back, new chat, close): no border, a tint on hover. */
.assistant .assistant-icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  box-shadow: none;
}

.assistant .assistant-icon[hidden] {
  display: none;
}

.assistant .assistant-icon:hover:not(:disabled) {
  background: var(--bg);
}

.assistant button.small {
  padding: 4px 8px;
  font-size: 0.85rem;
}

/* A button that reads as a link: Undo, Retry, a chat's title. */
.assistant button.link {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  font-family: var(--font-body);
  color: var(--accent);
  text-align: left;
  cursor: pointer;
}

.assistant-chat,
.assistant-list {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 10px;
}

.assistant-chat[hidden],
.assistant-list[hidden] {
  display: none;
}

.assistant-list {
  overflow-y: auto;
}

/* Scrolling past the end of the chat or of the list of chats stops there,
   rather than going on to scroll the page behind the panel. */
.assistant-list,
.assistant-scroll {
  overscroll-behavior: contain;
}

/* The list of chats: one card per chat, the whole card a button that opens
   it, sitting on the hard shadow and pressing into it like other buttons. */
.assistant-chats {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  /* Room for the last card's shadow. */
  padding: 0 4px 4px 0;
  list-style: none;
}

.assistant .assistant-chat-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 10px 12px;
  border-color: var(--border);
  background: var(--bg);
  color: var(--text);
  text-align: left;
}

.assistant .assistant-chat-card:hover {
  border-color: var(--accent);
}

/* The bin in each chat's top right corner, over its card, as a
   notification's × is (.notification-dismiss). */
.assistant-chats li {
  position: relative;
}

.assistant .assistant-chats .assistant-chat-card {
  padding-right: 44px;
}

.assistant .assistant-chat-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  line-height: 1;
}

.assistant .assistant-chat-delete:hover:not(:disabled) {
  color: var(--danger);
}

/* The chat's title in the pixel font, cut after two lines. */
.assistant-chat-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-weight: 600;
}

.assistant-chat-card .muted {
  font-family: var(--font-body);
}

/* The messages, then the changes waiting for approval, scrolling as one. */
.assistant-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Each keeps its own height; the scroll area scrolls rather than squeezing
   them. */
.assistant-scroll > * {
  flex: none;
}

.assistant-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.assistant-text p,
.assistant-text ul,
.assistant-text ol {
  margin: 0 0 8px;
}

.assistant-text > :last-child {
  margin-bottom: 0;
}

.assistant-text ul,
.assistant-text ol {
  padding-left: 20px;
}

/* The assistant's Markdown (js/assistant/markdown.js). */
.assistant-text h3,
.assistant-text h4,
.assistant-text h5 {
  margin: 12px 0 6px;
  line-height: 1.3;
}

.assistant-text h3 {
  font-size: 1.05rem;
}

.assistant-text h4 {
  font-size: 1rem;
}

.assistant-text h5 {
  font-size: 0.95rem;
}

.assistant-text > :first-child {
  margin-top: 0;
}

.assistant-text li > ul,
.assistant-text li > ol {
  margin: 2px 0;
}

.assistant-text blockquote {
  margin: 0 0 8px;
  padding-left: 10px;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

.assistant-text hr {
  margin: 10px 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.assistant-text code {
  padding: 1px 4px;
  border-radius: var(--radius);
  background: var(--bg);
  font: 0.85em/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Code blocks and tables scroll inside their own box, so the panel never
   scrolls sideways. */
.assistant-text pre.md-code {
  margin: 0 0 8px;
  padding: 8px;
  border-radius: var(--radius);
  background: var(--bg);
  overflow-x: auto;
  font: 0.8rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.assistant-text pre.md-code code {
  padding: 0;
  background: none;
  font: inherit;
}

.assistant-text .md-table {
  margin: 0 0 8px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Undoes the page's table styles: full width, 48px rows, uppercase muted
   headings, and bold that doesn't wrap. */
.assistant-text table {
  width: auto;
  min-width: 100%;
  font-size: 0.85rem;
}

.assistant-text th,
.assistant-text td {
  height: auto;
  min-width: 4rem;
  padding: 5px 8px;
  vertical-align: top;
  overflow-wrap: normal;
}

.assistant-text tbody tr:last-child td {
  border-bottom: 0;
}

.assistant-text th {
  font-size: inherit;
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  background: var(--bg);
}

.assistant-text td strong {
  white-space: normal;
}

.assistant-tool {
  font-size: 0.85rem;
  border-left: 3px solid var(--border);
  padding-left: 8px;
}

.assistant-tool summary {
  cursor: pointer;
}

.assistant-tool.refused {
  border-left-color: var(--danger);
}

/* Tool arguments and results, and the JSON an admin edits: wrapped, so the
   panel never scrolls sideways. */
.assistant-pre {
  margin: 6px 0 0;
  padding: 8px;
  border-radius: var(--radius);
  background: var(--bg);
  font: 0.8rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 240px;
  overflow-y: auto;
}

textarea.assistant-pre {
  width: 100%;
  border: 1px solid var(--border);
  color: var(--text);
}

/* The intro, then one card per change, apart from each other. */
.assistant-pending {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.assistant-pending:empty {
  display: none;
}

.assistant-pending-intro {
  margin: 0;
  font-weight: 600;
}

.assistant-approval {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
}

.assistant-approval p {
  margin: 0;
}

/* set_user_photos' approval: each image, cropped as the photo will be, next
   to the username it goes to. */
.assistant-photo-pairs {
  display: grid;
  gap: 6px;
}

.assistant-photo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border);
}

.assistant-banner {
  font-size: 0.85rem;
  padding: 6px 8px;
  border-radius: var(--radius);
  background: var(--bg);
}

/* The files, the box to write in, then the paperclip and Send. 10px apart:
   more than the 4px the focus ring reaches outside the box, so the ring
   never touches the buttons. */
.assistant-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.assistant-form textarea {
  width: 100%;
  resize: vertical;
}

/* The paperclip, then Send. */
.assistant .assistant-send-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

/* Files for the next message, each with its progress and a remove button. */
.assistant-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.assistant-attachments[hidden] {
  display: none;
}

.assistant-file {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 2px 2px 2px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 0.8rem;
}

.assistant-file.failed {
  border-color: var(--danger);
  color: var(--danger);
}

.assistant-file-name {
  min-width: 0;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assistant .assistant-file-remove {
  width: auto;
  min-height: 0;
  padding: 0 6px;
  border: 0;
  background: none;
  box-shadow: none;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
}

/* A file dragged over the panel. */
.assistant.dropping {
  outline: 2px dashed var(--accent);
  outline-offset: -6px;
}

/* The files an admin's message came with, under its bubble. */
.assistant-files {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 4px 0 0;
  font-size: 0.85rem;
}

.assistant-note {
  margin: 0;
}

.assistant-suggestions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

@media (max-width: 640px) {
  /* Beside the menu button: the bar's title, then these two. */
  .assistant-toggle:not([hidden]) {
    margin-left: auto;
    margin-right: 8px;
  }

  /* Only the crystal ball, the size of the menu button beside it: the bar
     has no room for the word. 32px, twice the sprite's 16, keeps its pixels
     sharp. */
  .assistant-toggle:not([hidden]) {
    justify-content: center;
    width: 44px;
    height: 40px;
    padding: 0;
  }

  .assistant-toggle .sprite {
    width: 32px;
    height: 32px;
  }

  .assistant-toggle-label {
    display: none;
  }

  .assistant {
    width: 100vw;
    border-left: 0;
    box-shadow: none;
  }

  /* The panel covers the page: the page stays still under it, so a swipe
     on the panel's header or on the box to write in doesn't scroll it. */
  html:has(> body.assistant-open),
  body.assistant-open {
    overflow: hidden;
  }

  /* Big enough to tap. */
  .assistant .assistant-icon {
    width: 40px;
    height: 40px;
  }

  /* Send fills the row beside the paperclip. */
  .assistant .assistant-send-row button[type="submit"] {
    flex: 1;
  }
}

/* The notification panel of the admin UI and the player page
   (ui/shared/notifications.js), in one block, phone rules included. A drawer
   on the right like the admin assistant's, which it replaces while open; a
   full-screen sheet on phones. */
.notifications-toggle:not([hidden]) {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* The unread count: filled with the accent, to stand out on the button. */
.notifications-toggle .count {
  min-width: 1.6em;
  padding: 0 4px;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  text-align: center;
}

.notifications-toggle .count[hidden] {
  display: none;
}

.notifications {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: min(420px, 100vw);
  padding: 16px;
  gap: 10px;
  border-left: 2px solid var(--border);
  background: var(--surface);
  box-shadow: -4px 0 0 var(--shadow);
}

.notifications[hidden] {
  display: none;
}

@media (min-width: 1200px) {
  body.notifications-open main {
    margin-right: 440px;
  }
}

.notifications-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.notifications-head h2 {
  margin: 0;
}

/* "Clear all" and "Close", side by side. */
.notifications-actions {
  display: flex;
  gap: 8px;
}

.notifications-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.notifications-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  /* Room for the last card's shadow. */
  padding: 0 4px 4px 0;
  list-style: none;
}

/* Each notification is a card that opens its page; unread ones carry the
   accent on their left edge. */
.notification {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}

.notification:hover {
  border-color: var(--accent);
}

.notification.unread {
  border-left: 6px solid var(--accent);
}

.notification-text {
  overflow-wrap: anywhere;
}

/* The × in each notification's top right corner, over its card. */
.notification-item {
  position: relative;
}

.notification-item .notification {
  padding-right: 44px;
}

.notification-dismiss {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 1;
  width: 30px;
  height: 30px;
  padding: 0;
  line-height: 1;
}

@media (max-width: 640px) {
  /* Beside the assistant's button, before the menu button: the first of
     them takes the free room in the bar. */
  .notifications-toggle:not([hidden]) {
    justify-content: center;
    width: 44px;
    height: 40px;
    margin-left: auto;
    margin-right: 8px;
    padding: 0;
  }

  .notifications-toggle:not([hidden]) + .assistant-toggle:not([hidden]) {
    margin-left: 0;
  }

  .notifications-toggle .sprite {
    width: 32px;
    height: 32px;
  }

  .notifications-toggle-label {
    display: none;
  }

  /* The count sits on the owl's corner. */
  .notifications-toggle {
    position: relative;
  }

  .notifications-toggle .count {
    position: absolute;
    top: -8px;
    right: -8px;
  }

  .notifications {
    width: 100vw;
    border-left: 0;
    box-shadow: none;
  }

  html:has(> body.notifications-open),
  body.notifications-open {
    overflow: hidden;
  }
}
