:root {
  color-scheme: dark;
  --background: #111318;
  --surface: #1a1d24;
  --raised: #252932;
  --line: #343946;
  --text: #e6e8ec;
  --quiet: #9aa1ad;
  --accent: #e0b050;
  --own: #5aa7ff; /* what marks a player's own tile */
  --warning: #f0a070;
  --danger: #c8443c;
  --good: #6fd49a;
  --bad: #ff8a80;
  --fair: #f0cf50; /* the dot of a connection that is there but not doing well */
  --poor: #f0564a; /* and of one that is not there */
  --panel-width: clamp(300px, 24vw, 420px); /* the side panel */
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

* { box-sizing: border-box; }

/* Layout rules below set `display`, which would otherwise win over the hidden attribute. */
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
body { background: var(--background); color: var(--text); }

h1 { font-size: 1.7rem; margin: 0 0 0.6em; }
h2 { font-size: 1rem; margin: 0 0 0.4em; }
p { margin: 0 0 0.8em; }
ul { margin: 0 0 0.8em; padding-left: 1.2em; }
li { margin-bottom: 0.4em; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.4em 0.7em;
}
button { cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--quiet); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #1a1408; font-weight: 600; padding: 0.6em 1.2em; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
button.danger:hover:not(:disabled) { border-color: #fff; }
button.wide { width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; color: var(--quiet); font-size: 0.85rem; margin: 0.9em 0 0.25em; }
textarea { width: 100%; resize: vertical; }
input[type="checkbox"] { padding: 0; margin: 0; accent-color: var(--accent); }

/* Buttons that show a small picture instead of words (see icons.js). */
.icon { display: block; width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-button { padding: 0.4em; line-height: 1; }

.quiet { color: var(--quiet); font-size: 0.85rem; }
.notice { color: var(--warning); }

/* Front page: two buttons and nothing else. */
.landing { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; }
.landing .notice { margin: 0; text-align: center; }
.landing-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
.landing-buttons button { font-size: 1.15rem; min-width: 12em; padding: 0.9em 1.4em; }

/* Join */
.page { max-width: 880px; margin: 0 auto; padding: 48px 24px; }
.join-columns { display: grid; grid-template-columns: 3fr 2fr; gap: 24px; align-items: start; }
.preview { width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 8px; object-fit: contain; }
.join-form > label:first-child { margin-top: 0; }
.join-form select, .join-form input { width: 100%; }
.join-form .primary { margin: 1.2em 0; width: 100%; }
.link-row { display: flex; gap: 6px; }
.link-row input { flex: 1; min-width: 0; }

/* Table */
.table { display: grid; grid-template-columns: minmax(0, 1fr) var(--panel-width); height: 100vh; }
.tiles {
  container: tiles / inline-size; /* (what is in a tile's bar is laid out by the room the tiles have) */
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  min-height: 0;
}
/* The four places: everyone at the table sees the same player in each (table.js says which). */
.tiles > [data-place="0"] { grid-area: 1 / 1; }
.tiles > [data-place="1"] { grid-area: 1 / 2; }
.tiles > [data-place="2"] { grid-area: 2 / 1; }
.tiles > [data-place="3"] { grid-area: 2 / 2; }
/* A tile is moved to another place by its bar. While it is, the place it would go to is marked. */
.tile.moving { opacity: 0.55; }
/* (Dashed, and not blue, so that it is not taken for the frame a player's own tile has.) */
.place-mark { z-index: 4; border: 2px dashed var(--accent); border-radius: 6px; background: rgb(224 176 80 / 14%); pointer-events: none; }
/* The invitation sits in the last place that nobody is in. */
.invite { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 1em; border: 1px dashed var(--line); border-radius: 6px; }
.invite button { position: relative; font-size: 1.05rem; padding: 0.7em 1.4em; }
/* Its words, with a link of chain before them. */
.invite-words { display: flex; align-items: center; gap: 0.5em; }
/* "Copied": a tick where the words were. The words are still there, unseen, holding the button's size. */
.invite button.copied .invite-words { visibility: hidden; }
.invite-tick { position: absolute; inset: 0; margin: auto; width: 1.4em; height: 1.4em; }
/* It arrives with a small bounce, quickly: from smaller and unseen to a little over its size, and back to it. */
.invite-tick { animation: tick-in 0.3s cubic-bezier(0.3, 1.7, 0.5, 1) both; }
@keyframes tick-in {
  from { opacity: 0; transform: scale(0.3); }
  50% { opacity: 1; }
  to { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .invite-tick { animation: none; }
}
.invite input { width: min(100%, 28em); }

.tile { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); border-radius: 6px; overflow: hidden; }
/* A player's own tile is told from the others at a glance: a blue frame (drawn in the gap around
   the tile, so nothing in it moves), a faint glow of the same blue just inside it, and their name
   in it. Its background is the same as any tile's, so the buttons on it stand out as they do elsewhere. */
.tile.own { outline: 2px solid var(--own); }
.tile.own::after { content: ""; position: absolute; inset: 0; z-index: 3; border-radius: inherit; box-shadow: inset 0 0 12px color-mix(in srgb, var(--own) 45%, transparent); pointer-events: none; }
.tile.own .tile-name { color: var(--own); }
/* It is theirs to change: a click on it puts a box in its place, to type another in (see tile.js).
   The box is about as wide as the name in it, and looks like the name. */
.tile.own .tile-name { cursor: text; }
.tile-name-edit { flex: 0 1 auto; width: 9em; min-width: 3em; padding: 0.1em 0.35em; font-weight: 600; font-style: italic; color: var(--own); }
@supports (field-sizing: content) {
  .tile-name-edit { field-sizing: content; width: auto; max-width: 16em; }
}
.tile-bar { display: flex; align-items: center; gap: 10px; padding: 3px 4px 3px 6px; cursor: grab; user-select: none; touch-action: none; }
.tile.moving .tile-bar { cursor: grabbing; }
/* A player's name is in italics, which tells it from the name of their commander beside it. */
.tile-name { font-weight: 600; font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* At the bar's near end, the small triangle that folds away the numbers under the bar: the one
   that folds a section of the side panel. With nothing to fold it is not shown, and keeps its room. */
.tile-fold { flex: none; margin-right: -9px; padding: 0.2em 0.1em 0.2em 0.3em; background: none; border: none; line-height: 1; }
.tile-fold .fold-mark { display: list-item; list-style: inside disclosure-open; }
.tile-fold.folded .fold-mark { list-style-type: disclosure-closed; }
.tile-fold.absent { visibility: hidden; }
/* Before the name, a dot for how the connection to that player is doing (tile.js says which):
   green, yellow or red, and in words when it is pointed at. (Its unseen edge is room to point at it.) */
.tile-dot { flex: none; box-sizing: content-box; width: 9px; height: 9px; margin: 0 -4px; border: 4px solid transparent; border-radius: 50%; background: var(--quiet) padding-box; cursor: default; }
.tile-dot[data-level="good"] { background-color: var(--good); }
.tile-dot[data-level="fair"] { background-color: var(--fair); }
.tile-dot[data-level="poor"] { background-color: var(--poor); }
/* Where the bar has not the room for everything, the commander gives way first, and the name
   only once that is as small as it goes. (The numbers are that far apart so that the name does
   not lose so much as a point of its width before then.) */
.tile-name { flex-shrink: 1; }
.tile-commanders { flex-shrink: 1000000; }
/* After the name, the player's commander (two, for partners): on the others' tiles its name,
   which shows the card when pointed at and puts it in the panel when clicked. */
.tile-commanders { display: flex; align-items: center; gap: 6px; min-width: 0; }
/* A faint line stands between the name and the first of them. */
.tile-commanders { padding-left: 10px; border-left: 1px solid var(--line); }
/* Two of them are "This & That". */
.tile-and { flex: none; color: var(--quiet); }
.tile-commander { min-width: 0; padding: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: none; border: none; border-radius: 0; color: var(--text); text-decoration: underline; text-decoration-color: var(--line); }
.tile-commander:hover { text-decoration-color: var(--text); }
/* On a player's own tile it is one piece, with nothing between its parts: a box to pick the
   commander in by typing its name (see picker.js), which has at its right end a button that
   takes the commander out, and joined to its side either a small "+" for a second commander or
   the box of that second one. (The boxes can be squeezed, but not to nothing.) */
.tile.own .tile-commanders { gap: 0; min-width: calc(5em + 11px); }
.tile.own.partners .tile-commanders { min-width: calc(7em + 11px); }
.card-pick { position: relative; display: flex; flex: 0 1 auto; min-width: 3.5em; background: var(--raised); border: 1px solid var(--line); border-radius: 6px; }
/* The box is about as wide as the name in it, within reason: --fit is how many letters that is (picker.js sets it). */
.card-pick input { flex: 1 1 auto; min-width: 0; width: clamp(7.5em, calc(var(--fit, 9) * 1ch + 1.4em), 16em); padding: 0.15em 0.4em; background: none; border: none; border-radius: inherit; text-overflow: ellipsis; }
/* (Whoever is in the box sees it on the whole box, button and all.) */
.card-pick input:focus-visible { outline: none; }
.card-pick:has(input:focus-visible) { z-index: 1; outline: 2px solid var(--accent); outline-offset: 1px; }
.card-pick-remove { flex: none; display: grid; place-items: center; padding: 0 0.4em 0 0.15em; background: none; border: none; border-radius: inherit; color: var(--quiet); }
.card-pick-remove:hover { color: var(--text); }
.card-pick-remove .icon { width: 0.8em; height: 0.8em; }
/* The "+" hangs off the box's right side: square, a little smaller than the box, and open to it. */
.commander-add { flex: none; display: grid; place-items: center; width: 1.45em; height: 1.45em; padding: 0; border-left: none; border-radius: 0 5px 5px 0; color: var(--quiet); }
.commander-add:hover { color: var(--text); }
.commander-add .icon { width: 0.85em; height: 0.85em; }
/* Two boxes are as one, like the partners in them: square where they meet, with one thin line between. */
.tile.partners .card-pick:first-child { border-radius: 6px 0 0 6px; }
.tile.partners .card-pick + .card-pick { border-left: none; border-radius: 0 6px 6px 0; }
/* Its matches drop down under it, as wide as their names. */
.card-pick .search-drop { right: auto; min-width: 100%; width: max-content; max-width: 22em; }
/* Two boxes (a player with partners) are more than the bar has room for where the tiles are
   narrow (a smaller screen, or a side panel made wide): there they go on a line of their own
   under it. */
@container tiles (max-width: 1290px) {
  .tile.own.partners .tile-bar { flex-wrap: wrap; row-gap: 3px; }
  .tile.own.partners .tile-commanders { order: 1; flex: 0 0 100%; padding-left: 0; border-left: none; }
}
/* Where they are narrower still (a side panel made very wide), one box goes there too. The
   name then has what room the rest of the bar leaves, so that the life total keeps its place
   at the end of the first line. */
@container tiles (max-width: 900px) {
  .tile.own .tile-bar { flex-wrap: wrap; row-gap: 3px; }
  .tile.own .tile-commanders { order: 1; flex: 0 0 100%; padding-left: 0; border-left: none; }
  .tile.own .tile-name { flex: 1 1 0; min-width: 2em; }
}
.tile-rotate { padding: 0.25em; }
.tile-rotate[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

/* Life, commander damage and counters */
.warn { color: var(--warning); }
.number { width: 3.2em; padding: 0.1em 0.2em 0.1em 0.4em; text-align: center; font-variant-numeric: tabular-nums; }
.tile-life { display: flex; align-items: center; margin-left: auto; }
.tile-life-value { font-size: 1.3rem; font-weight: 700; line-height: 1.1; min-width: 2.2ch; padding: 0 4px; text-align: center; font-variant-numeric: tabular-nums; }
.tile-life-value.number { width: 4.4em; padding: 0.05em 0.15em 0.05em 0.3em; }
/* A life total can be a great many digits: the box grows to hold them. */
@supports (field-sizing: content) {
  .tile-life-value.number { field-sizing: content; width: auto; min-width: 4.4em; }
}
/* One row: the counters from the left, commander damage at the right end, under the life total.
   (Where there is not the room, the damage goes on a line of its own, still at the right.) */
.tile-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 12px; padding: 4px 4px 4px 10px; font-size: 0.85rem; }
/* The row is darker than the bar it is under (the page's own dark), with as much room above what is in it as below. */
.tile-stats { background: var(--background); }
.stat-row { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 12px; }
.stat-damage { margin-left: auto; justify-content: flex-end; }
.tile-reset { padding: 0.25em; }
/* The button that puts a player's own numbers back to the start is at the far end with the life total, just before it. */
.tile-reset { margin-left: auto; }
.tile-reset + .tile-life { margin-left: 0; }
.stat-chips { display: contents; }
.stat-caption { color: var(--quiet); }
.stat { display: inline-flex; align-items: center; gap: 5px; margin: 0; font-size: inherit; color: inherit; white-space: nowrap; }
.stat-label { color: var(--quiet); max-width: 16ch; overflow: hidden; text-overflow: ellipsis; }
.stat-value { font-weight: 700; min-width: 1.6ch; text-align: center; font-variant-numeric: tabular-nums; }
.stat.warn, .stat.warn .stat-label { color: var(--warning); }

/* Which counters are on the tile: a button that opens a short list of tick boxes under it. (Its
   words end in dots, as a button's do that opens something more; it has no fold triangle.) */
.pick { position: relative; }
.pick summary { list-style: none; cursor: pointer; padding: 0.1em 0.6em; border: 1px solid var(--line); border-radius: 6px; background: var(--raised); white-space: nowrap; }
.pick summary::-webkit-details-marker { display: none; }
.pick summary:hover, .pick[open] summary { border-color: var(--quiet); }
.pick-menu { position: absolute; z-index: 5; top: calc(100% + 3px); left: 0; display: flex; flex-direction: column; gap: 4px; padding: 8px 10px; background: var(--raised); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 20px rgb(0 0 0 / 50%); }
.pick-menu label { display: flex; align-items: center; gap: 6px; margin: 0; font-size: inherit; color: var(--text); white-space: nowrap; cursor: pointer; }

/* (A container, so that what is drawn over the picture can be sized by the room the picture has.) */
.tile-stage { position: relative; flex: 1; min-height: 0; background: #000; cursor: crosshair; container-type: size; }
.tile-stage.rotated { transform: rotate(180deg); }
.tile-stage video, .tile-still, .tile-overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
/* (The still is the camera's last picture, kept by tile.js and shown in the video's place under a note.) */
.tile-stage video, .tile-still { object-fit: contain; }
.tile-still { background: #000; }
/* The overlay has the camera picture's own proportions, so it lines up with the video. */
.tile-overlay { pointer-events: none; }
.tile-outline, .tile-marker { display: none; fill: none; stroke: var(--accent); vector-effect: non-scaling-stroke; }
.tile-outline { stroke-width: 3px; stroke-linejoin: round; }
.tile-marker { stroke-width: 2px; animation: pulse 0.9s ease-in-out infinite alternate; }
.tile-outline.shown, .tile-marker.shown { display: inline; }
@keyframes pulse { from { opacity: 1; } to { opacity: 0.3; } }

/* A word or two in a red box in the middle of the picture, such as "Disconnected" over the last of it to arrive. */
.tile-note { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); margin: 0; padding: 0.35em 1em; white-space: nowrap; font-weight: 600; color: #fff; background: var(--danger); border-radius: 6px; box-shadow: 0 2px 12px rgb(0 0 0 / 60%); pointer-events: none; }
.tile-stage.rotated .tile-note { transform: translate(-50%, -50%) rotate(180deg); }

/* Reminder tokens. Their layer covers the picture exactly, as large as fits and centred like the
   video itself (--picture is the picture's width over its height, set by tile.js), so a token
   placed by fractions of it is over the same spot of the picture on every screen. */
.tile-tokens { position: absolute; left: 50%; top: 50%; width: min(100cqw, 100cqh * var(--picture, 1.7778)); aspect-ratio: var(--picture, 1.7778); transform: translate(-50%, -50%); pointer-events: none; }
/* A token is a small square with letters on it, or, made larger, a picture of its card. Its
   width and height (--w and --h, set by tile.js) are both parts of the camera picture's width,
   so it has the same shape on every screen; the layer is 1/--picture as tall as it is wide,
   hence the height. On a small screen neither goes under a size that can still be made out.
   Its coloured edge tells it from a real card. */
.token { position: absolute; transform: translate(-50%, -50%); width: max(22px, calc(var(--w, 0.035) * 100%)); height: max(22px, calc(var(--h, 0.035) * var(--picture, 1.7778) * 100%)); container-type: size; display: grid; place-items: center; padding: 0; overflow: hidden; color: var(--text); background: var(--raised); border: 2px solid var(--accent); border-radius: 3px; box-shadow: 0 1px 6px rgb(0 0 0 / 60%); pointer-events: auto; cursor: pointer; }
.token img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
/* The first letters of the card's name, as large as fit: on --rows lines, the widest of them
   --widest ems wide (tile.js sets both, and tokens.js chooses the lines by these same numbers). */
.token-letters { display: none; font-size: min(calc(84cqh / (var(--rows, 1) * 0.9)), calc(88cqw / var(--widest, 1.8))); font-weight: 700; line-height: 0.9; white-space: pre; text-align: center; pointer-events: none; }
.token.letters { background: rgb(0 0 0 / 80%); }
.token.letters img { display: none; }
.token.letters .token-letters { display: block; }
.token:hover:not(:disabled) { border-color: var(--accent); background: var(--raised); filter: brightness(1.15); }
.token.letters:hover:not(:disabled) { background: #000; }
.token.own { cursor: grab; touch-action: none; }
.token.dragging { cursor: grabbing; }
/* The corner of one of your own that is pulled to make it larger or smaller. */
.token-corner { position: absolute; right: 0; bottom: 0; width: 7px; height: 7px; background: linear-gradient(135deg, transparent 50%, var(--accent) 50%); opacity: 0; cursor: nwse-resize; }
.token:hover .token-corner, .token:focus-visible .token-corner, .token.dragging .token-corner { opacity: 1; }
.tile-stage.rotated .token { transform: translate(-50%, -50%) rotate(180deg); }

/* The few things that can be done with what was right-clicked (see menu.js). */
.menu { position: fixed; z-index: 20; display: flex; flex-direction: column; padding: 4px; background: var(--raised); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 20px rgb(0 0 0 / 50%); }
.menu button { background: none; border: none; border-radius: 4px; padding: 0.3em 0.9em; text-align: left; white-space: nowrap; }
.menu button:hover:not(:disabled), .menu button:focus-visible { background: var(--line); }

/* The side panel. Its parts keep the same distance from both of its edges; the part that scrolls
   reaches the edges itself, so its scrollbar sits in the margin instead of pushing the content aside. */
.panel { --edge: 10px; --scrollbar: 8px; position: relative; display: flex; flex-direction: column; gap: 12px; padding: 12px 0; min-height: 0; background: var(--surface); border-left: 1px solid var(--line); }
.panel > * { margin: 0; padding-left: var(--edge); padding-right: var(--edge); }
/* The panel is made wider or narrower by its left edge (see panel.js): a strip along it to take
   hold of, which shows as a line when it is pointed at, pulled, or reached with the keyboard. */
.panel > .panel-resize { position: absolute; z-index: 6; top: 0; bottom: 0; left: -5px; width: 8px; padding: 0; cursor: col-resize; touch-action: none; }
.panel-resize::after { content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 2px; background: var(--accent); opacity: 0; }
.panel-resize:hover::after, .panel-resize:focus-visible::after, .panel-resize.dragging::after { opacity: 1; }
.panel-resize:focus-visible { outline: none; }
/* Along its top, one line: this player's camera, a list to pick another from, which takes the
   room there is, and at the far end the small square button that leaves the table. */
.panel-top { display: flex; align-items: center; gap: 8px; }
.panel-top label { flex: none; margin: 0; }
.panel-top select { flex: 1; min-width: 0; height: 1.9rem; padding: 0 0.4em; font-size: 0.85rem; text-overflow: ellipsis; }
.panel-top #leave { flex: none; display: grid; place-items: center; width: 1.9rem; height: 1.9rem; padding: 0; }
.panel-top #leave .icon { width: 1.1rem; height: 1.1rem; }
/* The card and the lists scroll; what is above them stays in view. Room for the
   scrollbar is always kept, inside the right-hand margin, so nothing shifts when it appears. */
.panel-scroll { flex: 1; min-height: 0; overflow-y: auto; scrollbar-gutter: stable; padding-right: calc(var(--edge) - var(--scrollbar)); display: flex; flex-direction: column; gap: 8px; }
.panel-scroll::-webkit-scrollbar, .long-list::-webkit-scrollbar { width: var(--scrollbar); }
.panel-scroll::-webkit-scrollbar-thumb, .long-list::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.panel-scroll::-webkit-scrollbar-track, .long-list::-webkit-scrollbar-track { background: transparent; }
/* Browsers without those (Firefox) have a narrow scrollbar of about the same width built in. */
@supports not selector(::-webkit-scrollbar) {
  .panel-scroll, .long-list { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
}
.panel summary { cursor: pointer; font-weight: 600; }
/* A section that folds, and one that folds inside it (see .subfold), is in a frame of its own
   while it is open. Shut, it has the frame's room all the same, unseen, so that its heading is
   in the same place open or shut. */
.fold, .subfold { border: 1px solid transparent; border-radius: 6px; }
.fold[open], .subfold[open] { border-color: var(--line); }
.fold { padding: 7px 9px; }
.fold > summary { margin-bottom: 0.5em; }
.fold:not([open]) > summary { margin-bottom: 0; }
/* A button in a section's heading, at its far end. */
.fold > summary > button { float: right; margin-left: 6px; }
/* A tick box there too, such as "Share" on the decklist. */
.fold > summary > .summary-check { float: right; display: inline-flex; align-items: center; gap: 5px; margin: 0 0 0 14px; font-weight: 400; cursor: pointer; }
.subfold { margin-top: 0.5em; padding: 4px 7px; }
.subfold > summary { font-weight: 400; color: var(--quiet); margin-bottom: 0; }
.subfold[open] > summary { color: var(--text); margin-bottom: 0.3em; }
.subfold .subfold { margin-top: 0.9em; }
.panel progress { width: 100%; }
.panel input[type="search"] { width: 100%; margin-bottom: 0.5em; }
/* The cards whose names match what is typed drop down over what is below, moving nothing. */
.search-box { position: relative; margin-bottom: 0.5em; }
.search-box input[type="search"] { margin-bottom: 0; }
.search-drop { position: absolute; z-index: 5; top: calc(100% + 3px); left: 0; right: 0; padding: 4px; background: var(--raised); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 20px rgb(0 0 0 / 50%); }
.search-drop p { margin: 0; padding: 0.3em 0.6em; }
.search-drop .names button { display: block; width: 100%; padding: 0.3em 0.6em; border-radius: 4px; text-decoration: none; }
.search-drop .names button:hover, .search-drop .names button[aria-selected="true"] { background: var(--line); }
.button-row { display: flex; gap: 6px; margin-top: 10px; }
.button-row button { flex: 1; }
.decklist-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.decklist-row p { flex: 1; margin: 0; }
.decklist-row .icon-button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
/* The card recogniser on its way, in the Card section. */
.loading p { margin: 0 0 0.3em; }
.loading button { margin-top: 0.5em; }

/* A question asked over the page, such as "Leave the table?". */
.ask { color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 18px; min-width: 260px; }
.ask::backdrop { background: rgb(0 0 0 / 60%); }
.ask p { margin: 0 0 4px; font-weight: 600; }

/* The card's picture is as wide as there is room for, in the middle of it, unless the player has
   made it smaller (--card-width, set by panel.js). */
.card-image { display: block; width: min(100%, var(--card-width, 100%)); margin: 0 auto; aspect-ratio: 488 / 680; border-radius: 4.5% / 3.3%; background: var(--raised); }
/* It is made smaller or larger by its bottom edge: a strip along it to take hold of, which takes
   up no room of its own, and shows as a line when it is pointed at, pulled, or reached with the
   keyboard (as the panel's own edge does). */
.card-resize { position: relative; z-index: 1; width: min(100%, var(--card-width, 100%)); height: 10px; margin: -5px auto; cursor: row-resize; touch-action: none; }
.card-resize::after { content: ""; position: absolute; left: 0; right: 0; top: 4px; height: 2px; background: var(--accent); opacity: 0; }
.card-resize:hover::after, .card-resize:focus-visible::after, .card-resize.dragging::after { opacity: 1; }
.card-resize:focus-visible { outline: none; }
/* (A picture that could not be fetched is not shown, and has no edge.) */
.card-image[hidden] + .card-resize { display: none; }
.card-name { font-weight: 600; margin: 0 0 0.3em; }
/* A guess: how likely the recogniser holds it to be, then its name. The two are columns down
   the whole list (the first as wide as the widest of the numbers, which end level), so the
   numbers line up with the numbers and the names with the names. */
.guesses .names { display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: 10px; }
.guesses li { display: grid; grid-template-columns: subgrid; grid-column: 1 / -1; align-items: baseline; }
.guesses li button { justify-self: start; }
.chance { color: var(--quiet); font-size: 0.85rem; font-variant-numeric: tabular-nums; text-align: right; }
.names { list-style: none; padding: 0; margin: 0; }
.names li { margin: 0; }
.names button { background: none; border: none; padding: 0.15em 0; color: var(--text); text-align: left; text-decoration: underline; text-decoration-color: var(--line); }
.names button:hover { text-decoration-color: var(--text); }
.names button[aria-current="true"] { color: var(--accent); }
/* The two lists that keep growing scroll on their own, so neither pushes the other out of reach. */
.long-list { max-height: 11.5em; overflow-y: auto; }
/* A decklist: how many, then the card. Its own or another player's, it has more room than those two. */
.deck-cards.long-list { max-height: 24em; }
.deck-cards li { display: flex; align-items: baseline; gap: 7px; }
.deck-cards .copies { flex: none; min-width: 1.4em; text-align: right; color: var(--quiet); font-variant-numeric: tabular-nums; }
/* A name that is no card we know of is only words. */
.deck-cards .unknown { padding: 0.15em 0; color: var(--quiet); }

.face + .face { margin-top: 0.7em; padding-top: 0.7em; border-top: 1px solid var(--line); }
.face p { margin: 0 0 0.3em; }
.face-name { font-weight: 600; }
.face-type { color: var(--quiet); }
.face-rules { white-space: pre-line; }
.face-stats { font-weight: 600; }
/* A mana or tap symbol standing in the text, the size of a letter. */
.symbol { display: inline-block; width: 1.05em; height: 1.05em; margin: 0 0.05em; vertical-align: -0.17em; }
.rulings { margin: 0; padding-left: 1.4em; font-size: 0.9rem; }
.rulings li { margin-bottom: 0.6em; }
.changes { list-style: none; padding: 0; margin: 0; font-size: 0.9rem; }
.changes li { margin: 0; padding: 0.1em 0; }

/* The picture shown for the card under the pointer, as wide as the card in the side panel
   (the panel less its edge, its margins, and the frame and inset of the Card section). Placed by preview.js. */
.card-preview {
  position: fixed;
  z-index: 10;
  width: min(var(--panel-width) - 41px, (100vh - 16px) * 488 / 680);
  aspect-ratio: 488 / 680;
  border-radius: 4.5% / 3.3%;
  overflow: hidden;
  background: var(--raised);
  box-shadow: 0 8px 40px rgb(0 0 0 / 70%);
  pointer-events: none;
}
.card-preview img { position: absolute; inset: 0; width: 100%; height: 100%; }

/* Deck registration: the camera with the pile's place and the two boxes drawn over it, and the list beside it. */
.deck-view { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px; min-width: 0; min-height: 0; }
.deck-view > * { width: 100%; }
.deck-stage { position: relative; background: #000; border-radius: 6px; overflow: hidden; line-height: 0; user-select: none; }
/* Shown turned round, for a camera that looks at the table from its far side: the camera's picture alone turns, and nothing drawn over it moves. */
.deck-stage.rotated video { transform: rotate(180deg); }
.deck-stage video { display: block; width: 100%; height: 100%; }
/* Where the pile lies. All of it is watched; the frame inside is the size a card should be, and
   the hatched band between the two (--slop of the width and height, at each edge) is the room the card has. */
.deck-pile { --slop: 6%; position: absolute; border: 3px dashed; border-radius: 10px; color: var(--text); cursor: grab; touch-action: none; }
.deck-pile.dragging { cursor: grabbing; }
.deck-pile[data-state="ok"] { color: var(--good); }
.deck-pile[data-state="no"] { color: var(--bad); }
.deck-pile::before { content: ""; position: absolute; inset: 0; border-radius: 7px; background: repeating-linear-gradient(135deg, currentColor 0 2px, transparent 2px 10px); opacity: 0.4; mask: linear-gradient(#000 0 0), linear-gradient(#000 0 0) center / calc(100% - 2 * var(--slop)) calc(100% - 2 * var(--slop)) no-repeat; mask-composite: exclude; pointer-events: none; }
.deck-pile-card { position: absolute; inset: var(--slop); border: 2px solid; border-radius: 4.5% / 3.3%; box-shadow: 0 0 0 1px #000, inset 0 0 0 1px #000; pointer-events: none; }
.deck-box { position: absolute; display: flex; align-items: flex-start; justify-content: center; border: 3px dashed; border-radius: 10px; line-height: 1.3; cursor: grab; touch-action: none; }
.deck-box.dragging { cursor: grabbing; }
.deck-box > span { margin-top: 4px; padding: 1px 8px; border-radius: 4px; font-size: 0.85rem; font-weight: 600; color: #111; }
.deck-box.good { border-color: var(--good); background: rgb(111 212 154 / 8%); }
.deck-box.good > span { background: var(--good); }
.deck-box.bad { border-color: var(--bad); background: rgb(255 138 128 / 8%); }
.deck-box.bad > span { background: var(--bad); }
/* A card has just been put down in this box. */
.deck-box.flash { animation: deck-flash 0.5s ease-out; }
/* Arrows from the pile to a box (drawn by deck.js). */
.deck-arrows { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.deck-arrow { filter: drop-shadow(0 0 2px #000) drop-shadow(0 0 1px #000); }
.deck-arrow.ok { color: var(--good); }
.deck-arrow.no { color: var(--bad); }
.deck-arrow polyline { fill: none; stroke: currentColor; stroke-width: 9; stroke-linecap: round; }
.deck-arrow polygon { fill: currentColor; stroke: currentColor; stroke-width: 3; stroke-linejoin: round; }
/* A few words over a box, which rise and fade. */
.deck-pop { position: absolute; z-index: 2; transform: translate(-50%, -50%); padding: 3px 10px; border-radius: 6px; background: rgb(0 0 0 / 70%); line-height: 1.3; font-size: 1.15rem; font-weight: 700; white-space: nowrap; pointer-events: none; animation: deck-pop 1.5s ease-out forwards; }
.deck-pop.ok { color: var(--good); }
.deck-pop.no { color: var(--bad); }
@keyframes deck-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  10% { opacity: 1; transform: translate(-50%, calc(-50% - 8px)) scale(1); }
  55% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, calc(-50% - 110px)); }
}
@keyframes deck-flash { from { background: rgb(255 255 255 / 60%); } }
/* The card recogniser on its way: its progress over the middle of the picture, where the player is looking. */
.deck-loading { position: absolute; z-index: 3; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(80%, 24em); padding: 10px 14px; border-radius: 8px; background: rgb(0 0 0 / 75%); line-height: 1.3; text-align: center; pointer-events: none; }
.deck-loading p { margin: 0 0 6px; }
.deck-loading progress { display: block; width: 100%; }
.deck-bar { display: flex; align-items: center; gap: 6px; }
.deck-tools { display: flex; align-items: center; gap: 6px; }
.deck-now { flex: 1; min-width: 0; min-height: 1.45em; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.3rem; font-weight: 700; }
.deck-now[data-state="ok"] { color: var(--good); }
.deck-now[data-state="no"] { color: var(--bad); }
.deck-bar select { max-width: 16em; }
.deck-bar #rotate[aria-pressed="true"], .deck-bar #pause[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
/* Paused: the picture stands still, and is greyed so that it is seen to. */
.deck-stage.paused video { filter: grayscale(1) brightness(0.65); }
.count { margin-left: 0.3em; color: var(--quiet); font-weight: 400; }
.icon-button.small { padding: 0.15em; }
.icon-button.small .icon { width: 1em; height: 1em; }
.deck-list, .deck-aside { list-style: none; margin: 0; padding: 0; }
/* Each card counted is a line, coloured by how lately: the latest in green, earlier ones fading to grey. */
.deck-list li { display: flex; align-items: center; gap: 6px; margin: 0; padding: 1px 0; }
/* (A name typed in by hand that is no card's name.) */
.deck-list .unknown { color: var(--quiet); }
/* The cards counted, one by one, beside the recognized box (to its right, above it, or to its
   left). The latest is in green, earlier ones fade to grey. */
.deck-events { position: absolute; top: -3px; left: calc(100% + 10px); width: max-content; max-width: 19em; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; line-height: 1.3; font-size: 1.15rem; font-weight: 700; white-space: nowrap; cursor: default; }
.deck-events.left { left: auto; right: calc(100% + 10px); align-items: flex-end; }
/* Above the box they stand on it: the latest is the lowest, and each new one pushes the others up. */
.deck-events.above { top: auto; bottom: calc(100% + 10px); left: -3px; flex-direction: column-reverse; }
.deck-events.above ul { flex-direction: column-reverse; }
/* Each line looks like the note that rises from the box ("+1 Forest"), and is as wide as its words. */
.deck-events ul { list-style: none; margin: 0; padding: 0; max-width: 100%; display: flex; flex-direction: column; align-items: inherit; }
.deck-events li { display: flex; align-items: center; gap: 6px; max-width: 100%; margin: 0 0 3px; padding: 3px 5px 3px 10px; overflow: hidden; border-radius: 6px; background: rgb(0 0 0 / 70%); color: color-mix(in srgb, var(--good) calc(var(--fresh, 0) * 100%), var(--quiet)); }
.deck-events .deck-count { min-width: 0; font-weight: inherit; }
.deck-events button { background: rgb(0 0 0 / 70%); }
/* The button that takes a card out again is at the end of its line nearest the box, so that
   they stand in a column whatever the length of the names, and is plainly a button. */
.deck-events li button { flex: none; background: rgb(255 255 255 / 14%); border: 1px solid var(--quiet); border-radius: 4px; color: var(--text); }
.deck-events li button:hover { background: rgb(255 255 255 / 30%); border-color: var(--text); }
.deck-events:not(.left) li { padding: 3px 10px 3px 5px; }
.deck-events:not(.left) li button { order: -1; }
/* A new line slides in from above (for a card just dealt, while its note rises from the box). */
.deck-events li.arriving { animation: deck-event-in 0.5s ease-out both; }
@keyframes deck-event-in {
  from { max-height: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0; opacity: 0; transform: translateY(-80%); }
  to { max-height: 2.2em; opacity: 1; transform: none; }
}
/* (Above the box, from below: out of the box.) */
.deck-events.above li.arriving { animation-name: deck-event-up; }
@keyframes deck-event-up {
  from { max-height: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0; opacity: 0; transform: translateY(80%); }
  to { max-height: 2.2em; opacity: 1; transform: none; }
}
.deck-count { min-width: 1.6em; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.deck-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-aside li { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 8px; }
.deck-aside .names li { margin: 0; }
.deck-snapshot { flex: none; width: 64px; border-radius: 4px; }
.deck-words { flex: 1; min-width: 0; }
.deck-words p { margin: 0 0 2px; }
/* The card read last, drawn over the camera's picture above the pile: an empty frame until there is one. */
.deck-latest { position: absolute; display: flex; align-items: flex-start; justify-content: center; border: 3px dashed var(--quiet); border-radius: 4.5% / 3.3%; background: rgb(0 0 0 / 25%); line-height: 1.3; cursor: grab; touch-action: none; }
.deck-latest.dragging { cursor: grabbing; }
.deck-latest[data-state="ok"] { border: 3px solid var(--good); }
.deck-latest[data-state="no"] { border: 3px solid var(--bad); }
.deck-latest img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: inherit; object-fit: cover; pointer-events: none; }
.deck-latest span { position: relative; margin-top: 4px; padding: 1px 8px; border-radius: 4px; background: var(--quiet); font-size: 0.85rem; font-weight: 600; color: #111; pointer-events: none; }
.deck-latest[data-state="no"] span { background: var(--bad); }
/* Where the card's own picture is showing, its name is on it already. */
.deck-latest[data-state="ok"] img:not([hidden]) ~ span { display: none; }
.deck-latest[data-state="ok"] span { background: var(--good); }
/* The corner by which it is made larger or smaller. */
.deck-resize { position: absolute; right: -3px; bottom: -3px; width: 22px; height: 22px; border-radius: 0 0 6px; background: linear-gradient(135deg, transparent 50%, var(--text) 50%); opacity: 0.75; cursor: nwse-resize; }

/* The walkthrough of a page (tour.js): the page dimmed but for what a step is about, which
   shows through a hole and can be used, and a box of words beside that. */
.tour-shade { position: fixed; inset: 0; z-index: 40; width: 100%; height: 100%; pointer-events: none; }
.tour-dim { fill: rgb(0 0 0 / 68%); fill-rule: evenodd; pointer-events: auto; }
.tour-rim { fill: none; stroke: var(--accent); stroke-width: 2; }
.tour-box { position: fixed; z-index: 41; width: min(20em, calc(100vw - 16px)); padding: 12px 14px; border: 1px solid var(--accent); border-radius: 8px; background: var(--surface); box-shadow: 0 8px 28px rgb(0 0 0 / 60%); }
.tour-words { margin: 0 0 10px; font-size: 1.05rem; }
.tour-row { display: flex; align-items: center; gap: 6px; }
.tour-count { flex: 1; color: var(--quiet); font-variant-numeric: tabular-nums; }
.tour-row button.primary { padding: 0.4em 1em; }
/* One of the page's buttons, pictured among the words. */
.tour-icon { display: inline-block; vertical-align: -0.3em; padding: 0.15em; border: 1px solid var(--quiet); border-radius: 4px; background: rgb(255 255 255 / 14%); }
.tour-icon .icon { width: 1em; height: 1em; }
