/* =========================================================================
 * Layout & component styles. No colour literals live here — every colour is
 * a var(--color-*) defined in tokens.css, so recolouring is a tokens-only
 * edit. See tokens.css for the "Dual Land" palette rationale.
 *
 * ONE HOUSE RULE, enforced below: nothing is rounded. The deco language is
 * built on the 45° cut, and a stray border-radius reads as a different app
 * immediately — so the global reset zeroes it and plates/hero actions opt IN
 * to a real chamfer (see "Deco chrome"). Pills survive only where the shape
 * is semantic rather than decorative: status dots, counter circles, seat
 * markers and colour swatches, which are circles because they are *tokens*,
 * not because they are soft.
 * ========================================================================= */

* { box-sizing: border-box; margin: 0; padding: 0; }
/* The personal "Interface text size" setting. Every px font-size below is
   written calc(Npx * var(--ui-font-scale)); settings.js (and the pre-paint
   script in index.html) set it on <html>. Card text is scaled by this AND its
   own setting: board.js publishes --card-font-scale as their product. */
:root { --ui-font-scale: 1; }
body { font-family: var(--font-body); font-size: calc(14px * var(--ui-font-scale));
       height: 100vh; display: flex; flex-direction: column;
       background: var(--color-bg); color: var(--color-text);
       /* Jost is a geometric grotesque: its default figures are proportional
          and its default spacing is set for display sizes. Tabular numbers
          keep life totals and counts from jittering as they change, and a
          touch of tracking opens it up at 13px UI sizes. */
       font-variant-numeric: tabular-nums;
       letter-spacing: 0.01em;
       -webkit-font-smoothing: antialiased; }

/* =========================================================================
 * Deco chrome — the shared vocabulary every screen is assembled from.
 * ========================================================================= */

/* No rounding. Anything that needs a curve asks for it explicitly. */
button, input, select, textarea { border-radius: 0; font-family: inherit; }

/* Text selection is OFF by default across the app: this is a game board, not a
   document, and fast clicks (menu items, cards, counter chips) would otherwise
   snag word-selections. Only the chat log — the one place you want to copy text
   — and editable fields opt back in. user-select inherits, so the body rule
   cascades and these explicit rules override it for their subtrees. */
body { user-select: none; -webkit-user-select: none; }
#chat-feed, input, textarea, select, [contenteditable="true"] {
  user-select: text; -webkit-user-select: text; }

/* Native controls — checkboxes, radios, range thumbs and tracks — are the last
   thing in the app the browser still paints Windows-blue, and one property
   turns all of them to leaf. Cheaper and far more robust than rebuilding each
   control as a div. */
:root { accent-color: var(--color-primary); }

/* -- The plate ------------------------------------------------------------
 * A chamfered, gold-edged slab. This is the ONLY container shape in the app.
 *
 * The chamfer is drawn by two stacked pseudo-elements rather than by clipping
 * the element itself, because clip-path on the container would also clip
 * anything inside it that needs to escape — a dropdown, a hovered deck card
 * lifting out of its stack, a tooltip. So: ::before is the gilded edge,
 * ::after is the plate face inset 1px, both clipped to the octagon, both
 * behind the content. `isolation: isolate` is load-bearing — it gives the
 * plate its own stacking context so the z-index:-1/-2 pseudos land ABOVE the
 * plate's own background but BELOW its content, instead of falling through
 * to sit behind the screen's background entirely.
 *
 * The edge is a gradient, not a flat colour: real gilding catches light at
 * the top-left and dies out toward the bottom-right, and that one detail is
 * most of the difference between "gold" and "yellow line". */
.plate {
  position: relative;
  isolation: isolate;
  padding: 18px 20px;
  margin-bottom: 16px;
  background: transparent;
}
.plate::before {
  content: ''; position: absolute; inset: 0; z-index: -2;
  clip-path: var(--chamfer);
  background: linear-gradient(150deg,
    var(--color-leaf-hair) 0%, var(--color-border) 46%, var(--color-border) 100%);
  /* clip-path clips box-shadow, so separation comes from a drop-shadow on the
     clipped shape itself. */
  filter: drop-shadow(0 6px 18px var(--color-menu-shadow));
}
.plate::after {
  content: ''; position: absolute; inset: 1px; z-index: -1;
  clip-path: var(--chamfer);
  background: var(--color-surface);
}

/* The hero plate: same slab, bigger bite, and the gold actually reads as
   metal — a full leaf edge plus an inner glow, so the primary action on the
   screen is the one thing that looks lit. */
.plate-hero { --ch: var(--ch-lg); padding: 22px 24px; }
.plate-hero::before {
  background: linear-gradient(150deg,
    var(--color-leaf-bright) 0%, var(--color-leaf) 38%,
    var(--color-leaf-dim) 78%, var(--color-leaf) 100%);
  filter: drop-shadow(0 8px 26px var(--color-menu-shadow));
}
.plate-hero::after {
  background:
    radial-gradient(120% 90% at 50% 0%,
      var(--color-leaf-glow) 0%, transparent 62%),
    var(--color-surface);
}

/* -- Section titles -------------------------------------------------------
 * Cinzel, caps, letterspaced, with a gold hairline running from the last word
 * to the far edge of the plate — the rule is what makes a header feel cut
 * rather than typed. `flex: 1` on the rule is the whole trick: it measures
 * itself, so the line always meets the text no matter how long the title is. */
.plate-title, .sub-title {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-weight: 700;
  text-transform: uppercase; color: var(--color-text);
}
.plate-title { font-size: calc(13px * var(--ui-font-scale)); letter-spacing: 0.14em; margin-bottom: 14px; }
.sub-title {
  font-size: calc(11px * var(--ui-font-scale)); letter-spacing: 0.12em; color: var(--color-text-muted);
  margin: 18px 0 8px;
}
.plate-title::after, .sub-title::after {
  content: ''; flex: 1; height: 1px; min-width: 12px;
  background: linear-gradient(90deg,
    var(--color-leaf-hair) 0%, transparent 100%);
}
/* The count sits between the title and its rule — "OPEN LOBBIES 3 ———" — by
   simple source order, since ::after always comes last in the flex line.
   A real element rather than a ::marker so mainView.js can update it, and it
   hides itself at zero (setTally) instead of rendering a bare 0. */
.tally {
  font-family: var(--font-body); font-size: calc(11px * var(--ui-font-scale)); font-weight: 600;
  letter-spacing: 0.06em; color: var(--color-leaf);
  border: 1px solid var(--color-leaf-hair);
  padding: 1px 7px; flex: none;
}

/* -- Buttons --------------------------------------------------------------
 * Sharp-cornered, hollow, filling on hover. Deliberately NOT chamfered: a
 * clip-path would cut the 1px border off at each corner and leave the outline
 * broken, and faking it with pseudos would hide every `background:` the board
 * sets on its own buttons (phase stops, replay bar, token thumbs). Sharp
 * corners already carry the deco read; the chamfer is reserved for plates and
 * the hero actions below, which own their fill. */
button { padding: 6px 14px; border: 1px solid var(--color-control-border);
         cursor: pointer; background: transparent; font-size: calc(13px * var(--ui-font-scale));
         font-family: inherit; letter-spacing: 0.02em;
         color: var(--color-text);
         transition: background 0.14s, color 0.14s, border-color 0.14s; }
button:hover { background: var(--color-control-hover);
               border-color: var(--color-border-strong); }
button:active { background: var(--color-control-active); }
button.primary { background: transparent; color: var(--color-primary);
                 border-color: var(--color-primary); }
button.primary:hover { background: var(--color-primary); color: var(--color-on-primary);
                       border-color: var(--color-primary); }
button.danger { background: transparent; color: var(--color-danger);
                border-color: var(--color-danger); }
button.danger:hover { background: var(--color-danger); color: var(--color-on-danger); }
/* Disabled buttons: visibly inert (our explicit colours otherwise mask the
   browser default, making a disabled button look clickable). */
button:disabled { opacity: 0.4; cursor: not-allowed; }
button:disabled:hover { background: transparent;
                        border-color: var(--color-control-border); }
button.primary:disabled:hover { background: transparent; color: var(--color-primary);
                        border-color: var(--color-primary); }
button.danger:disabled:hover { background: transparent; color: var(--color-danger);
                        border-color: var(--color-danger); }

/* The hero action. Chamfered (it owns its fill, so clip-path is safe here),
   gilded, and set in Cinzel caps — the only button in the app that shouts.
   Selectors are qualified `button.btn-hero` (0-1-1) rather than bare
   `.btn-hero` (0-1-0) for the same reason .lobby-fab doubles up below: the
   generic `button` / `button:hover` rules set the `background` SHORTHAND at
   0-0-1 and 0-1-1, and a lone class loses that fight the moment you hover. */
button.btn-hero {
  width: 100%; margin-top: 4px; padding: 13px 20px;
  clip-path: var(--chamfer-sm);
  border: none;
  font-family: var(--font-display); font-weight: 700; font-size: calc(14px * var(--ui-font-scale));
  letter-spacing: 0.16em; text-transform: uppercase;
  background: var(--color-primary); color: var(--color-on-primary);
  transition: filter 0.14s, transform 0.08s;
}
button.btn-hero:hover:not(:disabled) {
  background: var(--color-primary); color: var(--color-on-primary);
  filter: brightness(1.14); }
button.btn-hero:active:not(:disabled) {
  background: var(--color-primary); transform: translateY(1px); }

/* -- Fields ---------------------------------------------------------------
 * Recessed, sharp, with the focus state carried by a gold underline rather
 * than a ring — a rule under the text matches the hairlines everywhere else. */
input[type="text"], input[type="number"], input[type="search"],
select, textarea {
  background: var(--color-bg-sunken); color: var(--color-text);
  border: 1px solid var(--color-border);
  padding: 7px 9px; font-size: calc(13px * var(--ui-font-scale));
  transition: border-color 0.14s, box-shadow 0.14s;
}
input[type="text"]:focus, input[type="number"]:focus, select:focus,
textarea:focus {
  outline: none; border-color: var(--color-leaf);
  box-shadow: inset 0 -2px 0 -1px var(--color-leaf);
}
input::placeholder, textarea::placeholder { color: var(--color-text-faint); }
.field-label { display: block; font-size: calc(10px * var(--ui-font-scale)); text-transform: uppercase;
               letter-spacing: 0.12em; color: var(--color-text-subtle);
               margin-bottom: 4px; }

/* -- Scrollbars -----------------------------------------------------------
 * The default chrome is the last cold-grey thing on screen; a thin leaf-dim
 * thumb on a sunken track keeps the frame consistent. */
* { scrollbar-width: thin;
    scrollbar-color: var(--color-border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-strong);
    border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--color-leaf-dim);
    background-clip: padding-box; }
::selection { background: var(--color-leaf); color: var(--color-on-primary); }

/* User chip: fixed avatar circle (top-right) + dropdown menu. Replaces the
   old header bar — the border colour is the connection indicator. */
#user-chip { position: fixed; top: 12px; right: 12px; z-index: 300; }

/* Disconnection strip (#188): a body flex child before #app, so it squeezes in
   and pushes the page down rather than overlaying. Carnelian FILL — a fill
   contrasts with the text ON it, not the surface (design-system §3.2). The
   danger fill flips lightness per theme (dark #d97a66 / light #a83a2c), so the
   text must flip too: ink on the light dark-theme fill, bone on the dark
   light-theme fill (checked both, §5). Right padding clears the fixed chip. */
#conn-strip { flex: 0 0 auto; display: flex; align-items: center;
              justify-content: center; gap: 12px;
              padding: 4px 62px 4px 14px;
              background: var(--color-danger); color: #1d1913;
              font-family: var(--font-body); font-size: calc(12px * var(--ui-font-scale)); font-weight: 600;
              letter-spacing: 0.04em;
              border-bottom: 1px solid var(--color-danger-border);
              /* Above the scrim, so Reconnect stays clickable. */
              position: relative; z-index: 501; }
:root[data-theme="light"] #conn-strip { color: #f4ecdc; }
#conn-strip.hidden { display: none; }

/* Full-viewport scrim while disconnected: dims and swallows every pointer
   event (pointer-events: auto) so drags/clicks can't fire doomed commands.
   Below the strip (501), above all app content. */
#conn-overlay { position: fixed; inset: 0; z-index: 500;
                background: rgba(0, 0, 0, 0.5); cursor: not-allowed; }
#conn-overlay.hidden { display: none; }
/* The lead dot is a semantic status mark — a circle is exempt from the global
   no-radius rule (§5). currentColor keeps it in step with the theme-flipped
   text. */
.conn-strip-label::before { content: ""; display: inline-block;
                            width: 8px; height: 8px; margin-right: 8px;
                            border-radius: 50%; background: currentColor;
                            vertical-align: middle; }
/* The button inverts the strip: text-colour ground, danger ink. Qualified +
   explicit :hover so the generic button background shorthand can't win on hover
   (the specificity trap, §6). */
button.conn-reconnect { background: #1d1913; color: var(--color-danger);
                        border: 1px solid currentColor;
                        padding: 2px 10px; font-family: var(--font-body);
                        font-size: calc(12px * var(--ui-font-scale)); font-weight: 600; letter-spacing: 0.04em;
                        cursor: pointer; }
button.conn-reconnect:hover { filter: brightness(1.15); }
:root[data-theme="light"] button.conn-reconnect { background: #f4ecdc; }

/* -- Table chat (#111) ---------------------------------------------------- */
/* Toggle FAB (bottom-right, in-game only). id selector (1-0-0) clears the
   generic button background trap without doubling. Chamfered, not round. */
#chat-toggle { position: fixed; right: 20px; bottom: 20px; z-index: 250;
               width: 44px; height: 44px; padding: 0; font-size: calc(20px * var(--ui-font-scale));
               line-height: 1; cursor: pointer; border: none;
               clip-path: var(--chamfer-sm);
               background: var(--color-surface); color: var(--color-text);
               filter: drop-shadow(0 4px 12px var(--color-menu-shadow)); }
#chat-toggle:hover { filter: drop-shadow(0 6px 16px var(--color-menu-shadow))
                             brightness(1.1); }
#chat-toggle.hidden { display: none; }
/* Unread mark — the one scarce gold touch, a "someone spoke" signal. */
#chat-toggle.has-unread::after { content: ""; position: absolute; top: 6px;
  right: 6px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--color-primary); }

/* The drawer: a full-height right rail, slid off-screen until .open. */
#chat-panel { position: fixed; top: 0; right: 0; bottom: 0; z-index: 260;
              width: min(var(--chat-width, 340px), 88vw);
              display: flex; flex-direction: column;
              background: var(--color-surface);
              border-left: 1px solid var(--color-leaf-hair);
              box-shadow: -8px 0 24px var(--color-menu-shadow);
              transform: translateX(100%); transition: transform 0.18s ease; }
#chat-panel.open { transform: translateX(0); }
/* Squeeze the board rather than overlay it: while the drawer is open, shrink
   #app by the drawer width so it sits in the freed strip, not on top (#111). */
#app { transition: margin-right 0.18s ease; }
body.chat-open #app { margin-right: min(var(--chat-width, 340px), 88vw); }
@media (prefers-reduced-motion: reduce) {
  #chat-panel, #app { transition: none; }
}
/* Right padding clears the fixed account chip (z 300) that floats over the
   panel's top-right corner, so the filter + close controls stay reachable. */
.chat-head { display: flex; align-items: center; justify-content: space-between;
             padding: 12px 56px 12px 14px;
             border-bottom: 1px solid var(--color-leaf-hair); }
.chat-title { font-family: var(--font-display); text-transform: uppercase;
              letter-spacing: 0.14em; font-size: calc(13px * var(--ui-font-scale)); color: var(--color-text); }
.chat-head-actions { display: flex; align-items: center; gap: 2px; }
button.chat-close, button.chat-filter-btn { background: none; border: none;
  color: var(--color-text-dim); font-size: calc(15px * var(--ui-font-scale)); cursor: pointer; padding: 2px 6px; }
button.chat-close:hover, button.chat-filter-btn:hover { background: none;
  color: var(--color-text); }

/* Drag handle on the drawer's left edge. */
#chat-resize { position: absolute; left: 0; top: 0; bottom: 0; width: 6px;
               cursor: ew-resize; z-index: 2; }
#chat-resize:hover { background: var(--color-leaf-hair); }

/* A turn bar between rounds. */
.chat-divider { border-top: 1px solid var(--color-control-border);
                margin: 5px 0; }

/* Filter + mute pane (toggled by .show-filters on the panel). */
#chat-filters { display: none; padding: 6px 12px 10px;
                border-bottom: 1px solid var(--color-leaf-hair);
                max-height: 45%; overflow-y: auto; }
#chat-panel.show-filters #chat-filters { display: block; }
.chat-filter-head { font-family: var(--font-display); text-transform: uppercase;
                    letter-spacing: 0.12em; font-size: calc(10px * var(--ui-font-scale));
                    color: var(--color-text-dim); margin: 8px 0 3px; }
.chat-filter-row { display: flex; align-items: center; gap: 6px; padding: 2px 0;
                   font-size: calc(12px * var(--ui-font-scale)); color: var(--color-text); cursor: pointer; }

#chat-feed { flex: 1; overflow-y: auto; padding: 10px 12px;
             display: flex; flex-direction: column; gap: 7px;
             font-size: calc(13px * var(--ui-font-scale)); line-height: 1.35; }
.chat-msg { color: var(--color-text); overflow-wrap: anywhere; }
.chat-msg-name { display: inline-block; padding: 0 6px; margin-right: 6px;
                 font-weight: 600; font-size: calc(12px * var(--ui-font-scale));
                 background: var(--color-control-active); color: var(--color-text);
                 clip-path: var(--chamfer-sm); }
.chat-event { color: var(--color-text-dim); font-style: italic;
              font-size: calc(12px * var(--ui-font-scale)); overflow-wrap: anywhere; }
/* A hoverable card name in the feed (#206): dotted underline hints the preview,
   brightening on hover. */
.chat-card { text-decoration: underline dotted var(--color-text-faint);
             text-underline-offset: 2px; cursor: help; }
.chat-card:hover { color: var(--color-text); }

.chat-input { display: flex; gap: 6px; padding: 10px 12px;
              border-top: 1px solid var(--color-leaf-hair); }
#chat-text { flex: 1; min-width: 0; }
button.chat-send { flex: 0 0 auto; padding: 6px 14px; cursor: pointer;
                   font-family: var(--font-body); font-weight: 600;
                   background: var(--color-control-active);
                   color: var(--color-text);
                   border: 1px solid var(--color-control-border); }
button.chat-send:hover { background: var(--color-surface-hover); }
#user-chip-avatar { width: 38px; height: 38px; border-radius: 50%; padding: 0;
                    display: flex; align-items: center; justify-content: center;
                    font-weight: bold; font-size: calc(16px * var(--ui-font-scale));
                    background: var(--chip-color, var(--color-header-bg));
                    color: var(--color-header-text);
                    border: 3px solid var(--color-warning);
                    box-shadow: 0 2px 8px var(--color-menu-shadow); }
#user-chip-avatar:hover { filter: brightness(1.25); }
#user-chip-avatar.chip-ok { border-color: var(--color-status-ok); }
#user-chip-avatar.chip-error { border-color: var(--color-status-error-bright); }
#user-chip-avatar.chip-connecting { border-color: var(--color-warning); }
#user-chip-menu { position: absolute; top: 46px; right: 0; min-width: 190px;
                  background: var(--color-surface);
                  border: 1px solid var(--color-leaf-hair);
                  clip-path: var(--chamfer-sm); padding: 5px; display: flex;
                  flex-direction: column; gap: 1px;
                  box-shadow: 0 6px 20px var(--color-menu-shadow); }
#user-chip-menu button { text-align: left; border: none; background: none;
                         padding: 7px 10px; font-size: calc(13px * var(--ui-font-scale)); }
#user-chip-menu button:hover { background: var(--color-surface-hover);
                               color: var(--color-leaf-bright); }
#user-chip-menu button.destructive { color: var(--color-danger); }
#user-chip-menu button.destructive:hover { color: var(--color-danger-hover); }
.chip-menu-header { padding: 7px 10px 9px; margin-bottom: 3px;
                    border-bottom: 1px solid var(--color-leaf-hair); }
.chip-menu-name { font-weight: 600; font-size: calc(13px * var(--ui-font-scale)); }
.chip-menu-status { font-size: calc(11px * var(--ui-font-scale)); color: var(--color-text-subtle); }
.chip-menu-status.ok { color: var(--color-status-ok); }
.chip-menu-status.error { color: var(--color-status-error); }
.chip-menu-status.connecting { color: var(--color-warning); }
.chip-menu-color { display: flex; align-items: center; justify-content: space-between;
                   padding: 6px 10px; font-size: calc(13px * var(--ui-font-scale)); cursor: pointer; }
.chip-menu-color:hover { background: var(--color-surface-hover); }
.chip-menu-color input[type="color"] { width: 28px; height: 22px; padding: 0;
                   border: 1px solid var(--color-border);
                   background: none; cursor: pointer; }


/* =========================================================================
 * Game board — one page, no scrolling. Vertical turn rail on the left, the
 * shared stack bar beside it, then one band per player (two columns at >=5
 * players) with own hand fanned along the bottom. Card size flows from
 * --card-w (set by board.js from the available height).
 * ========================================================================= */
#game-panel { flex: 1; display: flex; flex-direction: row; overflow: hidden;
              background: var(--color-bg-sunken); --card-w: 96px;
              /* Left-drag is rubber-band/move, not text selection. */
              user-select: none; -webkit-user-select: none; }

/* Vertical turn rail: turn header + full phase bar + core actions. */
.side-rail { flex: 0 0 112px; display: flex; flex-direction: column; gap: 5px;
             padding: 8px 6px; background: var(--color-action-bar-bg);
             overflow-y: auto; overflow-x: hidden; }
.side-rail .sr-info { font-size: calc(12px * var(--ui-font-scale)); text-align: center; }
/* Round over turn (#239): the round is the number you glance at, the turn is
   the footnote under it — so they differ in weight, not just order. */
/* Game clock: above the round, quiet — it's ambient, not something to act on. */
.side-rail .sr-clock { font-size: calc(11px * var(--ui-font-scale)); color: var(--color-text-muted);
                       font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.side-rail .sr-round { font-size: calc(15px * var(--ui-font-scale)); font-weight: bold; line-height: 1.1;
                       letter-spacing: 0.02em; }
.side-rail .sr-turn { font-size: calc(10px * var(--ui-font-scale)); color: var(--color-text-muted);
                      letter-spacing: 0.06em; text-transform: uppercase; }
.side-rail .sr-active { white-space: nowrap; overflow: hidden;
                        text-overflow: ellipsis; }
.side-rail .sr-active.me { color: var(--color-primary); font-weight: bold; }
.side-rail button { width: 100%; padding: 3px 2px; font-size: calc(11px * var(--ui-font-scale)); }

/* Phase bar: every phase/step stop, coloured by phase group. Left border
   marks the group; the current stop is a solid highlight. The phase bar + turn
   controls (Pass, Automation) form one cluster centred vertically in the rail:
   auto margin above the phase bar and below the last control split the free
   space, so the turn header/roster stay at the top and the cluster centres. */
.phase-bar { display: flex; flex-direction: column; gap: 3px; margin-top: auto; }
.side-rail .sr-automation { margin-bottom: auto; }
/* Read-only rail (spectator / replay / conceded): no turn controls below, so
   the phase bar takes its own bottom auto-margin to stay centred. */
.side-rail.read-only .phase-bar { margin-bottom: auto; }
/* Automation INDICATOR on a phase stop (#114): a small gold gear pinned to the
   right edge, shown only when an automation for that step is enabled. It's
   display-only — pointer-events: none, so clicking the stop always jumps there,
   identically whether or not the gear shows. Toggling lives in the Automation
   settings blade (the rail's Automation button). */
.phase-auto-ind { position: absolute; right: 3px; top: 50%;
                  transform: translateY(-50%); font-size: calc(9px * var(--ui-font-scale)); line-height: 1;
                  color: var(--color-primary); opacity: 0.9;
                  pointer-events: none; }

/* Separator between the phase bar and the turn controls (Pass, Automation). */
.side-rail .sr-sep { height: 1px; background: var(--color-leaf-hair);
                     opacity: 0.6; margin: 6px 2px 2px; }
.side-rail .sr-automation { font-size: calc(10px * var(--ui-font-scale)); color: var(--color-text-muted); }
.side-rail .sr-automation:hover { color: var(--color-text); }
.side-rail .phase-btn { position: relative; width: 100%; padding: 5px 3px;
             font-size: calc(10px * var(--ui-font-scale));
             display: flex; align-items: center; justify-content: center; gap: 5px;
             text-transform: uppercase; letter-spacing: 0.3px;
             border: 1px solid var(--color-border-soft); border-left-width: 3px;
             border-radius: 3px; background: var(--color-surface);
             color: var(--color-text); }
.side-rail .phase-btn:hover { background: var(--color-control-hover); }
.phase-btn.pg-beginning { border-left-color: var(--color-phase-beginning); }
.phase-btn.pg-ending { border-left-color: var(--color-phase-ending); }
.phase-btn.pg-main { border-left-color: var(--color-phase-main); }
.phase-btn.pg-combat { border-left-color: var(--color-phase-combat); }
.side-rail .phase-btn.current { font-weight: bold; color: #fff;
             border-color: transparent; cursor: default; }
.phase-btn.pg-beginning.current { background: var(--color-phase-beginning); }
.phase-btn.pg-ending.current { background: var(--color-phase-ending); }
.phase-btn.pg-main.current { background: var(--color-phase-main); }
.phase-btn.pg-combat.current { background: var(--color-phase-combat); }

/* Core action cluster + prominent Pass at the foot of the rail. */
.side-rail .sr-pass { padding: 7px 2px; font-weight: bold;
             border-color: var(--color-primary); color: var(--color-primary); }
.side-rail .sr-pass:hover { background: var(--color-primary);
             color: var(--color-on-primary); }

/* Shared stack bar: width tracks the personal --stack-w (resizable via the
   .stack-resize handle, capped ~1.5× the default) plus the alternate-card X
   offset so every other card's corner peeks out. board.js shrinks --stack-w
   when a deep stack would overflow the height. */
.stack-bar { --card-w: var(--stack-w, 96px);
             --stack-x: calc(var(--card-w) * 0.22);
             flex: 0 0 auto; width: calc(var(--card-w) + var(--stack-x) + 16px);
             display: flex; flex-direction: column;
             align-items: center; overflow: hidden;
             background: var(--color-zone-stack); }
/* The fanned-card peek (--stack-x) is reserved in the width even when the stack
   is empty, so the column keeps a constant width and the board doesn't shift as
   the first card lands. An empty stack still reads as a slim labelled strip
   (board.js narrows --stack-w when it's empty and untouched). */
.stack-bar .stack-label { font-size: calc(10px * var(--ui-font-scale)); text-transform: uppercase;
                          letter-spacing: 1px; color: var(--color-text-subtle);
                          padding: 4px 0; flex-shrink: 0; white-space: nowrap; }
/* Stack: vertically centered, cards overlapping so the top is clear; every
   other card is nudged right by --stack-x so a corner sticks out (fanned).
   Offset is assigned from the BOTTOM (nth-last-child) so a card keeps its side
   when a new one is inserted on top (cards[0]) and indices shift.
   The side padding is the bar's 16px of slack, given to the column so its
   overflow:hidden doesn't shave the selected ring (outline + glow, drawn
   outside the card box) off the left and right. Sides only: board.js budgets
   the column's height for the cards alone. */
.stack-bar .stack-cards { display: flex; flex-direction: column; flex: 1;
                          justify-content: center; align-items: flex-start;
                          overflow: hidden; padding: 0 8px; }
.stack-bar .stack-cards .card { margin: 0; }
.stack-bar .stack-cards .card + .card { margin-top: calc(var(--card-w) * -0.5); }
.stack-bar .stack-cards .card:nth-last-child(even) { margin-left: var(--stack-x); }
.stack-bar .stack-cards .card:hover { z-index: 3; }

/* Stack resize handle: a thin grip at the stack bar's right edge (mirrors the
   pile-column handle). */
.stack-resize { flex: 0 0 4px; align-self: stretch; cursor: col-resize;
                background: var(--color-zone-stack); touch-action: none; }
.stack-resize:hover { background: var(--color-border-strong); }

/* Main column: player bands + own hand. */
.board-main { flex: 1; display: flex; flex-direction: column; min-width: 0;
              overflow: hidden; }
.player-grid { flex: 1; display: grid; grid-auto-rows: 1fr; overflow: hidden;
               gap: 2px; padding: 2px; }
.player-grid.two-col { grid-template-columns: 1fr 1fr; }
/* Every seat's area carries a thin border in that player's colour (--player-color
   is set per seat in board.js), so you can tell whose board is whose at a glance
   (#231). The frame is drawn on a ::before OVERLAY (pointer-events:none, above
   the children) rather than a border/inset-shadow on the area itself — the
   area's opaque children (the battlefield) otherwise paint OVER an inset ring,
   so only its top/bottom would peek through the transparent left columns as
   stray lines. The active seat's frame turns the active colour with the player
   colour embedded just inside it. */
.player-area { position: relative; display: flex; min-height: 0; min-width: 0;
               overflow: hidden; border-radius: 4px;
               background: var(--color-surface); }
.player-area::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 5;
  border-radius: 4px;
  border: 1px solid var(--player-color, var(--color-border-soft)); }
/* The active seat keeps its colour border and gains an inward-facing glow in the
   active colour — a soft few-px halo along the inside edges reads clearly as
   "it's this player's turn" without a hard line. Drawn on the overlay pseudo so
   it sits above the board's opaque children (not hidden behind them). */
.player-area.active::before {
  box-shadow: inset 0 0 14px 2px var(--color-active-outline); }
/* A disconnected human's seat (Presence: connected=false): a red glyph before
   the name plus a translucent red veil + inset frame over their whole board,
   held while their session reconnects. The veil is click-through (purely
   visual) — nobody could act on that board anyway. */
.player-area.disconnected { position: relative; }
.player-area.disconnected::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 6;
  background: rgba(255, 68, 68, 0.09);
  box-shadow: inset 0 0 0 2px var(--color-status-error-bright); }
.disc-alert { color: var(--color-status-error-bright); font-weight: bold;
              margin-right: 4px; flex: 0 0 auto; line-height: 1; }

/* Personal pile-column width (issue N): --pile-w (set by board.js from the
   pileColScale pref, driven by the settings slider / drag handle) overrides
   --card-w inside the left-hand columns only, so the identity + pile columns
   (and the cards stacked in them) scale together as a group while the
   battlefield keeps its own --card-w. Local-only, never broadcast. */
.info-col, .pile-col { --card-w: var(--pile-w, 96px); }

/* Identity column — same width as a pile column so bands line up. */
.info-col { flex: 0 0 auto; width: max(var(--card-w), 74px);
            display: flex; flex-direction: column; gap: 3px; padding: 4px;
            border-right: 1px solid var(--color-border-subtle);
            background: var(--color-surface-raised); overflow: hidden; }
.rail-name { font-size: calc(12px * var(--ui-font-scale)); font-weight: bold; white-space: nowrap;
             overflow: hidden; text-overflow: ellipsis;
             display: flex; align-items: center; gap: 5px; }
/* Seat nameplate: a small plate behind the name that doubles as a player-level
   zone for targeting arrows (arrows.js). Tinted by --nameplate-color when the
   player has a colour, else a neutral surface. */
.player-nameplate { padding: 2px 8px; border-radius: 6px;
             background: var(--color-surface-hover);
             border: 1px solid var(--color-border-subtle);
             box-shadow: inset 0 0 0 1px var(--nameplate-color, transparent); }
.player-nameplate[style*="--nameplate-color"] {
             border-color: var(--nameplate-color); }
/* A bot's name opens its manage-menu (openBotMenu) — signal it's clickable. */
.bot-name { cursor: pointer; }
.bot-name:hover { text-decoration: underline; }
.player-color-swatch { flex: none; width: 10px; height: 10px; border-radius: 50%;
             border: 1px solid var(--color-border); }
.rail-badges { display: flex; gap: 3px; flex-wrap: wrap; }
.rail-hand { font-size: calc(24px * var(--ui-font-scale)); line-height: 1.1; color: var(--color-text-subtle);
             text-align: center; white-space: nowrap; }
.rail-hand.clickable { cursor: pointer; }
.rail-hand.clickable:hover { color: var(--color-text); }
.rail-life { display: flex; align-items: baseline; gap: 5px;
             justify-content: center; }
.rail-label { font-size: calc(10px * var(--ui-font-scale)); text-transform: uppercase; letter-spacing: 0.4px;
              color: var(--color-text-subtle); }
.rail-life .player-life { font-size: calc(17px * var(--ui-font-scale)); font-weight: bold; min-width: 24px;
                          text-align: center; color: #fff;
                          /* Black outline so the total reads on any player
                             colour / busy background: a stroke behind the fill
                             plus a 4-way shadow ring for browsers where
                             paint-order/stroke render thin. */
                          -webkit-text-stroke: 2px #000; paint-order: stroke fill;
                          text-shadow: -1px -1px 0 #000, 1px -1px 0 #000,
                                       -1px 1px 0 #000, 1px 1px 0 #000; }
/* Divider between rail sections (name / hand / life / commander damage /
   counters) — full width, clearly visible. */
.rail-sep { width: 100%; height: 1px; margin: 4px 0;
            background: var(--color-border); }
/* Click-to-adjust life (issue E): left +1, right −1. */
.rail-life .player-life.adjustable { cursor: pointer; border-radius: 4px;
                          padding: 0 6px; user-select: none; }
.rail-life .player-life.adjustable:hover { background: var(--color-surface-hover); }
.rail-life .btn-inline { padding: 0 6px; }
.info-col > .btn-inline { font-size: calc(10px * var(--ui-font-scale)); padding: 1px 4px; }
/* +Counter is pinned to the very bottom of the identity column, below whatever
   sections (life / commander damage / counters) are present. */
.info-col > .add-counter-btn { margin-top: auto; }
/* Player counters: one per row, centred, so each reads clearly in the rail. */
.rail-counters { display: flex; flex-direction: column; align-items: center;
                 gap: 3px; }

/* Commander-damage chips (issue E): one row per dealing player, one chip per
   commander (x/21), tinted by the dealer's colour. Click-to-adjust like life. */
.rail-cmdrdmg { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.rail-cmdrdmg-label { font-size: calc(10px * var(--ui-font-scale)); text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--color-text-subtle); text-align: center; }
.cmdrdmg-row { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; }
.cmdrdmg-chip { font-size: calc(11px * var(--ui-font-scale)); font-weight: bold; line-height: 1.4;
                padding: 0 6px; border-radius: 999px; cursor: pointer;
                user-select: none; color: #fff;
                background: var(--chip-color, var(--color-badge-bg));
                /* Border tracks the font colour (currentColor) — JS sets the
                   text to a legible tint of the dealer's colour, so the chip
                   gets a matching outline that lifts it off the rail (#113). */
                border: 1px solid currentColor; }
.cmdrdmg-chip:hover { filter: brightness(1.15); }
.cmdrdmg-chip.lethal { outline: 2px solid var(--color-danger); }

/* Commander tax (#319, commanderTax.js): "+{4}", what the next cast adds.
   Square, like every badge that isn't a counter: a circle on a card reads as
   a counter. On the card while it's in the command zone; on the pile, with the
   commander's name, while it's away. */
.cmdr-tax-badge { display: inline-flex; align-items: center; gap: 4px;
                  font-size: calc(11px * var(--card-font-scale, 1)); font-weight: bold;
                  line-height: 1.3; padding: 1px 5px; white-space: nowrap;
                  user-select: none; color: var(--color-text);
                  background: var(--color-surface);
                  border: 1px solid var(--color-leaf-hair); }
.cmdr-tax-badge .ms { font-size: 1.05em; }
.cmdr-tax-badge.interactive { cursor: pointer; }
.cmdr-tax-badge.interactive:hover { filter: brightness(1.1); }
.card .cmdr-tax-badge { position: absolute; top: 2px; right: 2px; z-index: 3; }
/* On the pile the badge lives in a column one card wide, so it is sized to the
   column, not to card text: the UI's small size, never wider than the column,
   the name giving way (ellipsis) before the cost does. */
.cmdr-tax-row { display: flex; flex-direction: column; align-items: stretch; width: 100%;
                gap: 3px; margin-top: 4px; padding: 0 4px; min-width: 0;
                max-width: 100%; box-sizing: border-box; }
.cmdr-tax-row .cmdr-tax-badge { display: flex; min-width: 0;
                                font-size: calc(11px * var(--ui-font-scale)); }
.cmdr-tax-row .ct-name { flex: 1 1 auto; min-width: 0; overflow: hidden;
                         white-space: nowrap; text-overflow: ellipsis;
                         font-weight: normal; }
.cmdr-tax-row .ct-cost { flex: 0 0 auto; }

/* Pile columns: library/graveyard/exile (and extras) stacked vertically,
   one pile per battlefield row height. */
.pile-col { flex: 0 0 auto; width: calc(var(--card-w) + 8px);
            display: flex; flex-direction: column; padding: 2px 4px;
            border-right: 1px solid var(--color-border-subtle);
            overflow: hidden; }
/* Drag handle at the right edge of the stacked left-hand columns; one drag
   resizes the identity + pile columns together (issue N). */
.pile-resize { flex: 0 0 4px; align-self: stretch; cursor: col-resize;
               background: transparent; touch-action: none; }
.pile-resize:hover { background: var(--color-border-strong); }
body.resizing-piles { cursor: col-resize; user-select: none; }

.pile { flex: 1; position: relative; min-height: 0; display: flex;
        flex-direction: column; justify-content: center; align-items: center; }
/* Zone label: a small overlay pinned to the top-center of the pile. */
.pile-label { position: absolute; top: 1px; left: 50%; transform: translateX(-50%);
              z-index: 2;
              font-size: calc(9px * var(--ui-font-scale)); text-transform: uppercase; letter-spacing: 0.5px;
              padding: 0 4px; border-radius: 3px;
              background: var(--color-tooltip-bg);
              color: var(--color-tooltip-text); opacity: 0.85;
              white-space: nowrap; }
.pile-label.clickable { cursor: pointer; }
.pile-label.clickable:hover { opacity: 1; }
.pile .card-back, .pile .card-slot, .pile .card-img, .pile .card.has-art {
  width: var(--card-w); min-width: var(--card-w); max-width: var(--card-w);
  margin: 0; }
.pile .card { margin: 0; min-width: 0; max-width: var(--card-w);
              font-size: calc(9px * var(--ui-font-scale)); }
.pile-cards { display: flex; flex-direction: column; }
.pile-cards .card + .card { margin-top: calc(var(--card-w) * -1.15); }
.pile-cards .card:hover { z-index: 2; }
/* Exile's optional-metadata drop target: a distinct "Exiled by…" target INSET
   within the exile pile's top region while a drag is in flight — it stops short
   of the pile's edges so it reads as a target inside exile, not the exile zone
   itself (the surrounding margin stays a plain exile drop). */
.pile-subdrop { display: none; position: absolute; top: 5px; left: 5px; right: 5px;
                height: 42%; z-index: 3; padding: 2px;
                align-items: center; justify-content: center;
                border: 2px dashed var(--color-border-strong); border-radius: 4px;
                font-size: calc(9px * var(--ui-font-scale)); text-align: center; text-transform: uppercase;
                letter-spacing: 0.5px; color: var(--color-text);
                background: var(--color-surface);
                opacity: 0.92; }
body.dragging .pile-subdrop { display: flex; }
.pile-subdrop.drop-target { border-color: var(--color-accent);
                            background: var(--color-accent-glow); }

/* Library placement overlay: four stacked bands filling the library pile while
   a drag is in flight — top band on top, bottom bands at the bottom, matching
   the deck positions. A drop places the card(s) on top (position 0), at a
   prompted depth, on the bottom, or on the bottom in random order (#224).
   Pointer-transparent — resolution is geometric by y (drag.js). Four bands
   share one pile's height, so the type is small and the faces carry short
   `bandLabel` text; the floating drag hint spells each one out in full. */
.lib-drop { display: none; position: absolute; top: 5px; left: 5px; right: 5px;
            bottom: 5px; z-index: 3; pointer-events: none;
            flex-direction: column; gap: 3px; }
body.dragging .lib-drop { display: flex; }
.lib-drop-band { flex: 1 1 0; min-width: 0; min-height: 0;
                 display: flex; align-items: center;
                 justify-content: center; padding: 2px;
                 border: 2px dashed var(--color-border-strong); border-radius: 4px;
                 font-size: calc(11px * var(--ui-font-scale)); font-weight: 600; text-align: center;
                 text-transform: uppercase; letter-spacing: 0.2px;
                 color: var(--color-text); line-height: 1.15;
                 background: var(--color-surface); opacity: 0.92;
                 overflow: hidden; overflow-wrap: anywhere; }
.lib-drop-band.drop-target { border-color: var(--color-accent);
                             background: var(--color-accent-glow); }

/* Floating action hint that follows the dragged card and names the drop it
   will perform ("Top of library", "To graveyard", "Exiled by…"). Lives on
   <body> beside the ghost; pointer-transparent so it never intercepts a drop. */
.drop-hint { position: fixed; z-index: 300; pointer-events: none;
             padding: 4px 10px; border-radius: 4px; font-size: calc(15px * var(--ui-font-scale));
             font-weight: 600; white-space: nowrap;
             color: var(--color-tooltip-text);
             background: var(--color-tooltip-bg);
             border: 1px solid var(--color-accent);
             box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35); }

/* Battlefield: three rows of a sparse grid. Stacks are fixed-width; gaps
   are literal slot widths but shrink before cards do when a row is tight;
   the tail absorbs leftover width (and far drops create new columns). */
.battlefield { flex: 1; display: flex; flex-direction: column; min-width: 0;
               overflow: hidden; }
/* A tapped card rotates 90° about its centre, so the leftmost card overhangs
   its column by ≈ (aspect − 1) / 2 ≈ 0.2 card-widths. Reserve that much extra
   left padding (proportional to the card size) so it doesn't clip off the
   battlefield's left edge (dev batch #7). */
.bf-row { flex: 1; display: flex; align-items: center;
          padding: 0 4px 0 calc(4px + var(--card-w) * 0.3);
          min-height: 0; overflow: hidden; }
/* An attachment fans UP and left out of flow (absolutely positioned), so the
   stack carrying one reserves the fan's height as padding ABOVE its anchor.
   That puts the fan inside the stack's own box, which means the row can centre
   the group like any other card instead of the group hanging off the bottom.

   It lands exactly level with its neighbours, because the per-slot shrink in
   fitRowWidths takes the fan height back off the card: it narrows the stack's
   cards by `up / 1.394`, and card height is ≈ 1.394 × width, so the card gets
   shorter by precisely `up`. Padding + shrunk card = one ordinary card height. */
.bf-row > .bf-stack[data-attach-up] { padding-top: var(--attach-up, 0px); }
.bf-row + .bf-row { border-top: 1px dashed var(--color-border); }
/* A stack grows to its own visual width (the anchor plus each peeking card), so
   stacked cards stay individually visible. Drop-target detection reads the
   rendered edges (computeBattlefieldSlot), so the marker lands to the RIGHT of
   the whole stack rather than overlapping it. */
/* Inter-column gap sized for TWO tapped cards' overhangs. A card rotated 90°
   about its centre overhangs its column by ≈(aspect−1)/2 ≈ (680/488−1)/2 ≈
   0.197 card-widths on EACH side, so two adjacent tapped cards reach ≈0.394W
   toward each other. The old 0.3W covered only one overhang (the ~0.22 estimate
   was per-side), leaving adjacent tapped cards ~0.09W overlapped; 0.42W clears
   both with a hair to spare (dev batch #83). */
.bf-stack { position: relative; display: flex; align-items: center;
            flex: 0 0 auto; width: auto;
            margin-right: calc(var(--card-w) * 0.42); }
/* No card margin on the battlefield: a lone card is exactly one card wide and
   the 6px column gap comes from .bf-stack / .bf-gap, so a card column matches a
   gap column and adding/removing a card never nudges the row. */
.bf-stack .card { margin: 0; }
/* Stacked cards peek out to the right so each stays visible (count also shown by
   the ×N badge). The anchor card inside an attach-group is exempt (direct-child
   selector) so it stays put behind its absolutely-positioned children. */
.bf-stack > .card + .card { margin-left: calc(var(--card-w) * -0.82); }
/* Raise a hovered card above the cards stacked in front of it, so hovering a
   middle card's peeking edge brings the whole card into view (dev batch #83).
   `.bf-raised` is driven by the preview reconcile (cardPreview.js) keyed to the
   card the cursor is really over, computed independently of this raise — so it
   moves to the neighbour the moment the cursor crosses onto its sliver instead
   of the raised card trapping the pointer over its whole overlapping box. The
   `:hover` rule stays as a no-JS fallback; on a tie the later-in-DOM `.bf-raised`
   card wins, which is exactly the card that should be on top. */
.bf-stack .card:hover { z-index: 5; }
/* Above :hover, not level with it: the wheel (#321) raises a card BELOW the one
   the cursor is on, and at a tie the later-in-DOM hovered card would stay on
   top of the card the preview is showing. */
.bf-stack .card.bf-raised { z-index: 6; }
.bf-stack.join-target { outline: 2px solid var(--color-accent);
                        outline-offset: 2px; border-radius: 6px;
                        background: var(--color-accent-glow); }
.bf-stack-count { position: absolute; top: -6px; right: -4px; z-index: 4;
                  font-size: calc(10px * var(--ui-font-scale)); font-weight: bold; padding: 0 5px;
                  border-radius: 999px; background: var(--color-tooltip-bg);
                  color: var(--color-tooltip-text); pointer-events: none; }
/* Empty columns are one full column-PITCH wide (card 1.0 + the 0.42 inter-stack
   gap = 1.42W) — no compression — so a gap column matches a card column exactly,
   columns line up across rows, and adding/removing a card never nudges the row.
   Kept in lockstep with .bf-stack's margin-right above. */
.bf-gap { flex: 0 0 calc(var(--card-w) * 1.42); align-self: stretch; }
.bf-tail { flex: 1 1 auto; min-width: 0; align-self: stretch; }
/* Your own rows always keep at least one empty slot at the end to drop into. */
.battlefield:not(.mirrored) .bf-tail { min-width: calc(var(--card-w) * 1.42); }

/* Own hand: full-width fan along the bottom. Height is drag-resizable
   (--hand-h, set by board.js from a saved pref); cards scale to fill it. */
.hand-bar { flex-shrink: 0; height: var(--hand-h, 134px); position: relative;
            display: flex; align-items: center;
            gap: 8px; padding: 4px 10px; border-top: 1px solid var(--color-border);
            overflow-x: auto; overflow-y: hidden;
            --hand-card-w: calc((var(--hand-h, 134px) - 20px) * 488 / 680); }
/* A slim grab strip along the hand's top edge — drag up/down to resize. */
.hand-resize { position: absolute; top: 0; left: 0; right: 0; height: 5px;
               cursor: row-resize; touch-action: none; z-index: 3; }
.hand-resize:hover { background: var(--color-border-strong); }
.hand-bar .pile-label { position: static; transform: none; left: auto; }
/* The fan fills the bar and centres its cards; board.js::fitHandFan sets
   --hand-gap per render so cards spread with a small gap when there's room and
   only overlap as much as needed when the hand is full (#107). */
.hand-bar .hand-fan { display: flex; align-items: center; flex: 1; min-width: 0;
                      justify-content: center; }
.hand-bar .card, .hand-bar .card.has-art { margin: 0; }
.hand-bar .card.has-art, .hand-bar .card .card-img {
  width: var(--hand-card-w); min-width: var(--hand-card-w);
  max-width: var(--hand-card-w); }
.hand-bar .hand-fan .card + .card { margin-left: var(--hand-gap, -26px); }
.hand-bar .hand-fan .card:hover { z-index: 2; transform: translateY(-6px); }

.player-counter-badge { font-size: calc(20px * var(--ui-font-scale)); background: var(--color-badge-bg);
                        padding: 3px 12px; border-radius: 999px; line-height: 1;
                        display: inline-flex; align-items: center; gap: 5px;
                        font-weight: 600; white-space: nowrap;
                        /* Consistent classic ink across every badge colour; the
                           light halo keeps it legible on the dark badges. */
                        color: #111;
                        text-shadow: 0 0 1px #fff, 0 0 2px rgba(255, 255, 255, 0.85);
                        box-shadow: 0 1px 2px var(--color-menu-shadow); }
/* Bare mana-font glyph (no ms-cost pip): line-height:1 + the badge's
   align-items:center put it on the optical centre alongside the count. */
.player-counter-badge .ms { line-height: 1; }
.player-counter-badge b { font-weight: 800; }
.player-counter-badge.interactive { cursor: pointer; user-select: none; }
.player-counter-badge.interactive:hover { filter: brightness(1.12);
                        outline: 1px solid rgba(255, 255, 255, 0.55); }

/* Zone backgrounds: the battlefield and hand elements carry a zone-* class
   purely to tint their background (the base class supplies layout). */
.zone-battlefield { background: var(--color-zone-battlefield); }
.zone-hand { background: var(--color-zone-hand); }

/* Card styling */
.card { display: inline-block;
        /* Border tinted with the controller's colour (issue B), default fallback. */
        border: 1px solid var(--card-border, var(--color-card-border)); border-radius: 4px;
        padding: 4px 8px; margin: 3px; min-width: calc(var(--card-w, 96px) * 0.9);
        max-width: calc(var(--card-w, 96px) * 1.45);
        font-size: calc(11px * var(--ui-font-scale)); background: var(--color-card-bg); cursor: pointer; position: relative;
        vertical-align: top; word-wrap: break-word; transition: transform 0.15s;
        /* Each card is its own stacking context so its overlays (name / P·T /
           counters, z-index'd within the card) stay contained. Without this a
           back card's P·T escapes and paints ON TOP OF the card overlapping it,
           since a bare position:relative card isn't a stacking context. */
        isolation: isolate; }
.card:hover { border-color: var(--color-card-border-hover); z-index: 1; }
/* Rotation only — no margin. A tapped card is only ever seen on the battlefield
   (hand/piles/stack don't tap), where any margin is harmful: a top margin shoves
   the anchor down inside its attach-group (attachments look shifted up), and a
   margin: shorthand would clobber the stack's negative overlap margin-left, so
   tapped cards in a stack would spread out and push their neighbours right. The
   rotation is a transform (no layout-box change), so alignment/overlap hold. */
.card.tapped { transform: rotate(90deg); }
/* Face-down / flipped-to-back: the generic card back (same art as .card-back and
   pile backs), never a nameplate or printed P/T (#95). A manual P/T override
   (morph 2/2) still renders over it. */
.card.face-down { color: var(--color-card-facedown-text);
                  border-color: var(--color-card-facedown-border);
                  background: url("../cardback.jpg") center / cover no-repeat,
                    radial-gradient(ellipse at 50% 40%,
                      var(--color-card-back-sheen) 0%,
                      var(--color-card-facedown-bg) 75%); }
/* Kamigawa flip: the card keeps one art, rotated 180° (spun in-plane, Z axis);
   overlays stay upright. This is the resting/end state — the SPIN itself is
   animated imperatively (Web Animations API, boardSync.js:patchFlipAnim), like
   the DFC/transform Y-axis flip, because a CSS transition can't survive the
   re-render that moves the card element (#95). The transition below only smooths
   the fallback path (a class toggle with no WAAPI, e.g. replay stepping). */
.card.flipped-180 .card-img { transform: rotate(180deg); }
.card .card-img { transition: transform 0.4s cubic-bezier(0.2, 0, 0, 1); }
@media (prefers-reduced-motion: reduce) {
  .card .card-img { transition: none; }
}
.card.token { border-style: dashed;
              border-color: var(--card-border, var(--color-card-token-border)); }
/* Token art cards: the dashed marker lives on the image border. */
.card.token .card-img { border-style: dashed; }
/* An ability on the stack (#112): the source card's art, dimmed, under a
   ribbon, so it reads as "this card's ability", never as the spell itself. */
.card.ability .card-img { filter: grayscale(0.6) brightness(0.75); }
.card.ability { border-style: dotted; border-color: var(--color-accent); }
.card.ability .card-img { border-style: dotted; }
.card .card-ability-ribbon { position: absolute; left: 0; right: 0; top: 40%;
  z-index: 2; padding: 1px 0; text-align: center; pointer-events: none;
  font-size: calc(10px * var(--card-font-scale, 1)); font-weight: bold;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--color-on-primary); background: var(--color-primary); }
.card.own-hand { border-color: var(--color-card-own-border); background: var(--color-card-own-bg); }
/* Selected card (issue A): a clear ring that survives re-renders. */
.card.selected { outline: 2px solid var(--color-primary); outline-offset: 1px;
                 border-color: var(--color-accent);
                 box-shadow: 0 0 6px var(--color-accent-glow); }
.card .card-name { font-weight: bold; font-size: calc(11px * var(--ui-font-scale)); }
/* Annotation: a text strip pinned to the BOTTOM of the card (mirrors the name
   strip up top), overlaid on the art. z-index 1 keeps it under the P/T corner
   (z 2) and the counter circles (z 3). Full text shows in the hover preview.

   Sized to the P/T corner (10px), not the name strip (8px): the name is text
   you can skip — you already know the card from its art — whereas an annotation
   is a note someone wrote FOR you, and at 8px it was unreadable (#258). For the
   same reason it wraps to a second line before ellipsing, so a short note lands
   whole instead of needing a hover. */
.card .card-annotation { position: absolute; left: 0; bottom: 0;
                         /* Stop short of the P/T corner instead of running
                            under it: the P/T sits at z 2 with its own dark
                            chip, so a full-width strip put text behind it.
                            The reserve tracks --card-font-scale because the
                            P/T chip grows with it. */
                         right: calc(30px * var(--card-font-scale, 1));
                         z-index: 1; font-style: italic; color: #fff;
                         font-size: calc(10px * var(--card-font-scale, 1));
                         line-height: 1.15;
                         padding: 1px 3px; overflow: hidden;
                         display: -webkit-box; -webkit-box-orient: vertical;
                         -webkit-line-clamp: 2; line-clamp: 2;
                         overflow-wrap: anywhere;
                         text-overflow: ellipsis; border-radius: 0 0 0 5px;
                         pointer-events: none;
                         /* A SOLID strip at the same weight as the name plate
                            up top (0.72) — the text sits on an even backing
                            rather than fading out across its own height. The
                            gradient survives only as a ~5px feather on the top
                            edge, so the strip doesn't cut a hard line across
                            the art but never washes over the words. */
                         background: linear-gradient(to top,
                           rgba(0,0,0,0.72) 0,
                           rgba(0,0,0,0.72) calc(100% - 5px),
                           rgba(0,0,0,0) 100%); }

/* No-art placeholder cards (unresolved names, most tokens, face-down morphs)
   keep a real card's footprint — full --card-w wide with the card aspect ratio —
   instead of collapsing to a small text box, so they read as cards next to art. */
.card:not(.has-art) { box-sizing: border-box;
                width: var(--card-w, 96px);
                min-width: var(--card-w, 96px);
                max-width: var(--card-w, 96px);
                min-height: calc(var(--card-w, 96px) * 680 / 488); }

/* Image cards: the printing art replaces the placeholder box. Badges
   (counters / annotation / token / attachments) flow under the image.
   Sizes flow from --card-w so the board can scale cards to fit one page. */
.card.has-art { padding: 0; border: none; background: none;
                min-width: var(--card-w, 96px); max-width: var(--card-w, 96px); }
.card.has-art:hover { border: none; }
.card .card-img { display: block; width: var(--card-w, 96px); border-radius: 5px;
                  border: 1px solid var(--card-border, var(--color-card-border));
                  box-shadow: 0 1px 3px var(--color-menu-shadow);
                  /* Reserve the card's height before the art decodes, so a
                     View Transition captures stable geometry and sibling cards
                     don't drift toward a half-laid-out board and snap back. */
                  aspect-ratio: 488 / 680; }
.card.has-art:hover .card-img { border-color: var(--color-card-border-hover); }
.card.has-art.selected .card-img { border-color: var(--color-accent);
                  box-shadow: 0 0 6px var(--color-accent-glow); }
/* Name overlay: a readable strip pinned to the top of the art (issue B).
   Font size scales with the user's card-text setting (issue B follow-up). */
.card.has-art .card-name { display: block; position: absolute; top: 0; left: 0; right: 0;
  z-index: 2; font-size: calc(8px * var(--card-font-scale, 1)); font-weight: bold;
  padding: 1px 3px; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-radius: 5px 5px 0 0; pointer-events: none;
  /* Solid dark strip behind the name so it stays legible over busy art. */
  background: rgba(0, 0, 0, 0.72); }
.card.has-art .card-counters, .card.has-art .card-annotation,
.card.has-art .card-attachments, .card.has-art .card-token-badge {
  max-width: var(--card-w, 96px); }
/* Power/Toughness overlay, bottom-right of the card (issue B). */
.card .card-pt { position: absolute; bottom: 1px; right: 1px; z-index: 2;
  font-size: calc(10px * var(--card-font-scale, 1)); font-weight: bold;
  line-height: 1; padding: 1px 4px;
  border-radius: 3px; color: #fff; background: rgba(0,0,0,0.8);
  pointer-events: none; }
/* A manually-set P/T override: tinted so it reads as player-applied, not
   printed. Ringed for contrast over art. */
.card .card-pt.pt-override { background: var(--color-accent);
  color: var(--color-on-primary, #000);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.35); }
/* Marked combat damage (#204): the (effective) toughness is struck through in
   red and the remaining toughness shown beside it — "3/5̶ 2". Force the dark P/T
   backdrop even over a gold P/T-override (damage is the louder signal), so the
   red always reads instead of blending salmon-on-orange; and use the BRIGHT
   danger — a small mark needs chroma to register (design system §3.2). */
.card .card-pt.pt-damaged { background: rgba(0,0,0,0.82); color: #fff;
  box-shadow: none; }
.card .card-pt.pt-damaged .pt-tough-struck {
  color: var(--color-status-error-bright, #f27a63); text-decoration: line-through;
  text-decoration-thickness: 2px; opacity: 0.9; }
.card .card-pt.pt-damaged .pt-tough-remain {
  color: var(--color-status-error-bright, #f27a63); font-weight: bold;
  margin-left: 3px; }

/* Counter circles overlaid on the card. The overlay spans the card; each badge
   is placed by percentage (board.js counterLayout) so they stay evenly spread,
   and is individually clickable (left +1 / right −1 / middle set). */
.card .card-counter-overlay { position: absolute; inset: 0; z-index: 3;
  pointer-events: none; }
.card .counter-badge { position: absolute; transform: translate(-50%, -50%);
  min-width: calc(15px * var(--card-font-scale, 1));
  height: calc(15px * var(--card-font-scale, 1));
  padding: 0 3px; box-sizing: border-box; border-radius: 999px;
  /* A light ring reads on dark art; the dark box-shadow ring reads on light
     art. Together the circle stays legible over any card image (#141). */
  border: 1.5px solid rgba(255,255,255,0.9); display: flex;
  align-items: center; justify-content: center;
  font-size: calc(9px * var(--card-font-scale, 1)); font-weight: bold;
  line-height: 1;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.7), 0 1px 2px rgba(0,0,0,0.5); }
/* Hover is for READING, clicking is for MUTATING — so every badge takes pointer
   events (its own hover roll-out below needs them), and only `.interactive` — a
   card you control — gets the grab cursor and the drag/click handlers. Gating
   pointer-events on `.interactive` meant the kind name never rolled out on an
   opponent's permanent, which is exactly when you need to know what the three
   circles are (#258). */
.card .counter-badge { pointer-events: auto; }
.card .counter-badge.interactive { cursor: grab; }
/* The click affordance (ring + lift) stays on controllable badges only. */
.card .counter-badge.interactive:hover { outline: 1px solid #fff;
  outline-offset: -1px; filter: brightness(1.12); }
/* Hover roll-out: the count always shows; the kind name slides in beside it
   ("2" -> "2 +1/+1") and the pill widens to fit (#233). */
.card .counter-badge .cb-name { max-width: 0; overflow: hidden;
  white-space: nowrap; opacity: 0;
  transition: max-width .18s ease, opacity .18s ease, margin-left .18s ease; }
.card .counter-badge:hover { z-index: 6; }
.card .counter-badge:hover .cb-name { max-width: 96px; opacity: 1;
  margin-left: 4px; }
@media (prefers-reduced-motion: reduce) {
  .card .counter-badge .cb-name { transition: none; }
}

/* Drag-and-drop counters (#233). The chips (menu palette) and the ghost live
   OUTSIDE a .card, so they can't ride the `.card .counter-badge` sizing above —
   give them standalone circle styling. Counter circles are a semantic-circle
   exemption from the no-radius rule (like status dots). */
.counter-chip, .counter-drag-ghost {
  min-width: 22px; height: 22px; padding: 0 5px; box-sizing: border-box;
  border-radius: 999px; border: 1.5px solid rgba(255, 255, 255, 0.9);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: calc(11px * var(--ui-font-scale)); font-weight: bold; line-height: 1;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.7), 0 1px 2px rgba(0, 0, 0, 0.5); }
.counter-chip { cursor: grab; flex: 0 0 auto; }
.counter-chip-custom { background: var(--color-surface-hover);
  color: var(--color-text); border-style: dashed; }
/* A pane of grabbable rows (one counter per row) in the Counters menu. */
.counter-palette { display: flex; flex-direction: column; gap: 2px;
  padding: 4px 4px; min-width: 160px; }
.counter-palette-row { display: flex; align-items: center; gap: 8px;
  padding: 3px 8px; cursor: grab; border-radius: 4px; }
.counter-palette-row:hover { background: var(--color-surface-hover); }
.counter-palette-name { font-size: calc(13px * var(--ui-font-scale)); white-space: nowrap; }
/* Ghost + label follow the cursor; the card under the pointer gets a ring. */
.counter-drag-ghost { position: fixed; z-index: 320; pointer-events: none;
  transform: translate(-50%, -50%); cursor: grabbing; }
.counter-drag-label { position: fixed; z-index: 320; pointer-events: none;
  padding: 3px 8px; border-radius: 4px; font-size: calc(13px * var(--ui-font-scale)); font-weight: 600;
  white-space: nowrap; color: var(--color-tooltip-text);
  background: var(--color-tooltip-bg); border: 1px solid var(--color-border-soft);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35); }
.counter-drag-label.is-armed { border-color: var(--color-accent); }
.card.counter-drop-target { box-shadow: inset 0 0 0 2px var(--color-accent);
  filter: brightness(1.06); }
body.dragging-counter { cursor: grabbing; user-select: none; }

/* Settings → Counters: the personal-list editor. */
.settings-textarea { width: 100%; box-sizing: border-box; resize: vertical;
  font-family: inherit; font-size: calc(13px * var(--ui-font-scale)); padding: 8px; margin: 4px 0;
  background: var(--color-surface); color: var(--color-text);
  border: 1px solid var(--color-border-soft); }
/* Move-some slider prompt (quick-modal). */
#quick-modal-slider-wrap { display: flex; align-items: center; gap: 10px;
  margin: 6px 0; }
#quick-modal-slider { flex: 1; }
#quick-modal-slider-val { min-width: 2ch; text-align: right; font-weight: 600;
  font-size: calc(16px * var(--ui-font-scale)); }

/* Linked cards (auras / equipment / exiled-by) render offset to the LEFT,
   behind their anchor card (which stays on top and fully visible). */
.attach-group { position: relative; display: inline-block; }
/* Every attachment rises ONE constant step (top, matching ATTACH_STEP in
   board.js) and fans progressively LEFT (newest furthest out, at the back).
   Nesting accumulates because a sub-group is itself offset from its parent, so
   an attachment-on-an-attachment climbs a second step up-and-left. Child (>)
   selectors so each level is offset only by its own parent group. */
.attach-group > .attached-child { position: absolute; z-index: 0; margin: 0;
  top: -20px; left: calc(var(--attach-i, 1) * -20px); }
.attach-group > .card:last-child { position: relative; z-index: 1; }
/* The wheel's pick (#321) outranks the anchor's own z-index 1 above, which ties
   `.bf-stack .card.bf-raised` on specificity and, coming later, used to win: a
   raised anchor stayed under an attachment the pointer was hovering. A nested
   attachment's sub-group is a stacking context of its own (absolute + z 0), so
   a pick inside it has to lift the sub-group too, or it can't clear its parent's
   anchor. */
.attach-group > .card.bf-raised { z-index: 6; }
.attach-group > .attach-group:has(.bf-raised) { z-index: 6; }

/* Face-down card backs: opponent hands + library piles. Placeholder chrome
   only — not .card, so drag/click handlers ignore them. The real card back
   image sits over a gradient that shows until it loads. */
.card-back { width: var(--card-w, 96px); aspect-ratio: 488 / 680; border-radius: 5px;
             display: inline-block; margin: 3px; vertical-align: top;
             border: 2px solid var(--color-card-facedown-border);
             background: url("../cardback.jpg") center / cover no-repeat,
               radial-gradient(ellipse at 50% 40%,
                 var(--color-card-back-sheen) 0%,
                 var(--color-card-facedown-bg) 75%);
             box-shadow: 0 1px 3px var(--color-menu-shadow); }
/* Opponent hand: overlap the backs so big hands stay compact. */

/* Card-shaped drop slots (graveyard / exile / "Exiled by…"). They carry the
   parent zone's data-zone-key so drops resolve to them (deeper element wins);
   an optional data-drop-link additionally starts a link pick on drop. */
.card-slot { width: var(--card-w, 96px); aspect-ratio: 488 / 680; border-radius: 5px;
             display: inline-flex; align-items: center; justify-content: center;
             margin: 3px; padding: 6px; vertical-align: top; text-align: center;
             border: 2px dashed var(--color-border-strong);
             color: var(--color-text-faint); font-size: calc(11px * var(--ui-font-scale));
             text-transform: uppercase; letter-spacing: 0.5px; }
.card-slot.drop-target { border-color: var(--color-accent);
                         background: var(--color-accent-glow);
                         color: var(--color-text); }

/* Clickable pile backs (own library / face-down subzone piles). */
.card-back.clickable { cursor: pointer; }
.card-back.clickable:hover { box-shadow: 0 0 6px var(--color-accent-glow);
                             border-color: var(--color-accent); }

/* Zone browser (issue K): an in-screen modal listing a zone's cards as full,
   interactable, draggable cards. Supersedes the old read-only Peek. */
/* Floating zone windows (issue K): non-modal, draggable panels — no backdrop,
   no scrim, several open at once. They never cover the whole board, so a card
   drags freely between windows and the battlefield (drop lands on whatever's
   under the cursor). Drag the header to move one aside. The drag ghost (z 200)
   and card menus (z 100) sit above the windows (z ~40+). */
/* Chamfered like a .plate (two clipped pseudo-layers) rather than by a bare
   clip-path: a clip-path on the element itself would cut off both the border
   AND the box-shadow at the 45° corners, leaving them open (see design-system
   §6). ::before is the gilded edge, ::after the face inset 1px; the elevation
   is a drop-shadow on the window (the shadow follows the chamfer and, unlike
   box-shadow, isn't eaten by the corner cut or the window's own overflow). */
.zone-window { position: fixed; display: flex; flex-direction: column;
               width: min(680px, 84vw); max-height: 70vh; z-index: 200;
               isolation: isolate; background: transparent; overflow: hidden;
               filter: drop-shadow(0 8px 30px var(--color-menu-shadow));
               /* Whole window is a drag handle; cards/controls reset below. */
               cursor: move; user-select: none; }
.zone-window::before { content: ''; position: absolute; inset: 0; z-index: -2;
               clip-path: var(--chamfer);
               background: linear-gradient(150deg, var(--color-leaf-hair) 0%,
                 var(--color-border) 46%, var(--color-border) 100%); }
.zone-window::after { content: ''; position: absolute; inset: 1px; z-index: -1;
               clip-path: var(--chamfer); background: var(--color-surface); }
.zw-search { cursor: text; }
.zw-btn { cursor: pointer; }
.zone-window .card { cursor: pointer; }
.zw-header { display: flex; align-items: center; gap: 10px; padding: 10px 12px;
            border-bottom: 1px solid var(--color-leaf-hair); }
.zw-title { font-size: calc(12px * var(--ui-font-scale)); font-family: var(--font-display); font-weight: 700;
            color: var(--color-text);
            text-transform: uppercase; letter-spacing: 0.13em; white-space: nowrap;
            /* A long one (a random reveal's, #322) ellipses rather than
               running under the search box; the full text is its tooltip. */
            min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* Card count beside the title. On a graveyard / exile it carries the by-type
   breakdown in its tooltip (#259, #270) — a dotted underline is the standard
   "there is more here on hover" cue, and it costs no header width. */
.zw-count { font-size: calc(12px * var(--ui-font-scale)); color: var(--color-text-subtle); flex: none; }
.zw-count.has-tally { cursor: help;
                      border-bottom: 1px dotted var(--color-text-subtle); }
.zw-search { flex: 1 1 auto; min-width: 70px; padding: 5px 8px; font-size: calc(13px * var(--ui-font-scale));
            border: 1px solid var(--color-control-border); }
.zw-btn { padding: 5px 10px; font-size: calc(12px * var(--ui-font-scale));
            border: 1px solid var(--color-control-border); }
.zw-close { font-weight: bold; }
/* ✕ means "discard" only once cards are staged — until then it is a plain
   close, and colouring it would cry wolf on every window. */
.zw-close.zw-discard { color: var(--color-danger); }

/* ---- Watch panel (experimental board queries, watchPanel.js) -------------
   The zone window's material: the same two clipped pseudo-layers, so the
   chamfer keeps its gilded edge and the drop-shadow follows the cut. Narrow
   and docked top-right by default — it is glanced at, not worked in. */
.watch-panel { position: fixed; top: 64px; right: 16px; z-index: 45;
               width: min(340px, calc(100vw - 32px)); max-height: 70vh;
               display: flex; flex-direction: column; isolation: isolate;
               background: transparent; overflow: hidden;
               filter: drop-shadow(0 8px 30px var(--color-menu-shadow)); }
.watch-panel::before { content: ''; position: absolute; inset: 0; z-index: -2;
               clip-path: var(--chamfer);
               background: linear-gradient(150deg, var(--color-leaf-hair) 0%,
                 var(--color-border) 46%, var(--color-border) 100%); }
.watch-panel::after { content: ''; position: absolute; inset: 1px; z-index: -1;
               clip-path: var(--chamfer); background: var(--color-surface); }
/* Once dragged, left/top are pinned inline; drop the right-dock. */
.watch-panel[style*="left"] { right: auto; }
.wp-header { display: flex; align-items: center; gap: 8px; padding: 10px 12px;
             border-bottom: 1px solid var(--color-leaf-hair); cursor: move;
             user-select: none; }
.wp-title { font-size: calc(12px * var(--ui-font-scale)); font-family: var(--font-display); font-weight: 700;
            color: var(--color-text); text-transform: uppercase;
            letter-spacing: 0.13em; white-space: nowrap; flex: 1 1 auto; }
.wp-preset { max-width: 130px; font-size: calc(12px * var(--ui-font-scale)); padding: 4px 6px;
             border: 1px solid var(--color-control-border); }
button.wp-btn { padding: 4px 9px; font-size: calc(12px * var(--ui-font-scale)); cursor: pointer;
                border: 1px solid var(--color-control-border); }
button.wp-btn.wp-icon { padding: 2px 6px; border-color: transparent;
                        background: transparent; color: var(--color-text-subtle); }
button.wp-btn.wp-icon:hover { background: var(--color-surface-hover);
                              color: var(--color-text); }
.wp-list { overflow-y: auto; padding: 4px 0; }
.wp-row { display: flex; align-items: center; gap: 4px; padding: 4px 8px 4px 12px; }
.wp-row:hover { background: var(--color-surface-hover); }
.wp-label { flex: 1 1 auto; min-width: 0; font-size: calc(13px * var(--ui-font-scale)); overflow: hidden;
            text-overflow: ellipsis; white-space: nowrap; cursor: help; }
.wp-value { flex: none; min-width: 3ch; text-align: right; font-size: calc(16px * var(--ui-font-scale));
            font-weight: 600; font-variant-numeric: tabular-nums;
            color: var(--color-text); }
.wp-goal { font-size: calc(12px * var(--ui-font-scale)); font-weight: 400; color: var(--color-text-subtle); }
/* A goal reached: a status dot, the one place a circle is semantic. */
.wp-met .wp-value::before { content: ''; display: inline-block; width: 8px;
            height: 8px; margin-right: 6px; vertical-align: middle;
            border-radius: 50%; background: var(--color-status-ok); }
.wp-empty { padding: 10px 12px; font-size: calc(12px * var(--ui-font-scale)); color: var(--color-text-subtle); }
.wp-editor { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px;
             border-top: 1px solid var(--color-leaf-hair); }
.wp-field { display: flex; align-items: center; gap: 8px; font-size: calc(12px * var(--ui-font-scale)); }
.wp-field > span { flex: 0 0 56px; color: var(--color-text-subtle); }
.wp-field > input, .wp-field > select { flex: 1 1 auto; min-width: 0;
            padding: 4px 6px; font-size: calc(13px * var(--ui-font-scale));
            border: 1px solid var(--color-control-border); }
.wp-in-query { font-family: ui-monospace, monospace; }
.wp-editor-actions { display: flex; gap: 8px; justify-content: flex-end; }
/* align-items: flex-start is load-bearing, not tidiness. Without it a card
   STRETCHES to the tallest item on its flex line — and a card's P/T, annotation
   and counters are absolutely positioned against the card box, so a stretched
   card drops its P/T into the empty space below the art. A long vertical edge
   marker ("BOTTOM OF GRAVEYARD") was tall enough to do exactly that (#272). */
.zw-grid { --card-w: 92px; display: flex; flex-wrap: wrap; gap: 10px;
            padding: 14px; overflow-y: auto;
            align-content: flex-start; align-items: flex-start; }
.zw-grid .card { margin: 0; flex: 0 0 auto; }
/* Zone-window scrollbars carry more contrast than the global thin default
   (#225): over a grid packed with card art, a border-toned thumb on a
   transparent track disappears exactly when you need it. A visibly sunken
   track plus a mid-tone thumb makes the scroll position findable without
   reaching for gold, which stays scarce (primary action, hairlines, wordmark).
   Square like the global thumb -- the deco language rounds nothing. */
.zw-grid, .zw-action { scrollbar-width: thin;
            scrollbar-color: var(--color-text-faint) var(--color-bg-sunken); }
.zw-grid::-webkit-scrollbar,
.zw-action::-webkit-scrollbar { width: 11px; }
.zw-grid::-webkit-scrollbar-track,
.zw-action::-webkit-scrollbar-track { background: var(--color-bg-sunken); }
.zw-grid::-webkit-scrollbar-thumb,
.zw-action::-webkit-scrollbar-thumb { background: var(--color-text-faint);
            border: 3px solid transparent; background-clip: padding-box; }
.zw-grid::-webkit-scrollbar-thumb:hover,
.zw-action::-webkit-scrollbar-thumb:hover { background: var(--color-text-subtle);
            background-clip: padding-box; }
.zw-empty { color: var(--color-text-subtle); font-size: calc(13px * var(--ui-font-scale)); padding: 20px; }
/* A random reveal (#322): the picks in a "Revealed" row above the pool they
   were drawn from, which is captioned and has the picks outlined in it. */
.zw-action.zw-revealed { border-top: none; border-bottom: 1px solid var(--color-border); }
.zw-pool-head { padding: 8px 14px 0; font-size: calc(11px * var(--ui-font-scale));
                text-transform: uppercase; letter-spacing: 0.06em;
                color: var(--color-text-subtle); }
.zw-grid .card.zw-picked { outline: 2px solid var(--color-accent); outline-offset: 2px; }
/* Top/bottom-of-library markers (#224). A full-height rule beside the first /
   last card, reading vertically so it takes a sliver of width rather than a
   whole grid row — a card grid gives no other clue which end of the deck you
   are looking at, and for a scry that is the entire question. Inert: no pointer
   events, never a drop target, never in the snapshot. */
/* `height: 0` + `align-self: stretch` means the marker FILLS its row without
   ever growing it: a definite height keeps its vertical text out of the flex
   line's cross-size calculation, so no label can stretch the cards beside it
   (#272). overflow: hidden is the backstop if one is longer than a card. */
.zw-edge { flex: 0 0 auto; align-self: stretch; pointer-events: none;
            display: flex; align-items: center; justify-content: center;
            height: 0; overflow: hidden;
            min-height: calc(92px * 680 / 488);
            writing-mode: vertical-rl; text-orientation: mixed;
            font-family: var(--font-display); font-weight: 700; font-size: calc(10px * var(--ui-font-scale));
            text-transform: uppercase; letter-spacing: 0.16em;
            color: var(--color-text-subtle);
            border-left: 1px solid var(--color-leaf-hair);
            border-right: 1px solid var(--color-leaf-hair);
            padding: 0 3px; }
/* Staging rows (#134, #140, #152, #224). Each IS a drop zone: they sit directly
   under the grid, carry the grid's own card sizing and padding, and stay a full
   card tall even when empty — further rows of cards, not bars to aim at. Cards
   inside are click-to-unstage and drag-to-reorder, and dragging one from one row
   to the other moves it across. A library view you manage shows two (bottom of
   library, graveyard); other zones show none. */
/* flex-shrink 1 (not 0): in a window too short for both rows the staging area
   yields and scrolls alongside the grid, rather than crushing it to nothing. */
/* A library view carries TWO of these (#224), so the per-row cap drops from
   40vh to 26vh — both rows have to stay reachable in a short window without
   either crushing the grid to nothing. */
.zw-action { flex: 0 1 auto; padding: 10px 14px 14px; max-height: 26vh;
             overflow-y: auto; cursor: default; user-select: none;
             border-top: 1px solid var(--color-leaf-hair);
             background: var(--color-bg-sunken); }
.zw-action.drop-target { background: var(--color-surface-hover);
             box-shadow: inset 0 0 0 1px var(--color-primary); }
.zw-action.drop-target .zw-staged-label { color: var(--color-primary); }
/* Head line: the row's label, plus the "random order" toggle where the row
   offers one. space-between keeps the toggle on the far edge whatever the
   label's length. */
.zw-staged-head { display: flex; align-items: center; justify-content: space-between;
             gap: 12px; margin-bottom: 8px; }
.zw-staged-label { font-size: calc(11px * var(--ui-font-scale));
             font-family: var(--font-display); font-weight: 700;
             text-transform: uppercase; letter-spacing: 0.11em;
             color: var(--color-text-muted); }
/* A real checkbox, so it picks up the palette from :root accent-color rather
   than needing a bespoke on-state — and stays keyboard-reachable for free. */
.zw-random { display: flex; align-items: center; gap: 6px; cursor: pointer;
             font-size: calc(11px * var(--ui-font-scale)); text-transform: uppercase; letter-spacing: 0.09em;
             color: var(--color-text-subtle); white-space: nowrap;
             user-select: none; }
.zw-random:hover { color: var(--color-text); }
.zw-random input { cursor: pointer; margin: 0; }
/* Arrangement discarded: the row's single end marker becomes a matching PAIR
   bracketing the whole set (see renderStaged). Brackets rather than dimming the
   cards — dimming reads as "disabled", and these are still fully draggable in
   and out; a bracket says "grouped, order ignored", which is what is true. The
   glyph is horizontal (the labelled markers read vertically) and drops the
   letter-spacing that would push a single character off-centre. */
.zw-edge.zw-bracket { writing-mode: horizontal-tb; font-size: calc(20px * var(--ui-font-scale));
            letter-spacing: 0; color: var(--color-text-muted); }
/* Same --card-w and gap as .zw-grid so the staged cards read as one more row of
   the same set. min-height keeps the empty row card-tall (488/680 art ratio). */
.zw-staged-cards { --card-w: 92px; display: flex; flex-wrap: wrap; gap: 10px;
             align-content: flex-start;
             min-height: calc(92px * 680 / 488); }
.zw-staged-cards .card { margin: 0; flex: 0 0 auto; cursor: pointer; }
/* Card-tall, like the cards it is standing in for. The parent's min-height
   alone did not do it: the row wraps and packs its line to the start, so the
   line's height was this box's text height and the placeholder sat as a thin
   strip above a large gap. An explicit min-height is what makes the empty row
   read as the card-sized drop target it actually is. */
.zw-staged-empty { flex: 1 1 auto; display: flex; align-items: center;
             justify-content: center; font-size: calc(12px * var(--ui-font-scale)); letter-spacing: 0.04em;
             min-height: calc(var(--card-w, 92px) * 680 / 488);
             color: var(--color-text-subtle); pointer-events: none;
             border: 1px dashed var(--color-leaf-hair); }
/* Corner resize handles (inside the clipped window). Cursor signals the grab,
   but a cursor only appears once you are already on target -- so the SE corner
   (the one people reach for) carries a visible grip as well (#225). The other
   three stay unmarked: four marked corners would read as decoration and fight
   the chamfer. Handles grew 16 -> 22px so the corner is hittable without
   pixel-hunting. */
.zw-resize { position: absolute; width: 22px; height: 22px; z-index: 3; }
.zw-resize.nw { top: 0; left: 0; cursor: nwse-resize; }
.zw-resize.ne { top: 0; right: 0; cursor: nesw-resize; }
.zw-resize.sw { bottom: 0; left: 0; cursor: nesw-resize; }
.zw-resize.se { bottom: 0; right: 0; cursor: nwse-resize; }
/* Three stacked 45deg hairlines echoing the chamfer, painted into the corner.
   pointer-events stay on the parent handle -- this mark is decoration.

   The corner is CUT, not square: .zone-window's own chamfer lives on its
   ::before/::after, and the root only has overflow:hidden -- which clips
   children to the BORDER box. So a mark drawn into the square corner paints
   over the bite the chamfer took out, floating outside the window's visible
   shape. clip-path takes the same --ch cut off this mark's own bottom-right,
   which is the window's bottom-right, so the hairlines stop exactly on the
   chamfer line instead of running past it. Keyed to --ch, so a guild that
   redefines the corner geometry carries this with it. */
.zw-resize.se::after { content: ''; position: absolute; inset: 0;
            pointer-events: none;
            background: repeating-linear-gradient(135deg,
              transparent 0 3px, var(--color-border-strong) 3px 4px);
            -webkit-mask-image: linear-gradient(315deg, #000 0 42%, transparent 42%);
            mask-image: linear-gradient(315deg, #000 0 42%, transparent 42%);
            clip-path: polygon(0 0, 100% 0,
              100% calc(100% - var(--ch)), calc(100% - var(--ch)) 100%, 0 100%); }
.zone-window:hover .zw-resize.se::after { background:
            repeating-linear-gradient(135deg,
              transparent 0 3px, var(--color-text-faint) 3px 4px); }

/* Insertion caret between grid cards during a drag (drag.js) — absolutely
   positioned, so it previews the drop without shifting any card. */
.drop-caret { position: fixed; z-index: 202; pointer-events: none; width: 3px;
              background: var(--color-accent); border-radius: 2px;
              box-shadow: 0 0 6px var(--color-accent-glow); }

/* Card action menu.
   NOT chamfered, deliberately: .menu-submenu below is a position:fixed CHILD,
   and a clip-path on this element would both become its containing block and
   guillotine it. A gold hairline carries the language instead. */
.card-action-menu { position: fixed; background: var(--color-surface);
                    border: 1px solid var(--color-leaf-hair); padding: 4px;
                    /* Above #dice-layer (300) and the fx layer (350) so a die's
                       right-click menu isn't buried under the dice; below the
                       modals (400+). */
                    z-index: 360; box-shadow: 0 6px 20px var(--color-menu-shadow);
                    display: flex; flex-direction: column; gap: 1px;
                    min-width: 130px; }
.card-action-menu button { text-align: left; border: none; background: none;
                           padding: 5px 9px; font-size: calc(12px * var(--ui-font-scale)); }
.card-action-menu button:hover { background: var(--color-surface-hover);
                                 color: var(--color-leaf-bright); }
.card-action-menu button.destructive { color: var(--color-danger); }
.card-action-menu button.muted { color: var(--color-text-faint); }
/* A menu item with a keyboard shortcut: label left, dimmed combo right. Shared
   by the card/zone/board menus (menu.js) and the user-chip menu, which builds
   its own buttons but wears the same clothes. The chip menu is addressed by its
   id: `.chip-menu-*` are child classes on a container that has no class. */
.card-action-menu button.menu-has-hotkey,
#user-chip-menu button.menu-has-hotkey { display: flex; align-items: baseline;
                           justify-content: space-between; gap: 18px; }
.card-action-menu .menu-hotkey,
#user-chip-menu .menu-hotkey { opacity: 0.5; font-size: 0.85em;
                           white-space: nowrap; }

/* Custom hover tooltip (#206) — replaces native title=. A chamfered plate:
   ::before is the gilded edge, ::after the ink face (isolation:isolate is
   load-bearing so the z-index:-1/-2 pseudos don't fall behind the screen bg).
   clip-path clips box-shadow, so the drop is a filter. */
.tooltip { position: fixed; z-index: 900; pointer-events: none;
           isolation: isolate; left: 0; top: 0; max-width: 260px;
           padding: 7px 10px; font-family: var(--font-body); font-size: calc(12px * var(--ui-font-scale));
           line-height: 1.35; color: var(--color-text);
           white-space: pre-line; /* honour \n in data-tip (phase tooltips) */
           filter: drop-shadow(0 6px 16px var(--color-menu-shadow));
           opacity: 0; transition: opacity 0.12s ease; }
.tooltip.visible { opacity: 1; }
/* Structured tooltip (phase stops): bold display-face header, muted
   description, bulleted automations. */
.tooltip .tt-title { font-family: var(--font-display); font-weight: 700;
           font-size: calc(11px * var(--ui-font-scale)); text-transform: uppercase; letter-spacing: 0.08em;
           color: var(--color-text); margin-bottom: 3px; }
/* A multi-line description keeps its line breaks — renderTip joins the lines
   with \n into one node, and two sentences of guidance must not run together. */
.tooltip .tt-desc { color: var(--color-text-muted); white-space: pre-line; }
.tooltip .tt-cap { margin-top: 6px; font-size: calc(10px * var(--ui-font-scale)); text-transform: uppercase;
           letter-spacing: 0.08em; color: var(--color-text-subtle); }
.tooltip .tt-list { margin: 2px 0 0; padding-left: 15px; }
.tooltip .tt-list li { margin: 1px 0; color: var(--color-text); }
.tooltip .tt-list li::marker { color: var(--color-primary); }
.tooltip::before, .tooltip::after { content: ''; position: absolute; inset: 0;
           clip-path: var(--chamfer-sm); }
.tooltip::before { background: var(--color-leaf-hair); z-index: -2; }
.tooltip::after { inset: 1px; background: var(--color-surface); z-index: -1; }
@media (prefers-reduced-motion: reduce) { .tooltip { transition: none; } }
.card-action-menu .menu-header { padding: 5px 9px 6px; font-size: calc(10px * var(--ui-font-scale));
                    font-family: var(--font-display); font-weight: 700;
                    color: var(--color-text-muted);
                    border-bottom: 1px solid var(--color-leaf-hair);
                    margin-bottom: 3px; text-transform: uppercase;
                    letter-spacing: 0.12em; }
.card-action-menu .menu-bold { font-weight: bold; }
.card-action-menu .menu-sep { height: 1px; background: var(--color-border-subtle);
                    margin: 3px 4px; }
/* Submenu parent row: a caret on the right; hover tints like a button. */
.card-action-menu .menu-parent-head { display: flex; align-items: center;
                    justify-content: space-between; gap: 12px; width: 100%;
                    text-align: left; border: none; background: none;
                    padding: 4px 8px; font-size: calc(12px * var(--ui-font-scale)); }
.card-action-menu .menu-parent:hover > .menu-parent-head,
.card-action-menu .menu-parent-head:hover { background: var(--color-surface-hover); }
.card-action-menu .menu-caret { color: var(--color-text-faint); font-size: calc(10px * var(--ui-font-scale)); }
/* The fly-out itself: same chrome as the root menu, positioned by JS. */
.card-action-menu .menu-submenu { position: fixed; background: var(--color-surface);
                    border: 1px solid var(--color-leaf-hair); padding: 4px;
                    z-index: 101; box-shadow: 0 6px 20px var(--color-menu-shadow);
                    display: flex; flex-direction: column; gap: 1px; min-width: 130px; }
.card-action-menu .menu-submenu button { text-align: left; border: none; background: none;
                    padding: 5px 9px; font-size: calc(12px * var(--ui-font-scale)); }
.card-action-menu .menu-submenu button:hover { background: var(--color-surface-hover);
                    color: var(--color-leaf-bright); }
/* Leaf fly-outs take the chamfer; one that itself contains another fly-out
   (e.g. Move to -> library) can't — clip-path clips its nested position:fixed
   submenu (design-system §6). clip-path also clips the border + box-shadow, so
   drop them and carry the elevation on a drop-shadow filter instead. The root
   card menu stays square by design (its submenus are fixed children). */
.card-action-menu .menu-submenu:not(:has(.menu-parent)) {
                    clip-path: var(--chamfer-sm); border: none; box-shadow: none;
                    filter: drop-shadow(0 6px 20px var(--color-menu-shadow)); }

/* ---- Hover-preview anchor picker (the "fixed" position setting) --------
   A full-viewport canvas you drag a marker across. Above the settings panel
   (400) because it replaces it for the duration; below the disconnect scrim
   (500), which must always win. The marker is the point you are STORING; the
   dashed box is where the preview would actually open, i.e. the marker after
   the fit clamp — so dragging into a corner visibly stops the box while the
   marker keeps going. */
#preview-anchor-pick { position: fixed; inset: 0; z-index: 450;
                       background: rgba(0, 0, 0, 0.45); cursor: crosshair; }
#preview-anchor-pick.pa-dragging { cursor: grabbing; }
/* Translucent, not a solid slab: you are placing this box RELATIVE to the board,
   so the board has to stay visible through it. */
.pa-ghost { position: absolute; box-sizing: border-box;
            border: 2px dashed var(--color-leaf);
            background: color-mix(in srgb, var(--color-surface) 40%, transparent);
            clip-path: var(--chamfer); pointer-events: none;
            padding: 8px 10px; }
.pa-ghost-label { font-size: calc(10px * var(--ui-font-scale)); text-transform: uppercase;
                  letter-spacing: 0.16em; color: var(--color-leaf);
                  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55); }
/* The marker is a crosshair, not a dot: it marks a POINT, and the arms let you
   line it up with the board behind it. Centred on its own position; the middle
   is a chamfer-language diamond rather than the usual dot. */
.pa-marker { position: absolute; width: 46px; height: 46px; margin: -23px 0 0 -23px;
             pointer-events: none; }
.pa-marker::before, .pa-marker::after { content: ''; position: absolute;
             background: var(--color-leaf-bright);
             box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6); }
.pa-marker::before { left: 50%; top: 0; width: 2px; height: 100%; margin-left: -1px; }
.pa-marker::after { top: 50%; left: 0; height: 2px; width: 100%; margin-top: -1px; }
.pa-marker span { position: absolute; left: 50%; top: 50%;
             width: 12px; height: 12px; margin: -6px 0 0 -6px;
             background: var(--color-leaf-bright); transform: rotate(45deg);
             box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6); }
.pa-help { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%);
           margin-bottom: 0; max-width: 620px; display: flex; gap: 18px;
           align-items: center; }
.pa-help-text { font-size: calc(12px * var(--ui-font-scale)); line-height: 1.45; color: var(--color-text-muted); }
.pa-help-text strong { color: var(--color-text); }
.pa-help-actions { display: flex; gap: 8px; flex: 0 0 auto; }

/* ---- Starting-team wheel (#239) ---------------------------------------
   The pregame spin, dressed as the lobby's round table so it reads as the same
   object players were just sitting at: same ring, same tick marks, same 45°
   diamond hub. Seat colour is inlay — a rim arc and a gem per segment — rather
   than a filled wedge, so the table keeps its own surface. Above the board,
   below the disconnect scrim. */
#starting-wheel { position: fixed; inset: 0; z-index: 460; display: flex;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 22px; background: rgba(0, 0, 0, 0.55); pointer-events: none; }
.sw-stage { position: relative; width: min(52vh, 46vw, 430px); aspect-ratio: 1; }
.sw-wheel { position: absolute; inset: 0; border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%,
      var(--color-leaf-glow) 0%, transparent 44%),
    radial-gradient(circle at 50% 42%,
      var(--color-surface-raised) 0%, var(--color-bg-sunken) 100%);
  box-shadow: inset 0 0 0 1px var(--color-leaf-hair),
              0 10px 40px var(--color-menu-shadow); }
/* The tick ring, lifted from .lobby-table so the two objects are plainly kin. */
.sw-wheel::before { content: ''; position: absolute; inset: 10px;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg at 50% 50%,
    var(--color-leaf-hair) 0deg 0.3deg, transparent 0.3deg 9deg);
  -webkit-mask-image: radial-gradient(circle at 50% 50%,
    transparent 25%, #000 33%, #000 91%, transparent 99%);
  mask-image: radial-gradient(circle at 50% 50%,
    transparent 25%, #000 33%, #000 91%, transparent 99%); }
/* Diamond hub — the chamfer language at the centre of a round object. */
.sw-wheel::after { content: ''; position: absolute; left: 50%; top: 50%;
  width: 22.5%; aspect-ratio: 1; transform: translate(-50%, -50%) rotate(45deg);
  background: var(--color-surface);
  box-shadow: 0 0 0 1px var(--color-leaf-hair),
              0 4px 18px var(--color-menu-shadow); }
/* Segment divider: a hairline from hub to rim, rotated onto the boundary. */
.sw-divider { position: absolute; left: 50%; top: 4%; width: 1px; height: 46%;
  margin-left: -0.5px; transform-origin: 50% 100%;
  background: linear-gradient(to bottom,
    var(--color-leaf-hair), transparent 85%); }
/* One arm per segment, rotated to its centre, carrying the gem and rim arc. */
.sw-gem-arm { position: absolute; inset: 0; transform-origin: 50% 50%; }
/* A cut stone rather than a coloured square: the body carries a light-to-dark
   rake so it reads as a solid with a lit face, a smaller inset facet stands in
   for the table, and a glint sits on the lit corner. Three flat layers, no
   images — the same trick the plate edges use for gilding. */
.sw-gem { position: absolute; left: 50%; top: 16%; width: 18px; height: 18px;
  margin-left: -9px; transform: rotate(45deg);
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--gem) 55%, #fff) 0%,
    var(--gem) 42%,
    color-mix(in srgb, var(--gem) 62%, #000) 100%);
  box-shadow: 0 0 0 1px var(--color-leaf-hair),
              0 0 14px color-mix(in srgb, var(--gem) 70%, transparent),
              inset 0 0 0 1px color-mix(in srgb, var(--gem) 55%, #fff); }
/* The table facet: a smaller diamond, brighter at the top-left. */
.sw-gem-facet { position: absolute; inset: 26%;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--gem) 25%, #fff) 0%,
    color-mix(in srgb, var(--gem) 85%, #fff) 55%,
    var(--gem) 100%);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gem) 40%, #000); }
/* One specular glint on the lit corner — small, so it reads as cut, not shiny. */
.sw-gem-glint { position: absolute; left: 14%; top: 14%; width: 26%; height: 26%;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), transparent 70%); }
/* The seat colours, as a band around the rim — one conic gradient masked to a
   ring, so each team owns an ARC rather than a painted wedge. */
.sw-rim { position: absolute; inset: 0; border-radius: 50%; opacity: 0.8;
  /* closest-side, so 100% is the wheel's edge rather than the box's corner —
     a farthest-corner mask puts the band outside the circle and it vanishes. */
  -webkit-mask-image: radial-gradient(circle closest-side at 50% 50%,
    transparent 86%, #000 89%, #000 98%, transparent 100%);
  mask-image: radial-gradient(circle closest-side at 50% 50%,
    transparent 86%, #000 89%, #000 98%, transparent 100%); }
/* Fixed pointer at the top — the wheel turns under it. */
.sw-pointer { position: absolute; left: 50%; top: -14px; width: 18px;
  height: 22px; margin-left: -9px; z-index: 2;
  background: var(--color-leaf-bright);
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6)); }
/* The caption is empty until the wheel lands, and it is a flex ITEM — so
   without a reserved line the column grows when the name appears and the
   centred wheel jumps up by half a line. Height is held from the start. */
.sw-caption { font-family: var(--font-display, inherit); font-size: calc(20px * var(--ui-font-scale));
  line-height: 1.35; min-height: 1.35em;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--color-text);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8); opacity: 0.55;
  transition: opacity 0.35s; }
#starting-wheel.sw-landed .sw-caption { opacity: 1; }
#starting-wheel.sw-landed .sw-wheel { transition: transform 0.4s ease-out; }

/* Settings modal */
/* Non-modal: a transparent, click-through layer (no backdrop) so the board
   behind stays fully interactive; only the floating panel captures pointer. */
#settings-modal { position: fixed; inset: 0; z-index: 400; pointer-events: none; }
/* Chamfered by clip-path rather than by .plate's pseudo-layers: modal panels
   are self-contained (they already clip their own overflow), and their only
   popups are native select/colour widgets, which the OS draws outside the
   page and clip-path cannot touch. */
#settings-modal .modal-panel { position: fixed; pointer-events: auto;
                               top: 8vh; left: 50%; transform: translateX(-50%);
                               min-width: 320px; max-height: 84vh; overflow: auto;
                               background: var(--color-surface);
                               border: 1px solid var(--color-leaf-hair);
                               clip-path: var(--chamfer); padding: 20px 22px;
                               box-shadow: 0 8px 30px var(--color-menu-shadow); }
/* Once dragged, board.js/settings.js pins left/top and clears the centering
   transform (via the .dragged marker). */
#settings-modal .modal-panel.dragged { transform: none; }
#settings-modal h3 { margin-bottom: 16px; font-size: calc(12px * var(--ui-font-scale));
                     font-family: var(--font-display); font-weight: 700;
                     color: var(--color-text); text-transform: uppercase;
                     letter-spacing: 0.14em; }
#settings-modal .settings-drag-handle { cursor: move; user-select: none; }
/* Sectioned settings: left nav swaps the right content pane. */
/* Explicit width (not min/max): a shrink-to-fit width recomputed per tab and on
   drag made the panel jump size when switching to a content-heavier tab and
   when the centering transform was dropped mid-drag. A fixed width is stable. */
#settings-modal .modal-panel.settings-panel { width: min(640px, 92vw);
                     max-width: 92vw; }
.settings-layout { display: flex; gap: 16px; min-height: 300px; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; min-width: 116px;
                border-right: 1px solid var(--color-leaf-hair);
                padding-right: 8px; }
.settings-nav button { text-align: left; padding: 7px 11px; border: none;
                background: none; cursor: pointer;
                font-size: calc(13px * var(--ui-font-scale)); color: var(--color-text); }
.settings-nav button:hover { background: var(--color-surface-hover); }
.settings-nav button.active { background: var(--color-primary);
                color: var(--color-on-primary); font-weight: 600; }
.settings-content { flex: 1; min-width: 0; max-height: 60vh; overflow-y: auto;
                padding-right: 4px; }
.settings-subactions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.settings-row { display: flex; justify-content: space-between; align-items: center;
                gap: 16px; padding: 6px 0 14px; font-size: calc(13px * var(--ui-font-scale)); }
/* A read-only figure sitting beside its control (the saved preview anchor). */
.settings-value { margin-left: auto; font-variant-numeric: tabular-nums;
                color: var(--color-text-muted); }
.theme-toggle { display: flex; }
.theme-toggle button { border-radius: 0; padding: 4px 14px;
                       border-color: var(--color-control-border); }
.theme-toggle button:last-child { border-left: none; }
.theme-toggle button.active { background: var(--color-primary);
                              color: var(--color-on-primary);
                              border-color: var(--color-primary); }
.modal-buttons { display: flex; justify-content: flex-end; gap: 8px;
                 border-top: 1px solid var(--color-border-subtle); padding-top: 12px; }
.settings-section-title { font-size: calc(11px * var(--ui-font-scale)); text-transform: uppercase;
                 letter-spacing: 0.5px; color: var(--color-text-muted);
                 margin-top: 6px; padding-top: 10px;
                 border-top: 1px solid var(--color-border-subtle); }

/* ---- Colors section (theme picker + per-token colour grid) ------------- */
.settings-hint { font-size: calc(11px * var(--ui-font-scale)); color: var(--color-text-muted);
                 margin: 2px 0 6px; line-height: 1.4; }
.color-group { margin-bottom: 2px; }
.color-row { display: flex; align-items: center;
                 gap: 12px; padding: 3px 0; font-size: calc(13px * var(--ui-font-scale)); }
.color-row label { flex: 1; }
.color-row input.color-token { width: 40px; height: 24px; padding: 0; flex: none;
                 border: 1px solid var(--color-control-border);
                 background: none; cursor: pointer; }
.color-row input.color-alpha { width: 80px; flex: none; }
.keybind-row { padding: 6px 0; }
.keybind-btn { font-size: calc(12px * var(--ui-font-scale)); padding: 4px 10px;
                 min-width: 90px; text-align: center;
                 border: 1px solid var(--color-control-border); }
.keybind-btn.capturing { border-color: var(--color-primary);
                 color: var(--color-primary); }

/* ---- Keybinds section (in the settings content pane) ------------------ */
.keybinds-hint { font-size: calc(11px * var(--ui-font-scale)); color: var(--color-text-muted);
                 margin-bottom: 10px; line-height: 1.4; }
#keybinds-list { overflow-y: auto; margin-bottom: 12px;
                 scrollbar-width: thin;
                 scrollbar-color: var(--color-border) transparent; }
/* Row: label | shortcut button | conflict note. */
#keybinds-list .keybind-row { display: grid;
                 grid-template-columns: 1fr auto; align-items: center;
                 gap: 6px 12px; padding: 7px 8px;
                 border: 1px solid transparent; }
#keybinds-list .keybind-row + .keybind-row { margin-top: 2px; }
.keybind-label { font-size: calc(13px * var(--ui-font-scale)); }
/* Conflict warning spans both columns on its own line under the row. */
.keybind-warn { grid-column: 1 / -1; font-size: calc(11px * var(--ui-font-scale)); font-weight: 600; }
/* Internal clash (two actions, same combo) — the harder error. */
.keybind-row.keybind-conflict { border-color: var(--color-danger, #d9534f);
                 background: var(--color-danger-glow, rgba(217, 83, 79, 0.12)); }
.keybind-row.keybind-conflict .keybind-warn { color: var(--color-danger, #d9534f); }
/* Browser-reserved — advisory amber. */
.keybind-row.keybind-browser { border-color: var(--color-warning, #c9820b);
                 background: var(--color-warning-glow, rgba(201, 130, 11, 0.12)); }
.keybind-row.keybind-browser .keybind-warn { color: var(--color-warning, #c9820b); }

/* Quick prompt modal (Set life; reused by later Set P/T) */
#quick-modal { position: fixed; inset: 0; z-index: 500;
               display: flex; align-items: center; justify-content: center; }
/* ---- Shared base modal (modal.js) ------------------------------------- */
.app-modal { position: fixed; inset: 0; z-index: 400; }
.app-modal .modal-backdrop { position: absolute; inset: 0;
               background: var(--color-scrim); }
.app-modal-panel { position: fixed; display: flex; flex-direction: column;
               max-width: min(92vw, 720px); max-height: 86vh;
               background: var(--color-surface);
               border: 1px solid var(--color-leaf-hair);
               clip-path: var(--chamfer);
               box-shadow: 0 12px 44px var(--color-menu-shadow); overflow: hidden; }
/* Centred by default (and stays centred as async content grows); dragging
   switches the panel to an explicit top-left position (modal.js). */
.app-modal-panel.is-centered { left: 50%; top: 50%;
               transform: translate(-50%, -50%); }
.app-modal-header { display: flex; align-items: center; gap: 10px; cursor: move;
               padding: 13px 16px; border-bottom: 1px solid var(--color-leaf-hair);
               user-select: none; }
.app-modal-title { flex: 1; margin: 0; font-size: calc(12px * var(--ui-font-scale));
               font-family: var(--font-display); font-weight: 700;
               text-transform: uppercase; letter-spacing: 0.14em; }
.app-modal-close { border: none; background: none; cursor: pointer;
               font-size: calc(22px * var(--ui-font-scale)); line-height: 1; color: var(--color-text-subtle);
               padding: 0 4px; }
.app-modal-close:hover { color: var(--color-text); }
.app-modal-body { padding: 14px; overflow-y: auto; }

/* Shared colour picker popup (colorPicker.js). */
.color-picker-modal .app-modal-body { display: flex; flex-direction: column;
               gap: 10px; }
.cp-preview { height: 44px;
               border: 1px solid var(--color-border);
               background-image:
                 linear-gradient(45deg, #bbb 25%, transparent 25%),
                 linear-gradient(-45deg, #bbb 25%, transparent 25%),
                 linear-gradient(45deg, transparent 75%, #bbb 75%),
                 linear-gradient(-45deg, transparent 75%, #bbb 75%);
               background-size: 14px 14px;
               background-position: 0 0, 0 7px, 7px -7px, -7px 0; }
.cp-field { display: flex; align-items: center; gap: 10px; font-size: calc(13px * var(--ui-font-scale)); }
.cp-field span { flex: 0 0 62px; color: var(--color-text-muted); }
.cp-field input[type="color"] { width: 44px; height: 26px; padding: 0;
               border: 1px solid var(--color-control-border);
               background: none; cursor: pointer; }
.cp-field input[type="range"] { flex: 1; }
.cp-field input[type="text"] { flex: 1; padding: 5px 8px;
               font-family: var(--font-mono);
               border: 1px solid var(--color-control-border);
               background: var(--color-bg-sunken); color: var(--color-text); }

#quick-modal .modal-backdrop { position: absolute; inset: 0;
               background: var(--color-scrim); }
.quick-modal-panel { position: relative; min-width: 260px;
               background: var(--color-surface);
               border: 1px solid var(--color-leaf-hair);
               clip-path: var(--chamfer);
               padding: 18px 20px; box-shadow: 0 8px 30px var(--color-menu-shadow); }
.quick-modal-panel h3 { margin-bottom: 12px; font-size: calc(12px * var(--ui-font-scale));
               font-family: var(--font-display); font-weight: 700;
               color: var(--color-text); text-transform: uppercase;
               letter-spacing: 0.14em; }
#quick-modal-input { width: 100%; margin-bottom: 12px; padding: 6px 8px;
               font-size: calc(14px * var(--ui-font-scale)); }
/* Segmented toggle for prompts whose input reads more than one way (#229's
   base-vs-final P/T). Mirrors .theme-toggle rather than inventing a second
   segmented look — same joined buttons, same gold active fill.
   The ID carries specificity 1-1-1, clearing the generic `button:hover`
   background SHORTHAND (0-1-1) that has twice eaten a lone class's fill here;
   the explicit :hover below keeps that deliberate rather than incidental. */
#quick-modal-toggle { display: flex; margin-bottom: 12px; }
#quick-modal-toggle button { border-radius: 0; padding: 4px 14px;
               font-size: calc(12px * var(--ui-font-scale)); letter-spacing: 0.04em;
               border: 1px solid var(--color-control-border); }
#quick-modal-toggle button:last-child { border-left: none; }
#quick-modal-toggle button:hover { background: var(--color-surface-hover); }
#quick-modal-toggle button.qm-toggle-on,
#quick-modal-toggle button.qm-toggle-on:hover {
               background: var(--color-primary);
               color: var(--color-on-primary);
               border-color: var(--color-primary); }
/* Name+count mode (#114): the quantity field sits under the name, narrower. */
#quick-modal-count { width: 120px; margin-bottom: 12px; padding: 6px 8px;
               font-size: calc(14px * var(--ui-font-scale)); box-sizing: border-box; }
#quick-modal-textarea { width: 100%; margin-bottom: 12px; padding: 6px 8px;
               font-size: calc(13px * var(--ui-font-scale)); font-family: monospace; resize: vertical;
               box-sizing: border-box; }

/* Roll-dice modal (diceModal.js): quantity + a grid of die sizes. Reuses the
   quick-modal panel look. Die buttons are qualified (button.dice-side-btn) and
   given explicit hover/selected states so the generic button:hover shorthand
   can't wipe their fill (the specificity trap). */
.dice-modal { position: fixed; inset: 0; z-index: 500;
               display: flex; align-items: center; justify-content: center; }
.dice-modal .modal-backdrop { position: absolute; inset: 0;
               background: var(--color-scrim); }
.dice-modal-panel { position: relative; min-width: 280px; }
.dice-count-row { display: flex; align-items: center; justify-content: space-between;
               gap: 12px; margin-bottom: 12px; font-size: calc(13px * var(--ui-font-scale));
               color: var(--color-text); }
.dice-count-row input { width: 74px; padding: 6px 8px; text-align: right;
               font-size: calc(14px * var(--ui-font-scale)); border: 1px solid var(--color-control-border);
               background: var(--color-bg-sunken); color: var(--color-text); }
.dice-sides { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
               margin-bottom: 14px; }
button.dice-side-btn { padding: 9px 0; cursor: pointer; font-size: calc(13px * var(--ui-font-scale));
               font-family: var(--font-body); color: var(--color-text);
               border: 1px solid var(--color-control-border);
               background: var(--color-bg-sunken); }
button.dice-side-btn:hover { border-color: var(--color-primary); }
button.dice-side-btn.selected { border-color: var(--color-primary);
               color: var(--color-primary); font-weight: 700; }

/* First-run welcome dialog (firstrun.js) — modal, centred, blocks the app. */
#welcome-modal { position: fixed; inset: 0; z-index: 600;
               display: flex; align-items: center; justify-content: center; }
#welcome-modal .modal-backdrop { position: absolute; inset: 0;
               background: var(--color-scrim); }
.welcome-panel { position: relative; width: min(440px, 92vw);
               background:
                 radial-gradient(120% 70% at 50% 0%,
                   var(--color-leaf-glow) 0%, transparent 58%),
                 var(--color-surface);
               border: 1px solid var(--color-leaf-hair);
               clip-path: var(--chamfer-lg);
               padding: 26px 26px 22px;
               box-shadow: 0 12px 44px var(--color-menu-shadow); }
/* Reuses .wordmark wholesale — same gilding, same strike-in, just sized for a
   dialog. Scoped overrides only, so the two can never drift apart. */
.welcome-panel .welcome-mark { font-size: calc(clamp(1.9rem, 6vw, 2.5rem) * var(--ui-font-scale));
               text-align: center; margin-bottom: 14px; }
.welcome-panel .mast-orn { margin-bottom: 16px; }
.welcome-panel .orn-rule { width: clamp(40px, 16vw, 96px); }
.welcome-intro { font-size: calc(13px * var(--ui-font-scale)); color: var(--color-text-muted);
               margin-bottom: 18px; line-height: 1.5; text-align: center; }
.welcome-field { display: flex; align-items: center; justify-content: space-between;
               gap: 12px; margin-bottom: 12px; font-size: calc(13px * var(--ui-font-scale)); }
.welcome-field > span { color: var(--color-text-muted); }
.welcome-field input[type="text"], .welcome-field select { flex: 1; max-width: 60%;
               padding: 6px 8px; font-size: calc(14px * var(--ui-font-scale)); }
.welcome-field input[type="color"], .welcome-color-btn {
               width: 44px; height: 26px; padding: 0;
               border: 1px solid var(--color-control-border);
               cursor: pointer; }
.welcome-color-btn:hover { box-shadow: 0 0 0 2px var(--color-accent); }
.welcome-privacy { font-size: calc(11px * var(--ui-font-scale)); color: var(--color-text-subtle);
               line-height: 1.5; margin: 6px 0 14px;
               border-top: 1px solid var(--color-leaf-hair); padding-top: 12px; }

/* Counter-color editor rows in the settings body. */
.settings-row.cc-row { padding: 4px 0; }
.cc-row .cc-name { flex: 1; font-family: monospace; }
.cc-row .cc-color, .cc-add-row input[type="color"] { width: 34px; height: 22px;
               padding: 0; border: 1px solid var(--color-control-border);
               background: none; cursor: pointer; }
.cc-row .cc-remove { border: none; background: none; cursor: pointer;
               color: var(--color-text-muted); font-size: calc(14px * var(--ui-font-scale)); line-height: 1; }
.cc-row .cc-remove:hover { color: var(--color-danger); }
.settings-row.cc-add-row { gap: 8px; padding-top: 6px; }
.cc-add-row #cc-new-name { flex: 1; min-width: 0; }

/* Notification */
/* Toasts stack top-centre, newest below, so simultaneous messages (two players
   rolling at once) don't overlap on the same spot. */
#toast-stack { position: fixed; top: 50px; left: 50%; transform: translateX(-50%);
               z-index: 200; display: flex; flex-direction: column; gap: 8px;
               align-items: center; pointer-events: none; }
/* Chamfered fill only — no border. A clip-path slices a border at the 45° cut,
   leaving the corners looking bitten off; a drop-shadow follows the clip cleanly
   and gives the edge definition the border used to. */
.notification { background: var(--color-tooltip-bg); color: var(--color-tooltip-text);
                padding: 9px 18px; clip-path: var(--chamfer-sm);
                filter: drop-shadow(0 1px 0 var(--color-leaf-hair))
                        drop-shadow(0 2px 7px rgba(0, 0, 0, 0.5));
                font-size: calc(14px * var(--ui-font-scale)); transition: opacity 0.3s; }
.notification.error { background: var(--color-status-error); }

/* Stale-client banner (#292): the running server is a different build from the
   one this page was loaded as. Bottom-centre and quiet — it is news, not an
   interruption, and a player mid-combat gets to finish. Chamfered fill with a
   drop-shadow, like the toasts; nothing here is rounded. */
#build-banner {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  z-index: 250; display: flex; align-items: center; gap: 12px;
  background: var(--color-surface); color: var(--color-text);
  border-left: 3px solid var(--color-primary);
  padding: 10px 14px; font-size: calc(13px * var(--ui-font-scale));
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}
#build-banner button {
  border: none; cursor: pointer; font: inherit;
}
.build-banner-reload {
  background: var(--color-primary); color: var(--color-bg);
  padding: 5px 14px; font-size: calc(12px * var(--ui-font-scale)); font-weight: 600;
  letter-spacing: 0.03em; text-transform: uppercase;
}
.build-banner-reload:hover { background: var(--color-primary-hover); }
.build-banner-dismiss {
  background: none; color: var(--color-text-subtle);
  padding: 0 2px; font-size: calc(16px * var(--ui-font-scale)); line-height: 1;
}
.build-banner-dismiss:hover { color: var(--color-text); }

/* Interrupt window — countdown toast + resume prompt (#7/#8).
   Both sit in #toast-stack alongside regular notifications but persist until
   the server sends a close event. pointer-events: auto overrides the stack's
   pointer-events: none so buttons are clickable. */
.interrupt-toast,
.interrupt-resume-prompt {
  background: var(--color-surface);
  color: var(--color-tooltip-text);
  padding: 12px 20px;
  min-width: 280px;
  max-width: 400px;
  border-left: 3px solid var(--color-primary);
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
  pointer-events: auto;
  display: flex; flex-direction: column; gap: 8px;
  opacity: 0.45;
  transition: opacity 0.2s ease;
}
.interrupt-toast:hover,
.interrupt-resume-prompt:hover {
  opacity: 1;
}
.interrupt-toast-text,
.interrupt-resume-text { font-size: calc(14px * var(--ui-font-scale)); line-height: 1.4; }
/* Shrinking progress bar. */
.interrupt-toast-bar {
  height: 4px; background: var(--color-surface-raised); overflow: hidden;
}
.interrupt-toast-bar-fill {
  height: 100%; width: 100%; background: var(--color-primary);
}
/* Buttons share the primary-action style: gold fill on dark, dark fill on light,
   no border-radius (Orzhov convention). */
.interrupt-toast-btn,
.interrupt-resume-btn {
  align-self: flex-end;
  background: var(--color-primary); color: var(--color-bg);
  border: none; padding: 6px 16px; cursor: pointer;
  font: inherit; font-size: calc(13px * var(--ui-font-scale)); font-weight: 600;
  letter-spacing: 0.03em; text-transform: uppercase;
}
.interrupt-toast-btn:hover,
.interrupt-resume-btn:hover {
  background: var(--color-primary-hover);
}

/* Event log entry styles live in the pop-out window document (eventlog.js). */

/* Game over overlay */
.game-over { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%);
             z-index: 120; min-width: 320px;
             background: var(--color-overlay); color: var(--color-header-text);
             padding: 28px 32px; clip-path: var(--chamfer);
             border: 1px solid var(--color-leaf-hair); text-align: center; }
.game-over h2 { margin-bottom: 10px; font-family: var(--font-display);
             font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
             color: var(--color-leaf); }
.game-over .game-over-btn { margin-top: 12px; padding: 8px 18px; font-size: calc(14px * var(--ui-font-scale));
             font-weight: bold; border-color: var(--color-primary);
             color: var(--color-primary); background: var(--color-surface); }
.game-over .game-over-btn:hover { background: var(--color-primary);
             color: var(--color-on-primary); }

/* AI player controls */
.ai-controls { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ai-controls select { padding: 5px 9px; border: 1px solid var(--color-border);
                       font-size: calc(13px * var(--ui-font-scale)); font-family: inherit; }
.ai-badge { display: inline-block; font-size: calc(9px * var(--ui-font-scale)); background: var(--color-ai);
            color: var(--color-on-ai); padding: 1px 5px; margin-left: 4px;
            text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; }
.team-badge { display: inline-block; min-width: 16px; text-align: center;
              font-size: calc(9px * var(--ui-font-scale)); font-weight: 700; padding: 1px 5px;
              letter-spacing: 0.08em; color: #fff; }
.team-badge.team-A { background: var(--color-team-a, #3b82f6); }
.team-badge.team-B { background: var(--color-team-b, #ef4444); }
/* Team tint (#262): the chip's FACE takes a wash of the team colour, so the two
   sides of the table read as two sides at a glance.
   Deliberately the face (::after) and not `--edge`: the edge already carries
   IDENTITY — gold for your own seat, error-red when disconnected — and those
   must survive team mode. Edge = who you are, face = who you're with. The chip
   is a chamfered plate (border: none, clip-path pseudos), so a border-left here
   would simply not render; the face background is the only surface to tint.
   `color-mix` against the same token keeps it honest in both themes rather than
   hard-coding a second pair of hexes. */
.lobby-chip.on-team-A::after {
  background: color-mix(in srgb, var(--color-team-a) 12%,
                        var(--color-surface)); }
.lobby-chip.on-team-B::after {
  background: color-mix(in srgb, var(--color-team-b) 12%,
                        var(--color-surface)); }
[data-action="cycleTeam"] { cursor: pointer; }
.btn-inline-danger { font-size: calc(11px * var(--ui-font-scale)); padding: 1px 6px; color: var(--color-danger); }
.btn-inline { font-size: calc(11px * var(--ui-font-scale)); padding: 2px 8px; }

/* Replay controls */
#replay-bar { display: flex; align-items: center; gap: 8px; padding: 6px 16px;
              background: var(--color-replay-bg); color: var(--color-replay-text);
              flex-shrink: 0; font-size: calc(13px * var(--ui-font-scale)); }
#replay-bar .replay-label { font-weight: bold; color: var(--color-replay-label); }
#replay-bar .replay-progress { color: var(--color-replay-progress); font-family: monospace;
                               font-size: calc(12px * var(--ui-font-scale)); }
#replay-bar button { background: var(--color-replay-control); color: var(--color-replay-text);
                     border-color: var(--color-replay-control-border); }
#replay-bar button:hover { background: var(--color-replay-control-hover); }

/* Replay section in lobby */
#replay-section { border-top: 1px solid var(--color-border-soft); padding-top: 12px; margin-top: 12px; }

/* =========================================================================
 * Screens: main / lobby / game
 * ========================================================================= */
#app { flex: 1; display: flex; overflow: hidden; }
.screen { flex: 1; display: flex; overflow: hidden; }

/* -- The two deco screens -------------------------------------------------
 * Axial, scrolling, and atmospheric. Deco composes around a centre line, so
 * these do too: the masthead owns the axis and the columns hang off it.
 *
 * The background is three layers, not a flat fill: a cool lift at the top
 * (light falling from above the masthead), a leaf-tinted bloom behind it, and
 * the ink. Then ::after lays grain over everything — scoped to these two
 * screens rather than <body>, so the board's card art stays untouched. */
.screen-main, .screen-lobby {
  position: relative;
  flex-direction: column; align-items: center;
  overflow-y: auto; overflow-x: hidden;
  padding: 0 22px 96px;
  background:
    radial-gradient(140% 70% at 50% -8%,
      var(--color-leaf-glow) 0%, transparent 58%),
    radial-gradient(100% 60% at 50% 0%,
      var(--color-surface) 0%, transparent 70%),
    var(--color-bg);
}
/* Film grain. An inline feTurbulence is ~200 bytes and needs no asset; at 4%
   it is invisible as texture and does all the work of stopping the large flat
   ink fields from banding. */
.screen-main::after, .screen-lobby::after {
  content: ''; position: fixed; inset: 0; z-index: 1;
  pointer-events: none; opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Radiant burst: the deco signature. A repeating conic gradient fanned from
   just above the masthead, masked to fade out radially so it reads as light
   rather than as a pattern. Purely decorative and pointer-transparent.

   Restraint is the entire job here. At full strength this reads as starburst
   wallpaper and eats the wordmark it is supposed to be lighting; it wants to
   be at the edge of noticing — the impression of gilding catching light
   behind the masthead, not a sunburst. Hence the low duty cycle (1.2° of 9°),
   the fast radial fade, and the low opacity on top of both. */
.rays {
  position: absolute; top: -6vmax; left: 50%; z-index: 0;
  width: 128vmax; height: 66vmax;
  transform: translateX(-50%);
  pointer-events: none; opacity: 0.4;
  background: repeating-conic-gradient(from -95deg at 50% 6%,
    var(--color-leaf-glow) 0deg 1.2deg, transparent 1.2deg 9deg);
  -webkit-mask-image: radial-gradient(40% 44% at 50% 5%,
    #000 0%, rgba(0, 0, 0, 0.34) 36%, transparent 66%);
  mask-image: radial-gradient(40% 44% at 50% 5%,
    #000 0%, rgba(0, 0, 0, 0.34) 36%, transparent 66%);
}
/* The lobby's rays sit quieter still — no wordmark to anchor them, and the
   table below is what should hold the eye. */
.rays-low { opacity: 0.22; }

/* -- Masthead -------------------------------------------------------------
 * The one thing someone remembers. Cinzel caps at display size, gilded with a
 * vertical gradient so the letterforms read as struck metal rather than
 * yellow text, wide-tracked the way inscriptional lettering is always cut. */
.masthead { position: relative; z-index: 2; text-align: center;
            padding: clamp(38px, 7vh, 76px) 0 clamp(30px, 5vh, 52px); }
.mast-orn { display: flex; align-items: center; justify-content: center;
            gap: 12px; margin-bottom: 20px; }
.orn-rule { display: block; width: clamp(50px, 12vw, 150px); height: 1px;
            background: linear-gradient(90deg,
              transparent, var(--color-leaf) 85%); }
.orn-rule:last-child { background: linear-gradient(270deg,
              transparent, var(--color-leaf) 85%); }
/* The lozenge: a square stood on its corner. The deco full stop. */
.orn-lozenge { display: block; width: 7px; height: 7px; flex: none;
               background: var(--color-leaf); transform: rotate(45deg);
               box-shadow: 0 0 10px var(--color-leaf-glow); }
.wordmark {
  font-family: var(--font-display); font-weight: 900;
  font-size: calc(clamp(2.4rem, 7.4vw, 5.4rem) * var(--ui-font-scale)); line-height: 0.98;
  text-transform: uppercase; letter-spacing: 0.16em;
  /* Tracking adds space to the RIGHT of the last letter too, which shoves an
     otherwise-centred word visibly off-axis. Half the tracking back as an
     indent re-centres it. */
  text-indent: 0.16em;
  background: linear-gradient(178deg,
    var(--color-leaf-bright) 0%, var(--color-leaf) 46%,
    var(--color-leaf-dim) 99%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 18px var(--color-leaf-glow));
}
.mast-sub { margin-top: 16px; font-size: calc(clamp(10px, 1.1vw, 12px) * var(--ui-font-scale));
            text-transform: uppercase; letter-spacing: 0.42em;
            text-indent: 0.42em; color: var(--color-text-subtle); }
.mast-sub .sep { color: var(--color-leaf); margin: 0 2px;
                 font-size: 0.7em; vertical-align: 0.15em; }

/* The closing ornament. Mirrors the masthead's rule/lozenge/rule so the page
   is bracketed top and bottom, and stops the menu from trailing off into an
   unresolved field of ink when the lobby list is empty. Purely a mark — no
   text — so it closes the composition without restarting it. */
.colophon { position: relative; z-index: 2; text-align: center;
            margin-top: clamp(34px, 6vh, 68px); padding-bottom: 10px;
            opacity: 0.8; }
.colophon .mast-orn { margin-bottom: 0; }
.colophon .orn-rule { width: clamp(40px, 9vw, 110px); }
.colophon .orn-lozenge { width: 5px; height: 5px; }

/* -- Main menu grid -------------------------------------------------------
 * Asymmetric by weight, not by whim: the left rail is what you DO (start a
 * table, join one), the side rail is context (who's here, what's been
 * played). The hero breaks the grid upward into the masthead's air so the
 * composition has one deliberate collision in it. */
.menu-grid, .lobby-grid {
  position: relative; z-index: 2;
  display: grid; gap: 20px; width: 100%; align-items: start;
}
.menu-grid { grid-template-columns: minmax(0, 1fr) 350px; max-width: 1140px; }
.menu-col { min-width: 0; }
.menu-col .plate-hero { margin-top: clamp(-40px, -3vh, -18px); }

/* -- Lobby ---------------------------------------------------------------- */
.lobby-grid { grid-template-columns: minmax(0, 1fr) 430px; max-width: 1500px; }
.lobby-head { position: relative; z-index: 2; text-align: center;
              padding: clamp(26px, 4vh, 44px) 0 clamp(20px, 3vh, 32px); }
.lobby-title { font-family: var(--font-display); font-weight: 700;
               font-size: calc(clamp(1.3rem, 2.8vw, 2.1rem) * var(--ui-font-scale));
               text-transform: uppercase; letter-spacing: 0.13em;
               text-indent: 0.13em; color: var(--color-text); }
.col-left { min-width: 0; }
.col-left-wide { min-width: 0; }
.col-right, .col-right-wide { min-width: 0; }
/* The whole right sidebar sticks to the viewport through the (taller) deck-column
   scroll, rather than only its action bar. align-self:start keeps it its own
   content height (not stretched), and it scrolls internally if it's ever taller
   than the viewport so nothing goes unreachable. */
.col-right-wide { align-self: start; position: sticky; top: 16px;
                  max-height: calc(100vh - 32px); overflow-y: auto;
                  scrollbar-gutter: stable; }

/* Fields inside a plate stretch by default; inline clusters opt out. */
.plate input, .plate textarea, .plate select { width: 100%; margin-bottom: 8px; }
.plate textarea { height: 130px; font-family: var(--font-mono); font-size: calc(12px * var(--ui-font-scale));
                  resize: vertical; letter-spacing: 0; }
.plate .flex-gap input, .plate .ai-controls input,
.plate .ai-controls select, .plate .settings-option-row input,
.plate .settings-option-row select { width: auto; margin-bottom: 0; }
.hero-fields { margin-bottom: 14px; }
.hero-fields select { margin-bottom: 0; }

/* -- Ledger lists ---------------------------------------------------------
 * Lobby/game rows. The whole row is the click target (no per-row button).
 * Header and rows share one column template so cells stay aligned.
 *
 * Hover doesn't just tint: a gold tick grows down the left edge (scaleY from
 * the centre) and the row warms. It's the same gesture as a nameplate being
 * slid into a slot, and it costs one transform. */
.list-table-row, .list-table-header { display: grid;
  grid-template-columns: minmax(0, 1.6fr) 92px 62px minmax(0, 1fr);
  gap: 12px; align-items: center; padding: 9px 10px; }
.list-table-header { color: var(--color-text-subtle); font-size: calc(10px * var(--ui-font-scale));
  text-transform: uppercase; letter-spacing: 0.13em;
  border-bottom: 1px solid var(--color-leaf-hair); padding-bottom: 7px; }
.list-table-row { position: relative; cursor: pointer;
  border-bottom: 1px solid var(--color-border-subtle);
  transition: background 0.14s, color 0.14s; }
.list-table-row::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: var(--color-leaf); transform: scaleY(0);
  transition: transform 0.18s cubic-bezier(0.2, 0, 0, 1); }
.list-table-row:hover { background: var(--color-surface-hover); }
.list-table-row:hover::before { transform: scaleY(1); }
.list-table-row .lt-name { font-weight: 600; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.list-table-row:hover .lt-name { color: var(--color-leaf-bright); }
.list-table-row .lt-meta { color: var(--color-text-subtle); font-size: calc(12px * var(--ui-font-scale));
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gametype-badge { display: inline-block; font-size: calc(9px * var(--ui-font-scale));
  background: transparent; color: var(--color-text-muted);
  border: 1px solid var(--color-border-strong);
  padding: 1px 7px; text-transform: uppercase; letter-spacing: 0.1em; }
.list-table-row:hover .gametype-badge { border-color: var(--color-leaf-hair);
  color: var(--color-leaf); }

/* Ready indicator in the lobby player table */
.ready-icon { font-weight: bold; }
.ready-icon.yes { color: var(--color-success); }
.ready-icon.no { color: var(--color-danger); }

/* -- The table ------------------------------------------------------------
 * The lobby's centrepiece, and the one screen element that had a good idea
 * already: seats laid around a circle. It was drawn as a grey dashed ring.
 * Here it becomes a gilded rosette — an inlaid medallion in the floor of the
 * cathedral, which is exactly what a round table with named places IS.
 *
 * Four stacked layers, all in one element's background, no extra DOM:
 *   1. repeating-conic  — the radial spokes, one thin gold ray every 6°,
 *                         masked to a ring so they read as inlay, not a fan
 *   2. radial (ring)    — the gold hairline circles at the rim and inner edge
 *   3. radial (bloom)   — a warm pool of light in the middle
 *   4. the fill
 * ::before carries the spokes (so it can be masked independently); ::after is
 * the inner hairline ring. */
.lobby-table-wrap { display: flex; flex-direction: column; align-items: center;
  gap: 18px; padding: 4px 0 2px; }
.lobby-table { position: relative; width: 100%; max-width: 430px;
  aspect-ratio: 1 / 1; margin: 0 auto; border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%,
      var(--color-leaf-glow) 0%, transparent 44%),
    radial-gradient(circle at 50% 42%,
      var(--color-surface-raised) 0%, var(--color-bg-sunken) 100%);
  box-shadow:
    inset 0 0 0 1px var(--color-leaf-hair),
    inset 0 0 0 8px var(--color-surface),
    inset 0 0 0 9px var(--color-leaf-hair),
    inset 0 0 60px var(--color-menu-shadow),
    0 10px 40px var(--color-menu-shadow);
}
/* Spokes: masked to an annulus so they start clear of the medallion and stop
   short of the rim, like radiating inlay between two gold rings. 40 rays at a
   0.3° duty — dense enough to read as engraving, sparse enough not to become
   a bicycle wheel. */
.lobby-table::before {
  content: ''; position: absolute; inset: 10px; border-radius: 50%;
  pointer-events: none;
  background: repeating-conic-gradient(from 0deg at 50% 50%,
    var(--color-leaf-hair) 0deg 0.3deg, transparent 0.3deg 9deg);
  -webkit-mask-image: radial-gradient(circle at 50% 50%,
    transparent 25%, #000 33%, #000 91%, transparent 99%);
  mask-image: radial-gradient(circle at 50% 50%,
    transparent 25%, #000 33%, #000 91%, transparent 99%);
  opacity: 0.6;
}
/* The medallion the seat count sits on. A lozenge, so it rhymes with the
   masthead ornament and the empty seats. Sized so its DIAGONAL (w × √2 ≈ 32%)
   lands just inside where the spokes begin at 33% — any larger and its points
   punch through the ring of engraving. */
.lobby-table::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 22.5%;
  aspect-ratio: 1; height: auto;
  transform: translate(-50%, -50%) rotate(45deg); pointer-events: none;
  background: var(--color-surface);
  box-shadow: 0 0 0 1px var(--color-leaf-hair),
              0 4px 18px var(--color-menu-shadow);
}

.seat { position: absolute; transform: translate(-50%, -50%);
  display: flex; align-items: center; justify-content: center; z-index: 2; }
/* An empty seat is a lozenge — a place setting, not a bubble. It's the one
   circle-shaped thing the deco system genuinely wants square. */
.seat.empty { width: 34px; height: 34px; cursor: pointer;
  background: var(--color-surface); color: var(--color-text-subtle);
  border: 1px solid var(--color-border-strong);
  transform: translate(-50%, -50%) rotate(45deg);
  transition: border-color .16s, color .16s, background .16s,
              box-shadow .16s, transform .16s; }
.seat.empty .seat-plus { display: block; transform: rotate(-45deg);
  font-size: calc(17px * var(--ui-font-scale)); line-height: 1; font-weight: 300; }
.seat.empty:hover { border-color: var(--color-leaf); color: var(--color-leaf-bright);
  background: var(--color-surface-hover);
  box-shadow: 0 0 0 4px var(--color-leaf-glow);
  transform: translate(-50%, -50%) rotate(45deg) scale(1.12); }

.table-center { position: absolute; left: 50%; top: 50%; z-index: 2;
  transform: translate(-50%, -50%); display: flex; align-items: center; gap: 4px;
  white-space: nowrap; }
.table-center .slot-count { min-width: 62px; text-align: center;
  font-family: var(--font-display); font-weight: 700; font-size: calc(11px * var(--ui-font-scale));
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--color-text-muted); }
.table-center .btn-inline { border-color: transparent; color: var(--color-leaf);
  font-size: calc(14px * var(--ui-font-scale)); line-height: 1; padding: 0 5px; }
.table-center .btn-inline:hover:not(:disabled) { border-color: var(--color-leaf-hair);
  background: transparent; color: var(--color-leaf-bright); }

/* Player chip (shared by seats + observers) — a nameplate at a place setting.
   Chamfered by the same two-pseudo trick as .plate rather than by clipping,
   because the remove × and the Take Host button live outside the padding box
   and a clip-path would guillotine them. --edge lets each state (me / picked /
   disconnected) restate the gilding without restating the geometry. */
.lobby-chip { --edge: var(--color-border-strong);
  position: relative; isolation: isolate; display: flex; flex-direction: column;
  gap: 2px; width: 166px; padding: 6px 10px; font-size: calc(12px * var(--ui-font-scale));
  background: transparent; border: none; cursor: pointer; }
.lobby-chip::before { content: ''; position: absolute; inset: 0; z-index: -2;
  clip-path: var(--chamfer-sm); background: var(--edge);
  filter: drop-shadow(0 3px 10px var(--color-menu-shadow)); }
.lobby-chip::after { content: ''; position: absolute; inset: 1px; z-index: -1;
  clip-path: var(--chamfer-sm); background: var(--color-surface); }
.seat.occupied .lobby-chip { cursor: default; }
/* Your own seat is gilded — the only chip at the table that is. */
.lobby-chip.me { --edge: var(--color-leaf); }
.lobby-chip.picked { outline: 1px solid var(--color-accent); outline-offset: 3px; }
.lobby-chip.is-disconnected { --edge: var(--color-status-error-bright); }
.chip-row { display: flex; align-items: center; gap: 5px; }
.chip-row:first-child { padding-right: 14px; } /* clear the remove × */
.chip-row-sub { font-size: calc(11px * var(--ui-font-scale)); color: var(--color-text-subtle); }
.chip-disc { font-size: calc(10px * var(--ui-font-scale)); font-weight: 600; letter-spacing: 0.04em;
  color: var(--color-status-error-bright); white-space: nowrap; }
.lobby-chip .chip-swatch { flex: none; width: 12px; height: 12px; border-radius: 50%;
  background: var(--chip-color, var(--color-text-subtle));
  border: 1px solid var(--color-border); }
/* Editable swatch for AI bots (host): the 12px dot as a button that opens the
   shared colour picker. Cursor hints it's clickable. */
.lobby-chip .chip-swatch-btn { padding: 0; cursor: pointer;
  -webkit-appearance: none; appearance: none; }
.lobby-chip .chip-swatch-btn:hover { box-shadow: 0 0 0 2px var(--color-accent); }
.lobby-chip .chip-name { font-weight: 600; flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  letter-spacing: 0.02em; }
.chip-deck { flex: 1 1 auto; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.chip-deck.ok { color: var(--color-success); }
.chip-deck.none { color: var(--color-danger); }
.chip-ready { flex: none; }
.chip-ready.yes { color: var(--color-success); font-weight: bold; }
.chip-ready.no { color: var(--color-danger); font-weight: bold; }
.chip-remove { position: absolute; top: 2px; right: 4px; border: none;
  background: none; color: var(--color-danger); font-size: calc(15px * var(--ui-font-scale)); line-height: 1;
  padding: 0 2px; cursor: pointer; }
.chip-take-host { display: block; width: 100%; margin-top: 5px; padding: 3px 6px;
  font-size: calc(11px * var(--ui-font-scale)); font-weight: 600; cursor: pointer;
  border: 1px solid var(--color-accent); background: var(--color-accent-glow);
  color: var(--color-text); letter-spacing: 0.06em; text-transform: uppercase; }
.chip-take-host:hover { background: var(--color-accent);
  color: var(--color-on-primary); }

/* Observers: the pews. A dashed enclosure off the axis of the table, sized to
   match the table's width so the two read as one composition. */
.observers-area { width: 100%; max-width: 430px; min-height: 52px;
  border: 1px dashed var(--color-border-strong);
  padding: 8px 12px; cursor: pointer;
  transition: border-color .16s, background .16s; }
.observers-area:hover { border-color: var(--color-border-strong);
  background: var(--color-surface-raised); }
.observers-area.droppable { border-color: var(--color-accent);
  background: var(--color-accent-glow); }
.observers-title { font-family: var(--font-display); font-weight: 700;
  font-size: calc(10px * var(--ui-font-scale)); text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--color-text-subtle); margin-bottom: 8px; }
.observers-list { display: flex; flex-wrap: wrap; gap: 8px; }
.lp-actions { text-align: right; }

/* Game settings rows (generated from the option registry) */
.settings-option-row { display: flex; justify-content: space-between;
                       align-items: center; gap: 10px; padding: 5px 0;
                       font-size: calc(13px * var(--ui-font-scale)); }
.settings-option-row input, .settings-option-row select {
  width: auto; margin-bottom: 0; }
.settings-option-row input[type="number"] { width: 70px; }
#preset-select { flex: 1; width: auto; margin-bottom: 0; }

/* Stack the ready/start/leave controls so a button changing label (Ready ->
   Unready) or appearing (Start) never reflows the others sideways. */
.lobby-buttons { display: flex; flex-direction: column; align-items: stretch;
                 gap: 6px; margin-top: 4px; }

/* Lobby actions: ready (everyone) and start (host). They lead the right sidebar
   and stick to the top of the viewport as a long deck scrolls, so they're always
   where the eye and pointer already are — never stranded in a corner on
   ultrawide (#103). Left-aligned so they clear the fixed corner user-chip;
   z-index lifts them over the plates they pin above. (col-right-wide stretches
   to the full grid height so the pin lasts the whole scroll.) Sized/coloured so
   your ready state reads at a glance from across the room. */
/* The sidebar column is now the sticky element (see .col-right-wide); the fabs
   stay sticky to the TOP of that column so Ready/Start remain reachable if the
   sidebar ever scrolls internally. */
.lobby-fabs { position: sticky; top: 0; z-index: 5;
              display: flex; gap: 12px; align-items: center;
              flex-wrap: wrap; }
/* The bar carries the .plate backdrop (opaque chamfered face + gilded edge) so
   that, pinned over scrolling content, it reads as a stable frame rather than
   buttons floating on the page (#103). Tighter than a content plate's padding —
   it's an action bar, not a panel of text. The buttons fill the frame and drop
   their own shadow (the plate provides the elevation), so a lone Ready spans the
   width and Ready+Start split it evenly. */
.lobby-fabs.plate { padding: 12px 14px; }
.lobby-fabs .lobby-fab { flex: 1 1 0; filter: none; }
/* Cache-warming readiness note (#228): its own full-width row above the fabs,
   quiet so it informs without competing with the actions. Always visible while
   in the lobby — "ready" (dim) most of the time, "loading N…" (amber) when art
   is still downloading. */
.warm-status { flex: 1 0 100%; font-size: calc(12px * var(--ui-font-scale)); text-align: center;
               color: var(--color-text-subtle); }
.warm-status.is-loading { color: var(--color-warning, var(--color-primary)); }
.warm-status.is-ready { color: var(--color-text-subtle); }
/* Chamfered by clip-path (not by pseudos): these own their own fill, and the
   ready wipe below lives on the element's own `background`, which a pseudo
   overlay would bury. The border goes for the same reason it goes on .btn-hero
   — clip-path would cut it off at all four corners. Separation is a
   drop-shadow instead of box-shadow, since clip-path eats box-shadow. */
.lobby-fab { min-width: 158px; padding: 15px 24px;
             clip-path: var(--chamfer-sm); border: none;
             font-family: var(--font-display); font-weight: 700;
             font-size: calc(13px * var(--ui-font-scale)); letter-spacing: 0.14em; text-transform: uppercase;
             background: var(--color-control-active); color: var(--color-text);
             filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.5));
             transition: background-color 0.12s, filter 0.16s,
                         transform 0.06s; }
.lobby-fab:hover:not(:disabled) { transform: translateY(-1px); }
/* Dropping the border (clip-path would cut it at every corner) means a
   disabled fab has nothing but its fill to hold the shape — at 0.5 on
   parchment it disappeared entirely. The fill does the work instead: a
   control-ACTIVE neutral, and only a light dimming on top. */
.lobby-fab:disabled { opacity: 0.6; filter: none; }

/* The ready button flips state with a wipe: a green fill over the blue base,
   grown and shrunk by transitioning background-size across a gradient.
   Anchored at the LEFT in both directions, so unready is the exact reverse of
   ready: the fill's leading edge sweeps left->right on ready, and retreats
   right->left on unready. (Flipping the anchor to the right on the way out
   looks wrong — the fill collapses rightward, so the *blue* edge sweeps
   left->right and both transitions appear to travel the same way.)

   Selectors are doubled up (.lobby-fab.lobby-fab-ready, 0-2-0) rather than
   single-class (0-1-0) because the base `button:hover` rule is 0-1-1 and sets
   the `background` SHORTHAND — which resets background-image/size/position. A
   single class loses to it, so the gradient vanished the moment you hovered to
   click, i.e. always. Same reason .lobby-fab-start is doubled. */
/* Ink on gold, then ink on verdigris — white would have failed contrast on
   both, now that primary is leaf rather than blue. */
.lobby-fab.lobby-fab-ready { color: var(--color-on-primary);
             background-color: var(--color-primary);
             border-color: var(--color-primary-border);
             background-image: linear-gradient(var(--color-success) 0 100%);
             background-repeat: no-repeat;
             background-position: left center;
             background-size: 0% 100%;
             transition: background-size 0.64s ease, background-color 0.12s,
                         border-color 0.2s, transform 0.06s; }
.lobby-fab.lobby-fab-ready:not(.is-ready):not(:disabled):hover {
             background-color: var(--color-primary-hover); }
.lobby-fab.lobby-fab-ready.is-ready {
             background-size: 100% 100%;
             border-color: var(--color-success); }
.lobby-fab.lobby-fab-ready.is-ready:hover {
             filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.5)) brightness(1.12); }
/* No draft yet: neutral, so the gold never reads as "click me" prematurely. */
.lobby-fab.lobby-fab-ready:disabled {
             background-color: var(--color-control-active);
             background-image: none; color: var(--color-text); }
@media (prefers-reduced-motion: reduce) {
  .lobby-fab.lobby-fab-ready { transition: background-color 0.12s; }
}
/* Start stays neutral until every check passes, then goes hot. */
.lobby-fab.lobby-fab-start { background: var(--color-control-active);
             color: var(--color-text); }
.lobby-fab.lobby-fab-start.is-go:not(:disabled) {
             background: var(--color-accent); color: var(--color-on-primary); }
.lobby-fab.lobby-fab-start.is-go:not(:disabled):hover {
             filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.5)) brightness(1.1); }

/* Deck pane: tabs + drag-and-drop import + library */
/* Deck library: one searchable list over both sources, in a modal — the lobby
   panel lists only your recent decks, so its height can't follow the library. */
.deck-browser-modal .app-modal-panel,
.app-modal-panel.deck-browser-modal { width: min(92vw, 620px); }
.deck-search { width: 100%; margin-bottom: 6px; }
/* inline-flex, not flex: a <label> is block-level, so a full-width row put the
   checkbox adrift from its text at the far side of the panel. */
.deck-server-row { display: inline-flex; align-items: center; gap: 6px;
                   width: auto; margin-bottom: 8px; font-size: calc(12px * var(--ui-font-scale));
                   cursor: pointer; color: var(--color-text-subtle); }
.deck-server-row input { margin: 0; }
/* A fixed height, not max-height: the modal must not resize under you as a
   search narrows — typing "gol|" through to "golgari" would otherwise collapse
   the panel at every keystroke that matches nothing, and snap back after. */
.deck-library-list { height: 58vh; overflow-y: auto; }
/* Recents panel: a fixed handful, so the sidebar is the same size every time. */
#deck-recent { display: flex; flex-direction: column; gap: 6px; }
.deck-browse-all { width: 100%; margin-top: 8px; }
/* A folder per set — hundreds of shipped precons, so they start collapsed. */
.deck-folder > summary { cursor: pointer; font-size: calc(10px * var(--ui-font-scale));
                   font-family: var(--font-display); font-weight: 700;
                   text-transform: uppercase; letter-spacing: 0.12em;
                   color: var(--color-text-muted); padding: 6px 2px;
                   border-bottom: 1px solid var(--color-leaf-hair); }
.deck-folder > summary:hover { color: var(--color-text); }
.deck-folder-count { float: right; font-weight: normal;
                   color: var(--color-text-faint); }
.deck-folder > .deck-row { margin-left: 8px; }
/* Colour identity pips, one per colour. */
.deck-row-pips { display: inline-flex; gap: 2px; flex: none; }
.deck-pip { width: 9px; height: 9px; border-radius: 50%;
            border: 1px solid rgba(0, 0, 0, 0.45); }
.deck-row-kind { flex: none; font-size: calc(10px * var(--ui-font-scale)); color: var(--color-text-faint);
                 min-width: 62px; text-align: right; }
.deck-row-size { flex: none; font-size: calc(10px * var(--ui-font-scale)); color: var(--color-text-faint);
                 min-width: 26px; text-align: right; }

.deck-tabs, .deck-view-tabs { display: flex; gap: 4px; margin-bottom: 10px;
             border-bottom: 1px solid var(--color-border-soft); }
.deck-view-tabs { margin-bottom: 0; border-bottom: none; }
.deck-tabs .tab, .deck-view-tabs .tab { background: none; border: none;
                  border-radius: 0;
                  border-bottom: 2px solid transparent; padding: 6px 12px;
                  color: var(--color-text-subtle); font-size: calc(13px * var(--ui-font-scale)); }
.deck-tabs .tab:hover, .deck-view-tabs .tab:hover {
                  background: var(--color-surface-hover); }
.deck-tabs .tab.active, .deck-view-tabs .tab.active {
                         color: var(--color-text); font-weight: bold;
                         border-bottom-color: var(--color-primary); }
.dropzone { border: 1px dashed var(--color-border-strong);
            padding: 6px; margin-bottom: 8px; }
.dropzone.dragover { border-color: var(--color-primary);
                     background: var(--color-zone-battlefield); }
.dropzone textarea { margin-bottom: 4px; }
.dropzone-hint { font-size: calc(11px * var(--ui-font-scale)); color: var(--color-text-faint); }

/* Structured deck preview: the loaded deck parsed into per-zone sections.
   Lives in the lobby's right column; capped + scrollable so 100-card lists
   don't stretch the page. */
/* Full height, no inner scroll — the lobby column (.screen-cols) is the
   scroller, so dragging a card never has to fight a small scrollport. */
/* No `gap` between sections: a flex gap belongs to this container, not to
   either section, so dragging across one hit dead space — cancel cursor, and
   the highlight dropped. The spacing is section padding instead, so every
   pixel between two zones is inside a drop target. */
#deck-preview { display: flex; flex-direction: column;
                --deck-card-w: 92px; --deck-card-h: 128px; --deck-strip: 22px; }
.deck-preview-section { min-width: 0; border: 1px dashed transparent;
                        padding: 4px 4px 12px; }
.deck-preview-section.deck-drop-over { border-color: var(--color-accent);
                        background: var(--color-accent-glow); }
.deck-preview-title { font-size: calc(10px * var(--ui-font-scale)); font-family: var(--font-display);
                      font-weight: 700;
                      color: var(--color-text-muted); text-transform: uppercase;
                      letter-spacing: 0.12em; margin-bottom: 4px;
                      border-bottom: 1px solid var(--color-leaf-hair);
                      padding-bottom: 3px; }
.deck-preview-count { color: var(--color-text-subtle); font-weight: normal; }
.deck-preview-zone { float: right; color: var(--color-text-faint);
                     font-weight: normal; text-transform: none;
                     letter-spacing: 0; }
.deck-grp { margin: 4px 0; }
.deck-grp-label { font-size: calc(10px * var(--ui-font-scale)); color: var(--color-text-faint);
                  text-transform: uppercase; letter-spacing: 0.4px;
                  margin-bottom: 2px; }
.deck-grp-count { color: var(--color-text-subtle); }
/* Cards fan down a column: each overlaps the one above, leaving only its name
   strip showing, so a 99-card deck reads at a glance instead of tiling the
   whole pane. Columns sit side by side and wrap. */
.deck-grp-cards { display: flex; flex-wrap: wrap; gap: 8px;
                  align-items: flex-start; }
/* Card size is set by JS (--deck-card-*) to hit a target column count across
   whatever width the pane has; the values here are the pre-measure defaults. */
.deck-stack { display: flex; flex-direction: column; flex: none;
              width: var(--deck-card-w); padding-bottom: 4px; }
.deck-thumb { position: relative; flex: none;
              width: var(--deck-card-w); height: var(--deck-card-h);
              border-radius: 5px; border: 1px solid var(--color-border);
              background: var(--color-bg-sunken) center / cover no-repeat;
              cursor: grab; overflow: hidden; }
/* Overlap all but the first card, leaving each one's name strip showing. */
.deck-stack .deck-thumb + .deck-thumb {
              margin-top: calc(var(--deck-strip) - var(--deck-card-h)); }
/* Lift a hovered card clear of the cards fanned over it. */
.deck-thumb:hover { z-index: 20; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.65); }
.deck-thumb:active { cursor: grabbing; }
/* Count + name share the top strip — it's the only part a fanned card shows. */
.deck-thumb-strip { position: absolute; top: 0; left: 0; right: 0;
                    height: var(--deck-strip);
                    display: flex; align-items: center; gap: 3px;
                    padding: 0 3px; color: #fff;
                    background: rgba(0, 0, 0, 0.72); }
.deck-thumb-name { font-size: calc(9px * var(--ui-font-scale)); line-height: 1.15; min-width: 0;
                   overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-thumb-count { font-size: calc(10px * var(--ui-font-scale)); font-weight: bold; flex: none;
                    padding: 0 3px; border-radius: 3px;
                    background: rgba(255, 255, 255, 0.16); }
/* The head owns the spacing below it now that the title's own margin is
   zeroed to keep it aligned with the tabs on the same line. */
.deck-pane-head { display: flex; align-items: center; gap: 8px;
                  margin-bottom: 12px; }
/* The title takes the slack so its hairline runs all the way to the tabs.
   Without the flex:1 the rule collapses to its 12px min-width and reads as a
   stray hyphen after the words. */
.deck-pane-head .plate-title { flex: 1; margin-bottom: 0; }
.deck-pane-head .deck-view-tabs { margin-left: auto; }
/* Import sits with the library, not beside the deck you're holding. */
.deck-import-row { display: flex; align-items: center; gap: 6px;
                   margin-bottom: 8px; }
.deck-import-spacer { flex: 1; }
.deck-import-row .deck-server-row { margin-bottom: 0; }
.deck-status { font-size: calc(11px * var(--ui-font-scale)); color: var(--color-text-faint);
               margin: 4px 0 8px; }
/* Right-click menu on a deck card. */
.deck-thumb-menu { position: fixed; z-index: 500; min-width: 150px;
                   display: flex; flex-direction: column;
                   background: var(--color-surface);
                   border: 1px solid var(--color-leaf-hair);
                   clip-path: var(--chamfer-sm);
                   box-shadow: 0 6px 22px var(--color-menu-shadow);
                   padding: 5px; }
.deck-thumb-menu button { text-align: left; background: none; border: none;
                   color: var(--color-text); font-size: calc(13px * var(--ui-font-scale)); padding: 6px 10px;
                   cursor: pointer; }
.deck-thumb-menu button:hover { background: var(--color-accent-glow); }

/* ---- Token picker modal (on the shared base modal) --------------------- */
.token-picker-modal .app-modal-body { display: flex; flex-direction: column;
                gap: 10px; }
#token-search { width: 100%; padding: 8px 10px; font-size: calc(14px * var(--ui-font-scale));
                border: 1px solid var(--color-control-border);
                background: var(--color-bg-sunken); color: var(--color-text); }
.token-results { display: flex; flex-wrap: wrap; gap: 8px; overflow-y: auto;
                 align-content: flex-start; padding: 2px; min-height: 140px;
                 max-height: 34vh; }
.token-card { position: relative; width: 96px; height: 134px; flex: none;
              border-radius: 6px; border: 1px solid var(--color-border);
              background: var(--color-bg-sunken) center / cover no-repeat;
              cursor: pointer; overflow: hidden; padding: 0;
              transition: transform 0.12s ease, box-shadow 0.12s ease; }
/* Hovering highlights the thumbnail; the large art reads via the shared
   floating card preview (same one the board uses), not an in-place zoom.
   Re-assert the cover/center background: the generic `button:hover` rule
   (higher specificity than `.token-card`) would otherwise reset background-size
   to auto and show the top-left corner of the full-size art. */
.token-card:hover { border-color: var(--color-accent); z-index: 3;
                    box-shadow: 0 6px 20px var(--color-menu-shadow);
                    background: var(--color-bg-sunken) center / cover no-repeat; }
/* Name across the top, P/T badge at the bottom-right — same overlay language as
   the board / deck-thumb cards. */
.token-card-name { position: absolute; top: 0; left: 0; right: 0;
                   font-size: calc(10px * var(--ui-font-scale)); line-height: 1.15; padding: 2px 3px;
                   color: #fff; background: rgba(0, 0, 0, 0.6);
                   overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.token-card-pt { position: absolute; bottom: 3px; right: 3px; z-index: 2;
                 font-size: calc(12px * var(--ui-font-scale)); font-weight: bold; padding: 0 6px;
                 border-radius: 999px; background: var(--color-tooltip-bg);
                 color: var(--color-tooltip-text); }
.token-custom { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
                border-top: 1px solid var(--color-border-subtle); padding-top: 10px; }
.token-custom-label { font-size: calc(10px * var(--ui-font-scale)); text-transform: uppercase;
                font-family: var(--font-display); font-weight: 700;
                letter-spacing: 0.12em; color: var(--color-text-subtle); }
.token-custom input { flex: 1; min-width: 90px; padding: 6px 8px;
                border: 1px solid var(--color-control-border);
                background: var(--color-bg-sunken); color: var(--color-text); }

/* "Create card" modal: name + optional printing pin, a live resolve
   status, and a Create button that stays disabled until the name resolves. */
.create-card-modal .app-modal-body { display: flex; flex-direction: column;
                gap: 12px; }
.cc-field { display: flex; flex-direction: column; gap: 4px; }
.cc-field > label { font-size: calc(10px * var(--ui-font-scale)); text-transform: uppercase;
                font-family: var(--font-display); font-weight: 700;
                letter-spacing: 0.12em; color: var(--color-text-subtle); }
.cc-optional { color: var(--color-text-faint); font-weight: 400;
                letter-spacing: normal; text-transform: none; }
.cc-field input { padding: 7px 9px; border: 1px solid var(--color-control-border);
                background: var(--color-bg-sunken); color: var(--color-text); }
.cc-pin-inputs { display: flex; gap: 8px; }
.cc-status { min-height: 1.2em; font-size: calc(13px * var(--ui-font-scale)); }
.cc-status.pending { color: var(--color-text-faint); }
.cc-status.bad { color: var(--color-danger, #b5462f); }
.cc-status.ok { color: var(--color-status-ok, #5c8f7a); }
.cc-status .cc-name { font-weight: 700; color: var(--color-text); }
.cc-status .cc-pt { color: var(--color-text); font-weight: 700; }
.cc-status .cc-type { color: var(--color-text-subtle); font-size: calc(12px * var(--ui-font-scale));
                margin-top: 2px; }
.cc-status .cc-print { color: var(--color-text-faint);
                font-variant-numeric: tabular-nums; }
.cc-actions { display: flex; justify-content: flex-end; }

/* Saved-decks library: whole row is the click target; Delete is a nested
   button whose own data-action wins over the row's in click delegation. */
.deck-row { display: flex; justify-content: space-between; align-items: center;
            gap: 8px; padding: 8px 10px; margin-bottom: 6px; cursor: pointer;
            background: var(--color-surface-raised);
            border: 1px solid transparent;
            transition: background .14s, border-color .14s; }
.deck-row:last-child { margin-bottom: 0; }
.deck-row:hover { background: var(--color-surface-hover);
                  border-color: var(--color-leaf-hair); }
/* Takes the slack so the columns after it (pips / format / size) stay put and
   line up down the list; the name truncates rather than shoving them around. */
.deck-row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0;
                 flex: 1; }
.deck-row-name { font-weight: bold; font-size: calc(13px * var(--ui-font-scale)); overflow: hidden;
                 text-overflow: ellipsis; white-space: nowrap; }
.deck-row-meta { color: var(--color-text-subtle); font-size: calc(12px * var(--ui-font-scale));
                 overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Game screen */
.screen-game { flex-direction: column; }
.game-body { flex: 1; display: flex; overflow: hidden; }

/* =========================================================================
 * Motion — one orchestrated arrival, not scattered twitches.
 *
 * Every element on the two deco screens carries --i (its rank down the page,
 * set in the markup); the delay is derived from it, so the screen assembles
 * top-down in one gesture: masthead, then hero, then the rails. Nothing loops
 * and nothing moves after ~0.7s — the composition is meant to be still.
 *
 * The wordmark gets its own reveal: the rules draw outward from the centre
 * lozenge, THEN the letters strike in. It only fires on the main screen, once.
 * ========================================================================= */
.rise { animation: rise 0.62s cubic-bezier(0.16, 0.84, 0.3, 1) backwards;
        animation-delay: calc(var(--i, 0) * 85ms + 40ms); }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
.rays { animation: rays-in 1.5s ease-out backwards; }
@keyframes rays-in { from { opacity: 0; } }
.orn-rule { animation: rule-draw 0.85s cubic-bezier(0.2, 0, 0, 1) 0.12s backwards;
            transform-origin: right center; }
.orn-rule:last-child { transform-origin: left center; }
@keyframes rule-draw { from { transform: scaleX(0); } }
.orn-lozenge { animation: lozenge-in 0.5s cubic-bezier(0.2, 0, 0, 1) backwards; }
@keyframes lozenge-in {
  from { transform: rotate(45deg) scale(0); opacity: 0; }
}
/* The strike: letters arrive slightly wide and settle to their tracking, so
   the wordmark reads as being set rather than as fading in. */
.wordmark { animation: strike 0.9s cubic-bezier(0.16, 0.84, 0.3, 1) 0.3s backwards; }
@keyframes strike {
  from { opacity: 0; letter-spacing: 0.42em; filter: blur(6px); }
  to   { opacity: 1; letter-spacing: 0.16em; filter: none; }
}
.mast-sub { animation: rise 0.7s cubic-bezier(0.16, 0.84, 0.3, 1) 0.62s backwards; }

/* Honour the OS setting: keep the composition, drop the movement. */
@media (prefers-reduced-motion: reduce) {
  .rise, .rays, .orn-rule, .orn-lozenge, .wordmark, .mast-sub {
    animation: none; }
  .list-table-row::before { transition: none; }
}

/* Utility */
.hidden { display: none !important; }
.error-msg { color: var(--color-danger); font-size: calc(12px * var(--ui-font-scale)); margin: 4px 0; }
.empty-hint { color: var(--color-text-faint); font-size: calc(12px * var(--ui-font-scale));
              font-style: italic; }
.flex-gap { display: flex; gap: 6px; align-items: center; }
.mb-8 { margin-bottom: 8px; }

/* ---- Drag-to-move (drag.js) ------------------------------------------- */
/* Cards are pointer-dragged, so suppress native text/image selection + drag. */
.card { user-select: none; -webkit-user-select: none; }
.card .card-img { -webkit-user-drag: none; user-drag: none; }
/* The card lifted under the cursor; a clone, so the board layout is undisturbed. */
.drag-ghost { position: fixed; z-index: 200; pointer-events: none; margin: 0;
              opacity: 0.9; transform: rotate(-3deg) scale(1.04);
              box-shadow: 0 6px 18px var(--color-menu-shadow); transition: none; }
/* A TAPPED ghost: `.card.tapped` (0-2-0) outranks `.drag-ghost` (0-1-0), so the
   lift above was silently dropped for tapped cards — they lifted flat while
   every other card tilted. Restate it, composing the tap rotation in (#270). */
.drag-ghost.tapped { transform: rotate(87deg) scale(1.04); }
/* Count badge on the ghost when dragging a multi-card selection. */
.drag-ghost .drag-count { position: absolute; top: -8px; right: -8px; min-width: 18px;
              height: 18px; padding: 0 4px; border-radius: 9px; font-size: calc(11px * var(--ui-font-scale));
              font-weight: bold; line-height: 18px; text-align: center;
              background: var(--color-primary); color: var(--color-on-primary); }
/* The original stays in place, dimmed, as a "ghost slot" while dragging. */
.card.drag-source { opacity: 0.35; }
/* Rubber-band rectangle for drag-select on empty board space. z-index 35:
   over the board and its arrows (30), but UNDER every floating layer — zone
   windows (41+), the watch panel (45), modals — because a board band can't
   select anything inside them and shouldn't look like it can. */
.rubber-band { position: fixed; z-index: 35; pointer-events: none;
              border: 1px solid var(--color-primary);
              background: var(--color-accent-glow); }
/* A zone-window band is drawn inside its window (selection.js `frame`) and
   clamped to it, so it stacks with that window and stops at its edges. */
.rubber-band.rubber-band-framed { position: absolute; z-index: 10; }
/* Zone the cursor is over and that the card would actually move into.
   Any drop container (battlefield, piles, hand bar, stack) qualifies. */
[data-zone-key].drop-target { outline: 2px dashed var(--color-accent);
                    outline-offset: -2px; background: var(--color-accent-glow); }
/* Slot marker: the card-shaped grid cell a battlefield drop will land in. */
.slot-marker { position: fixed; z-index: 201; pointer-events: none;
               border: 2px dashed var(--color-accent); border-radius: 5px;
               background: var(--color-accent-glow);
               box-shadow: 0 0 6px var(--color-accent-glow); }

/* ---- Targeting arrows (arrows.js) ------------------------------------- */
#arrow-overlay { position: fixed; inset: 0; width: 100%; height: 100%;
                 pointer-events: none; z-index: 30; }
.arrow-line { fill: none; stroke: var(--color-accent); stroke-width: 5;
              stroke-linecap: round;
              filter: drop-shadow(0 1px 2px var(--color-menu-shadow)); }
.arrow-line.pending { stroke-dasharray: 7 6; opacity: 0.9; }
/* Hover affordance: a subtle thickening + glow on the arrow a click would
   delete (arrows.js marks it while the cursor is within the hit threshold). */
.arrow-line.hover { stroke-width: 6.5;
              filter: drop-shadow(0 0 3px var(--color-accent-glow)); }
/* Inherit the referencing line's stroke so the head matches the player colour.
   The first declaration is the fallback where context-stroke is unsupported. */
.arrow-head { fill: var(--color-accent); fill: context-stroke; }
/* Drop-target hover while dragging an arrow (or a link pick): the card / seat
   under the cursor gets the same accent cue a stack join / zone drop uses, so
   it's clear you can release there (matches the card hover language). */
.arrow-drop-hover { outline: 2px solid var(--color-accent); outline-offset: 2px;
                    border-radius: 6px; background: var(--color-accent-glow); }

/* ---- Card preview popup (cardPreview.js) ----------------------------- */
/* Self-contained; pointer-events:none so it never intercepts board interaction.
   The 50% here is only the pre-placement default — cardPreview.js writes an
   explicit left/top on every render, putting the preview on the far side of the
   page from the card being hovered (see previewPlace.js). The translate stays,
   because that left/top is a CENTRE point. */
#card-preview { position: fixed; top: 50%; left: 50%;
                transform: translate(-50%, -50%) scale(var(--cp-scale, 1));
                z-index: 300;
                pointer-events: none; display: flex; gap: 12px;
                max-width: min(92vw, 720px); padding: 12px;
                clip-path: var(--chamfer);
                background: var(--color-surface);
                border: 1px solid var(--color-leaf-hair);
                box-shadow: 0 12px 44px var(--color-menu-shadow); }
#card-preview.hidden, #card-preview .cp-rulings.hidden { display: none; }
/* Footer: one line of key reminders (see render). Quiet: they're for keys
   you already own, not part of the card. */
#card-preview .cp-hints { margin-top: 2px; font-size: calc(11px * var(--ui-font-scale));
                          color: var(--color-text-faint);
                          border-top: 1px solid var(--color-border);
                          padding-top: 5px;
                          display: flex; flex-wrap: wrap; gap: 2px 14px; }
/* Driven by a modal (token picker): raise above the app-modal (z 400). It's
   pointer-events:none, so hovering "through" it still reaches the thumbnails. */
#card-preview.cp-standalone { z-index: 500; }

/* ---- Keyword explainer (ruleExplainer.js) ---------------------------------
   Pinned, the preview takes the pointer so its underlined terms can be
   hovered; a gold edge says "held" (drawn on the ::before edge layer — see the
   chamfered-surfaces layer at the end of the file). Gold is scarce on purpose:
   here it means "this one is pinned" and nothing else. */
#card-preview.cp-pinned { pointer-events: auto; }
/* Both hint states are rendered; the pinned class picks one. */
#card-preview .cp-pin-hint .cp-when-pinned,
#card-preview.cp-pinned .cp-pin-hint .cp-when-free { display: none; }
#card-preview.cp-pinned .cp-pin-hint .cp-when-pinned { display: inline; }
/* An explainable word: a dotted underline, the "there is more here" cue the
   graveyard tally already uses. Help cursor only where it can be hovered. */
.rx-term { text-decoration: underline dotted;
           text-decoration-color: var(--color-text-subtle);
           text-underline-offset: 3px; }
#card-preview.cp-pinned .rx-term, .rx-pop.rx-pinned .rx-term { cursor: help; }
#card-preview.cp-pinned .rx-term:hover, .rx-pop.rx-pinned .rx-term:hover {
  text-decoration-style: solid; text-decoration-color: var(--color-text); }
/* A popup: the preview's material, narrower, beside the layer it came from.
   Following (unpinned) it ignores the pointer, exactly like the preview. Its
   chamfered edge and face are the shared pseudo layers at the end of the file;
   the BODY scrolls, never the popup, or the edge would scroll away with it. */
.rx-pop { position: fixed; max-width: min(380px, calc(100vw - 16px));
          max-height: min(60vh, 520px); display: flex; flex-direction: column;
          padding: 10px 12px; pointer-events: none;
          font-size: calc(13px * var(--ui-font-scale)); line-height: 1.45; color: var(--color-text); }
.rx-pop .rx-body { overflow-y: auto; min-height: 0; }
.rx-pop.rx-pinned { pointer-events: auto; }
.rx-title { font-family: var(--font-display); font-weight: 700; font-size: calc(12px * var(--ui-font-scale));
            text-transform: uppercase; letter-spacing: 0.13em; }
.rx-sub { font-size: calc(11px * var(--ui-font-scale)); color: var(--color-text-subtle); margin: 2px 0 6px; }
.rx-text p { margin: 0 0 6px; }
.rx-rule-line b { color: var(--color-text-subtle); font-weight: 600; }
.rx-loading { color: var(--color-text-subtle); font-style: italic; }
.rx-hint { margin-top: 6px; padding-top: 5px; font-size: calc(11px * var(--ui-font-scale));
           color: var(--color-text-faint);
           border-top: 1px solid var(--color-border); }
/* The picture column: one art, or both sides of a two-faced card stacked
   (#290). Two arts are narrower so the pair still fits the preview's height. */
#card-preview .cp-arts { display: flex; flex-direction: column; gap: 8px;
                         flex: 0 0 auto; align-self: flex-start; }
/* The aspect-ratio is load-bearing, not decoration: it reserves the art's
   HEIGHT before the image arrives. Without it the box measures ~0 tall on the
   art side at render time, and cardPreview.js places a box far shorter than the
   one that ends up on screen — a basic land (no text to hold the box open)
   flew to the top of the viewport and then grew its own top off it. 488x680 is
   Scryfall's `normal` image. It lives on the BOX rather than the image so a
   rotated face can reserve its landscape footprint instead. */
#card-preview .cp-art-box { position: relative; width: 300px; max-width: 42vw;
                           aspect-ratio: 488 / 680; }
#card-preview .cp-arts.two .cp-art-box { width: 210px; }
#card-preview .cp-art { width: 100%; height: 100%; display: block;
                        border-radius: 10px; object-fit: contain; }
/* A face printed landscape (a Battle's Siege front, a plane, a scheme) still
   arrives in Scryfall's portrait frame, a quarter turn anticlockwise. Turn it
   back and let the box reserve the landscape footprint. The image's own sides
   swap under the rotation, so its width is the box's height and vice versa —
   expressed as the same 488/680 ratio, read both ways. */
#card-preview .cp-art-box.sideways { aspect-ratio: 680 / 488; }
#card-preview .cp-art-box.sideways .cp-art {
  position: absolute; left: 50%; top: 50%;
  width: calc(100% * 488 / 680); height: calc(100% * 680 / 488);
  transform: translate(-50%, -50%) rotate(90deg); }
/* Which side the board is actually showing, when both are up. */
#card-preview .cp-art-box.current .cp-art {
  outline: 2px solid var(--color-accent); outline-offset: 2px; }
#card-preview .cp-body { display: flex; flex-direction: column; gap: 6px;
                         overflow-y: auto; max-height: 84vh; min-width: 220px;
                         max-width: 360px; font-size: calc(13px * var(--ui-font-scale)); line-height: 1.35; }
/* Owner / controller chips at the top of the preview (issue F). */
#card-preview .cp-identity { display: flex; flex-wrap: wrap; gap: 5px; }
#card-preview .cp-idbadge { display: inline-flex; align-items: baseline; gap: 4px;
    font-size: calc(11px * var(--ui-font-scale)); font-weight: bold; padding: 1px 8px; border-radius: 999px;
    color: #fff; background: var(--chip-color, var(--color-badge-bg));
    border: 1px solid var(--color-border); }
#card-preview .cp-idlabel { font-size: calc(9px * var(--ui-font-scale)); text-transform: uppercase;
    letter-spacing: 0.4px; opacity: 0.85; font-weight: normal; }
/* Previewed instance's live state: current P·T + counter chips + annotation. */
#card-preview .cp-instance { display: flex; flex-direction: column; gap: 4px; }
#card-preview .cp-inst-chips { display: flex; flex-wrap: wrap; gap: 5px;
    align-items: center; }
#card-preview .cp-inst-pt { font-weight: bold; font-size: calc(12px * var(--ui-font-scale)); padding: 1px 8px;
    border-radius: 999px; background: var(--color-surface-sunken, rgba(0,0,0,0.12));
    border: 1px solid var(--color-border-subtle); }
#card-preview .cp-inst-counter { font-size: calc(11px * var(--ui-font-scale)); font-weight: bold;
    padding: 1px 8px; border-radius: 999px; border: 1px solid rgba(0,0,0,0.35); }
#card-preview .cp-inst-note { font-size: calc(12px * var(--ui-font-scale)); font-style: italic;
    color: var(--color-text-subtle); white-space: pre-wrap;
    overflow-wrap: anywhere; }
#card-preview .cp-head { display: flex; justify-content: space-between; gap: 8px;
                         align-items: baseline; }
#card-preview .cp-name { font-weight: bold; font-size: calc(15px * var(--ui-font-scale)); }
#card-preview .cp-mana { color: var(--color-text-subtle); white-space: nowrap; }
#card-preview .cp-type { color: var(--color-text-subtle); font-size: calc(12px * var(--ui-font-scale)); }
#card-preview .cp-oracle { white-space: normal; }
#card-preview .cp-pt { font-weight: bold; align-self: flex-end; }
#card-preview .cp-face { border-top: 1px dashed var(--color-border-subtle);
                         padding-top: 6px; display: flex; flex-direction: column;
                         gap: 4px; }
#card-preview .cp-rulings { border-top: 1px solid var(--color-border-subtle);
                            padding-top: 6px; margin-top: 2px; display: flex;
                            flex-direction: column; gap: 6px;
                            /* Long rulings get their own scroll region rather
                               than being clipped; cardPreview.js forwards wheel
                               events here since the popup is pointer-events:none. */
                            max-height: 34vh; overflow-y: auto;
                            scrollbar-width: thin;
                            scrollbar-color: var(--color-border) transparent; }
#card-preview .cp-rulings::-webkit-scrollbar { width: 7px; }
#card-preview .cp-rulings::-webkit-scrollbar-track { background: transparent; }
#card-preview .cp-rulings::-webkit-scrollbar-thumb {
    background: var(--color-border); border-radius: 999px;
    border: 2px solid transparent; background-clip: padding-box; }
#card-preview .cp-rulings::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-faint); background-clip: padding-box; }
#card-preview .cp-rulings-title { font-weight: bold; text-transform: uppercase;
                            font-size: calc(11px * var(--ui-font-scale)); letter-spacing: 0.5px;
                            color: var(--color-text-subtle); }
#card-preview .cp-ruling { font-size: calc(12px * var(--ui-font-scale)); }
#card-preview .cp-ruling-date { color: var(--color-text-faint); font-size: calc(11px * var(--ui-font-scale));
                                margin-right: 4px; }
/* Hold A (#321): the hovered card's attachment group, a third column. The box
   may grow wider for it; the column scrolls once pinned, like the rulings. */
#card-preview.cp-with-attached { max-width: min(96vw, 1060px); }
#card-preview .cp-attached { display: flex; flex-direction: column; gap: 8px;
                             width: 300px; max-height: 84vh; overflow-y: auto;
                             padding-left: 12px;
                             border-left: 1px solid var(--color-border-subtle); }
#card-preview .cp-att { display: flex; gap: 8px; align-items: flex-start; }
#card-preview .cp-att-art { flex: 0 0 96px; }
#card-preview .cp-att-art img { width: 100%; display: block; }
#card-preview .cp-att-text { display: flex; flex-direction: column; gap: 4px;
                             min-width: 0; font-size: calc(12px * var(--ui-font-scale)); }
#card-preview .cp-att .cp-name { font-size: calc(13px * var(--ui-font-scale)); }
#card-preview .cp-att-hidden { color: var(--color-text-faint); font-style: italic;
                               font-size: calc(11px * var(--ui-font-scale)); }
/* "Scroll: 2 of 5 here" is about the board, which a pinned preview has left. */
#card-preview.cp-pinned .cp-more-hint { display: none; }
#card-preview .cp-more-hint.hidden { display: none; }

/* ---- Card movement animation (board.js) ------------------------------ */
/* Card slides are FLIP + the Web Animations API, driven entirely from
   board.js — there is no CSS here to tune, and nothing calls
   `document.startViewTransition` any more.
   The View Transition rules that used to live here are gone with it. They are
   worth a note, because what removed them was not a preference: CAPTURING AN
   ELEMENT FOR A TRANSITION SUPPRESSES HIT-TESTING ON IT, not just its painting.
   So a card was unclickable for the whole time it slid, and — because the
   `view-transition-name` was never cleared off a reused node — stayed that way
   through every later transition too, including ones another player caused.
   `pointer-events: none` on the pseudo tree did not fix it: the pseudo was
   never the hit target, the hit fell through to <html>, which is why `.card`'s
   `cursor: pointer` dropped to the plain arrow mid-slide and stacks refused to
   be picked up (#257, #203). If you ever reintroduce a view transition here,
   `tests/integration/test_ui_smoke.py` has the guard. */

/* A container held open while a card flies through it (board.js::liftFlight).
   The card is moved by `transform`, so it is laid out at its DESTINATION and the
   first half of a cross-row flight sits outside the destination row — which is
   `overflow: hidden`, so it was clipped away and the card appeared to slide out
   from under the neighbouring row. Must come after `.bf-row` / `.battlefield` in
   this file: same specificity, so source order decides.

   Deliberately ONLY `overflow`. An earlier version also set
   `position: relative; z-index`, which turned every opened container into a
   STACKING CONTEXT and so trapped the flying card's own z-index inside it.
   Opening the clip and raising the card are separate jobs; keep them separate.

   `!important` because this overrides WHATEVER rule happens to clip a container
   on the way, and those are not all one specificity: `.bf-row` is 0-1-0 (source
   order settles it) but `.stack-bar .stack-cards` is 0-2-0 and silently won —
   so the stack column was never opened at all and a card crossing hand -> stack
   spent the middle of its flight clipped to a column it hadn't reached yet.
   This is a transient, JS-applied override of arbitrary author rules, which is
   what `!important` is actually for; matching specificity by hand here just
   means the next zone with a nested selector breaks it again. */
.fly-unclipped { overflow: visible !important; }

/* The card itself, while it flies: lifted clear of everything it crosses.
   Clipping is only half of being seen — `.hand-bar` and `.player-area` are
   `position: relative`, so they paint above the static columns beside them, and
   a card flying hand -> stack is clipped by nothing yet still vanishes behind
   the board. Because nothing on its way up is a stacking context, a z-index here
   resolves against the page: 100 clears the board's own chrome while staying
   under zone windows (200), the chat panel (260), menus (360) and tooltips
   (900). It also covers the battlefield-row case — rows are siblings, so a card
   flying down out of an earlier row would otherwise pass behind the row below.
   `!important` for the same reason as above: the hover raises it competes with
   are nested and of assorted specificity (`.bf-stack .card:hover` is 0-3-0,
   `.stack-bar .stack-cards .card:hover` 0-4-0), and a flight must win all of
   them. `.card` is already `position: relative`, so z-index alone does the
   work. */
.card.card-flying { z-index: 100 !important; }

/* Running count beside the cursor while rubber-band selecting (selection.js).
   A band gave no feedback until release, so "four tokens or five?" meant
   letting go, counting outlines, and starting over. pointer-events:none — it
   follows the cursor and must never become the drop/hit target. z-index sits
   above the band and the board but below menus (360) and tooltips (900). */
.band-tally { position: fixed; z-index: 310; pointer-events: none;
              padding: 5px 9px; font-size: calc(12px * var(--ui-font-scale)); line-height: 1.4;
              background: var(--color-tooltip-bg); color: var(--color-tooltip-text);
              clip-path: var(--chamfer-sm);
              box-shadow: 0 4px 14px var(--color-menu-shadow); }
.band-tally-count { font-weight: bold; }
.band-tally-row { opacity: 0.9; }
/* The Shift affordance: present, but never competing with the count itself. */
.band-tally-hint { margin-top: 2px; font-size: calc(10px * var(--ui-font-scale)); opacity: 0.6;
                   text-transform: uppercase; letter-spacing: 0.5px; }

/* ---- Transient board effects (animations.js, issue G) ----------------- */
#fx-layer { position: fixed; inset: 0; z-index: 350; pointer-events: none;
            overflow: hidden; }

/* Floating life-change number that rises and fades near a life total. */
.fx-life { position: fixed; transform: translate(-50%, -50%);
           font-weight: bold; font-size: calc(40px * var(--ui-font-scale)); white-space: nowrap;
           /* Black outline so the floating number reads over the board. */
           -webkit-text-stroke: 2px #000; paint-order: stroke fill;
           text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
           animation: fx-life-rise 1.5s ease-out forwards; }
.fx-life.gain { color: var(--color-status-ok); }
.fx-life.loss { color: var(--color-status-error-bright); }
@keyframes fx-life-rise {
  0%   { opacity: 0; transform: translate(-50%, -30%) scale(0.8); }
  15%  { opacity: 1; }
  100% { opacity: 0;
         transform: translate(calc(-50% + var(--fx-drift, 0%)), -170%) scale(1); }
}

/* Shuffle riffle: three face-down cards that fan out and snap back. */
.fx-shuffle { position: fixed; }
.fx-shuffle-card { position: absolute; inset: 0; border-radius: 5px;
           background: url("../cardback.jpg") center / cover no-repeat,
                       var(--color-card-facedown-bg);
           border: 1px solid var(--color-card-facedown-border);
           animation: fx-riffle 0.5s ease-in-out; }
.fx-shuffle-card.c0 { animation-delay: 0ms; }
.fx-shuffle-card.c1 { animation-delay: 70ms; }
.fx-shuffle-card.c2 { animation-delay: 140ms; }
@keyframes fx-riffle {
  0%   { transform: translateX(0) rotate(0); opacity: 0.9; }
  40%  { transform: translateX(-40%) rotate(-8deg); opacity: 0.85; }
  60%  { transform: translateX(40%) rotate(8deg); opacity: 0.85; }
  100% { transform: translateX(0) rotate(0); opacity: 0; }
}

/* Draw fly: a full-size card-back travelling from the library to over the hand,
   holding briefly, then shrinking into the hand. Width/height are set inline to
   the pile's rendered card size; the element is centered on its (left, top) via
   the -50% translate baked into every keyframe. */
.fx-draw-card { position: fixed; border-radius: 5px;
           background: url("../cardback.jpg") center / cover no-repeat,
                       var(--color-card-facedown-bg);
           border: 1px solid var(--color-card-facedown-border);
           box-shadow: 0 4px 14px var(--color-menu-shadow);
           animation: fx-draw-fly 1.4s ease-in-out forwards; }
@keyframes fx-draw-fly {
  0%   { transform: translate(-50%, -50%) scale(1); opacity: 0; }
  10%  { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  38%  { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy)))
                    scale(1); opacity: 1; }
  70%  { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy)))
                    scale(1); opacity: 1; } /* pause over the hand */
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy)))
                    scale(0.05); opacity: 0; } /* shrink into the hand */
}

/* Mill (#260): the same card-back as the draw fly, but one-way — library to
   graveyard with no pause, because a mill is a dump, not a gain. */
.fx-mill-card { position: fixed; border-radius: 5px;
           background: url("../cardback.jpg") center / cover no-repeat,
                       var(--color-card-facedown-bg);
           border: 1px solid var(--color-card-facedown-border);
           box-shadow: 0 4px 14px var(--color-menu-shadow);
           animation: fx-mill-fly 0.75s cubic-bezier(0.3, 0, 0.4, 1) forwards; }
@keyframes fx-mill-fly {
  0%   { transform: translate(-50%, -50%) scale(1); opacity: 0; }
  12%  { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy)))
                    scale(0.85); opacity: 0; }
}

/* Incoming turn (#260): the app telling you to act, so it's gold — the scarce
   "act on this" material (design system §3.3). One pass, no loop; the deco
   language is "struck, then still".
   The first cut was a single 22%-alpha diagonal band and was, in practice,
   invisible over a board full of card art — the effect fired correctly and
   nobody could see it (#272). Two layers now do the work: a gilded FRAME that
   flares around the whole viewport (reads instantly, obscures nothing, since
   the middle of the screen stays clear) and a brighter sweep across it. */
.fx-turn-sweep { position: fixed; inset: 0; pointer-events: none;
  background: linear-gradient(100deg,
    transparent 34%,
    color-mix(in srgb, var(--color-primary) 46%, transparent) 50%,
    transparent 66%);
  background-size: 260% 100%;
  animation: fx-turn-sweep 1s ease-out forwards; }
/* The frame: an inset ring that flares and settles. Its own element-less layer
   via ::after so it can carry a different timing curve from the sweep. */
.fx-turn-sweep::after { content: ''; position: absolute; inset: 0;
  box-shadow: inset 0 0 0 3px var(--color-primary),
              inset 0 0 42px 6px color-mix(in srgb,
                var(--color-primary) 55%, transparent);
  animation: fx-turn-frame 1s ease-out forwards; }
@keyframes fx-turn-sweep {
  0%   { background-position: 130% 0; opacity: 0; }
  12%  { opacity: 1; }
  100% { background-position: -130% 0; opacity: 0; }
}
@keyframes fx-turn-frame {
  0%   { opacity: 0; }
  14%  { opacity: 1; }
  55%  { opacity: 0.85; }
  100% { opacity: 0; }
}

/* 3D dice roll (issue #9): a polyhedron that tumbles in the rolling player's own
   zone, tinted with their seat colour (--die-color), and lingers until clicked
   away. The seed decides the value; the geometry only orients the settled face
   to camera (see diceGeometry.js). Ink faces, seat-coloured edges, bone
   numerals. Dice live in a fixed overlay so a board re-render can't destroy a
   lingering result — diceTray.js re-anchors them after each render. */
#dice-layer { position: fixed; inset: 0; z-index: 300; pointer-events: none; }
/* NO filter here: a `filter` on the perspective root flattens the preserve-3d
   subtree in Chrome/Blink — the tumbling solid collapses to a flat diamond with
   missing/partial faces (Firefox renders the 3D first, so it looked fine). The
   drop-shadow it used to carry isn't worth breaking the 3D (#230). */
.die { position: fixed; pointer-events: auto; cursor: pointer;
       perspective: 520px; --die-color: var(--color-primary, #c9a227); }
.die-orient { transform-style: preserve-3d; }
.die-spin { position: relative; transform-style: preserve-3d; }
/* Outer = seat-colour polygon (the edge); inner = ink face scaled in so the
   colour reads as a rim, carrying the numeral. A plain border can't do this —
   it sits on the element rectangle, not the clipped polygon. */
/* backface-visibility:hidden hides the solid's FAR faces — without it their
   numerals render mirrored and paint-sort over the near faces (#230). Kept on
   both the polygon and the numeral. */
.die-face { position: absolute; box-sizing: border-box;
       background: var(--die-color); backface-visibility: hidden; }
/* translateZ lifts the numeral a hair OUTWARD off its face (the transform is in
   the face's local space, so +Z is along the face normal): coplanar with the
   face it z-fights in preserve-3d, which on Chrome intermittently hid the final
   result (the hover tooltip still showed it) and left faces reading blank. */
.die-face-inner { position: absolute; inset: 0;
       transform: translateZ(0.6px) scale(0.82);
       display: flex; align-items: center; justify-content: center;
       line-height: 1; font-family: var(--font-body); font-weight: 700;
       color: var(--color-bone, #ece5d4); background: var(--color-ink, #17130f);
       text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
       backface-visibility: hidden; }

/* Eye overlay: another player is browsing this library right now — a large
   centered indicator filling the pile, not a corner badge.
   Icon and count are separate stacked rows (#225). As one inline string the
   count's width shifted the glyph off-centre, and the more cards someone was
   peeking at the further off it drifted -- so the eye now centres on its own
   row and the number sits beneath it, at a size that stays legible over art. */
.lib-browsing { position: absolute; inset: 0; z-index: 4; display: flex;
           flex-direction: column; gap: 2px;
           align-items: center; justify-content: center; pointer-events: none;
           line-height: 1;
           filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.7));
           background: rgba(0, 0, 0, 0.28); border-radius: 5px;
           animation: fx-browse-pulse 1.6s ease-in-out infinite; }
.lib-browsing .lib-browsing-eye { font-size: calc(var(--card-w) * 0.5); }
.lib-browsing .lib-browsing-count { font-size: calc(var(--card-w) * 0.22);
           font-weight: 700; letter-spacing: 0.04em; color: #fff; }
@keyframes fx-browse-pulse { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .lib-browsing { animation: none; } }
/* ---- Main-menu online roster (issue F) -------------------------------- */
.online-row { display: flex; align-items: center; gap: 8px; padding: 4px 2px;
              font-size: calc(13px * var(--ui-font-scale)); }
.online-dot { width: 8px; height: 8px; border-radius: 50%; flex: none;
              background: var(--color-text-dim); }
/* Presence status by location: menu = green (idle/available), lobby = yellow
   (gathering), in-game = red (busy). */
.online-dot.loc-menu { background: var(--color-status-ok); }
.online-dot.loc-lobby { background: var(--color-warning); }
.online-dot.loc-game { background: var(--color-status-error); }
.online-name { flex: 1; overflow: hidden; text-overflow: ellipsis;
               white-space: nowrap; }
.online-status { color: var(--color-text-subtle); font-size: calc(11px * var(--ui-font-scale)); }

/* ---- Game history list (main screen) ---------------------------------- */
.history-row { display: flex; align-items: center; gap: 8px; padding: 6px 4px;
               border-bottom: 1px solid var(--color-border-subtle); }
.history-main { flex: 1; min-width: 0; }
.history-when { font-size: calc(13px * var(--ui-font-scale)); font-weight: bold; }
.history-meta { font-size: calc(11px * var(--ui-font-scale)); color: var(--color-text-subtle); }
.history-players { font-size: calc(12px * var(--ui-font-scale)); color: var(--color-text-muted);
                   overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-decks { font-size: calc(11px * var(--ui-font-scale)); color: var(--color-text-faint);
                 overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-actions { display: flex; flex-direction: column; gap: 3px; flex: none; }
.history-actions button { font-size: calc(11px * var(--ui-font-scale)); padding: 2px 8px; }

/* ---- In-game side-rail roster (seated players + observers) ------------ */
.sr-roster { display: flex; flex-direction: column; gap: 2px; margin: 6px 0;
             width: 100%; }
.sr-roster-label { font-size: calc(10px * var(--ui-font-scale)); text-transform: uppercase;
             letter-spacing: 0.5px; color: var(--color-text-subtle);
             margin-top: 4px; }
.sr-roster-row { display: flex; align-items: center; gap: 5px; font-size: calc(11px * var(--ui-font-scale));
             padding: 2px 4px; border-radius: 4px; }
.sr-roster-row.current { background: var(--color-surface-hover); font-weight: bold; }
.sr-roster-row.me .sr-roster-name { color: var(--color-primary); }
.sr-roster-dot { width: 8px; height: 8px; border-radius: 50%; flex: none;
             background: var(--color-text-dim); }
.sr-roster-name { flex: 1; overflow: hidden; text-overflow: ellipsis;
             white-space: nowrap; }
.sr-roster-icon { flex: none; font-size: calc(10px * var(--ui-font-scale)); }
.sr-roster-time { flex: none; font-size: calc(10px * var(--ui-font-scale)); color: var(--color-text-muted);
                  font-variant-numeric: tabular-nums; }
.sr-roster-row.current .sr-roster-time { color: var(--color-text); }
.sr-roster-row.conceded, .sr-roster-row.left { opacity: 0.5; }
.sr-roster-row.offline .sr-roster-icon { color: var(--color-status-error-bright); }
.sr-roster-row.observing { opacity: 0.8; }
.sr-roster-row.observing .sr-roster-icon { color: var(--color-text-subtle); }

/* === Chamfered surfaces: draw the edge with pseudos, not a clipped border ====
   A plain `border` on a clip-path'd surface is sliced off at the 45° corners,
   leaving the outline open there — the recurring "missing corners" bug
   (design-system §6). Reuse the .plate two-layer technique: a chamfered
   ::before gilded edge with an ::after face inset 1px, the element itself
   transparent + isolation:isolate, so the edge follows the chamfer the whole
   way round. Moving the clip off the element onto the pseudos also stops the
   element clipping its own fixed children (fly-out submenus). This layer lives
   at the end of the file so it overrides every surface that declared
   border + clip-path, wherever that base rule sits. */

/* Regular chamfer, plain surface face. */
.quick-modal-panel,
.app-modal-panel,
#settings-modal .modal-panel,
#card-preview,
.rx-pop {
  background: transparent; border: none; clip-path: none; box-shadow: none;
  isolation: isolate;
}
.quick-modal-panel::before,
.app-modal-panel::before,
#settings-modal .modal-panel::before,
#card-preview::before,
.rx-pop::before {
  content: ''; position: absolute; inset: 0; z-index: -2; clip-path: var(--chamfer);
  background: linear-gradient(150deg, var(--color-leaf-hair) 0%,
    var(--color-border) 46%, var(--color-border) 100%);
  filter: drop-shadow(0 10px 34px var(--color-menu-shadow));
}
.quick-modal-panel::after,
.app-modal-panel::after,
#settings-modal .modal-panel::after,
#card-preview::after,
.rx-pop::after {
  content: ''; position: absolute; inset: 1px; z-index: -1; clip-path: var(--chamfer);
  background: var(--color-surface);
}
/* Pinned by the rules explainer: the edge itself turns gold. */
#card-preview.cp-pinned::before,
.rx-pop.rx-pinned::before { background: var(--color-primary); }

/* Small chamfer, plain surface face — the chip and deck-thumb menus. */
#user-chip-menu,
.deck-thumb-menu {
  background: transparent; border: none; clip-path: none; box-shadow: none;
  isolation: isolate;
}
#user-chip-menu::before,
.deck-thumb-menu::before {
  content: ''; position: absolute; inset: 0; z-index: -2; clip-path: var(--chamfer-sm);
  background: linear-gradient(150deg, var(--color-leaf-hair) 0%,
    var(--color-border) 46%, var(--color-border) 100%);
  filter: drop-shadow(0 6px 20px var(--color-menu-shadow));
}
#user-chip-menu::after,
.deck-thumb-menu::after {
  content: ''; position: absolute; inset: 1px; z-index: -1; clip-path: var(--chamfer-sm);
  background: var(--color-surface);
}

/* Game-over dialog keeps its darker overlay face. */
.game-over {
  background: transparent; border: none; clip-path: none; isolation: isolate;
}
.game-over::before {
  content: ''; position: absolute; inset: 0; z-index: -2; clip-path: var(--chamfer);
  background: linear-gradient(150deg, var(--color-leaf-hair) 0%,
    var(--color-border) 46%, var(--color-border) 100%);
  filter: drop-shadow(0 10px 34px var(--color-menu-shadow));
}
.game-over::after {
  content: ''; position: absolute; inset: 1px; z-index: -1; clip-path: var(--chamfer);
  background: var(--color-overlay);
}

/* Welcome keeps its top glow on the face and uses the larger chamfer. */
.welcome-panel {
  background: transparent; border: none; clip-path: none; box-shadow: none;
  isolation: isolate;
}
.welcome-panel::before {
  content: ''; position: absolute; inset: 0; z-index: -2; clip-path: var(--chamfer-lg);
  background: linear-gradient(150deg, var(--color-leaf-hair) 0%,
    var(--color-border) 46%, var(--color-border) 100%);
  filter: drop-shadow(0 12px 44px var(--color-menu-shadow));
}
.welcome-panel::after {
  content: ''; position: absolute; inset: 1px; z-index: -1; clip-path: var(--chamfer-lg);
  background:
    radial-gradient(120% 70% at 50% 0%, var(--color-leaf-glow) 0%, transparent 58%),
    var(--color-surface);
}

/* ---- Player "+Counter" modal (playerCounterModal.js, #158) --------------
   Quantity + one-click common/mana counters + a custom name. Choice buttons
   are qualified (button.pcm-choice) with explicit :hover/:focus states so the
   generic `button:hover` background SHORTHAND can't wipe their fill — the
   specificity trap (design-system §6). Nothing is rounded; the panel's chamfer
   comes from .app-modal-panel. */
.player-counter-modal .app-modal-body { display: flex; flex-direction: column;
               gap: 10px; }
.pcm-qty-row { display: flex; align-items: center; justify-content: space-between;
               gap: 12px; font-size: calc(13px * var(--ui-font-scale)); color: var(--color-text); }
.pcm-qty-row input { width: 74px; padding: 6px 8px; text-align: right;
               font-size: calc(14px * var(--ui-font-scale)); border: 1px solid var(--color-control-border);
               background: var(--color-bg-sunken); color: var(--color-text); }
.pcm-section-label { font-size: calc(11px * var(--ui-font-scale)); text-transform: uppercase;
               letter-spacing: 0.5px; color: var(--color-text-muted);
               padding-top: 8px; border-top: 1px solid var(--color-border-subtle); }
.pcm-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pcm-grid.pcm-mana { grid-template-columns: repeat(6, 1fr); }
button.pcm-choice { padding: 9px 4px; cursor: pointer; font-size: calc(12px * var(--ui-font-scale));
               border: 1px solid var(--color-control-border);
               background: var(--color-bg-sunken); color: var(--color-text); }
button.pcm-choice:hover { background: var(--color-bg-sunken);
               border-color: var(--color-primary); }
button.pcm-choice:focus-visible { border-color: var(--color-primary); }
button.pcm-mana-btn { font-size: calc(15px * var(--ui-font-scale)); line-height: 1; padding: 8px 0; }
.pcm-custom-row { display: flex; align-items: center; gap: 6px; }
.pcm-custom-row input { flex: 1; min-width: 0; padding: 6px 8px; font-size: calc(13px * var(--ui-font-scale));
               border: 1px solid var(--color-control-border);
               background: var(--color-bg-sunken); color: var(--color-text); }
button.pcm-add { padding: 6px 14px; cursor: pointer; }
