/* Virtual table. Colours follow the brand through the Bootstrap variables of the brand layer
   (theme/table_<brand>.scss, loaded before this file; see the README, "Brand look"), with
   PhaseSix-like fallbacks for the standalone dev harness. */

/* Stacking order of the table page, bottom to top. The table root makes no stacking context of
   its own, so these layers and the page's back link share one; every z-index of such a layer
   uses one of these tokens (add a new layer here, never as a bare number):
     board        auto     the viewport: layers, objects, overlay (z 0–6 inside it)
     hud          10       combat tracker, status, the HUD bar, toasts
     panel        11       inspector, map panel, token picker
     back-link    12       link back to the campaign (page template)
     character    14       character / foe fly-in
     showcase     15       the image the GM shows everyone
     dice         16       3D dice, badges, result cards; click-through except the cards
     dialog       18       modal dialogs (adventure picker): above the dice
     menu         20       context and Add menus, dice preferences popover */
:root {
  --table-z-hud: 10;
  --table-z-panel: 11;
  --table-z-back-link: 12;
  --table-z-character: 14;
  --table-z-showcase: 15;
  --table-z-dice: 16;
  --table-z-dialog: 18;
  --table-z-menu: 20;
}

.table-root {
  --table-accent: var(--bs-primary, #4f8fdb);
  --table-accent-rgb: var(--bs-primary-rgb, 79, 143, 219);
  /* Accent as text: the brand layer lightens a primary that is too dark for text. */
  --table-accent-text: var(--table-brand-accent-text, var(--table-accent));
  --table-black-rgb: var(--bs-black-rgb, 0, 0, 0);
  --table-white-rgb: var(--bs-white-rgb, 255, 255, 255);
  --table-text: var(--bs-body-color, #dee2e6);
  --table-muted: var(--bs-secondary-color, rgba(222, 226, 230, 0.65));
  --table-panel-rgb: var(--bs-tertiary-bg-rgb, 22, 26, 34);
  /* Fog of war (`plain`): this colour, darkened (fogOverlay.js). The same in every brand. */
  --table-fog-rgb: 22, 26, 34;
  --table-danger: var(--bs-danger, #dc3545);
  --table-handle-size: 10px;

  position: fixed;
  inset: 0;
  overflow: hidden;
  color: var(--table-text);
  font-family: var(--bs-body-font-family, system-ui, sans-serif);
  background: #0c0e12;
}

/* ---- Surface ---------------------------------------------------------------------------- */

.table-viewport {
  --table-bg: var(--table-cloth, #171b22);
  /* The settled camera scale (`var(--cam-scale, 1)`) is not set here: Camera writes it into a
     rule for only the elements that use it (CAM_SCALE_SELECTOR), so a settle restyles just them. */

  position: absolute;
  inset: 0;
  overflow: hidden;
  outline: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  /* No iOS callout (save image, copy link) under a finger held to ping. */
  -webkit-touch-callout: none;
  cursor: default;
  background-color: var(--table-bg);
  /* A soft light pool; the dot grid that moves with the camera is .table-dots. */
  background-image:
    radial-gradient(ellipse 70% 60% at 50% 45%, rgba(var(--table-accent-rgb), 0.07), transparent 70%),
    radial-gradient(ellipse 120% 90% at 50% 40%, rgba(var(--table-white-rgb), 0.04), transparent 75%);
}

/* Images on the table are never dragged out by a long press (iOS, Android). */
.table-viewport img {
  -webkit-user-drag: none;
}

/* The table cloth's image (Cloth.js): `cover` fills the viewport and stays put; `tile` follows
   the camera through its background size and position. */
.table-cloth {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-repeat: repeat;
  /* Its own layer, so following the camera repaints only the cloth. */
  will-change: transform;
}

.table-cloth[hidden] {
  display: none;
}

.table-cloth[data-mode="cover"] {
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
}

/* The dot grid would only add noise to a picture. */
.table-viewport.has-cloth-image .table-dots {
  display: none;
}

/* ---- Cloth pattern: a registered pattern over the cloth (ClothPattern.js, PatternControls.js) */

/* The pattern's tile in the pattern colour, repeated as the background. ClothPattern sizes it
   (larger than the viewport) and its tiles when the camera settles, and moves it by transform and
   opacity only. */
.table-cloth-pattern {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  pointer-events: none;
  background-repeat: repeat;
  will-change: transform;
}

.table-cloth-pattern[hidden] {
  display: none;
}

/* Switched off in the Performance tab (effectSettings.js): the cloth without its pattern. */
.table-effect-off--cloth-pattern .table-cloth-pattern {
  display: none;
}

/* A patterned cloth has its own structure; the dot grid would only add noise. */
.table-viewport.has-cloth-pattern .table-dots {
  display: none;
}

.table-pattern__details {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.table-pattern__details[hidden] {
  display: none;
}

.table-pattern__swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 6px;
}

.table-pattern__swatch {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  overflow: hidden;
  color: var(--table-text);
  font: inherit;
  background: var(--pattern-bg, #171b22);
  border: 1px solid rgba(var(--table-white-rgb), 0.15);
  border-radius: 8px;
  cursor: pointer;
}

.table-pattern__swatch:hover:not(:disabled) {
  border-color: rgba(var(--table-accent-rgb), 0.6);
}

.table-pattern__swatch.is-selected {
  border-color: var(--table-accent);
  box-shadow: 0 0 0 1px var(--table-accent), 0 0 10px rgba(var(--table-accent-rgb), 0.35);
}

.table-pattern__swatch:focus-visible {
  outline: 2px solid var(--table-accent);
  outline-offset: 2px;
}

.table-pattern__swatch:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.table-pattern__sample {
  position: absolute;
  inset: 0;
  background-color: var(--pattern-fg, #9aa4b8);
  -webkit-mask-repeat: repeat;
  mask-repeat: repeat;
}

/* The uploaded image shows in its own colours. */
.table-pattern__swatch[data-pattern="image"] .table-pattern__sample {
  background-color: transparent;
  background-position: center;
  background-size: cover;
}

.table-pattern__name {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 10px 4px 3px;
  overflow: hidden;
  font-size: 10px;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  text-overflow: ellipsis;
  background: linear-gradient(transparent, rgba(var(--table-black-rgb), 0.75));
  text-shadow: 0 1px 2px rgba(var(--table-black-rgb), 0.9);
}

.table-pattern__color,
.table-pattern__range {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.table-pattern__auto {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  white-space: nowrap;
}

.table-pattern__color input[type="color"] {
  width: 36px;
}

.table-pattern__color input[type="color"]:disabled {
  opacity: 0.4;
}

.table-pattern input[type="range"] {
  margin: 0;
}

.table-pattern__range input {
  flex: 1;
  min-width: 0;
}

.table-pattern__value {
  min-width: 42px;
  color: var(--table-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* The colour, opacity and scale rows need more room than the grid's 88px control column. */
.table-pattern .table-panel__field:not(.is-check) {
  grid-template-columns: 64px minmax(0, 1fr);
}

/* ---- End of cloth pattern ---------------------------------------------------------------- */

/* The camera moves this layer by transform only and sets its size and background size when it
   settles, so panning never repaints the viewport. */
.table-dots {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
  pointer-events: none;
  /* Zoomed out, Camera thins the dots out (dotLevels): the coarse period doubles and the dots
     between coarse ones (three offset layers, so they never draw over a coarse dot) fade with
     --dots-between, the fine dots with --dots-fine. */
  --dots-between: 0;
  --dots-fine: 1;
  --dot-between: radial-gradient(
    circle,
    rgba(var(--table-white-rgb), calc(0.07 * var(--dots-between))) 1px,
    transparent 1.6px
  );
  background-image:
    radial-gradient(circle, rgba(var(--table-white-rgb), 0.07) 1px, transparent 1.6px),
    var(--dot-between),
    var(--dot-between),
    var(--dot-between),
    radial-gradient(circle, rgba(var(--table-white-rgb), calc(0.035 * var(--dots-fine))) 1px, transparent 1.4px);
  background-size: 128px 128px, 128px 128px, 128px 128px, 128px 128px, 32px 32px;
  background-position: 0 0, 64px 0, 0 64px, 64px 64px, 0 0;
}

.table-viewport.is-space-held {
  cursor: grab;
}

.table-viewport.is-panning,
.table-viewport.is-panning * {
  cursor: grabbing !important;
}

.table-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 85% 80% at 50% 50%, transparent 55%, rgba(var(--table-black-rgb), 0.55) 100%),
    linear-gradient(rgba(var(--table-black-rgb), 0.25), transparent 18%, transparent 82%, rgba(var(--table-black-rgb), 0.3));
}

.table-world {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
}

.table-world.is-moving {
  will-change: transform;
}

.table-layer {
  position: absolute;
  top: 0;
  left: 0;
}

.table-layer--map {
  z-index: 1;
}

.table-layer--objects {
  z-index: 2;
}

.table-layer--tokens {
  z-index: 3;
}

/* ---- 3D props (PropLayer.js) ----------------------------------------------------------- */

/* The shared three.js canvas covers the visible world rect; it stands above the objects layer
   (same z-index, later in the DOM) and below the tokens. The light pools lie on the maps. */
.table-props {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  transform-origin: 0 0;
  pointer-events: none;
}

.table-prop-lights {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  pointer-events: none;
}

.table-prop-light {
  --light-color: #ffb35c;
  --light-strength: 0.75;

  position: absolute;
  top: 0;
  left: 0;
  border-radius: 50%;
  mix-blend-mode: screen;
}

/* The glow; a flickering light (PropLayer) sets --light-flicker in steps, without the pool's fade. */
.table-prop-light::before {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  content: "";
  opacity: var(--light-flicker, 1);
  background: radial-gradient(
    circle,
    color-mix(in srgb, var(--light-color) calc(var(--light-strength) * 52%), transparent) 0%,
    color-mix(in srgb, var(--light-color) calc(var(--light-strength) * 24%), transparent) 24%,
    color-mix(in srgb, var(--light-color) calc(var(--light-strength) * 8%), transparent) 50%,
    transparent 70%
  );
}

.table-prop-light.is-hidden {
  opacity: 0.45;
}

/* The prop's own box only catches the pointer; its mesh is on the canvas. */
.table-object__content.table-prop {
  background: none;
  border-radius: 50%;
  box-shadow: none;
}

.table-object.is-selected .table-prop:not(.table-fallback) {
  box-shadow: 0 0 0 calc(1.5px / var(--cam-scale, 1)) rgba(var(--table-accent-rgb), 0.85);
}

/* ---- Objects ---------------------------------------------------------------------------- */

.table-object {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 50% 50%;
  cursor: grab;
}

.table-object.is-readonly,
.table-object.is-locked {
  cursor: default;
}

.is-transforming .table-viewport,
.is-transforming .table-viewport * {
  cursor: grabbing !important;
}

.table-object__content {
  position: absolute;
  inset: 0;
  border-radius: 3px;
  box-shadow:
    0 2px 4px rgba(var(--table-black-rgb), 0.35),
    0 10px 28px rgba(var(--table-black-rgb), 0.45);
}

.table-object[data-layer="map"] > .table-object__content {
  border-radius: 0;
  box-shadow: 0 0 60px rgba(var(--table-black-rgb), 0.6);
}

/* Objects well outside the view (OffscreenObjects.js): their content is skipped, so its
   animations are neither styled nor painted, yet stay on their timeline and show in phase when
   the object comes back. */
.table-object--offscreen {
  content-visibility: hidden;
}

.table-object.is-hidden > .table-object__content {
  outline: 2px dashed rgba(var(--table-white-rgb), 0.5);
  outline-offset: -2px;
}

/* Images and maps draw the same mark as a border on ::before: an outline around an animated
   image frame made Chrome repaint and re-raster the image on every frame. As the first positioned
   child, ::before lies over the picture and under the frame, the grid and the effect, like the
   outline did. (Tokens do the same in their section.) */
.table-object.is-hidden:is([data-kind="image"], [data-kind="map"]) > .table-object__content {
  outline: none;
}

.table-object.is-hidden:is([data-kind="image"], [data-kind="map"]) > .table-object__content::before {
  position: absolute;
  inset: 0;
  content: "";
  border: 2px dashed rgba(var(--table-white-rgb), 0.5);
  border-radius: inherit;
  pointer-events: none;
}

.table-object__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  border-radius: inherit;
  pointer-events: none;
}

.table-object__content.is-missing {
  background: repeating-linear-gradient(45deg, rgba(var(--table-white-rgb), 0.05) 0 10px, transparent 10px 20px),
    rgba(var(--table-panel-rgb), 0.9);
}

/*
 * Notes look like a slip of paper. Paddings and frames are unitless px values (--note-py,
 * --note-px, optional --note-pb/--note-pl, --note-frame) so that tiny notes can shrink them:
 * a note with room for a line of text keeps them exactly, a smaller one (a map label 44 px
 * high) gives that room to its text.
 */
.table-object[data-kind="note"] {
  container-type: size;
}

.table-note {
  --note-color: #e8dcb5;
  --note-py: 14;
  --note-px: 16;
  --note-frame: 0;

  display: flex;
  /*
   * The height a line of text needs with the full padding and frame (the line without most of
   * its leading), and the width for a few letters. Below them, padding and frame shrink linearly (to 2 px over 24 px of height or
   * 48 px of width); at or above them nothing changes.
   */
  --note-room-y: calc((var(--note-py) + var(--note-pb, var(--note-py)) + 2 * var(--note-frame)) * 1px + var(--note-size, 18px) * var(--note-font-scale, 1) * 1.3);
  --note-room-x: calc((var(--note-px) + var(--note-pl, var(--note-px)) + 2 * var(--note-frame)) * 1px + 48px);
  --note-fit-y: max(0px, calc(1px - (var(--note-room-y) - 100cqh) / 24));
  --note-fit-x: max(0px, calc(1px - (var(--note-room-x) - 100cqw) / 48));

  padding:
    min(calc(var(--note-py) * 1px), max(2px, calc(var(--note-py) * var(--note-fit-y))))
    min(calc(var(--note-px) * 1px), max(2px, calc(var(--note-px) * var(--note-fit-x))))
    min(calc(var(--note-pb, var(--note-py)) * 1px), max(2px, calc(var(--note-pb, var(--note-py)) * var(--note-fit-y))))
    min(calc(var(--note-pl, var(--note-px)) * 1px), max(2px, calc(var(--note-pl, var(--note-px)) * var(--note-fit-x))));
  border-width: min(calc(var(--note-frame) * 1px), max(min(calc(var(--note-frame) * 1px), 2px), calc(var(--note-frame) * min(var(--note-fit-y), var(--note-fit-x)))));
  overflow: hidden;
  color: #2b2620;
  background:
    linear-gradient(rgba(255, 255, 255, 0.25), transparent 30%),
    var(--note-color);
  border-radius: 2px;
}

.table-note__text {
  flex: 1;
  overflow: hidden;
  /* A note too low for a line of its text size takes a smaller one. */
  font-size: min(calc(var(--note-size, 18px) * var(--note-font-scale, 1)), 45cqh);
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  outline: none;
}

/* Markdown the server rendered: its own line breaks, compact blocks in the note's font. */
.table-note__text.is-markup {
  white-space: normal;
}

.table-note__text.is-markup > :first-child {
  margin-top: 0;
}

.table-note__text.is-markup > :last-child {
  margin-bottom: 0;
}

.table-note__text.is-markup :is(p, ul, ol, blockquote, pre, table) {
  margin: 0 0 0.5em;
}

.table-note__text.is-markup :is(h1, h2, h3, h4, h5) {
  margin: 0.4em 0 0.3em;
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
}

.table-note__text.is-markup h1 {
  font-size: 1.45em;
}

.table-note__text.is-markup h2 {
  font-size: 1.25em;
}

.table-note__text.is-markup :is(h3, h4, h5) {
  font-size: 1.1em;
}

.table-note__text.is-markup :is(ul, ol) {
  padding-left: 1.3em;
}

.table-note__text.is-markup blockquote {
  padding-left: 0.6em;
  border-left: 3px solid color-mix(in srgb, currentColor 35%, transparent);
  font-style: italic;
}

.table-note__text.is-markup :is(code, pre) {
  font-family: ui-monospace, monospace;
  font-size: 0.9em;
}

.table-note__text.is-markup pre {
  white-space: pre-wrap;
}

.table-note__text.is-markup table {
  border-collapse: collapse;
}

.table-note__text.is-markup :is(th, td) {
  padding: 0.1em 0.4em;
  border: 1px solid color-mix(in srgb, currentColor 30%, transparent);
}

.table-note__text.is-markup a {
  color: inherit;
  text-decoration: underline;
}

.table-object.is-editing {
  cursor: text;
}

.table-object.is-editing .table-note__text {
  user-select: text;
  -webkit-user-select: text;
  overflow: auto;
}

/* ---- Note looks: paper (data-note-style), font (data-note-font), size (--note-size) --------- */
/* The papers, fonts and inks are the bundled `papers` plugin's (plugins/papers/papers.css, with
   its fonts). The core keeps the sticky note (no data-note-style rule of its own) and the text label
   with its default ink; the seafaring papers and font are sea-pack's (sea-pack.css). */

/*
 * Text label (data-note-style="label"): no paper, the text alone, to name what lies on a map. It
 * keeps the world size of its text (it scales with the map) and draws an outline in the opposite
 * tone of its ink, behind the letters (paint-order): light inks get a dark one, the black ink a
 * light one. Only the text takes clicks (the box's empty part
 * lets them through to the map), and its height follows the text (NoteObject.labelFit).
 */
.table-object.is-label {
  pointer-events: none;
}

.table-object.is-label > .table-object__content {
  border-radius: 0;
  box-shadow: none;
}

/* The inks, shared with the inspector's tiles: light (the default), then the others. */
:is(.table-note[data-note-style="label"], .table-inspector__ink) {
  --note-ink: #f6f1e6;
  --note-halo-rgb: 24, 19, 14;
}

.table-note[data-note-style="label"] {
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 0;
  overflow: visible;
  color: var(--note-ink);
  background: none;
  border: 0;
}

.table-note[data-note-style="label"][data-note-align="center"] {
  align-items: center;
}

.table-note[data-note-style="label"][data-note-align="right"] {
  align-items: flex-end;
}

.table-note[data-note-style="label"][data-note-align="justify"] {
  align-items: stretch;
}

.table-note[data-note-style="label"] .table-note__text {
  flex: none;
  max-width: 100%;
  overflow: visible;
  font-size: calc(var(--note-size, 18px) * var(--note-font-scale, 1));
  line-height: 1.25;
  /* 0.14em of outline, half of it outside the letters; at least 0.8 screen px, so tiny text far
     out keeps an edge, but never more than 0.2em, so small letters stay open instead of filling
     in. --cam-scale is the camera's zoom. No blurred halo: with one, 40 labels cost frames of
     up to 100 ms at zoom steps and at the start of a pan. */
  -webkit-text-stroke-width: max(0.14em, min(calc(0.8px / var(--cam-scale, 1)), 0.2em));
  -webkit-text-stroke-color: rgba(var(--note-halo-rgb), 0.92);
  paint-order: stroke fill;
  pointer-events: auto;
}

.table-object.is-editing.is-label .table-note__text {
  overflow: visible;
}

/*
 * An empty label shows where it is to whoever may write in it, to others nothing. The
 * placeholder lies over the empty line (one line high, so the caret shows) on the side the text
 * will start, and catches the clicks of those who may write.
 */
.table-note[data-note-style="label"] .table-note__text:empty {
  position: relative;
  min-width: 1px;
  min-height: 1.25em;
}

.table-note.is-editable[data-note-style="label"] .table-note__text:empty::before,
.table-object.is-editing.is-label .table-note__text:empty::before {
  position: absolute;
  top: 0;
  left: 0;
  content: attr(data-placeholder);
  white-space: nowrap;
  opacity: 0.55;
}

.table-note[data-note-align="center"] .table-note__text:empty::before {
  left: 50%;
  transform: translateX(-50%);
}

.table-note[data-note-align="right"] .table-note__text:empty::before {
  right: 0;
  left: auto;
}

.table-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px;
  text-align: center;
  background: rgba(var(--table-panel-rgb), 0.92);
  border: 1px solid rgba(var(--table-white-rgb), 0.12);
}

.table-fallback__kind {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--table-muted);
}

.table-fallback__name {
  font-size: 16px;
}

/* Battlemap grid: line width divided by the camera scale, so lines stay about 1 screen px. */
.table-grid {
  --grid-line: calc(1px / var(--cam-scale, 1));

  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: var(--grid-opacity, 0.4);
  background-image:
    linear-gradient(to right, var(--grid-color, #000) var(--grid-line), transparent var(--grid-line)),
    linear-gradient(to bottom, var(--grid-color, #000) var(--grid-line), transparent var(--grid-line));
  background-size: var(--grid-size, 64px) var(--grid-size, 64px);
  background-position: var(--grid-x, 0) var(--grid-y, 0);
}

/* Fog of war (objects/fogOverlay.js): above the grid, below the image frame. The canvas holds one
   pixel per mask sample and is scaled up smoothly; nothing about it changes with the camera. Until
   its first drawing the layer's own background hides the whole map (the darkened fog colour). */
.table-fog {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
}

.table-fog:not(.is-drawn) {
  background:
    linear-gradient(rgba(var(--table-black-rgb), 0.38), rgba(var(--table-black-rgb), 0.38)),
    rgb(var(--table-fog-rgb));
}

/* The GM sees through the fog. */
.table-fog.is-gm {
  opacity: 0.5;
}

.table-fog__canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* A style's moving layers (objects/fogStyles/): generated tiles above the base, cut out by the
   base canvas as their mask (set when it is ready; hidden until then). Each layer moves by a
   stepped animation of transform (drift) or opacity (twinkle), whose duration, steps and travel
   (--fog-dx/--fog-dy) the layer sets. The animations pause while the camera moves (Camera puts
   .is-camera-moving on the motion layer), with reduced motion, "reduce effects" and the
   fog-styles switch, which leaves a still picture. */
.table-fog__motion {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
}

.table-fog__motion:not(.is-masked) {
  visibility: hidden;
}

.table-fog__layer {
  position: absolute;
  inset: 0;
  background-repeat: repeat;
  background-position: 0 0;
  animation-iteration-count: infinite;
}

.table-fog__layer--drift {
  animation-name: table-fog-drift;
}

.table-fog__layer--twinkle {
  animation-name: table-fog-twinkle;
}

@keyframes table-fog-drift {
  to {
    transform: translate(var(--fog-dx, 0), var(--fog-dy, 0));
  }
}

@keyframes table-fog-twinkle {
  0%,
  100% {
    opacity: 0.25;
  }

  50% {
    opacity: 1;
  }
}

.table-fog__motion.is-camera-moving .table-fog__layer,
.table-root.is-effects-reduced .table-fog__layer,
.table-effect-off--fog-styles .table-fog__layer {
  animation-play-state: paused;
}

@media (prefers-reduced-motion: reduce) {
  .table-fog__layer {
    animation-play-state: paused;
  }
}

/* Hidden / locked badges keep a constant screen size: sizes are divided by the camera scale. */
.table-object__badges {
  --badge: calc(22px / var(--cam-scale, 1));

  position: absolute;
  top: calc(var(--badge) * -0.4);
  right: calc(var(--badge) * -0.4);
  z-index: 1;
  display: flex;
  gap: calc(var(--badge) * 0.15);
  pointer-events: none;
}

.table-object__badge {
  display: grid;
  place-items: center;
  width: var(--badge);
  height: var(--badge);
  color: var(--table-text);
  background: rgba(var(--table-panel-rgb), 0.92);
  border: calc(1px / var(--cam-scale, 1)) solid rgba(var(--table-white-rgb), 0.35);
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(var(--table-black-rgb), 0.5);
  box-sizing: border-box;
}

.table-object__badge .table-icon {
  width: 62%;
  height: 62%;
}

.table-object__badge--eyeSlash {
  color: var(--bs-warning, #ffc107);
}

.table-object__badge--fog {
  color: var(--bs-info, #6edff6);
}

/* Hidden objects: translucent for the GM, but the badge stays readable. */
.table-object.is-hidden > .table-object__content {
  opacity: 0.45;
}

.table-measure-bar__button[hidden] {
  display: none;
}

/* The bar below a selected measure: shape, colour, a cone's opening, delete. */
.table-measure-bar {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: rgba(var(--table-panel-rgb), 0.9);
  border: 1px solid rgba(var(--table-white-rgb), 0.1);
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(var(--table-black-rgb), 0.45);
  backdrop-filter: blur(6px);
  pointer-events: auto;
}

/* Narrow screens: the bar wraps onto two rows instead of running off the side. */
@media (max-width: 576px) {
  .table-measure-bar {
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 4px;
    box-sizing: border-box;
    max-width: calc(100% - 16px);
    border-radius: 18px;
  }

  .table-measure-bar__angle {
    width: 72px;
  }
}

.table-measure-bar[hidden],
.table-measure-bar__group[hidden],
body.is-transforming .table-measure-bar {
  display: none;
}

.table-measure-bar__group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.table-measure-bar__group + .table-measure-bar__group {
  margin-left: 3px;
  padding-left: 5px;
  border-left: 1px solid rgba(var(--table-white-rgb), 0.1);
}

.table-measure-bar__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--table-muted);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.table-measure-bar__button .table-icon {
  width: 16px;
  height: 16px;
}

.table-measure-bar__button:hover,
.table-measure-bar__button:focus-visible {
  color: var(--table-text);
  background: rgba(var(--table-white-rgb), 0.08);
  outline: none;
}

.table-measure-bar__button[aria-pressed="true"] {
  color: var(--table-text);
  background: rgba(var(--table-accent-rgb), 0.22);
}

.table-measure-bar__button.is-danger:hover,
.table-measure-bar__button.is-danger:focus-visible {
  color: var(--table-danger);
}

/* Step arrows around the selected token on touch devices (StepArrows.js): one cell per tap. */
.table-step-arrows {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.table-step-arrows[hidden],
.table-step-arrows.is-off-screen,
.table-viewport.is-panning .table-step-arrows,
body.is-transforming .table-step-arrows {
  display: none;
}

.table-step-arrows__button {
  position: absolute;
  top: 0;
  left: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--table-text);
  background: rgba(var(--table-panel-rgb), 0.88);
  border: 1px solid rgba(var(--table-accent-rgb), 0.45);
  border-radius: 50%;
  box-shadow:
    0 4px 12px rgba(var(--table-black-rgb), 0.45),
    0 0 10px rgba(var(--table-accent-rgb), 0.18);
  backdrop-filter: blur(6px);
  cursor: pointer;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

.table-step-arrows__button:active,
.table-step-arrows__button:focus-visible {
  color: var(--table-text);
  background: rgba(var(--table-accent-rgb), 0.3);
  border-color: var(--table-accent);
  outline: none;
}

.table-step-arrows__button .table-icon {
  width: 20px;
  height: 20px;
}

.table-step-arrows__button--right .table-icon {
  transform: rotate(90deg);
}

.table-step-arrows__button--down .table-icon {
  transform: rotate(180deg);
}

.table-step-arrows__button--left .table-icon {
  transform: rotate(-90deg);
}

/* A stepped token glides into its next cell. */
.table-object.is-stepping {
  transition: transform 0.15s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .table-object.is-stepping {
    transition: none;
  }
}

.table-measure-bar__angle {
  width: 84px;
  accent-color: var(--table-accent);
}

/* ---- Tokens ----------------------------------------------------------------------------- */

/* The settled camera scale for the token overlays (Camera writes it per settle into a rule for
   them, TOKEN_CAM_SELECTOR). Not inherited: a settle restyles only the overlay roots below, not
   their icons and stars. */
@property --token-cam {
  syntax: "<number>";
  inherits: false;
  initial-value: 1;
}

.table-token {
  --token-color: #c9a227;
  --token-width: 4px;
  /* The overlays (name, health bar, civic stars, status discs) grow with the token and the zoom up
     to this factor of their size at 100 % on screen, about the size of UI text; zoomed in further
     they scale themselves back by transform (scale(min(1, max / (token scale × zoom))), inlined in
     each so that nothing their children inherit changes); zoomed out they shrink as before. One
     factor for all keeps them in proportion. Only transforms change: no layout, no reflow. */
  --token-ui-max: 1.5;

  overflow: visible;
  background: none;
  border-radius: 0;
  box-shadow: none;
}

/* A hidden token's dashed mark (the GM's view) is a border on ::before, not the `outline` of other
   hidden objects: an outline around the animated frame layers made Chrome repaint and re-raster
   every hidden token on every frame. The border looks the same and, as the first positioned
   child, lies under the frame like the outline did. */
.table-object.is-hidden > .table-token {
  outline: none;
}

.table-object.is-hidden > .table-token::before {
  position: absolute;
  inset: 0;
  content: "";
  border: 2px dashed rgba(var(--table-white-rgb), 0.5);
  pointer-events: none;
}

.table-token__frame {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: rgba(var(--table-panel-rgb), 0.95);
  border: var(--token-width) solid var(--token-color);
  box-shadow: 0 4px 14px rgba(var(--table-black-rgb), 0.55);
  box-sizing: border-box;
  container-type: size;
}

.table-token[data-shape="round"] .table-token__frame {
  border-radius: 50%;
}

.table-token[data-shape="square"] .table-token__frame {
  border-radius: 12%;
}

.table-token__frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.table-token__sigil {
  color: var(--token-color);
  font-size: 40cqmin;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.table-token__name {
  position: absolute;
  top: calc(100% + 4px * var(--token-scale, 1));
  left: 50%;
  max-width: 180%;
  padding: calc(1px * var(--token-scale, 1)) calc(7px * var(--token-scale, 1));
  overflow: hidden;
  color: var(--table-text);
  font-size: calc(12px * var(--token-scale, 1));
  white-space: nowrap;
  text-overflow: ellipsis;
  background: rgba(var(--table-panel-rgb), 0.85);
  border-radius: 999px;
  transform: translateX(-50%) scale(min(1, calc(var(--token-ui-max) / (var(--token-scale, 1) * var(--token-cam)))));
  transform-origin: 50% 0;
  pointer-events: none;
}

.table-token__health {
  position: absolute;
  bottom: calc(-3px * var(--token-scale, 1));
  left: 50%;
  width: min(76%, 76px * var(--token-scale, 1));
  height: calc(6px * var(--token-scale, 1));
  overflow: hidden;
  background: rgba(var(--table-black-rgb), 0.7);
  border: 1px solid rgba(var(--table-black-rgb), 0.8);
  border-radius: calc(3px * var(--token-scale, 1));
  /* Only its thickness is capped: its length stays a share of the token. */
  transform: translateX(-50%) scaleY(min(1, calc(var(--token-ui-max) / (var(--token-scale, 1) * var(--token-cam)))));
}

.table-token__health[hidden],
.table-token__name[hidden] {
  display: none;
}

.table-token__health-fill {
  height: 100%;
  background: var(--bs-success, #198754);
}

.table-token__health[data-level="mid"] .table-token__health-fill {
  background: var(--bs-warning, #ffc107);
}

.table-token__health[data-level="low"] .table-token__health-fill {
  background: var(--bs-danger, #dc3545);
}

/* A Sternlos character's civic score above its head (TokenObject.renderCivic): five stars on a dark
   pill, as many lit as it has, the gold of the sheet's civic tile. The pill keeps them readable on
   any map; it grows with the name (--token-scale). Static: no animation, no filter. Unrated: five
   unlit stars, greyer, the rating nobody wants. */
.table-token__civic {
  --civic-gold: 227, 192, 99;

  position: absolute;
  bottom: calc(100% + 3px * var(--token-scale, 1));
  left: 50%;
  display: flex;
  padding: calc(2px * var(--token-scale, 1)) calc(5px * var(--token-scale, 1));
  background: rgba(var(--table-panel-rgb), 0.88);
  border: 1px solid rgba(var(--civic-gold), 0.4);
  border-radius: 999px;
  transform: translateX(-50%) scale(min(1, calc(var(--token-ui-max) / (var(--token-scale, 1) * var(--token-cam)))));
  transform-origin: 50% 100%;
  pointer-events: none;
}

.table-token__civic[hidden] {
  display: none;
}

.table-token__civic svg {
  display: block;
  width: calc(55px * var(--token-scale, 1));
  height: calc(11px * var(--token-scale, 1));
  overflow: visible;
}

.table-token__civic path {
  fill: none;
  stroke: rgba(var(--civic-gold), 0.55);
  stroke-width: 1.3;
  stroke-linejoin: round;
}

.table-token__civic path.is-lit {
  fill: rgb(var(--civic-gold));
  stroke: rgb(var(--civic-gold));
}

.table-token__civic.is-unrated {
  border-color: rgba(var(--table-white-rgb), 0.18);
}

.table-token__civic.is-unrated path {
  stroke: rgba(var(--table-white-rgb), 0.45);
}

/* The GM's view of stars or status badges hidden from players: dimmed, in a dashed outline. */
.table-token__civic.is-hidden-from-players {
  opacity: 0.5;
  border-style: dashed;
  border-color: rgba(var(--table-white-rgb), 0.55);
}

/* A character's status effects (TokenObject.renderStatus): small dark discs down the right edge,
   half over the frame, each with the effect's icon in its colour and how often it stacks in the
   corner. At most four; a fifth place counts the rest. Clear of the stars (top centre), the
   health bar (bottom centre) and the name (below). Static. */
.table-token__status {
  position: absolute;
  top: calc(-2px * var(--token-scale, 1));
  left: calc(100% - 9px * var(--token-scale, 1));
  display: flex;
  flex-direction: column;
  gap: calc(2px * var(--token-scale, 1));
  /* Shrinks around the discs' centre line on the token's edge. */
  transform: scale(min(1, calc(var(--token-ui-max) / (var(--token-scale, 1) * var(--token-cam)))));
  transform-origin: calc(9px * var(--token-scale, 1)) 0;
  pointer-events: none;
}

.table-token__status[hidden] {
  display: none;
}

.table-token__status-badge {
  --status-color: var(--table-text);

  position: relative;
  display: grid;
  place-items: center;
  width: calc(17px * var(--token-scale, 1));
  height: calc(17px * var(--token-scale, 1));
  color: var(--status-color);
  font-size: calc(9px * var(--token-scale, 1));
  line-height: 1;
  background: rgba(var(--table-panel-rgb), 0.92);
  border: 1px solid color-mix(in srgb, var(--status-color) 55%, transparent);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(var(--table-black-rgb), 0.6);
}

/* The brand's colours in their dark-theme text tint (the table is dark), readable on the disc. */
.table-token__status-badge[data-color="info"] { --status-color: var(--bs-info-text-emphasis, #6edff6); }
.table-token__status-badge[data-color="success"] { --status-color: var(--bs-success-text-emphasis, #75b798); }
.table-token__status-badge[data-color="primary"] { --status-color: var(--bs-primary-text-emphasis, #6ea8fe); }
.table-token__status-badge[data-color="secondary"] { --status-color: var(--bs-secondary-text-emphasis, #a7acb1); }
.table-token__status-badge[data-color="warning"] { --status-color: var(--bs-warning-text-emphasis, #ffda6a); }
.table-token__status-badge[data-color="danger"] { --status-color: var(--bs-danger-text-emphasis, #ea868f); }

/* How often it stacks: a tiny number on the disc's lower right. */
.table-token__status-count {
  position: absolute;
  right: calc(-4px * var(--token-scale, 1));
  bottom: calc(-3px * var(--token-scale, 1));
  min-width: calc(10px * var(--token-scale, 1));
  padding: 0 calc(2px * var(--token-scale, 1));
  color: var(--table-text);
  font-family: var(--bs-body-font-family, system-ui, sans-serif);
  font-size: calc(8px * var(--token-scale, 1));
  font-weight: 700;
  line-height: calc(10px * var(--token-scale, 1));
  text-align: center;
  background: rgba(var(--table-black-rgb), 0.85);
  border-radius: 999px;
}

.table-token__status-more {
  color: var(--table-text);
  font-family: var(--bs-body-font-family, system-ui, sans-serif);
  font-size: calc(8px * var(--token-scale, 1));
  font-weight: 700;
  border-color: rgba(var(--table-white-rgb), 0.35);
}

.table-token__status.is-hidden-from-players {
  opacity: 0.5;
}

.table-token__status.is-hidden-from-players .table-token__status-badge {
  border-style: dashed;
  border-color: rgba(var(--table-white-rgb), 0.6);
}

/* The combat turn marker under the active token (TokenObject.setTurn): a dashed track with
   three arcs, one turn a minute; it stands still with reduced motion. */
.table-token__turn {
  position: absolute;
  top: -24%;
  left: -24%;
  width: 148%;
  height: 148%;
  overflow: visible;
  color: var(--table-accent-text);
  pointer-events: none;
  filter: drop-shadow(0 0 3px rgba(var(--table-accent-rgb), 0.75));
  animation: table-turn-spin 60s linear infinite;
}

.table-token__turn circle {
  fill: none;
  stroke: currentColor;
}

.table-token__turn-inner {
  stroke-width: 0.8;
  opacity: 0.45;
}

.table-token__turn-ticks {
  stroke-width: 1.6;
  stroke-dasharray: 0.6 2.4;
  opacity: 0.8;
}

.table-token__turn-arcs {
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-dasharray: 26 14;
}

@keyframes table-turn-spin {
  to {
    transform: rotate(1turn);
  }
}

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

/* ---- Token frames (objects/tokenFrames.js) --------------------------------------------------
   A user's frame around their tokens: two inline SVG layers next to the frame, reaching 14 % past
   the token. Each frame sets its colours (--tf-a…d, mixed with the token's --token-color) and the
   animated layer's motion in its plugin's CSS (the `token-frames` plugin's frames.css,
   sea-pack.css). Only transform and opacity animate, on the whole layer; the motion
   pauses while the camera moves and stops with reduced motion or the "reduce effects" switch. */

.table-token[data-frame]:not([data-frame="classic"]) .table-token__frame {
  border: 0;
  box-shadow:
    0 4px 14px rgba(var(--table-black-rgb), 0.55),
    inset 0 0 0 1px rgba(var(--table-black-rgb), 0.45);
}

.tf-layer {
  position: absolute;
  top: -14%;
  left: -14%;
  width: 128%;
  height: 128%;
  overflow: visible;
  pointer-events: none;
}

.tf-base {
  filter: drop-shadow(0 1px 1.5px rgba(var(--table-black-rgb), 0.6));
}

.tf-anim {
  opacity: var(--tf-rest, 0.7);
  transform-origin: 50% 50%;
  animation: var(--tf-motion, none) var(--tf-duration, 8s) ease-in-out infinite;
}

.tf-fa { fill: var(--tf-a); }
.tf-fb { fill: var(--tf-b); }
.tf-fc { fill: var(--tf-c); }
.tf-fd { fill: var(--tf-d); }
.tf-sa { stroke: var(--tf-a); }
.tf-sb { stroke: var(--tf-b); }
.tf-sc { stroke: var(--tf-c); }
.tf-sd { stroke: var(--tf-d); }
.tf-fe { fill: var(--tf-e); }
.tf-se { stroke: var(--tf-e); }
.tf-faint { opacity: 0.55; }
.tf-dim { opacity: 0.4; }

.tf-anim--spin { --tf-motion: tf-pulse; }
.table-token[data-shape="round"] .tf-anim--spin {
  --tf-motion: tf-spin;
  opacity: var(--tf-spin-opacity, 0.8);
  animation-timing-function: linear;
}
.tf-anim--pulse { --tf-motion: tf-pulse; }
.tf-anim--sway { --tf-motion: tf-sway; --tf-rest: 1; }
.tf-anim--twinkle { --tf-motion: tf-twinkle; }
.tf-anim--flicker { --tf-motion: tf-flicker; --tf-rest: 0.9; }
.tf-anim--rise { --tf-motion: tf-rise; --tf-rest: 0.5; animation-timing-function: linear; }
.tf-anim--breathe { --tf-motion: tf-breathe; --tf-rest: 0.3; }
.tf-anim--strike { --tf-motion: tf-strike; --tf-rest: 0.15; animation-timing-function: linear; }

@keyframes tf-spin {
  to {
    transform: rotate(1turn);
  }
}

@keyframes tf-pulse {
  0%,
  100% {
    opacity: var(--tf-low, 0.25);
  }

  50% {
    opacity: var(--tf-high, 0.9);
  }
}

@keyframes tf-sway {
  0%,
  100% {
    transform: rotate(calc(var(--tf-sway, 1.6deg) * -1));
  }

  50% {
    transform: rotate(var(--tf-sway, 1.6deg));
  }
}

@keyframes tf-twinkle {
  0%,
  100% {
    opacity: 0.15;
    transform: scale(0.995);
  }

  45% {
    opacity: 1;
    transform: scale(1.005);
  }

  65% {
    opacity: 0.7;
  }
}

@keyframes tf-flicker {
  0%,
  100% {
    opacity: 0.9;
    transform: scale(1);
  }

  9% {
    opacity: 0.55;
  }

  11% {
    opacity: 1;
    transform: scale(1.01);
  }

  45% {
    opacity: 0.7;
    transform: scale(0.995);
  }

  48% {
    opacity: 1;
  }

  72% {
    opacity: 0.8;
    transform: scale(1.008);
  }
}

@keyframes tf-rise {
  0% {
    opacity: 0;
    transform: translateY(3%);
  }

  30% {
    opacity: 0.9;
  }

  100% {
    opacity: 0;
    transform: translateY(-5%);
  }
}

/* Lightning: two quick strikes, then about three dark seconds (never three flashes a second). */
@keyframes tf-strike {
  0%,
  16%,
  100% {
    opacity: 0.15;
  }

  3% {
    opacity: 1;
  }

  6% {
    opacity: 0.35;
  }

  9% {
    opacity: 0.95;
  }
}

@keyframes tf-breathe {
  0%,
  100% {
    opacity: 0.08;
    transform: scale(0.99);
  }

  50% {
    opacity: 0.45;
    transform: scale(1.01);
  }
}

/* tokenFrames.js freezes the rendered layers while the camera moves (a paused animation keeps
   its compositor layers); this pause holds the others. */
.table-world.is-moving .tf-anim {
  animation-play-state: paused;
}

.table-root.is-effects-reduced .tf-anim,
.table-effect-off--token-frames .tf-anim {
  animation: none;
}

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

/* The "Appearance" tab of the settings (LooksPanel): collapsible sections, each with its title
   and the current choice in the summary, a one-line hint and a grid of uniform radio tiles (a
   small picture over the name). Frames, cursors and pings share the tile. */
.table-looks {
  display: flex;
  flex-direction: column;
}

.table-looks__section + .table-looks__section {
  border-top: 1px solid rgba(var(--table-white-rgb), 0.08);
}

.table-looks__summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 2px;
  list-style: none;
  cursor: pointer;
}

.table-looks__summary::-webkit-details-marker {
  display: none;
}

/* A chevron that turns when the section opens. */
.table-looks__summary::after {
  width: 7px;
  height: 7px;
  margin: 0 3px 3px 0;
  border-right: 1.5px solid var(--table-muted);
  border-bottom: 1.5px solid var(--table-muted);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  content: "";
}

.table-looks__section[open] > .table-looks__summary::after {
  margin-bottom: -2px;
  transform: rotate(225deg);
}

.table-looks__summary:focus-visible {
  outline: 2px solid var(--table-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.table-looks__title {
  color: var(--table-muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.table-looks__current {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  color: var(--table-text);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.table-looks__dot {
  flex: none;
  width: 12px;
  height: 12px;
  background: var(--swatch);
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px rgba(var(--table-black-rgb), 0.5);
}

.table-looks__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 0 12px;
}

.table-looks__hint {
  margin: 0;
  color: var(--table-muted);
  font-size: 12px;
}

.table-looks__tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 5px;
}

.table-looks__tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
  padding: 4px 2px 5px;
  background: rgba(var(--table-white-rgb), 0.04);
  border: 1px solid rgba(var(--table-white-rgb), 0.1);
  border-radius: 8px;
  cursor: pointer;
}

/* The radio stays focusable for the keyboard but the tile shows the state. */
.table-looks__tile input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.table-looks__tile:has(input:checked) {
  background: rgba(var(--table-accent-rgb), 0.16);
  border-color: var(--table-accent);
}

.table-looks__tile:has(input:focus-visible) {
  outline: 2px solid var(--table-accent);
  outline-offset: 2px;
}

.table-looks__pic {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 40px;
  overflow: hidden;
}

.table-looks__pic .table-token {
  position: relative;
  width: 28px;
  height: 28px;
  --token-width: 2.5px;
}

/* A ping, low in the picture so beacons and arrow drops have room; still unless just chosen. */
.table-looks__pic .table-ping {
  top: 72%;
  left: 50%;
  transform: scale(0.42);
}

.table-looks__pic:not(.is-playing) .table-ping,
.table-looks__pic:not(.is-playing) .table-ping * {
  animation-delay: -0.6s;
  animation-play-state: paused;
}

.table-looks__pic .table-cursor {
  top: 50%;
  left: 50%;
}

/* Up to two lines, so longer names ("Gilded filigree") stay whole. */
.table-looks__name {
  display: -webkit-box;
  max-width: 100%;
  overflow: hidden;
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

/* The user's colour: "Automatic", the palette and a custom colour as round swatches. */
.table-looks__colors {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(28px, 1fr));
  gap: 6px;
}

.table-looks__swatch {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  background: var(--swatch, transparent);
  border: 2px solid rgba(var(--table-white-rgb), 0.15);
  border-radius: 50%;
  cursor: pointer;
}

.table-looks__swatch input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.table-looks__swatch:has(input:checked) {
  border-color: var(--table-text);
  box-shadow: 0 0 0 2px var(--table-accent);
}

.table-looks__swatch:has(input:focus-visible) {
  outline: 2px solid var(--table-accent);
  outline-offset: 2px;
}

.table-looks__swatch-text {
  color: rgba(var(--table-black-rgb), 0.75);
  font-size: 11px;
  font-weight: 700;
}

/* The custom swatch is the colour input itself, showing the custom colour. */
.table-looks__custom-color {
  width: 100%;
  height: 100%;
  padding: 0;
  overflow: hidden;
  background: conic-gradient(#ff6b6b, #feca57, #4cd964, #3dd6d0, #6c8cff, #c77dff, #ff6b6b);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.table-looks__swatch.is-custom:has(input:checked) .table-looks__custom-color {
  background: none;
}

.table-looks__custom-color::-webkit-color-swatch-wrapper {
  padding: 0;
}

.table-looks__custom-color::-webkit-color-swatch {
  border: 0;
  border-radius: 50%;
}

.table-looks__custom-color::-moz-color-swatch {
  border: 0;
  border-radius: 50%;
}

.table-looks__swatch.is-custom:not(:has(input:checked)) .table-looks__custom-color::-webkit-color-swatch {
  opacity: 0;
}

.table-looks__swatch.is-custom:not(:has(input:checked)) .table-looks__custom-color::-moz-color-swatch {
  opacity: 0;
}

.table-looks__status {
  min-height: 1.2em;
  margin: 0;
  color: var(--table-muted);
  font-size: 12px;
}

.table-looks__status[data-state="error"] {
  color: var(--bs-danger, #dc3545);
}

/* ---- Image frames (objects/imageFrames.js) --------------------------------------------------
   A frame the GM puts around an image or battlemap: one layer, the last child of the image's
   content, so it lies above the image, its effect and its grid. "inner" frames cover the image's
   edge, "outer" ones lie around it; neither takes pointer input or changes the object's bounds.
   The layer carries --if-w/--if-h (image), --if-t (thickness) and --if-lw/--if-lh (layer) in
   world px; each frame sets its palette (--if-a…) on .if-<id> in its plugin's CSS (the
   `image-frames` plugin's frames.css, sea-pack.css). Motion is transform and opacity only; it pauses while the camera moves
   and stops with reduced motion or the "reduce effects" switch. */

.table-image-frame {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.table-image-frame[data-placement="outer"] {
  inset: calc(-1 * var(--if-t));
}

.table-image-frame > * {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Camera sets .is-camera-moving on the frames themselves: a class on the world restyled every
   node of the table at each start and stop of a camera move. */
.table-image-frame.is-camera-moving,
.table-image-frame.is-camera-moving *,
.table-image-frame.is-camera-moving *::before,
.table-image-frame.is-camera-moving *::after {
  animation-play-state: paused !important;
}

.table-root.is-effects-reduced .table-image-frame,
.table-root.is-effects-reduced .table-image-frame *,
.table-root.is-effects-reduced .table-image-frame *::before,
.table-root.is-effects-reduced .table-image-frame *::after,
.table-effect-off--image-frames .table-image-frame,
.table-effect-off--image-frames .table-image-frame *,
.table-effect-off--image-frames .table-image-frame *::before,
.table-effect-off--image-frames .table-image-frame *::after {
  animation-play-state: paused !important;
}

@media (prefers-reduced-motion: reduce) {
  .table-image-frame,
  .table-image-frame *,
  .table-image-frame *::before,
  .table-image-frame *::after {
    animation-play-state: paused !important;
  }
}

/* Shared shading: the moulding's light from the top left, a dark rim. */
.table-image-frame .if-light {
  opacity: 0.1;
}

.table-image-frame .if-rim {
  stroke: rgba(0, 0, 0, 0.6);
}

/* ---- End of image frames (set 3) ----------------------------------------------------------- */

/* ---- Icons ------------------------------------------------------------------------------ */

.table-icon {
  display: block;
  width: 18px;
  height: 18px;
}

/* ---- Selection and handles (screen space, constant size) -------------------------------- */

.table-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.table-alignment-guide {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  background: var(--table-accent);
  box-shadow: 0 0 5px var(--table-accent);
  opacity: 0.8;
}

.table-alignment-guide[hidden] { display: none; }
/* A segment between the dragged object and the one it aligns with (Transformer._showGuides). */
.table-alignment-guide--vertical { width: 1px; margin-left: -0.5px; }
.table-alignment-guide--horizontal { height: 1px; margin-top: -0.5px; }

.table-selection {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 50% 50%;
  border: 1.5px solid var(--table-accent);
  box-shadow:
    0 0 0 1px rgba(var(--table-black-rgb), 0.35),
    0 0 14px rgba(var(--table-accent-rgb), 0.45);
  box-sizing: border-box;
}

.table-selection.is-readonly {
  border-style: dashed;
  border-color: rgba(var(--table-white-rgb), 0.55);
  box-shadow: none;
}

.table-token-transform-toggle,
.table-token-portrait-action {
  position: absolute;
  width: 36px;
  height: 36px;
  padding: 0;
  pointer-events: auto;
  touch-action: manipulation;
  color: var(--table-accent-text);
  background: rgb(var(--table-panel-rgb));
  border: 1px solid var(--table-accent);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(var(--table-black-rgb), 0.6);
  cursor: pointer;
}

.table-token-transform-toggle,
.table-token-portrait-action { display: inline-flex; align-items: center; justify-content: center; }
.table-token-transform-toggle[hidden],
.table-token-portrait-action[hidden] { display: none; }
.table-token-transform-toggle .table-icon { width: 20px; height: 20px; }
.table-token-portrait-action .table-icon { width: 18px; height: 18px; }
.table-token-transform-toggle[aria-pressed="true"] { background: var(--table-accent); color: rgb(var(--table-panel-rgb)); }
.table-token-portrait-action:hover { background: rgba(var(--table-accent-rgb), 0.18); }
.table-token-transform-toggle:focus-visible,
.table-token-portrait-action:focus-visible { outline: 3px solid var(--table-accent); outline-offset: 3px; }

.table-handle {
  position: absolute;
  display: none;
  width: var(--table-handle-size);
  height: var(--table-handle-size);
  margin: calc(var(--table-handle-size) / -2) 0 0 calc(var(--table-handle-size) / -2);
  pointer-events: auto;
  background: #fff;
  border: 1.5px solid var(--table-accent);
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(var(--table-black-rgb), 0.5);
  box-sizing: border-box;
  touch-action: none;
}

/* Only visible handles extend their hit area. */
.table-selection.has-handles .table-handle::before {
  content: "";
  position: absolute;
  inset: -6px;
}

.table-selection.has-handles .table-handle {
  display: block;
}

.table-selection.has-handles.is-small .table-handle--n,
.table-selection.has-handles.is-small .table-handle--e,
.table-selection.has-handles.is-small .table-handle--s,
.table-selection.has-handles.is-small .table-handle--w {
  display: none;
}

.table-handle--nw { top: 0; left: 0; }
.table-handle--n { top: 0; left: 50%; }
.table-handle--ne { top: 0; left: 100%; }
.table-handle--e { top: 50%; left: 100%; }
.table-handle--se { top: 100%; left: 100%; }
.table-handle--s { top: 100%; left: 50%; }
.table-handle--sw { top: 100%; left: 0; }
.table-handle--w { top: 50%; left: 0; }

/* Token handles sit beyond the token's own hit area, leaving its whole face draggable. */
.table-selection.is-token .table-handle--nw { top: -12px; left: -12px; }
.table-selection.is-token .table-handle--n { top: -12px; }
.table-selection.is-token .table-handle--ne { top: -12px; left: calc(100% + 12px); }
.table-selection.is-token .table-handle--e { left: calc(100% + 12px); }
.table-selection.is-token .table-handle--se { top: calc(100% + 12px); left: calc(100% + 12px); }
.table-selection.is-token .table-handle--s { top: calc(100% + 12px); }
.table-selection.is-token .table-handle--sw { top: calc(100% + 12px); left: -12px; }
.table-selection.is-token .table-handle--w { left: -12px; }

.table-handle--rotate {
  top: -28px;
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--table-accent);
  border-color: #fff;
  cursor: grab;
}

/* Stem between the rotate handle and the frame. */
.table-handle--rotate::after {
  content: "";
  position: absolute;
  top: 12px;
  left: 50%;
  width: 1.5px;
  height: 16px;
  margin-left: -0.75px;
  background: var(--table-accent);
}

.table-marquee {
  position: absolute;
  top: 0;
  left: 0;
  border: 1px solid rgba(var(--table-accent-rgb), 0.9);
  background: rgba(var(--table-accent-rgb), 0.12);
}

.table-marquee__mode {
  position: absolute;
  top: 2px;
  left: 2px;
  padding: 2px 6px;
  color: var(--table-text);
  background: rgba(var(--table-panel-rgb), 0.95);
  border: 1px solid var(--table-accent);
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
}

/* ---- Pings (Ping.js) -------------------------------------------------------------------- */

/* Screen-space layer above the world; each ping is placed by transform only. */
.table-pings {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.table-ping,
.table-ping-arrow {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  animation: table-ping-fade 2.6s ease-in forwards;
}

.table-ping__ring,
.table-ping__dot {
  position: absolute;
  border-radius: 50%;
}

.table-ping__ring {
  top: -36px;
  left: -36px;
  width: 72px;
  height: 72px;
  border: 3px solid var(--ping-color);
  box-shadow: 0 0 12px var(--ping-color);
  opacity: 0;
  animation: table-ping-ripple 1.1s ease-out 2;
}

.table-ping__ring + .table-ping__ring {
  animation-delay: 0.35s;
}

.table-ping__dot {
  top: -6px;
  left: -6px;
  width: 12px;
  height: 12px;
  background: var(--ping-color);
  box-shadow: 0 0 0 2px rgba(var(--table-black-rgb), 0.5);
}

.table-ping__label {
  position: absolute;
  top: 18px;
  left: 0;
  max-width: 160px;
  padding: 1px 7px;
  overflow: hidden;
  color: var(--table-text);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
  background: rgba(var(--table-panel-rgb), 0.85);
  border-left: 3px solid var(--ping-color);
  border-radius: 4px;
  transform: translateX(-50%);
}

/* The arrow points from the viewport centre towards the ping (--ping-angle). */
.table-ping-arrow__head {
  position: absolute;
  top: -11px;
  left: -11px;
  width: 22px;
  height: 22px;
  background: var(--ping-color);
  clip-path: polygon(100% 50%, 0 0, 25% 50%, 0 100%);
  filter: drop-shadow(0 0 4px rgba(var(--table-black-rgb), 0.6));
  transform: rotate(var(--ping-angle, 0rad));
  animation: table-ping-nudge 0.55s ease-in-out 4 alternate;
}

.table-ping-arrow .table-ping__label {
  top: -9px;
  left: 18px;
  transform: none;
}

.table-ping-arrow.is-right .table-ping__label {
  right: 18px;
  left: auto;
}

.table-ping-arrow.is-bottom .table-ping__label {
  top: auto;
  bottom: -9px;
}

/* Rulers: the ruler tool's line, everyone else's and a dragged token's trail (Ruler.js). Thin,
   in the measurer's ping colour, with a dark halo so they read on any battlemap. */
.table-rulers {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.table-rulers__svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.table-ruler {
  transition: opacity 0.3s ease-out;
}

.table-ruler__halo {
  stroke: rgba(var(--table-black-rgb), 0.45);
  stroke-width: 4.5px;
  stroke-linecap: round;
}

.table-ruler__line {
  stroke: var(--ruler-color);
  stroke-width: 1.5px;
  stroke-linecap: round;
}

.table-ruler.is-dashed .table-ruler__line {
  stroke-dasharray: 6px 5px;
}

.table-ruler__start {
  fill: rgba(var(--table-panel-rgb), 0.85);
  stroke: var(--ruler-color);
  stroke-width: 1.5px;
}

.table-ruler__end {
  fill: var(--ruler-color);
}

.table-ruler.is-fading,
.table-ruler__label.is-fading {
  opacity: 0;
}

.table-ruler__label {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  gap: 6px;
  align-items: baseline;
  padding: 1px 8px 2px;
  color: var(--table-text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
  white-space: nowrap;
  background: rgba(var(--table-panel-rgb), 0.82);
  border: 1px solid color-mix(in srgb, var(--ruler-color) 55%, transparent);
  border-radius: 999px;
  translate: 0 -50%;
  transition: opacity 0.3s ease-out;
}

.table-ruler__label.is-left {
  translate: -100% -50%;
}

.table-ruler__label[hidden] {
  display: none;
}

.table-ruler__value:empty,
.table-ruler__name:empty {
  display: none;
}

.table-ruler__name {
  max-width: 140px;
  overflow: hidden;
  color: var(--table-muted);
  text-overflow: ellipsis;
}

/* After release the line lingers with a quiet offer to keep it as a measure. */
.table-ruler__label.has-keep {
  pointer-events: auto;
}

.table-ruler__keep {
  padding: 0 0 0 7px;
  color: var(--ruler-color);
  font: inherit;
  background: none;
  border: 0;
  border-left: 1px solid rgba(var(--table-white-rgb), 0.15);
  cursor: pointer;
}

.table-ruler__keep:hover,
.table-ruler__keep:focus-visible {
  text-decoration: underline;
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  .table-ruler,
  .table-ruler__label {
    transition: none;
  }
}

@keyframes table-ping-ripple {
  from {
    opacity: 1;
    transform: scale(0.15);
  }

  to {
    opacity: 0;
    transform: scale(1.5);
  }
}

@keyframes table-ping-fade {
  0%,
  75% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

@keyframes table-ping-nudge {
  to {
    translate: calc(cos(var(--ping-angle, 0rad)) * 6px) calc(sin(var(--ping-angle, 0rad)) * 6px);
  }
}

/* Ping styles (Ping.js `pingElement`): the parts sit around the spot, which is the 0×0 box of
   .table-ping; SVG shapes use a viewBox of -40 -80 80 120 at 1 px per unit, so their (0 0) is
   the spot too. Everything animates transform and opacity only, on the compositor (see the
   README's ping styles for what keeps it there), and ends within PING_MS. */
.table-ping__shape,
.table-ping__circle {
  position: absolute;
  top: -80px;
  left: -40px;
  width: 80px;
  height: 120px;
  overflow: visible;
  fill: var(--ping-color);
  stroke: var(--ping-color);
  transform-origin: 40px 80px;
  filter: drop-shadow(0 0 5px var(--ping-color)) drop-shadow(0 1px 2px rgba(var(--table-black-rgb), 0.6));
}

.table-ping__shape {
  stroke: none;
}

/* A box around SVG parts (Ping.js `box`), placed and pivoting like them, plays one of their
   motions; no element runs two transform animations, which the compositor can't play. */
.table-ping__box {
  position: absolute;
  top: -80px;
  left: -40px;
  width: 80px;
  height: 120px;
  transform-origin: 40px 80px;
}

.table-ping__box > svg {
  top: 0;
  left: 0;
}

.table-ping__flash {
  position: absolute;
  top: -36px;
  left: -36px;
  width: 72px;
  height: 72px;
  background: radial-gradient(circle, rgba(var(--table-white-rgb), 0.9), var(--ping-color) 30%, transparent 70%);
  border-radius: 50%;
  opacity: 0;
  animation: table-ping-flash 0.7s ease-out;
}

.table-ping__ground {
  position: absolute;
  top: -10px;
  left: -30px;
  width: 60px;
  height: 20px;
  border: 2px solid var(--ping-color);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--ping-color);
  opacity: 0;
  animation: table-ping-ripple 1.1s ease-out 2;
}

.table-ping__drop {
  position: absolute;
  top: -4px;
  left: -4px;
  width: 8px;
  height: 8px;
  background: var(--ping-color);
  border-radius: 50% 50% 50% 0;
  opacity: 0;
  animation: table-ping-drop 0.9s ease-out 2;
}

/* Shared light details: the compass's north point, the bell's gleam, the eye's glint. */
.table-ping__north {
  fill: color-mix(in srgb, var(--ping-color) 35%, #ffffff);
}

.table-ping__rachis {
  stroke: color-mix(in srgb, var(--ping-color) 40%, #ffffff);
}

/* With reduced motion: a still ring and dot that only fade with the ping. */
.table-ping--still .table-ping__ring {
  opacity: 0.85;
  animation: none;
}

@keyframes table-ping-flash {
  from {
    opacity: 1;
    transform: scale(0.2);
  }

  to {
    opacity: 0;
    transform: scale(1.6);
  }
}

@keyframes table-ping-drop {
  from {
    opacity: 1;
    transform: rotate(calc(var(--i) / var(--n) * 1turn)) translateY(-6px) rotate(-45deg);
  }

  to {
    opacity: 0;
    transform: rotate(calc(var(--i) / var(--n) * 1turn)) translateY(-36px) rotate(-45deg) scale(0.4);
  }
}


@media (prefers-reduced-motion: reduce) {
  .table-ping__ring {
    opacity: 0.8;
    animation: none;
  }

  .table-ping__ring + .table-ping__ring {
    display: none;
  }

  .table-ping-arrow__head {
    animation: none;
  }
}

.table-root.is-effects-reduced .table-ping-arrow__head,
.table-effect-off--pings .table-ping-arrow__head {
  animation: none;
}

/* Fills under the cursor while a press is held for a ping (Table._startLongPress). It shows
   only after a moment, so ordinary clicks and drags never flash it. */
.table-press-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.table-press-ring svg {
  position: absolute;
  top: -20px;
  left: -20px;
  width: 40px;
  height: 40px;
  opacity: 0;
  transform: rotate(-90deg);
  animation: table-press-show 0.1s linear 0.15s forwards;
}

.table-press-ring circle {
  fill: none;
  stroke-width: 3.5;
}

.table-press-ring__track {
  stroke: rgba(var(--table-black-rgb), 0.45);
}

.table-press-ring__fill {
  stroke: var(--ping-color, var(--table-accent));
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: table-press-fill 0.5s linear forwards;
}

@keyframes table-press-show {
  to {
    opacity: 1;
  }
}

@keyframes table-press-fill {
  to {
    stroke-dashoffset: 0;
  }
}

.table-viewport.is-drop-target::after {
  content: "";
  position: absolute;
  inset: 12px;
  z-index: 6;
  pointer-events: none;
  border: 2px dashed rgba(var(--table-accent-rgb), 0.8);
  border-radius: 12px;
  background: rgba(var(--table-accent-rgb), 0.07);
}

.table-fit-rect {
  position: absolute;
  top: 0;
  left: 0;
  border: 1.5px solid var(--bs-warning, #ffc107);
  background: rgba(255, 193, 7, 0.15);
}

.table-viewport.is-fitting,
.table-viewport.is-fitting * {
  cursor: crosshair !important;
}

/* ---- Ghost cursors (GhostCursors.js, cursorStyles.js) ------------------------------------ */

/* Everyone else's pointers: above the objects, below the HUD and menus. Placed by transform. */
.table-ghost-cursors {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.table-cursor {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  transition: opacity 0.35s ease;
}

/* Only the ghosts glide; the previews in the looks panel stay put and get no layer of their own. */
.table-ghost-cursors .table-cursor {
  will-change: transform;
}

.table-cursor.is-fading {
  opacity: 0;
}

.table-cursor__shape {
  position: absolute;
  overflow: visible;
  filter: drop-shadow(0 1px 2px rgba(var(--table-black-rgb), 0.55));
}

/* On the table the others' cursors stay in the background: the pointer and its trail are
   translucent, with a thin dark halo so they still read on light maps; the name chip is a
   little see-through too, its text solid. */
.table-ghost-cursors .table-cursor__shape {
  opacity: 0.65;
  filter:
    drop-shadow(0 0 1px rgba(var(--table-black-rgb), 0.55))
    drop-shadow(0 1px 2px rgba(var(--table-black-rgb), 0.35));
}

.table-ghost-cursors .table-cursor__name {
  background: color-mix(in srgb, var(--cursor-color) 70%, transparent);
  box-shadow: 0 1px 3px rgba(var(--table-black-rgb), 0.3);
}

/* Shape parts: the user's colour, a pale edge drawn under it, dark ink and pale highlights. */
.table-cursor .c-fill {
  fill: var(--cursor-color);
}

.table-cursor .c-edge {
  stroke: rgba(var(--table-white-rgb), 0.95);
  stroke-width: 1.6;
  stroke-linejoin: round;
  paint-order: stroke;
}

.table-cursor .c-light {
  fill: rgba(var(--table-white-rgb), 0.9);
}

.table-cursor .c-ink-line,
.table-cursor .c-outline,
.table-cursor .c-stroke,
.table-cursor .c-outline-wide,
.table-cursor .c-ink-line-wide,
.table-cursor .c-stroke-wide {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.table-cursor .c-ink-line {
  stroke: rgba(var(--table-black-rgb), 0.5);
  stroke-width: 1.3;
}

.table-cursor .c-outline {
  stroke: rgba(var(--table-black-rgb), 0.6);
  stroke-width: 4;
}

.table-cursor .c-stroke {
  stroke: var(--cursor-color);
  stroke-width: 2;
}

.table-cursor .c-outline-wide {
  stroke: rgba(var(--table-white-rgb), 0.9);
  stroke-width: 5.5;
}

.table-cursor .c-ink-line-wide {
  stroke: rgba(var(--table-black-rgb), 0.85);
  stroke-width: 3;
}

.table-cursor .c-stroke-wide {
  stroke: var(--cursor-color);
  stroke-width: 3.2;
}

/* A dark edge under pale parts (a blade, the white of an eye). */
.table-cursor .c-dark-edge {
  stroke: rgba(var(--table-black-rgb), 0.7);
  stroke-width: 1.4;
  stroke-linejoin: round;
  paint-order: stroke;
}

/* Glass: a pale wash of the user's colour (a lens, a lantern's panes). */
.table-cursor .c-glass {
  fill: color-mix(in srgb, var(--cursor-color) 30%, rgba(var(--table-white-rgb), 0.35));
}

.table-cursor .c-light-line {
  fill: none;
  stroke: rgba(var(--table-white-rgb), 0.9);
  stroke-width: 1.4;
  stroke-linecap: round;
}

/* The name chip, beside the pointer; centred styles keep it clear of their shape. */
.table-cursor__name {
  position: absolute;
  top: 20px;
  left: 14px;
  max-width: 180px;
  padding: 1px 7px;
  overflow: hidden;
  color: var(--cursor-ink);
  font-size: 11px;
  font-weight: 600;
  line-height: 16px;
  white-space: nowrap;
  text-overflow: ellipsis;
  background: var(--cursor-color);
  border-radius: 999px;
  box-shadow: 0 1px 3px rgba(var(--table-black-rgb), 0.45);
}

/* Trails: sparkles behind the wand, a glowing tail behind the comet, drawn on one canvas under
   the cursors (GhostCursors.js `trailSprite` draws the dots: the comet's ball with an 8px 2px glow,
   the sparkle's star twinkling with a 3px drop shadow, both at 60% like the pointers). */
.table-cursor-trails {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* No trails with reduced effects (GhostCursors.js also stops laying them). */
.table-root.is-effects-reduced .table-cursor-trails {
  display: none;
}

/* Switched off in the Performance tab (effectSettings.js): the others' pointers are not shown. */
.table-effect-off--cursors .table-ghost-cursors,
.table-effect-off--cursors .table-cursor-trails {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .table-cursor-trails {
    display: none;
  }

  .table-cursor {
    transition: none;
  }
}

/* The Appearance tab's cursor switch. */
.table-looks__switch {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

/* ---- Panels ------------------------------------------------------------------------------ */

/* Read-only campaign roll history. It stays at the edge, away from the table's bottom controls. */
.table-dice-log {
  position: absolute;
  right: 16px;
  bottom: var(--table-hud-clear);
  z-index: var(--table-z-panel);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: min(270px, calc(100% - 32px));
  max-height: min(45vh, 390px);
  overflow: hidden;
  color: var(--table-text);
  background: rgba(var(--table-panel-rgb), 0.94);
  border: 1px solid rgba(var(--table-accent-rgb), 0.35);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(var(--table-black-rgb), 0.45);
  backdrop-filter: blur(6px);
}

.table-dice-log[hidden],
.table-dice-log [hidden] { display: none !important; }

.table-dice-log__close,
.table-dice-log__older {
  color: var(--table-text);
  background: transparent;
  border: 0;
  cursor: pointer;
}

.table-dice-log__header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 4px 4px 12px;
}

.table-dice-log__title { font-weight: 600; }

.table-dice-log__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  color: var(--table-muted);
  border-radius: 6px;
}

.table-dice-log__close .table-icon { width: 16px; height: 16px; }
.table-dice-log__close:hover,
.table-dice-log__older:hover { color: var(--table-text); background: rgba(var(--table-accent-rgb), 0.12); }
.table-dice-log__close:focus-visible,
.table-dice-log__older:focus-visible { outline: 2px solid var(--table-accent); outline-offset: -2px; }

.table-dice-log__body { min-height: 0; overflow: auto; border-top: 1px solid rgba(var(--table-accent-rgb), 0.2); }
.table-dice-log__status { margin: 8px 12px; color: var(--table-muted); font-size: 12px; }
.table-dice-log__list { margin: 0; padding: 0; list-style: none; }
.table-dice-log__row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 8px;
  padding: 8px 12px 8px 15px;
  font-size: 12px;
  border-bottom: 1px solid rgba(var(--table-white-rgb), 0.09);
}
.table-dice-log__row::before {
  content: "";
  position: absolute;
  inset: 8px auto 8px 6px;
  width: 3px;
  border-radius: 2px;
  background: var(--roll-color, var(--table-accent));
}
.table-dice-log__head { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 8px; }
.table-dice-log__head strong,
.table-dice-log__label { overflow-wrap: anywhere; }
.table-dice-log__head time,
.table-dice-log__detail,
.table-dice-log__row small { color: var(--table-muted); }
.table-dice-log__head time { white-space: nowrap; font-size: 11px; }
.table-dice-log__detail { min-width: 0; overflow-wrap: anywhere; }
/* One number per die, coloured like the result card's chips (and the character page's roll list):
   below the minimum muted, a success in the text colour, criticals in theirs. An exploded die's
   throws are its tooltip (DiceLog._row). */
.table-dice-log__die { font-variant-numeric: tabular-nums; }
.table-dice-log__die.is-fail { color: var(--dice-fail); }
.table-dice-log__die.is-success { color: var(--dice-success); }
.table-dice-log__die.is-crit { color: var(--dice-crit); font-weight: 600; }
.table-dice-log__die.is-megacrit { color: var(--dice-megacrit); font-weight: 600; }
.table-dice-log__die[title] { text-decoration: underline dotted; text-underline-offset: 2px; cursor: help; }
/* The throws of an exploded die, read by screen readers only. */
.table-dice-log__throws {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.table-dice-log__total { align-self: center; font-size: 16px; color: var(--table-accent); }
.table-dice-log__row small { grid-column: 1 / -1; }
/* The dice system's line about the roll (dice.summary), under the total. */
.table-dice-log__summary { grid-column: 1 / -1; text-align: end; overflow-wrap: anywhere; }
.table-dice-log__older { width: 100%; min-height: 36px; padding: 6px 12px; font-size: 12px; }
.table-dice-log__older:disabled { cursor: wait; opacity: 0.65; }
.table-dice-log__announce {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* A roll's rank in the log (DiceLog.js, diceResult.rollRank), as on the tray's card: the total in
   the rank's colour, a crit or megacrit tagged next to the time. A system roll without a rank
   ("plain") keeps the accent. */
.table-dice-log__total.is-fail { color: var(--dice-fail); }
.table-dice-log__total.is-success { color: var(--dice-success); }
.table-dice-log__total.is-crit { color: var(--dice-crit); font-weight: 700; }
.table-dice-log__total.is-megacrit { color: var(--dice-megacrit); font-weight: 700; }
.table-dice-log__head:has(.table-dice-log__tag) strong { margin-right: auto; }
.table-dice-log__tag {
  align-self: center;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
  white-space: nowrap;
  color: var(--dice-crit);
  background: color-mix(in srgb, var(--dice-crit) 16%, transparent);
}
.table-dice-log__row.is-megacrit .table-dice-log__tag {
  color: var(--dice-megacrit);
  background: color-mix(in srgb, var(--dice-megacrit) 16%, transparent);
}

@media (max-width: 576px) {
  .table-dice-log {
    right: 16px;
    left: 16px;
    bottom: 64px;
    width: auto;
    max-height: min(42dvh, 330px);
    border-radius: 12px 12px 8px 8px;
  }
  .table-dice-log__close { width: 44px; height: 44px; }
}

/* Switched off in the Performance tab (effectSettings.js): panels and bars no longer blur what
   lies behind them. Their backgrounds are opaque enough to read on their own. */
.table-effect-off--panel-blur * {
  backdrop-filter: none !important;
}

.table-panel {
  position: absolute;
  top: 64px;
  left: 16px;
  z-index: var(--table-z-panel);
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 220px;
  max-height: calc(100% - 96px);
  padding: 10px 12px 12px;
  overflow: auto;
  font-size: 13px;
  background: rgba(var(--table-panel-rgb), 0.88);
  border: 1px solid rgba(var(--table-accent-rgb), 0.3);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(var(--table-black-rgb), 0.45);
  backdrop-filter: blur(6px);
}

.table-panel,
.table-panel * {
  box-sizing: border-box;
}

.table-panel[hidden],
.table-panel [hidden] {
  display: none !important;
}

.table-panel__title {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--table-accent-text);
}

.table-panel__fields {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.table-panel__field {
  display: grid;
  grid-template-columns: 1fr 88px;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--table-muted);
}

.table-panel__field.is-check {
  grid-template-columns: 1fr auto;
}

.table-panel__field input {
  width: 100%;
  min-width: 0;
  color: var(--table-text);
  font: inherit;
  accent-color: var(--table-accent);
}

.table-panel__field input[type="number"] {
  padding: 2px 6px;
  background: rgba(var(--table-black-rgb), 0.3);
  border: 1px solid rgba(var(--table-white-rgb), 0.15);
  border-radius: 5px;
}

.table-panel__field input[type="color"] {
  height: 26px;
  padding: 0 2px;
  background: transparent;
  border: 1px solid rgba(var(--table-white-rgb), 0.15);
  border-radius: 5px;
}

.table-panel__field input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.table-panel__button {
  padding: 5px 10px;
  color: var(--table-text);
  font: inherit;
  background: rgba(var(--table-accent-rgb), 0.18);
  border: 1px solid rgba(var(--table-accent-rgb), 0.45);
  border-radius: 6px;
  cursor: pointer;
}

.table-panel__button:hover:not(:disabled),
.table-panel__button:focus-visible {
  background: rgba(var(--table-accent-rgb), 0.32);
  outline: none;
}

.table-panel__button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* A destructive panel action ("Remove battlemap"): red on hover, solid red while it waits for
   the second click (`is-armed`). */
.table-panel__button.is-danger:not(.is-armed):hover,
.table-panel__button.is-danger:not(.is-armed):focus-visible {
  color: var(--table-danger);
}

.table-panel__button.is-danger.is-armed,
.table-panel__button.is-danger.is-armed:hover:not(:disabled) {
  color: rgb(var(--table-white-rgb));
  background: var(--table-danger);
  border-color: var(--table-danger);
}

/* Set apart from the panel's other actions, at its end (MapPanel's "Remove battlemap"). */
.table-panel__aside {
  display: flex;
  flex-direction: column;
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid rgba(var(--table-white-rgb), 0.12);
}

.table-panel__hint {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  color: var(--table-text);
  background: rgba(255, 193, 7, 0.1);
  border: 1px solid rgba(255, 193, 7, 0.45);
  border-radius: 6px;
}

/* Inspector on the right, token picker as a drawer on the left. */
.table-inspector {
  right: 16px;
  left: auto;
  width: 240px;
  /* It ends where the dice log does, clear of the HUD bar under it. */
  max-height: calc(100% - 64px - var(--table-hud-clear));
}

/* The token's frame (FramePicker.js): a button with the frame as a small token and its name, and a
   menu of every frame beside the panel. The button is a row of the panel; the menu floats over the
   table like the other menus, its top level with the button. */
.table-frame-picker {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

.table-frame-picker__button {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 46px;
  padding: 5px 10px 5px 6px;
  color: var(--table-text);
  font: inherit;
  text-align: left;
  background: rgba(var(--table-white-rgb), 0.04);
  border: 1px solid rgba(var(--table-white-rgb), 0.14);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.table-frame-picker__button:hover,
.table-frame-picker__button[aria-expanded="true"] {
  background: rgba(var(--table-accent-rgb), 0.08);
  border-color: rgba(var(--table-accent-rgb), 0.6);
}

.table-frame-picker__button:focus-visible {
  border-color: var(--table-accent);
  outline: 2px solid var(--table-accent);
  outline-offset: 1px;
}

/* The small token: the frame reaches 14% beyond it, so it sits inside a 36px cell. */
.table-frame-picker .table-frame-picker__token,
.table-frame-picker__item .table-token {
  position: relative;
  justify-self: center;
  width: 28px;
  height: 28px;
  --token-width: 2.5px;
}

/* Tokens with different frames: an empty dashed ring keeps the button's layout. */
.table-frame-picker__token.is-mixed {
  border: 1.5px dashed rgba(var(--table-white-rgb), 0.35);
  border-radius: 50%;
}

.table-frame-picker__token.is-mixed > * {
  display: none;
}

.table-frame-picker__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.table-frame-picker__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-frame-picker__note {
  overflow: hidden;
  color: var(--table-muted);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-frame-picker__note[hidden] {
  display: none;
}

.table-frame-picker__chevron {
  width: 16px;
  height: 16px;
  color: var(--table-muted);
  rotate: 90deg;
  transition: rotate 0.15s ease;
}

.table-frame-picker__button[aria-expanded="true"] .table-frame-picker__chevron {
  color: var(--table-accent-text);
  rotate: -90deg;
}

.table-frame-picker__menu {
  position: absolute;
  z-index: var(--table-z-menu);
  box-sizing: border-box;
  padding: 0 8px 8px;
  overflow: auto;
  overscroll-behavior: contain;
  font-size: 12px;
  /* Opaque: it often lies over the panel's own text (on a phone, over the sheet). */
  background: rgb(var(--table-panel-rgb));
  border: 1px solid rgba(var(--table-accent-rgb), 0.35);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(var(--table-black-rgb), 0.55);
}

.table-frame-picker__menu[hidden] {
  display: none;
}

.table-frame-picker__heading {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0 -8px 6px;
  padding: 9px 12px 7px;
  color: var(--table-accent-text);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgb(var(--table-panel-rgb));
  border-bottom: 1px solid rgba(var(--table-white-rgb), 0.08);
}

/* Four to a row at the menu's full width, three where it is narrower (a phone, beside the
   character panel): each name fits its tile on one line. */
.table-frame-picker__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 4px;
}

.table-frame-picker__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 9px 3px 6px;
  color: var(--table-text);
  font: inherit;
  font-size: 10.5px;
  line-height: 1.2;
  background: rgba(var(--table-white-rgb), 0.03);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.table-frame-picker__grid .table-frame-picker__label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Standard first, across the menu: what the token wears without a frame of its own. A dashed
   edge tells it apart from the frames, as it follows a user's choice. */
.table-frame-picker__item.is-default {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 8px;
  width: 100%;
  margin-bottom: 8px;
  padding: 7px 10px 7px 6px;
  font-size: 12.5px;
  text-align: left;
  border: 1px dashed rgba(var(--table-white-rgb), 0.3);
}

.table-frame-picker__item:hover,
.table-frame-picker__item:focus-visible {
  background: rgba(var(--table-white-rgb), 0.09);
  outline: none;
}

.table-frame-picker__item:focus-visible {
  box-shadow: 0 0 0 2px var(--table-accent);
}

.table-frame-picker__item[aria-pressed="true"] {
  background: rgba(var(--table-accent-rgb), 0.18);
  border-color: rgba(var(--table-accent-rgb), 0.7);
  border-style: solid;
}

@media (prefers-reduced-motion: reduce) {
  .table-frame-picker__button,
  .table-frame-picker__chevron {
    transition: none;
  }
}

.table-inspector__frame-name {
  color: var(--table-muted);
  font-size: 12px;
}

/* A text label's inks: letters in each ink with its outline, on a ground between light and dark. */
.table-inspector__ink-field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

.table-inspector__inks {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
}

.table-inspector__ink {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 34px;
  background:
    linear-gradient(135deg, rgba(var(--table-white-rgb), 0.16), rgba(var(--table-black-rgb), 0.2)),
    #6b6459;
  border: 1px solid rgba(var(--table-white-rgb), 0.12);
  border-radius: 6px;
  cursor: pointer;
}

.table-inspector__ink input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.table-inspector__ink:has(input:checked) {
  border-color: var(--table-accent);
  box-shadow: 0 0 0 1px var(--table-accent);
}

.table-inspector__ink:has(input:focus-visible) {
  outline: 2px solid var(--table-accent);
  outline-offset: 1px;
}

.table-inspector__ink-sample {
  color: var(--note-ink);
  font-family: "Table MetaMorphous", Georgia, serif;
  font-size: 17px;
  line-height: 1;
  -webkit-text-stroke: 0.14em rgba(var(--note-halo-rgb), 0.92);
  paint-order: stroke fill;
}

/* A player's panel: only the look of the notes they control and the parts for players (the
   plugin dice's), as Inspector.js and permissions.js say. */
.table-inspector.is-player > :not(.table-inspector__head, .table-inspector__notes, .table-inspector__players) {
  display: none;
}

/* A player who edits everything: all but visibility, lock, layer and controllers. */
.table-inspector.is-editor .table-inspector__gm {
  display: none;
}

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

/* The bottom sheet's handle, phones only. */
.table-inspector__toggle {
  display: none;
}

/* Choices like "Typewritten page" need more room than a number: after a short label column,
   so the selects line up, the select takes the rest. The column fits the longest German label
   ("Schriftgröße"). */
.table-inspector .table-panel__field:has(> select) {
  grid-template-columns: 84px minmax(0, 1fr);
}

.table-panel__row {
  display: flex;
  gap: 6px;
}

.table-panel__row > * {
  flex: 1;
}

.table-inspector__arrange > .table-panel__field { flex: 2; }
.table-inspector__arrange > button { align-self: end; }

.table-panel__field.is-wide {
  grid-template-columns: 1fr;
  gap: 2px;
}

.table-panel__field input[type="text"],
.table-panel__field select,
.table-token-picker__search {
  width: 100%;
  min-width: 0;
  padding: 3px 6px;
  color: var(--table-text);
  font: inherit;
  background: rgba(var(--table-black-rgb), 0.3);
  border: 1px solid rgba(var(--table-white-rgb), 0.15);
  border-radius: 5px;
}

.table-panel__field select option,
.table-panel__field select optgroup {
  color: #111;
}

.table-panel__group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  margin: 2px 0 0;
  padding: 8px 0 0;
  border: 0;
  border-top: 1px solid rgba(var(--table-white-rgb), 0.1);
}

.table-panel__group legend {
  float: left;
  width: 100%;
  margin-bottom: 2px;
  padding: 0;
  color: var(--table-accent-text);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.table-panel__muted {
  color: var(--table-muted);
  font-size: 12px;
}

/* A plugin's drawer (Drawers.js): the pickers' panel, its body scrolls. */
.table-drawer__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.table-token-picker {
  top: 64px;
  bottom: 80px;
  left: 16px;
  width: 260px;
  max-height: none;
}

.table-root.has-token-picker .table-map-panel,
.table-root.has-prop-picker .table-map-panel,
.table-root.has-drawer .table-map-panel {
  left: 292px;
}

/*
 * The GM's file dialogs (UploadDialog.js): naming the files of an upload and keeping their
 * pictures in the plot, and the name prompt of "Keep as…". Built like the die prompt: a panel
 * over a dimmed table, a bottom sheet on phones.
 */
.table-file-dialog {
  position: fixed;
  inset: 0;
  z-index: var(--table-z-dialog);
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(var(--table-black-rgb), 0.55);
}

.table-file-dialog[hidden] {
  display: none;
}

.table-file-dialog__box {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  width: min(100%, 540px);
  max-height: min(100%, 720px);
  margin: 0;
  padding: 18px 18px 14px;
  color: var(--table-text);
  background: rgb(var(--table-panel-rgb));
  border: 1px solid rgba(var(--table-accent-rgb), 0.48);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(var(--table-black-rgb), 0.56);
}

.table-keep-dialog {
  width: min(100%, 400px);
}

.table-file-dialog__title {
  margin: 0 0 12px;
  font-size: 1.15rem;
}

.table-file-dialog__body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

/* The rows scroll. */
.table-upload-dialog__rows {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  margin: 0;
  padding: 0 2px 0 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}

.table-upload-dialog__row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 12px;
  padding: 10px;
  background: rgba(var(--table-white-rgb), 0.03);
  border: 1px solid rgba(var(--table-white-rgb), 0.08);
  border-radius: 10px;
}

.table-upload-dialog__row.is-invalid {
  border-color: var(--table-danger);
}

.table-upload-dialog__thumb {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  overflow: hidden;
  color: var(--table-muted);
  background:
    repeating-conic-gradient(rgba(var(--table-white-rgb), 0.06) 0% 25%, transparent 0% 50%) 0 0 / 12px 12px,
    rgba(var(--table-black-rgb), 0.3);
  border-radius: 8px;
}

.table-upload-dialog__thumb :is(img, canvas) {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.table-upload-dialog__thumb svg {
  width: 28px;
  height: 28px;
}

.table-upload-dialog__fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 4px 8px;
  min-width: 0;
}

.table-upload-dialog__head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.table-upload-dialog__name {
  font-size: 13px;
  font-weight: 600;
}

.table-upload-dialog__file {
  overflow: hidden;
  color: var(--table-muted);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.table-file-dialog input[type="text"] {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 5px 9px;
  color: var(--table-text);
  font: inherit;
  background: rgba(var(--table-black-rgb), 0.3);
  border: 1px solid rgba(var(--table-white-rgb), 0.18);
  border-radius: 7px;
}

.table-file-dialog input[type="text"]:focus-visible {
  border-color: var(--table-accent);
  outline: 2px solid rgba(var(--table-accent-rgb), 0.45);
  outline-offset: 0;
}

.table-file-dialog input[aria-invalid="true"] {
  border-color: var(--table-danger);
}

.table-file-dialog input[readonly] {
  color: var(--table-muted);
}

.table-upload-dialog__error {
  margin: 0;
  color: var(--table-danger);
  font-size: 13px;
}

.table-upload-dialog__note,
.table-upload-dialog__status {
  margin: 0;
  color: var(--table-muted);
  font-size: 13px;
}

.table-upload-dialog__row.is-done .table-upload-dialog__status {
  color: var(--bs-success, #198754);
}

.table-upload-dialog__row.is-failed {
  border-color: var(--table-danger);
}

.table-upload-dialog__row.is-failed .table-upload-dialog__status {
  color: var(--table-danger);
}

/* A file that can't go on the table: listed, dimmed, never sent. */
.table-upload-dialog__row.is-refused {
  opacity: 0.75;
}

.table-upload-dialog__row.is-refused .table-upload-dialog__note {
  color: var(--table-danger);
}

.table-file-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.table-file-dialog__button {
  min-height: 40px;
  padding: 6px 18px;
  color: inherit;
  font: inherit;
  cursor: pointer;
  background: rgba(var(--table-accent-rgb), 0.1);
  border: 1px solid rgba(var(--table-accent-rgb), 0.42);
  border-radius: 9px;
}

.table-file-dialog__button:hover:not(:disabled) {
  background: rgba(var(--table-accent-rgb), 0.24);
}

.table-file-dialog__button.is-primary {
  color: rgb(var(--table-panel-rgb));
  font-weight: 600;
  background: var(--table-accent);
  border-color: var(--table-accent);
}

.table-file-dialog__button.is-primary:hover:not(:disabled) {
  background: rgba(var(--table-accent-rgb), 0.85);
}

.table-file-dialog__button:disabled {
  cursor: progress;
  opacity: 0.7;
}

.table-file-dialog__button:focus-visible {
  outline: 2px solid var(--table-accent);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .table-file-dialog {
    align-items: end;
    padding: 0;
  }

  .table-file-dialog__box {
    width: 100%;
    max-height: 92%;
    border-radius: 16px 16px 0 0;
  }

  .table-upload-dialog__row {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 10px;
  }

  .table-upload-dialog__thumb {
    width: 48px;
    height: 48px;
  }

  .table-file-dialog__actions .table-file-dialog__button {
    flex: 1;
  }

  /* Touch targets of at least 44 px. */
  .table-file-dialog input[type="text"],
  .table-file-dialog__button {
    min-height: 44px;
  }
}

/* The prop picker: preview tiles in the token picker's drawer. */
.table-prop-picker__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
  min-height: 0;
  overflow: auto;
}

.table-prop-picker__tile {
  position: relative;
}

.table-prop-picker__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 6px 4px 8px;
  color: var(--table-text);
  font: inherit;
  font-size: 12px;
  text-align: center;
  background: rgba(var(--table-white-rgb), 0.04);
  border: 1px solid rgba(var(--table-white-rgb), 0.1);
  border-radius: 8px;
  cursor: grab;
}

.table-prop-picker__item:hover,
.table-prop-picker__item:focus-visible {
  background: rgba(var(--table-accent-rgb), 0.14);
  border-color: rgba(var(--table-accent-rgb), 0.55);
  outline: none;
}

.table-prop-picker__picture {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: radial-gradient(circle at 50% 60%, rgba(var(--table-white-rgb), 0.08), transparent 70%);
  border-radius: 6px;
}

.table-prop-picker__picture img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.table-prop-picker__picture img:not([src]) {
  visibility: hidden;
}

.table-prop-picker__picture.is-rendering {
  background-image: linear-gradient(100deg, transparent 30%, rgba(var(--table-white-rgb), 0.08) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: table-prop-shimmer 1.2s linear infinite;
}

@keyframes table-prop-shimmer {
  to {
    background-position: -200% 0;
  }
}

/* A gentle turn of the picture on hover. */
.table-prop-picker__item:hover img {
  animation: table-prop-turn 2.4s ease-in-out infinite;
}

@keyframes table-prop-turn {
  0%,
  100% {
    transform: perspective(240px) rotateY(-14deg);
  }

  50% {
    transform: perspective(240px) rotateY(14deg);
  }
}

.table-prop-picker__name {
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.table-prop-picker__info {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px !important;
  height: 22px !important;
  font-size: 13px !important;
}

@media (prefers-reduced-motion: reduce) {
  .table-prop-picker__item:hover img,
  .table-prop-picker__picture.is-rendering {
    animation: none;
  }
}

/* Credits of a prop's model: a popover (picker, context menu) and the settings' list. */
.table-credits-popover {
  position: absolute;
  top: 0;
  left: 0;
  z-index: var(--table-z-menu);
  width: min(300px, calc(100% - 16px));
  max-height: none;
}

.table-credit {
  display: grid;
  gap: 2px;
  font-size: 13px;
}

.table-credit + .table-credit {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(var(--table-white-rgb), 0.08);
}

.table-credit__title {
  font-weight: 600;
}

.table-credit__by {
  color: var(--table-muted);
  font-weight: 400;
}

.table-credit__row {
  display: flex;
  gap: 6px;
  min-width: 0;
}

.table-credit__label {
  flex: none;
  min-width: 52px;
  color: var(--table-muted);
}

.table-credit a {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--table-accent-text);
}

.table-settings__credits {
  display: grid;
}

.table-token-picker__header {
  display: flex;
  align-items: center;
  gap: 4px;
}

.table-token-picker__header .table-panel__title {
  flex: 1;
}

.table-token-picker__icon-button {
  width: 26px;
  height: 26px;
  padding: 0;
  color: var(--table-text);
  font: inherit;
  font-size: 15px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.table-token-picker__icon-button:hover,
.table-token-picker__icon-button:focus-visible {
  background: rgba(var(--table-accent-rgb), 0.2);
  outline: none;
}

.table-token-picker__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  margin: 0 -6px;
  overflow: auto;
}

.table-token-picker__group {
  margin: 8px 6px 2px;
  color: var(--table-muted);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.table-token-picker__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 6px;
  color: var(--table-text);
  font: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: grab;
}

.table-token-picker__item:hover,
.table-token-picker__item:focus-visible {
  background: rgba(var(--table-accent-rgb), 0.16);
  outline: none;
}

.table-token-picker__portrait {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  overflow: hidden;
  color: var(--table-accent-text);
  font-weight: 600;
  background: rgba(var(--table-accent-rgb), 0.15);
  border: 2px solid rgba(var(--table-accent-rgb), 0.55);
  border-radius: 50%;
}

.table-token-picker__portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.table-token-picker__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.table-token-picker__health {
  color: var(--table-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* ---- Context menu ------------------------------------------------------------------------ */

.table-menu {
  position: absolute;
  top: 0;
  left: 0;
  z-index: var(--table-z-menu);
  display: flex;
  flex-direction: column;
  min-width: 190px;
  padding: 4px;
  font-size: 13px;
  background: rgba(var(--table-panel-rgb), 0.97);
  border: 1px solid rgba(var(--table-accent-rgb), 0.3);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(var(--table-black-rgb), 0.55);
}

.table-menu[hidden] {
  display: none;
}

/* A long list (the GM's object menu on a phone) scrolls inside the table. */
.table-menu {
  max-height: calc(100% - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-touch-callout: none;
  user-select: none;
}

/* Fingers (the long-press menu): items big enough to hit. */
@media (pointer: coarse) {
  .table-menu {
    min-width: 220px;
    font-size: 15px;
  }

  .table-menu__item {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 8px 12px;
  }
}

.table-menu__item {
  padding: 6px 10px;
  color: var(--table-text);
  font: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
}

.table-menu__item:hover,
.table-menu__item:focus-visible {
  background: rgba(var(--table-accent-rgb), 0.2);
  outline: none;
}

/* A checkable option: a box in front, filled while it is on (drawn, not a font glyph). */
.table-menu__item[role="menuitemcheckbox"]::before {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 8px;
  vertical-align: -1px;
  box-sizing: border-box;
  border: 1.5px solid var(--table-accent);
  border-radius: 3px;
  content: "";
}

.table-menu__item[aria-checked="true"]::before {
  background: var(--table-accent);
  box-shadow: inset 0 0 0 2px rgb(var(--table-panel-rgb));
}

/* Add menu entries lead with an icon. */
.table-menu__item.has-icon {
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-menu__item .table-icon {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--table-accent-text);
}

.table-menu__item.is-danger {
  color: var(--table-danger);
}

.table-menu__separator {
  height: 1px;
  margin: 4px 6px;
  background: rgba(var(--table-white-rgb), 0.1);
}

/* Link back to the campaign; part of the page template, above the table. */
.table-back-link {
  position: fixed;
  top: 12px;
  left: 16px;
  z-index: var(--table-z-back-link);
  max-width: calc(50% - 120px);
  padding: 6px 12px;
  overflow: hidden;
  color: var(--bs-body-color, #dee2e6);
  font-family: var(--bs-body-font-family, system-ui, sans-serif);
  font-size: 13px;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
  background: rgba(var(--bs-body-bg-rgb, 22, 26, 34), 0.78);
  border: 1px solid rgba(var(--bs-primary-rgb, 79, 143, 219), 0.25);
  border-radius: 8px;
  backdrop-filter: blur(6px);
}

.table-back-link:hover,
.table-back-link:focus-visible {
  color: var(--bs-primary, #4f8fdb);
}

.table-back-link:focus-visible {
  outline: 2px solid var(--bs-primary, #4f8fdb);
  outline-offset: 2px;
}

body:has(.table-root) {
  margin: 0;
  background: #0c0e12;
  /* No page pinch or double-tap zoom anywhere on the table page; panels still scroll. The table
     viewport itself takes no browser gestures at all (touch-action: none). */
  touch-action: pan-x pan-y;
}

/* ---- Dice ------------------------------------------------------------------------------- */

/* Above the board, the character panel (14) and the showcase (15), so a roll is seen while the
   GM shows an image or a phone user rolls in the full-width panel; below dialogs and menus.
   Only the result cards take clicks, so the HUD under it stays usable; trays and cards keep clear
   of the HUD bar and of a side panel on wide screens (DiceTray._freeWidth). */
.table-dice,
.table-dice-log {
  --dice-one: var(--table-danger, #e5484d);
  --dice-six: #f2c14e;
  --dice-explode: #ff9f43;
  --dice-crit: #46c97a;
  --dice-megacrit: #b07cff;
  --dice-fail: rgba(var(--table-white-rgb), 0.45);
  --dice-success: var(--table-text);
}

.table-dice {
  position: absolute;
  inset: 0;
  z-index: var(--table-z-dice);
  overflow: hidden;
  pointer-events: none;
}

.table-dice[hidden] {
  display: none;
}

.table-dice__canvas {
  position: absolute;
  top: 0;
  left: 0;
}

/* Running sum of an exploding chain, above its first die. */
.dice-badge {
  position: absolute;
  top: 0;
  left: 0;
  padding: 2px 9px;
  color: var(--table-text);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  background: rgba(var(--table-panel-rgb), 0.92);
  border: 1px solid var(--dice-six);
  border-radius: 999px;
  box-shadow: 0 0 12px color-mix(in srgb, var(--dice-six) 45%, transparent);
  transition: opacity 0.6s ease;
}

.dice-badge.is-done {
  border-color: var(--dice-crit);
  box-shadow: 0 4px 14px rgba(var(--table-black-rgb), 0.4);
}

.dice-card {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: max-content;
  min-width: 200px;
  max-width: min(340px, calc(100% - 32px));
  padding: 10px 12px;
  color: var(--table-text);
  font-size: 13px;
  pointer-events: auto;
  background: rgba(var(--table-panel-rgb), 0.94);
  border: 1px solid rgba(var(--table-accent-rgb), 0.35);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(var(--table-black-rgb), 0.5);
  backdrop-filter: blur(6px);
  cursor: pointer;
  animation: dice-card-in 0.25s ease-out;
  transition: opacity 0.6s ease;
}

.dice-card.is-crit {
  border-color: var(--dice-crit);
}

.dice-card.is-megacrit {
  border-color: var(--dice-megacrit);
  box-shadow: 0 0 22px color-mix(in srgb, var(--dice-megacrit) 45%, transparent), 0 10px 30px rgba(var(--table-black-rgb), 0.5);
}

.dice-card.is-fail {
  border-color: color-mix(in srgb, var(--dice-one) 55%, transparent);
}

.dice-card.is-leaving,
.dice-badge.is-leaving {
  opacity: 0;
}

.dice-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
}

.dice-card__header {
  font-size: 14px;
  font-weight: 600;
}

.dice-card__who {
  color: var(--table-muted);
}

/* The roller's colour (userColors.js) as a dot before their name. */
.dice-card__who.has-color::before {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 5px;
  vertical-align: 1px;
  background: var(--user-color);
  border-radius: 50%;
  content: "";
}

.dice-card__tag {
  flex-basis: 100%;
  color: var(--dice-crit);
  font-weight: 600;
}

.dice-card.is-megacrit .dice-card__tag {
  color: var(--dice-megacrit);
}

.dice-card__dice {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.dice-chip {
  min-width: 26px;
  height: 26px;
  padding: 0 5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 24px;
  text-align: center;
  border: 1px solid rgba(var(--table-white-rgb), 0.2);
  border-radius: 6px;
}

.dice-chip.is-fail {
  color: var(--dice-fail);
}

.dice-chip.is-success {
  color: var(--dice-success);
  border-color: rgba(var(--table-accent-rgb), 0.6);
}

.dice-chip.is-crit {
  color: var(--dice-crit);
  border-color: var(--dice-crit);
}

.dice-chip.is-megacrit {
  color: var(--dice-megacrit);
  border-color: var(--dice-megacrit);
  box-shadow: 0 0 8px color-mix(in srgb, var(--dice-megacrit) 50%, transparent);
}

.dice-card__foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--table-muted);
}

.dice-card__total {
  color: var(--table-text);
  font-weight: 600;
}

/* The dice system's line about the roll (dice.summary), under the total. */
.dice-card__summary {
  color: var(--table-text);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.dice-card__description {
  max-height: 4.5em;
  overflow: hidden;
  color: var(--table-muted);
  font-size: 12px;
}

.dice-card--batch {
  min-width: 180px;
}

.dice-batch {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: min(40vh, 220px);
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.dice-batch__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dice-batch__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes dice-card-in {
  from {
    opacity: 0;
  }
}

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

/* ---- Dice preferences (section of the settings dialog) ------------------------------------ */

.table-dice-prefs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.table-dice-prefs__preview:hover,
.table-dice-prefs__preview:focus-visible {
  color: var(--table-text);
  background: rgba(var(--table-accent-rgb), 0.2);
  outline: none;
}

.table-dice-prefs__hint {
  margin: 0;
  color: var(--table-muted);
  font-size: 12px;
}

.table-dice-prefs__group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.table-dice-prefs__group legend {
  margin-bottom: 4px;
  padding: 0;
  color: var(--table-muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* The shown skin: a large 3D picture with its name and family. It stays in view while the
   swatches scroll under it, so a hovered or focused skin is always visible. */
.table-dice-prefs__stage {
  position: sticky;
  /* The dialog's top padding (.table-panel), so no swatch shows above it. */
  top: -10px;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  background:
    linear-gradient(rgba(var(--table-white-rgb), 0.04), rgba(var(--table-white-rgb), 0.04)),
    rgb(var(--table-panel-rgb));
  border: 1px solid rgba(var(--table-accent-rgb), 0.35);
  border-radius: 10px;
}

.table-dice-prefs__stage-picture {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 200px;
  aspect-ratio: 5 / 3;
}

.table-dice-prefs__stage-caption {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.table-dice-prefs__stage-name {
  font-size: 15px;
  overflow-wrap: anywhere;
}

.table-dice-prefs__stage-family {
  color: var(--table-muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

@media (max-width: 576px) {
  .table-dice-prefs__stage-picture {
    width: 140px;
  }
}

.table-dice-prefs__families {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.table-dice-prefs__family {
  min-height: 28px;
  padding: 2px 10px;
  color: var(--table-muted);
  font: inherit;
  font-size: 12px;
  background: transparent;
  border: 1px solid rgba(var(--table-white-rgb), 0.18);
  border-radius: 999px;
  cursor: pointer;
}

.table-dice-prefs__family:hover {
  color: var(--table-text);
}

.table-dice-prefs__family[aria-pressed="true"] {
  color: var(--table-text);
  background: rgba(var(--table-accent-rgb), 0.2);
  border-color: var(--table-accent);
}

.table-dice-prefs__family:focus-visible {
  outline: 2px solid var(--table-accent);
  outline-offset: 2px;
}

/* The family chips and the search field: one row when there is room, the search below otherwise. */
.table-dice-prefs__filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.table-dice-prefs__filters .table-dice-prefs__families {
  flex: 1 1 260px;
}

.table-dice-prefs__count {
  margin-left: 5px;
  color: var(--table-muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.table-dice-prefs__search {
  flex: 1 1 140px;
  min-width: 0;
  min-height: 28px;
  padding: 3px 10px;
  color: var(--table-text);
  font: inherit;
  font-size: 12px;
  background: rgba(var(--table-black-rgb), 0.25);
  border: 1px solid rgba(var(--table-white-rgb), 0.16);
  border-radius: 999px;
}

.table-dice-prefs__search:focus-visible {
  border-color: var(--table-accent);
  outline: none;
}

/* A family's name over its run of swatches ("All" only). */
.table-dice-prefs__heading {
  grid-column: 1 / -1;
  margin: 6px 0 0;
  padding-bottom: 2px;
  color: var(--table-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(var(--table-accent-rgb), 0.25);
}

.table-dice-prefs__heading:first-child {
  margin-top: 0;
}

.table-dice-prefs__heading[hidden],
.table-dice-prefs__empty[hidden] {
  display: none;
}

.table-dice-prefs__empty {
  margin: 0;
  color: var(--table-muted);
  font-size: 12px;
}

/* Small swatches, as many to a row as fit. */
.table-dice-prefs__skins {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
  gap: 4px;
}

.table-dice-prefs__skin {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
  padding: 4px 2px;
  background: rgba(var(--table-white-rgb), 0.04);
  border: 1px solid rgba(var(--table-white-rgb), 0.12);
  border-radius: 8px;
  cursor: pointer;
}

.table-dice-prefs__skin[hidden] {
  display: none;
}

.table-dice-prefs__skin:hover {
  border-color: rgba(var(--table-accent-rgb), 0.5);
}

/* The radio stays focusable for the keyboard but the tile shows the state. */
.table-dice-prefs__skin input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.table-dice-prefs__skin:has(input:checked) {
  background: rgba(var(--table-accent-rgb), 0.16);
  border-color: var(--table-accent);
}

.table-dice-prefs__skin:has(input:focus-visible) {
  outline: 2px solid var(--table-accent);
  outline-offset: 2px;
}

.table-dice-prefs__swatch {
  display: block;
  width: 44px;
  height: 44px;
  overflow: hidden;
  background: rgba(var(--table-white-rgb), 0.08);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(var(--table-black-rgb), 0.5);
}

.table-dice-prefs__swatch canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.table-dice-prefs__flat {
  width: 72px;
  height: 72px;
  border-radius: 12px;
}

/* Fills the 5:3 picture box without ever stretching the dice. */
.table-dice-prefs__render {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.table-dice-prefs__name {
  max-width: 100%;
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
}

.table-dice-prefs__effect {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 30px;
  align-items: center;
  gap: 6px;
}

.table-dice-prefs__effect select {
  min-width: 96px;
  padding: 3px 6px;
  color: var(--table-text);
  font: inherit;
  background: rgba(var(--table-white-rgb), 0.06);
  border: 1px solid rgba(var(--table-white-rgb), 0.18);
  border-radius: 6px;
}

/* The native dropdown is light: dark text for the options and their group labels. */
.table-dice-prefs__effect select option,
.table-dice-prefs__effect select optgroup {
  color: #000;
}

.table-dice-prefs__preview {
  width: 30px;
  height: 28px;
  color: var(--table-accent-text);
  font-size: 11px;
  background: transparent;
  border: 1px solid rgba(var(--table-accent-rgb), 0.35);
  border-radius: 6px;
  cursor: pointer;
}

.table-dice-prefs__reduce {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

/* The effects' colour: a switch with the user's colour as a dot and a short explanation. */
.table-dice-prefs__tint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 4px;
  cursor: pointer;
}

.table-dice-prefs__tint input {
  margin-top: 3px;
}

.table-dice-prefs__tint-dot {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  margin-top: 2px;
  border: 1px solid rgba(var(--table-white-rgb), 0.5);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(var(--table-black-rgb), 0.5);
}

.table-dice-prefs__tint-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.table-dice-prefs__tint-text small {
  color: var(--table-muted);
  font-size: 11px;
}

.table-dice-prefs__status {
  min-height: 1.2em;
  margin: 0;
  color: var(--table-muted);
  font-size: 12px;
}

.table-dice-prefs__status[data-state="ok"] {
  color: var(--bs-success, #198754);
}

.table-dice-prefs__status[data-state="error"] {
  color: var(--table-danger);
}

/* ---- Settings dialog ------------------------------------------------------------------- */

/* Light backdrop and the dialog on the right, so dice previews stay visible on the table. */
.table-settings {
  position: absolute;
  inset: 0;
  z-index: var(--table-z-dialog);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 16px;
  background: rgba(var(--table-black-rgb), 0.25);
}

.table-settings[hidden] {
  display: none;
}

.table-settings__dialog {
  position: static;
  gap: 10px;
  width: min(380px, 100%);
  max-height: min(86vh, 820px);
  max-height: min(86dvh, 820px);
  background: rgba(var(--table-panel-rgb), 0.97);
}

@media (max-width: 576px) {
  .table-settings {
    justify-content: center;
  }

  /* Not the bottom sheet of the other panels. */
  .table-settings .table-settings__dialog {
    width: 100%;
    max-height: min(86dvh, 820px);
  }
}

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

.table-settings__title {
  margin: 0;
}

.table-settings__close {
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--table-text);
  font: inherit;
  font-size: 18px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.table-settings__close:hover,
.table-settings__close:focus-visible {
  background: rgba(var(--table-accent-rgb), 0.2);
  outline: none;
}

/* Five tabs for the GM: they wrap rather than widen the dialog (a scrollbar takes its room). */
.table-settings__tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0 2px;
  border-bottom: 1px solid rgba(var(--table-white-rgb), 0.12);
}

.table-settings__tabs[hidden],
.table-settings__tab[hidden],
.table-settings__pane[hidden] {
  display: none;
}

.table-settings__tab {
  padding: 6px 10px;
  color: var(--table-muted);
  font: inherit;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.table-settings__tab:hover,
.table-settings__tab:focus-visible {
  color: var(--table-text);
  outline: none;
}

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

.table-settings__pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.table-settings__hint {
  margin: 0;
  font-size: 12px;
}

/* The players section: per kind "May create", then the properties in columns. */
.table-settings__subtitle {
  margin: 4px 0 0;
  color: var(--table-muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.table-settings__checks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 4px 16px;
}

.table-settings__create {
  font-weight: 600;
}

/* A checklist: the box before its label. */
.table-settings__permissions .table-panel__field.is-check {
  grid-template-columns: auto minmax(0, 1fr);
  justify-content: start;
}

.table-settings__permissions .table-panel__field.is-check input {
  order: -1;
  width: auto;
}

.table-settings__gm-only {
  margin: 0;
  padding-left: 18px;
  color: var(--table-muted);
  font-size: 12px;
}

.table-settings__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.table-settings__cloth-preview {
  width: 44px;
  height: 30px;
  background-position: center;
  background-size: cover;
  border: 1px solid rgba(var(--table-white-rgb), 0.2);
  border-radius: 4px;
}

.table-settings__cloth-preview[hidden],
.table-settings .table-panel__button[hidden] {
  display: none;
}

.table-settings .table-panel__field {
  grid-template-columns: 1fr 150px;
}

.table-settings .table-panel__field.is-wide {
  grid-template-columns: 1fr;
}

/* A wide field keeps its select below its label (the arrange select beside "Apply"), also in the
   Inspector, whose label column for selects would squeeze it to nothing. */
.table-inspector .table-panel__field.is-wide:has(> select) {
  grid-template-columns: 1fr;
}

/* Amount and unit of the distance per cell side by side (settings and map panel). */
.table-settings__distance,
.table-panel__distance {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px;
}

/* The reveal range's unit (MapPanel). */
.table-panel__unit {
  align-self: center;
  color: var(--table-muted);
}

.table-panel__distance select,
.table-settings__distance select {
  padding: 2px 4px;
  color: var(--table-text);
  font: inherit;
  background: rgba(var(--table-black-rgb), 0.3);
  border: 1px solid rgba(var(--table-white-rgb), 0.15);
  border-radius: 5px;
}

.table-panel__distance select option,
.table-settings__distance select option {
  color: #111;
}

/* The Performance tab (PerformancePanel.js): a switch per effect, its cost and what "off"
   means below it. Held rows are off while "reduce effects" is on. */
.table-perf,
.table-perf__list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.table-perf__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.table-perf__switch {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  color: var(--table-text);
  cursor: pointer;
}

.table-perf__switch input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--table-accent);
  cursor: inherit;
}

.table-perf__switch.is-master .table-perf__name {
  font-weight: 600;
}

.table-perf__effect.is-held .table-perf__switch {
  color: var(--table-muted);
  cursor: default;
}

.table-perf__hint {
  padding-left: 24px;
}

.table-perf__cost {
  padding: 1px 7px;
  font-size: 11px;
  white-space: nowrap;
  border: 1px solid currentColor;
  border-radius: 999px;
}

.table-perf__cost.is-high {
  color: var(--bs-warning, #ffc107);
}

.table-perf__cost.is-medium {
  color: var(--table-accent-text);
}

.table-perf__cost.is-low {
  color: var(--table-muted);
}

.table-hud__settings {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.table-hud__settings .table-icon {
  width: 15px;
  height: 15px;
  color: var(--table-accent-text);
}

.table-hud__settings.is-active {
  background: rgba(var(--table-accent-rgb), 0.2) !important;
}

/* On a phone the gear alone. */
@media (max-width: 576px) {
  .table-hud__settings > span {
    display: none;
  }
}

/* ---- HUD -------------------------------------------------------------------------------- */

.table-hud {
  position: absolute;
  inset: 0;
  z-index: var(--table-z-hud);
  pointer-events: none;
  font-size: 13px;
}

.table-hud__bar,
.table-toast {
  background: rgba(var(--table-panel-rgb), 0.78);
  border: 1px solid rgba(var(--table-accent-rgb), 0.25);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(var(--table-black-rgb), 0.4);
  backdrop-filter: blur(6px);
}

.table-hud__bar {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  pointer-events: auto;
}

.table-hud__bar button {
  min-width: 30px;
  height: 28px;
  padding: 0 8px;
  color: var(--table-text);
  font: inherit;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.table-hud__bar button:hover,
.table-hud__bar button:focus-visible {
  background: rgba(var(--table-accent-rgb), 0.2);
  outline: none;
}

.table-hud__add::before {
  content: "+";
  content: "+" / "";
  margin-right: 4px;
  color: var(--table-accent-text);
  font-weight: 600;
}

.table-hud__add.is-active {
  background: rgba(var(--table-accent-rgb), 0.2) !important;
}

/* The "Add" menu opens above the HUD bar (see AddMenu._position). */
.table-add-menu {
  min-width: 210px;
}

/* A group of entries under its muted heading; the heading is no entry (arrows skip it). */
.table-menu__group {
  display: flex;
  flex-direction: column;
}

.table-menu__heading {
  padding: 4px 10px 2px;
  color: var(--table-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: default;
}

/* ---- Saved views (SavedViewsMenu): a popup above the viewfinder ---------------------------- */

.table-views {
  gap: 2px;
  width: 264px;
  padding: 6px;
}

.table-views__head {
  padding: 4px 8px 2px;
  color: var(--table-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.table-views__start,
.table-views__row {
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: 6px;
  transition: background-color 0.12s ease;
}

.table-views__row:hover,
.table-views__row:has(:focus-visible),
.table-views__start:hover,
.table-views__start:has(:focus-visible) {
  background: rgba(var(--table-white-rgb), 0.05);
}

/* The start view row sits apart from the user's own views by a hairline. */
.table-views__start {
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(var(--table-white-rgb), 0.08);
  border-radius: 6px 6px 0 0;
}

.table-views__list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.table-views__list[hidden],
.table-views__empty[hidden],
.table-views__save[hidden],
.table-views__markers[hidden] {
  display: none;
}

/* The table's markers, by owner, below the views; a long list scrolls inside the popup. */
.table-views__markers {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: min(40vh, 320px);
  margin-top: 4px;
  padding-top: 4px;
  overflow-y: auto;
  border-top: 1px solid rgba(var(--table-white-rgb), 0.08);
}

.table-views__owner {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 2px;
  color: var(--owner-color, var(--table-text));
  font-size: 12px;
  font-weight: 600;
}

.table-views__owner::before {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--owner-color, var(--table-muted));
  content: "";
}

/* A fixed box: effect art (marker-effects.css) fills whatever box it gets. */
.table-views__marker-icon {
  position: relative;
  display: inline-flex;
  flex: none;
  width: 18px;
  height: 18px;
  overflow: hidden;
  border-radius: 4px;
}


.table-views__marker-icon .table-marker__glyph {
  width: 100%;
  height: 100%;
  fill: var(--marker-color, var(--table-accent));
}

.table-views__go {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  color: var(--table-text);
  font: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
}

.table-views__go:hover,
.table-views__go:focus-visible {
  color: var(--table-accent-text);
  outline: none;
}

.table-views__go:focus-visible {
  background: rgba(var(--table-accent-rgb), 0.16);
}

.table-views__go .table-icon {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--table-accent-text);
}

.table-views__go--start {
  font-weight: 600;
}

.table-views__name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Row tools (star, rename, delete): quiet until the row is pointed at or focused by keyboard. */
.table-views__tool {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  color: var(--table-muted);
  background: transparent;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  opacity: 0;
  transition:
    opacity 0.12s ease,
    color 0.12s ease,
    background-color 0.12s ease;
}

.table-views__tool .table-icon {
  width: 14px;
  height: 14px;
}

.table-views__row:hover .table-views__tool,
.table-views__row:has(:focus-visible) .table-views__tool,
.table-views__start:hover .table-views__tool,
.table-views__start:has(:focus-visible) .table-views__tool {
  opacity: 1;
}

.table-views__tool:hover,
.table-views__tool:focus-visible {
  color: var(--table-text);
  background: rgba(var(--table-white-rgb), 0.08);
  outline: none;
}

/* The star of the view the table opens at stays lit. */
.table-views__row.is-start .table-views__star {
  color: var(--table-accent-text);
  opacity: 1;
}

/* The GM's start view controls stay in sight: setting the start view must not hide behind a
   hover. The other stars show faintly, so the GM sees that any view can become the start view.
   Pointed at or focused, the row's tools show fully like every other row's. */
.table-views__start.is-gm:not(:hover):not(:has(:focus-visible)) .table-views__tool {
  opacity: 0.75;
}

.table-views__star {
  opacity: 0.35;
}

/* "Use this view as the start view": the one button of the GM's empty start row. */
.table-views__start-use {
  flex: none;
  width: 100%;
  color: var(--table-accent-text);
  font-weight: 600;
}

.table-views__start:has(.table-views__start-use) {
  flex-direction: column;
  align-items: stretch;
}

.table-views__delete:hover,
.table-views__delete:focus-visible {
  color: var(--table-danger);
}

/* A first press on ×: the row asks for a second one. */
.table-views__row.is-armed,
.table-views__start.is-armed {
  background: rgba(var(--bs-danger-rgb, 220, 53, 69), 0.12);
}

.table-views__row.is-armed .table-views__delete,
.table-views__start.is-armed .table-views__delete {
  color: var(--bs-white, #fff);
  background: var(--table-danger);
  opacity: 1;
}

.table-views__empty {
  margin: 0;
  padding: 6px 8px;
  color: var(--table-muted);
  font-size: 12px;
}

.table-views__save {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid rgba(var(--table-white-rgb), 0.08);
}

.table-views__input {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  color: var(--table-text);
  font: inherit;
  background: rgba(var(--table-white-rgb), 0.05);
  border: 1px solid rgba(var(--table-white-rgb), 0.1);
  border-radius: 6px;
  user-select: text;
}

.table-views__input:focus {
  border-color: rgba(var(--table-accent-rgb), 0.7);
  outline: none;
  box-shadow: 0 0 0 2px rgba(var(--table-accent-rgb), 0.2);
}

/* Renaming: the field takes the name's place in the row. */
.table-views__rename {
  height: 28px;
  margin: 1px 0;
}

.table-views__save-button {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 30px;
  padding: 0;
  color: var(--table-accent-text);
  background: rgba(var(--table-accent-rgb), 0.14);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.table-views__save-button .table-icon {
  width: 16px;
  height: 16px;
}

.table-views__save-button:hover,
.table-views__save-button:focus-visible {
  background: rgba(var(--table-accent-rgb), 0.28);
  outline: none;
}

/* Fingers: no hover, so the tools always show, and every control is big enough to hit. */
@media (pointer: coarse) {
  .table-views {
    width: min(300px, calc(100% - 16px));
  }

  .table-views__go,
  .table-views__input,
  .table-views__save-button {
    height: 44px;
  }

  .table-views__tool {
    width: 40px;
    height: 44px;
    opacity: 0.75;
  }

  .table-views__save-button {
    width: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .table-views__start,
  .table-views__row,
  .table-views__tool {
    transition: none;
  }
}

/* Icon-only HUD buttons: the viewfinder (saved views, or "go to the start view" for viewers). */
.table-hud__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--table-muted) !important;
}

.table-hud__icon[hidden] {
  display: none;
}

.table-hud__icon .table-icon {
  width: 16px;
  height: 16px;
}

.table-hud__icon:hover,
.table-hud__icon:focus-visible {
  color: var(--table-text) !important;
}

.table-hud__views.is-active {
  color: var(--table-accent) !important;
  background: rgba(var(--table-accent-rgb), 0.2) !important;
}

/* A shutter: the viewfinder flashes once when a view was saved. */
.table-hud__views.is-flashing {
  animation: table-shutter 0.45s ease-out;
}

@keyframes table-shutter {
  0% {
    color: rgb(var(--table-panel-rgb));
    background: rgba(var(--table-white-rgb), 0.9);
  }

  100% {
    background: transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  .table-hud__views.is-flashing {
    animation: none;
  }
}

/* A plugin's tool button (`ui.hud.button` with `toggle`, the ruler's too): pressed while active. */
.table-hud__icon[data-mount].is-active,
.table-hud__dice-log.is-active {
  color: var(--table-accent) !important;
  background: rgba(var(--table-accent-rgb), 0.2) !important;
}

/* The dice log button counts the rolls that came in while the log was closed. */
.table-hud__dice-log { position: relative; }

/* Touch has no box selection (a drag pans), so the switch would do nothing there. */
@media (hover: none) and (pointer: coarse) {
  .table-hud__selection-mode { display: none !important; }
}

.table-hud__badge {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  box-sizing: border-box;
  color: rgb(var(--table-panel-rgb));
  font-size: 9px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
  background: var(--table-accent);
  border-radius: 7px;
  pointer-events: none;
}

.table-hud__badge[hidden] { display: none; }

/* A player's own character: a portrait badge in the top left corner, below the link back to
   the campaign, like a game's player frame. On phones only the round portrait. */
.table-character-badge-wrap {
  position: absolute;
  top: 52px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  /* The badge plus its two round buttons ("Go to my token", the portrait). */
  max-width: min(302px, calc(50% - 32px));
  pointer-events: auto;
}

.table-character-badge-wrap[hidden] {
  display: none;
}

.table-character-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: calc(100% - 84px);
  padding: 4px 16px 4px 4px;
  color: var(--table-text);
  font: inherit;
  text-align: left;
  pointer-events: auto;
  cursor: pointer;
  background: rgba(var(--table-panel-rgb), 0.78);
  border: 1px solid rgba(var(--table-accent-rgb), 0.25);
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(var(--table-black-rgb), 0.4);
  backdrop-filter: blur(6px);
}

.table-character-badge__view {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 8px;
  color: var(--table-text) !important;
  background: rgba(var(--table-panel-rgb), 0.9);
  border: 1px solid rgba(var(--table-accent-rgb), 0.4);
  border-radius: 50%;
  cursor: pointer;
}

.table-character-badge__view:focus-visible {
  outline: 2px solid var(--table-accent);
  outline-offset: 2px;
}

.table-character-badge__view:hover:not(.is-disabled) {
  border-color: var(--table-accent);
}

/* "Go to my token" without a token on the table: faded, but focusable, so its hint stays readable. */
.table-character-badge__goto.is-disabled {
  cursor: default;
  opacity: 0.45;
}

.table-character-badge[hidden] {
  display: none;
}

.table-character-badge:hover {
  border-color: rgba(var(--table-accent-rgb), 0.55);
}

.table-character-badge:focus-visible {
  outline: 2px solid var(--table-accent);
  outline-offset: 2px;
}

.table-character-badge.is-active {
  background: rgba(var(--table-panel-rgb), 0.9);
  border-color: var(--table-accent);
  box-shadow:
    0 6px 20px rgba(var(--table-black-rgb), 0.4),
    0 0 0 3px rgba(var(--table-accent-rgb), 0.2);
}

.table-character-badge__portrait {
  position: relative;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
}

.table-character-badge__portrait img,
.table-character-badge__sigil {
  position: absolute;
  inset: 5px;
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: 50%;
}

.table-character-badge__portrait img[hidden],
.table-character-badge__sigil[hidden] {
  display: none;
}

.table-character-badge__sigil {
  display: grid;
  place-items: center;
  color: var(--table-text);
  font-size: 14px;
  font-weight: 700;
  background: rgba(var(--table-accent-rgb), 0.3);
}

/* Health as a ring round the portrait; without health only a faint track. */
.table-character-badge__ring {
  position: absolute;
  inset: 0;
  width: 48px;
  height: 48px;
  transform: rotate(-90deg);
}

.table-character-badge__track,
.table-character-badge__fill {
  fill: none;
  stroke-width: 3;
}

.table-character-badge__track {
  stroke: rgba(var(--table-white-rgb), 0.14);
}

.table-character-badge__fill {
  stroke: var(--bs-success, #198754);
  stroke-dasharray: var(--health, 0) 100;
  stroke-linecap: round;
  transition: stroke-dasharray 0.4s ease;
}

.table-character-badge[data-level="mid"] .table-character-badge__fill {
  stroke: var(--bs-warning, #ffc107);
}

.table-character-badge[data-level="low"] .table-character-badge__fill {
  stroke: var(--bs-danger, #dc3545);
}

.table-character-badge__ring.is-empty .table-character-badge__fill {
  display: none;
}

.table-character-badge.is-active .table-character-badge__track {
  stroke: rgba(var(--table-accent-rgb), 0.45);
}

.table-character-badge__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.table-character-badge__name {
  overflow: hidden;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.table-character-badge__health {
  color: var(--table-muted);
  font-size: 11px;
}

.table-character-badge__health[hidden] {
  display: none;
}

@media (max-width: 576px) {
  .table-character-badge-wrap {
    left: 12px;
  }

  .table-character-badge {
    padding: 2px;
  }

  .table-character-badge__text {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .table-character-badge__fill {
    transition: none;
  }
}

/* ---- Combat tracker: the turn order at the top centre (CombatTracker.js) ----------------- */

.table-combat {
  position: absolute;
  top: 12px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
  max-width: min(880px, calc(100% - 32px));
  padding: 4px 6px;
  font-size: 13px;
  pointer-events: auto;
  background: rgba(var(--table-panel-rgb), 0.78);
  border: 1px solid rgba(var(--table-accent-rgb), 0.25);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(var(--table-black-rgb), 0.4);
  backdrop-filter: blur(6px);
  translate: -50% 0;
  animation: table-combat-in 0.32s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.table-combat[hidden],
.table-combat [hidden] {
  display: none !important;
}

@keyframes table-combat-in {
  from {
    opacity: 0;
    transform: translateY(-24px);
  }
}

.table-combat button {
  color: var(--table-text);
  font: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.table-combat button:focus-visible {
  outline: 2px solid var(--table-accent);
  outline-offset: 1px;
}

.table-combat__status {
  display: flex;
  flex: none;
  align-items: center;
  gap: 2px;
  padding-right: 8px;
  border-right: 1px solid rgba(var(--table-accent-rgb), 0.2);
}

.table-combat__step {
  width: 24px;
  height: 28px;
  padding: 0;
  font-size: 11px !important;
  border-radius: 6px;
}

.table-combat__step:hover {
  background: rgba(var(--table-accent-rgb), 0.2) !important;
}

.table-combat__round {
  display: grid;
  justify-items: center;
  min-width: 44px;
  padding: 0 4px;
  line-height: 1.1;
}

.table-combat__round-label {
  color: var(--table-muted);
  font-size: 11px;
}

.table-combat__round-number {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.table-combat:not(.is-started) .table-combat__round-label {
  color: var(--table-text);
  font-size: 12px;
}

/* The cards scroll sideways; the padding leaves room for the active card's lift and glow. */
.table-combat__cards {
  position: relative;
  display: flex;
  flex: 0 1 auto;
  gap: 4px;
  min-width: 0;
  padding: 7px 7px 3px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--table-accent-rgb), 0.4) transparent;
}

.table-combat.is-empty .table-combat__cards {
  display: none;
}

.table-combat__card {
  --card-color: #c9a227;

  position: relative;
  display: grid;
  flex: none;
  justify-items: center;
  gap: 3px;
  width: 64px;
}

.table-combat__card.is-leaving {
  position: absolute;
  pointer-events: none;
}

.table-combat__portrait {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0 !important;
  overflow: hidden;
  background: rgb(var(--table-panel-rgb)) !important;
  border: 2px solid var(--card-color) !important;
  border-radius: 50%;
  box-sizing: border-box;
  transition:
    transform 0.25s ease,
    box-shadow 0.25s ease,
    filter 0.25s ease;
}

.table-combat__card[data-shape="square"] .table-combat__portrait {
  border-radius: 12%;
}

.table-combat__portrait:disabled {
  cursor: default !important;
}

.table-combat__portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.table-combat__sigil {
  color: var(--card-color);
  font-size: 15px;
  font-weight: 600;
}

/* Still waiting for initiative: dimmed until the number is in. */
.table-combat__card:not(.is-rolled) .table-combat__portrait {
  filter: saturate(0.5) brightness(0.75);
}

.table-combat__card.is-hidden .table-combat__portrait {
  border-style: dashed !important;
  opacity: 0.65;
}

.table-combat__card.is-active .table-combat__portrait {
  box-shadow:
    0 0 0 2px rgb(var(--table-panel-rgb)),
    0 0 0 4px var(--table-accent),
    0 0 18px rgba(var(--table-accent-rgb), 0.65);
  transform: translateY(1px) scale(1.06);
}

.table-combat__name {
  max-width: 100%;
  overflow: hidden;
  color: var(--table-muted);
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.table-combat__card.is-active .table-combat__name {
  color: var(--table-text);
  font-weight: 600;
}

.table-combat__badge,
.table-combat__roll {
  position: absolute;
  top: 28px;
  right: 0;
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 18px;
  padding: 0 4px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  background: rgb(var(--table-panel-rgb)) !important;
  border: 1px solid rgba(var(--table-accent-rgb), 0.55) !important;
  border-radius: 9px;
  box-sizing: border-box;
}

.table-combat__badge:disabled {
  color: var(--table-text) !important;
  cursor: default !important;
}

.table-combat__badge:not(:disabled):hover {
  border-color: var(--table-accent) !important;
}

.table-combat__card.is-active .table-combat__badge {
  color: #fff !important;
  background: var(--table-accent) !important;
  border-color: var(--table-accent) !important;
}

/* The dice button of an unrolled card the user may roll for. */
.table-combat__roll {
  top: 25px;
  right: -2px;
  width: 24px;
  height: 22px;
  padding: 0 !important;
  color: #fff !important;
  background: var(--table-accent) !important;
  border-color: rgba(var(--table-white-rgb), 0.35) !important;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(var(--table-black-rgb), 0.5);
}

.table-combat__roll .table-icon {
  width: 15px;
  height: 15px;
}

.table-combat__roll:hover {
  filter: brightness(1.15);
}

.table-combat__enter,
.table-combat__remove {
  position: absolute;
  top: 0;
  width: 18px;
  height: 18px;
  padding: 0 !important;
  font-size: 12px !important;
  line-height: 1;
  background: rgb(var(--table-panel-rgb)) !important;
  border: 1px solid rgba(var(--table-accent-rgb), 0.4) !important;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.table-combat__enter {
  left: 0;
}

.table-combat__remove {
  right: 0;
}

.table-combat__card:hover .table-combat__enter,
.table-combat__card:hover .table-combat__remove,
.table-combat__card:focus-within .table-combat__enter,
.table-combat__card:focus-within .table-combat__remove {
  opacity: 1;
}

.table-combat__remove:hover {
  color: var(--table-danger) !important;
  border-color: var(--table-danger) !important;
}

.table-combat__actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 4px;
}

.table-combat__actions:has(> :not([hidden])) {
  padding-left: 8px;
  border-left: 1px solid rgba(var(--table-accent-rgb), 0.2);
}

.table-combat__action,
.table-combat__done {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px !important;
  white-space: nowrap;
  border: 1px solid rgba(var(--table-accent-rgb), 0.35) !important;
  border-radius: 6px;
}

.table-combat__action .table-icon {
  width: 16px;
  height: 16px;
  color: var(--table-accent-text);
}

.table-combat__action:hover {
  background: rgba(var(--table-accent-rgb), 0.2) !important;
}

.table-combat__done {
  color: #fff !important;
  font-weight: 600 !important;
  background: var(--table-accent) !important;
  border-color: var(--table-accent) !important;
}

.table-combat__done:hover {
  filter: brightness(1.12);
}

.table-combat__end {
  width: 28px;
  height: 28px;
  padding: 0 !important;
  color: var(--table-muted) !important;
  font-size: 18px !important;
  line-height: 1;
  border-radius: 6px;
}

.table-combat__end:hover {
  color: var(--table-danger) !important;
  background: rgba(220, 53, 69, 0.15) !important;
}

.table-combat__turn {
  padding: 3px 10px;
  color: var(--table-accent-text);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: rgba(var(--table-accent-rgb), 0.14);
  border: 1px solid rgba(var(--table-accent-rgb), 0.45);
  border-radius: 999px;
}

.table-combat__turn--gm {
  color: var(--table-text);
  box-shadow: 0 0 12px rgba(var(--table-accent-rgb), 0.35);
}

/* Manual entry: under its card, for campaigns that roll real dice and for corrections. */
.table-combat__entry {
  position: absolute;
  top: calc(100% + 8px);
  display: grid;
  gap: 8px;
  width: 220px;
  padding: 10px 12px 12px;
  background: rgba(var(--table-panel-rgb), 0.96);
  border: 1px solid rgba(var(--table-accent-rgb), 0.35);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(var(--table-black-rgb), 0.5);
  animation: table-toast-in 0.16s ease-out;
}

.table-combat__entry-hint {
  font-size: 12px;
  line-height: 1.35;
}

.table-combat__entry-name {
  overflow: hidden;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.table-combat__entry-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--table-muted);
  font-size: 12px;
}

.table-combat__entry-row input {
  width: 84px;
  padding: 4px 8px;
  color: var(--table-text);
  font: inherit;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  background: rgba(var(--table-black-rgb), 0.3);
  border: 1px solid rgba(var(--table-accent-rgb), 0.35);
  border-radius: 6px;
}

.table-combat__entry-row input:focus {
  border-color: var(--table-accent);
  outline: none;
}

.table-combat__entry-row input.is-invalid {
  border-color: var(--table-danger);
}

.table-combat__entry-submit {
  height: 30px;
  color: #fff !important;
  font-weight: 600 !important;
  background: var(--table-accent) !important;
  border-radius: 6px;
}

/* The sound hint moves below the tracker. */
.table-root.has-combat .table-hud__sound {
  top: 104px;
}

@media (prefers-reduced-motion: reduce) {
  .table-combat,
  .table-combat__entry {
    animation: none;
  }

  .table-combat__portrait {
    transition: none;
  }
}

/* Below the back link where the top row gets tight. */
@media (max-width: 900px) {
  .table-combat {
    top: 52px;
  }

  .table-root.has-combat .table-hud__sound {
    top: 144px;
  }
}

/* Phones: avatars only, the cards on a row of their own, the controls below them. */
@media (max-width: 576px) {
  .table-combat {
    right: 16px;
    left: 16px;
    flex-wrap: wrap;
    gap: 4px 6px;
    max-width: none;
    translate: none;
  }

  .table-combat__cards {
    flex: 1 0 100%;
    order: -1;
    padding-top: 5px;
  }

  .table-combat__card {
    width: 40px;
  }

  .table-combat__portrait {
    width: 36px;
    height: 36px;
  }

  .table-combat__name,
  .table-combat__enter,
  .table-combat__remove,
  .table-combat__action > span {
    display: none;
  }

  .table-combat__badge {
    top: 22px;
    right: -4px;
    min-width: 20px;
    height: 16px;
  }

  .table-combat__roll {
    top: 18px;
    right: -5px;
    width: 22px;
    height: 20px;
  }

  .table-combat__status {
    padding-right: 0;
    border-right: 0;
  }

  .table-combat__actions {
    margin-left: auto;
  }

  .table-combat__actions:has(> :not([hidden])) {
    padding-left: 0;
    border-left: 0;
  }

  .table-combat__entry {
    top: calc(100% + 6px);
  }
}

/* ---- Initiative prompt: a player's call to roll for their tokens (InitiativePrompt.js) ---- */

.table-initiative {
  position: absolute;
  bottom: 16px;
  left: 16px;
  z-index: var(--table-z-hud);
  display: grid;
  gap: 10px;
  box-sizing: border-box;
  width: 300px;
  max-width: calc(100% - 32px);
  padding: 12px 14px 14px;
  overflow: hidden;
  font-size: 13px;
  pointer-events: auto;
  background:
    radial-gradient(ellipse 90% 70% at 0% 0%, rgba(var(--table-accent-rgb), 0.16), transparent 70%),
    rgba(var(--table-panel-rgb), 0.92);
  border: 1px solid rgba(var(--table-accent-rgb), 0.45);
  border-radius: 12px;
  box-shadow:
    0 12px 32px rgba(var(--table-black-rgb), 0.5),
    0 0 24px rgba(var(--table-accent-rgb), 0.18);
  backdrop-filter: blur(8px);
}

/* A thin line of light along the top edge. */
.table-initiative::before {
  position: absolute;
  top: 0;
  right: 18px;
  left: 18px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(var(--table-accent-rgb), 0.9), transparent);
  content: "";
}

.table-initiative[hidden],
.table-initiative [hidden] {
  display: none !important;
}

.table-initiative.is-entering {
  animation:
    table-initiative-in 0.52s cubic-bezier(0.2, 1.25, 0.4, 1),
    table-initiative-flare 1.4s ease-out;
}

@keyframes table-initiative-in {
  from {
    opacity: 0;
    transform: translateY(28px) scale(0.92);
  }
}

@keyframes table-initiative-flare {
  0% {
    box-shadow:
      0 12px 32px rgba(var(--table-black-rgb), 0.5),
      0 0 0 rgba(var(--table-accent-rgb), 0);
  }

  35% {
    box-shadow:
      0 12px 32px rgba(var(--table-black-rgb), 0.5),
      0 0 44px rgba(var(--table-accent-rgb), 0.55);
  }
}

.table-initiative button {
  color: var(--table-text);
  font: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.table-initiative button:focus-visible,
.table-initiative input:focus-visible {
  outline: 2px solid var(--table-accent);
  outline-offset: 1px;
}

.table-initiative__head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-initiative__die {
  display: grid;
  flex: none;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--table-accent-text);
  filter: drop-shadow(0 0 6px rgba(var(--table-accent-rgb), 0.6));
}

.table-initiative__die svg {
  width: 100%;
  height: 100%;
}

.table-initiative__die-face {
  fill: rgba(var(--table-accent-rgb), 0.28);
}

/* The die tumbles in, then rests with a slow glint. */
.table-initiative.is-entering .table-initiative__die {
  animation: table-initiative-tumble 0.9s cubic-bezier(0.2, 0.8, 0.3, 1.15);
}

.table-initiative__die svg {
  animation: table-initiative-glint 3.2s ease-in-out 1s infinite;
}

@keyframes table-initiative-tumble {
  0% {
    opacity: 0;
    transform: translate(-18px, -14px) rotate(-300deg) scale(0.4);
  }

  60% {
    opacity: 1;
    transform: translate(2px, 1px) rotate(18deg) scale(1.08);
  }

  80% {
    transform: rotate(-6deg) scale(0.98);
  }
}

@keyframes table-initiative-glint {
  0%,
  100% {
    transform: rotate(0);
  }

  50% {
    transform: rotate(8deg);
  }
}

.table-initiative__title {
  flex: 1;
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.table-initiative__close {
  flex: none;
  align-self: flex-start;
  width: 26px;
  height: 26px;
  padding: 0;
  color: var(--table-muted) !important;
  font-size: 18px !important;
  line-height: 1;
  border-radius: 6px;
}

.table-initiative__close:hover {
  color: var(--table-text) !important;
  background: rgba(var(--table-white-rgb), 0.08) !important;
}

.table-initiative__hint {
  color: var(--table-muted);
  font-size: 12px;
  line-height: 1.35;
}

.table-initiative__rows {
  display: grid;
  gap: 6px;
  max-height: 40vh;
  overflow-y: auto;
}

.table-initiative__row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 4px 4px 4px 6px;
  background: rgba(var(--table-white-rgb), 0.04);
  border: 1px solid rgba(var(--table-accent-rgb), 0.18);
  border-radius: 10px;
}

.table-initiative__portrait {
  display: grid;
  flex: none;
  place-items: center;
  width: 36px;
  height: 36px;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  background: rgba(var(--table-black-rgb), 0.35);
  border: 2px solid var(--token-color, var(--table-accent));
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(var(--table-accent-rgb), 0.3);
}

.table-initiative__portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.table-initiative__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.table-initiative__roll,
.table-initiative__all {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px !important;
  color: #fff !important;
  font-weight: 600 !important;
  background: var(--table-accent) !important;
  border: 1px solid rgba(var(--table-white-rgb), 0.3) !important;
  border-radius: 8px;
  box-shadow: 0 3px 10px rgba(var(--table-black-rgb), 0.45);
}

.table-initiative__roll .table-icon,
.table-initiative__all .table-icon {
  width: 17px;
  height: 17px;
}

/* Waiting for the player: the button breathes softly. */
.table-initiative__roll:not(:disabled) {
  animation: table-initiative-pulse 1.8s ease-out 0.6s infinite;
}

@keyframes table-initiative-pulse {
  0% {
    box-shadow:
      0 3px 10px rgba(var(--table-black-rgb), 0.45),
      0 0 0 0 rgba(var(--table-accent-rgb), 0.6);
  }

  70%,
  100% {
    box-shadow:
      0 3px 10px rgba(var(--table-black-rgb), 0.45),
      0 0 0 9px rgba(var(--table-accent-rgb), 0);
  }
}

.table-initiative__roll:hover:not(:disabled),
.table-initiative__all:hover:not(:disabled) {
  filter: brightness(1.15);
}

.table-initiative__roll:disabled,
.table-initiative__all:disabled {
  cursor: default;
  opacity: 0.7;
}

/* Rolling: the dice in the button spin until the result is in. */
.table-initiative__row.is-rolling .table-initiative__roll .table-icon {
  animation: table-initiative-spin 0.7s linear infinite;
}

@keyframes table-initiative-spin {
  to {
    transform: rotate(360deg);
  }
}

.table-initiative__all {
  justify-self: stretch;
  background: transparent !important;
  border-color: rgba(var(--table-accent-rgb), 0.55) !important;
  color: var(--table-text) !important;
  box-shadow: none;
}

.table-initiative__all:hover:not(:disabled) {
  background: rgba(var(--table-accent-rgb), 0.18) !important;
}

.table-initiative__entry {
  display: flex;
  flex: none;
  gap: 4px;
}

.table-initiative__entry input {
  width: 64px;
  height: 34px;
  padding: 0 8px;
  box-sizing: border-box;
  color: var(--table-text);
  font: inherit;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  background: rgba(var(--table-black-rgb), 0.3);
  border: 1px solid rgba(var(--table-accent-rgb), 0.45);
  border-radius: 8px;
}

.table-initiative__entry input:focus {
  border-color: var(--table-accent);
  outline: none;
}

.table-initiative__entry input.is-invalid {
  border-color: var(--table-danger);
}

.table-initiative__submit {
  width: 34px;
  height: 34px;
  padding: 0 !important;
  color: #fff !important;
  font-weight: 600 !important;
  background: var(--table-accent) !important;
  border-radius: 8px;
}

.table-initiative__live {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .table-initiative.is-entering,
  .table-initiative.is-entering .table-initiative__die,
  .table-initiative__die svg,
  .table-initiative__roll:not(:disabled),
  .table-initiative__row.is-rolling .table-initiative__roll .table-icon {
    animation: none;
  }
}

/* Phones: across the bottom, above the HUD bar; only the dice icon on the roll buttons. */
@media (max-width: 576px) {
  .table-initiative {
    right: 16px;
    bottom: 60px;
    width: auto;
    max-width: none;
    padding: 10px 12px 12px;
  }

  .table-initiative__rows {
    max-height: 30vh;
  }

  .table-initiative__roll {
    padding: 0 10px !important;
  }

  .table-initiative__roll > span {
    display: none;
  }
}

/* ---- Character panel: the sheet fly-in on the right (CharacterPanel.js) -------------------- */

.table-root {
  --table-character-panel-width: 420px;
}

.table-character-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  /* Above the HUD and panels, below the showcase (15) and menus (20). */
  z-index: var(--table-z-character);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: min(var(--table-character-panel-width), 100%);
  background: rgb(var(--table-panel-rgb));
  border-left: 1px solid rgba(var(--table-accent-rgb), 0.3);
  box-shadow: -10px 0 30px rgba(var(--table-black-rgb), 0.45);
  transform: translateX(100%);
  visibility: hidden;
  transition:
    transform 0.25s ease,
    visibility 0s linear 0.25s;
}

.table-character-panel.is-open {
  transform: none;
  visibility: visible;
  transition: transform 0.25s ease;
}

.table-character-panel__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 14px;
  font-size: 13px;
  border-bottom: 1px solid rgba(var(--table-accent-rgb), 0.25);
}

.table-character-panel__title {
  flex: 1;
  overflow: hidden;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.table-character-panel__close,
.table-character-panel__portrait-action {
  width: 30px;
  height: 30px;
  padding: 0;
  color: var(--table-text);
  font: inherit;
  font-size: 20px;
  line-height: 1;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.table-character-panel__close:hover,
.table-character-panel__close:focus-visible,
.table-character-panel__portrait-action:hover,
.table-character-panel__portrait-action:focus-visible {
  background: rgba(var(--table-accent-rgb), 0.2);
  outline: none;
}

.table-character-panel__portrait-action[hidden] {
  display: none;
}

.table-character-panel__portrait-action .table-icon {
  width: 18px;
  height: 18px;
}

/* The shown page and, while another one loads, that one on top of it, transparent until it is
   ready with its fonts (CharacterPanel._ready): the panel never shows a half-built page. */
.table-character-panel__body {
  position: relative;
  flex: 1;
  min-height: 0;
}

.table-character-panel__frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  animation: table-panel-page-in 0.12s ease-out;
}

.table-character-panel__frame.is-pending {
  opacity: 0;
  pointer-events: none;
  animation: none;
}

@keyframes table-panel-page-in {
  from {
    opacity: 0;
  }
}

/* A page that takes longer than a moment: a thin line under the header sweeps across. */
.table-character-panel__loading {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 2px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.table-character-panel__loading::before {
  position: absolute;
  inset: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, rgba(var(--table-accent-rgb), 0.8), transparent);
  animation: table-panel-loading 1.1s ease-in-out infinite paused;
  content: "";
}

.table-character-panel.is-loading .table-character-panel__loading {
  opacity: 1;
}

/* The line sweeps only while a page loads. Paused, it costs nothing between loads, and as it
   fades out it rests where it was instead of jumping back. */
.table-character-panel.is-loading .table-character-panel__loading::before {
  animation-play-state: running;
}

@keyframes table-panel-loading {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(250%);
  }
}

/* A roll of the shown character or foe on a phone: the panel slides aside to a handle at the
   edge until the result card has faded (CharacterPanel.stepAsideFor). */
.table-character-panel.is-open.is-aside {
  transform: translateX(calc(100% - 36px));
}

.table-character-panel__handle {
  position: absolute;
  top: 50%;
  left: 0;
  display: none;
  width: 36px;
  height: 72px;
  padding: 0;
  color: var(--table-text);
  font: inherit;
  font-size: 22px;
  background: rgba(var(--table-accent-rgb), 0.25);
  border: 0;
  border-radius: 8px 0 0 8px;
  transform: translateY(-50%);
  cursor: pointer;
}

.table-character-panel.is-aside .table-character-panel__handle {
  display: block;
}

/* While the panel is aside only its handle strip is on screen: the HUD bar keeps clear of it. */
.table-root.has-character-panel:has(.table-character-panel.is-aside) .table-hud__bar {
  right: 52px;
}

.table-character-panel.is-aside .table-character-panel__frame,
.table-character-panel.is-aside .table-character-panel__header {
  visibility: hidden;
}

/* Keep the inspector and the HUD bar beside the open panel. */
.table-root.has-character-panel .table-inspector,
.table-root.has-character-panel .table-hud__bar {
  right: calc(var(--table-character-panel-width) + 16px);
}

.table-hud__sound {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  color: var(--table-text);
  font: inherit;
  pointer-events: auto;
  background: rgba(var(--table-panel-rgb), 0.9);
  border: 1px solid rgba(255, 193, 7, 0.6);
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(var(--table-black-rgb), 0.4);
  cursor: pointer;
}

.table-hud__sound[hidden] {
  display: none;
}

.table-hud__zoom {
  min-width: 56px !important;
  font-variant-numeric: tabular-nums;
}

.table-hud__status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px 0 8px;
  color: var(--table-muted);
}

.table-hud__status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--table-muted);
}

.table-hud__status[data-status="open"]::before {
  background: var(--bs-success, #198754);
  box-shadow: 0 0 6px var(--bs-success, #198754);
}

.table-hud__status[data-status="closed"]::before {
  background: var(--bs-warning, #ffc107);
}

.table-hud__status[data-status="offline"]::before {
  background: var(--table-accent);
}

.table-hud__status[data-status="denied"]::before {
  background: var(--table-danger);
}

.table-hud__status[data-status="outdated"]::before {
  background: var(--table-accent);
}

/* The server speaks another protocol version (ProtocolReload, protocolVersion.js): a card at the
   top says that the page reloads, or offers the reload when one did not help. */
.table-version {
  position: absolute;
  inset: 12px 12px auto;
  z-index: var(--table-z-dialog);
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.table-version__card {
  position: static;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 14px;
  width: auto;
  max-width: min(560px, 100%);
  max-height: none;
  padding: 12px 16px;
  background: rgba(var(--table-panel-rgb), 0.97);
  border-color: rgba(var(--table-accent-rgb), 0.45);
  box-shadow: 0 12px 40px rgba(var(--table-black-rgb), 0.55);
  pointer-events: auto;
}

.table-version__text {
  flex: 1 1 240px;
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--table-text);
}

.table-version__reload {
  min-height: 44px;
  padding: 8px 18px;
  font-size: 14px;
}

/* ---- Who is at the table (PresenceDots.js) ----------------------------------------------- */

/* Small dots in the members' colours, close together. */
.table-hud__bar .table-hud__presence {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  min-width: 0;
  padding: 0 8px 0 6px;
}

.table-hud__presence[hidden] {
  display: none;
}

.table-presence__dot {
  flex: none;
  width: 8px;
  height: 8px;
  background: var(--presence-color);
  border-radius: 50%;
}

.table-presence__dot.is-new {
  animation: table-presence-in 0.3s ease-out;
}

@keyframes table-presence-in {
  from {
    opacity: 0;
    transform: scale(0.4);
  }
}

.table-presence__more {
  margin-left: 2px;
  color: var(--table-muted);
  font-size: 11px;
}

.table-presence {
  min-width: 240px;
  max-width: min(340px, calc(100% - 16px));
  padding: 8px 10px;
  user-select: text;
}

.table-presence__title {
  margin-bottom: 6px;
  color: var(--table-muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.table-presence__list {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 6px 10px;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
}

.table-presence__row {
  display: contents;
}

.table-presence__name {
  overflow: hidden;
  color: var(--table-text);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.table-presence__you,
.table-presence__tabs,
.table-presence__role {
  color: var(--table-muted);
}

.table-presence__role {
  font-size: 12px;
}

.table-presence__latency {
  color: var(--table-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.table-presence__latency[data-quality="good"] {
  color: var(--bs-success, #198754);
}

.table-presence__latency[data-quality="fair"] {
  color: var(--bs-warning, #ffc107);
}

.table-presence__latency[data-quality="poor"] {
  color: var(--table-danger);
}

@media (prefers-reduced-motion: reduce) {
  .table-presence__dot.is-new {
    animation: none;
  }
}

@media (max-width: 576px) {
  .table-hud__bar .table-hud__presence {
    padding: 0 6px 0 4px;
  }
}

/* ---- View only and no access ------------------------------------------------------------- */

/* A read-only table (a viewer, a preview, a locked table: `Access.readOnly`) keeps the camera
   controls; every tool that changes something is gone. */
.table-root.is-read-only .table-hud__add,
.table-root.is-read-only .table-character-badge {
  display: none !important;
}

.table-root.is-read-only .table-viewport {
  cursor: grab;
}

.table-root.is-read-only .table-viewport.is-panning {
  cursor: grabbing;
}

.table-hud__view-only {
  display: inline-flex;
  align-items: center;
  align-self: center;
  margin: 0 4px;
  padding: 2px 9px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--table-accent-text);
  background: rgba(var(--table-accent-rgb), 0.12);
  border: 1px solid rgba(var(--table-accent-rgb), 0.45);
  border-radius: 999px;
}

.table-hud__view-only[hidden] {
  display: none;
}

/* The access dialog covers everything, the back link included: its actions lead away. */
.table-access {
  position: absolute;
  inset: 0;
  z-index: var(--table-z-dialog);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(var(--table-black-rgb), 0.55);
  backdrop-filter: blur(4px);
}

.table-access[hidden] {
  display: none;
}

.table-access__dialog {
  position: static;
  align-items: center;
  gap: 12px;
  width: min(400px, 100%);
  max-height: none;
  padding: 24px 24px 22px;
  text-align: center;
  background: rgba(var(--table-panel-rgb), 0.97);
  border-color: rgba(var(--table-accent-rgb), 0.45);
  box-shadow:
    0 12px 40px rgba(var(--table-black-rgb), 0.55),
    0 0 0 1px rgba(var(--table-accent-rgb), 0.08),
    0 0 32px rgba(var(--table-accent-rgb), 0.12);
}

.table-access__sigil {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  color: var(--table-accent-text);
  background: radial-gradient(circle, rgba(var(--table-accent-rgb), 0.18), transparent 70%);
  border: 1px solid rgba(var(--table-accent-rgb), 0.4);
  border-radius: 50%;
}

.table-access__sigil svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.table-access__title {
  margin: 0;
  font-size: 13px;
}

.table-access__text {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--table-text);
}

.table-access__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}

.table-access__actions .table-panel__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 18px;
  font-size: 14px;
  text-decoration: none;
}

/* "Log in" is the way in; "Back to campaign" stays quieter next to it. */
.table-access__login {
  color: var(--bs-white, #fff) !important;
  background: rgba(var(--table-accent-rgb), 0.85) !important;
  border-color: rgba(var(--table-accent-rgb), 1) !important;
}

.table-access__login:hover,
.table-access__login:focus-visible {
  background: rgba(var(--table-accent-rgb), 1) !important;
}

.table-access__login + .table-access__back {
  background: transparent;
}

/* Nothing behind the dialog takes input; the back link is one of its actions now. */
.table-root.is-denied > :not(.table-access) {
  pointer-events: none;
}

body:has(.table-root.is-denied) .table-back-link {
  display: none;
}

.table-hud__toasts {
  position: absolute;
  left: 50%;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(480px, calc(100% - 32px));
  transform: translateX(-50%);
}

.table-toast {
  padding: 8px 14px;
  animation: table-toast-in 0.18s ease-out;
}

.table-toast--error {
  border-color: rgba(220, 53, 69, 0.6);
  border-color: color-mix(in srgb, var(--table-danger) 60%, transparent);
}

@keyframes table-toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@media (max-width: 576px) {
  .table-hud__status {
    display: none;
  }

  /* The bar has to fit a phone: "Add" shows only its "+", labels never wrap. */
  .table-hud__bar button {
    white-space: nowrap;
  }

  .table-hud__bar .table-hud__add {
    font-size: 0;
  }

  .table-hud__bar .table-hud__add::before {
    margin: 0;
    font-size: 18px;
  }

  .table-hud__toasts {
    bottom: 64px;
  }
}

@media (max-width: 576px) {
  .table-panel {
    top: auto;
    bottom: 64px;
    width: calc(100% - 32px);
    max-height: 45%;
  }

  /* A bottom sheet, collapsed to its title by default, so the selected token and its step
     arrows stay in sight above it (Inspector pans them there). */
  .table-inspector {
    right: 16px;
    left: 16px;
    width: auto;
    max-height: min(40dvh, 360px);
    padding-top: 0;
  }

  .table-inspector__head {
    position: sticky;
    top: 0;
    z-index: 1;
    margin: 0 -12px;
    padding: 0 4px 0 12px;
    background: rgba(var(--table-panel-rgb), 0.96);
  }

  .table-inspector__toggle {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    color: var(--table-accent-text);
    background: none;
    border: 0;
    cursor: pointer;
  }

  .table-inspector__toggle svg {
    width: 20px;
    height: 20px;
    transition: rotate 0.2s ease;
  }

  .table-inspector:not(.is-collapsed) .table-inspector__toggle svg {
    rotate: 180deg;
  }

  .table-inspector.is-collapsed {
    padding-bottom: 0;
  }

  .table-inspector.is-collapsed > :not(.table-inspector__head) {
    display: none;
  }

  /* The map panel makes way for the sheet at the top. */
  .table-root:has(> .table-inspector:not([hidden])) .table-map-panel {
    top: 64px;
    bottom: auto;
    max-height: 30%;
  }

  .table-token-picker {
    top: 64px;
    bottom: 64px;
    max-height: none;
  }

  .table-root.has-token-picker .table-map-panel,
  .table-root.has-token-picker .table-inspector,
  .table-root.has-prop-picker .table-map-panel,
  .table-root.has-prop-picker .table-inspector,
  .table-root.has-drawer .table-map-panel,
  .table-root.has-drawer .table-inspector {
    display: none;
  }

  /* A bottom sheet: the table stays in sight above it for placing. */
  .table-prop-picker {
    top: auto;
    bottom: 64px;
    max-height: 55%;
  }

  .table-prop-picker__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Phones and narrow windows: the panel covers the whole table. */
@media (max-width: 576px) {
  .table-character-panel {
    width: 100%;
  }

  .table-root.has-character-panel .table-inspector,
  .table-root.has-character-panel .table-map-panel,
  body:has(.table-root.has-character-panel) .table-back-link {
    display: none;
  }
}

/* Too narrow for the HUD bar beside the panel: it stays in place, under the panel. */
@media (max-width: 760px) {
  .table-root.has-character-panel .table-hud__bar {
    right: 16px;
  }
}

/* The bar never leaves the free part of the table: beside the open panel it is at most as wide
   as the room there. Its items keep their size; the presence dots give way first (each person
   adds a dot, up to 8), and the dots that do not fit are cut off (the button's tooltip and
   popover still list everyone). */
.table-hud__bar {
  box-sizing: border-box;
  max-width: calc(100% - 32px);
}

/* A phone's bar is tight: slimmer buttons and gaps, so it fits a 360px screen with one dot. */
@media (max-width: 576px) {
  .table-hud__bar {
    gap: 0;
  }

  .table-hud__bar button {
    padding: 0 6px;
  }
}

.table-hud__bar > * {
  flex: none;
}

.table-hud__bar > .table-hud__presence {
  flex: 0 1 auto;
  min-width: 22px;
  overflow: hidden;
}

@media (min-width: 761px) {
  .table-root.has-character-panel .table-hud__bar {
    max-width: calc(100% - var(--table-character-panel-width) - 32px);
  }
}

/* No room for the labelled bar (about 645px for the GM in German, 610 for a player): it goes
   compact as on phones, the status its dot, "Add" its "+", settings its gear. The words stay for
   screen readers, and every button keeps its tooltip. Beside the panel that is up to 1099px,
   without it up to 699px. */
@media (min-width: 577px) and (max-width: 699px) {
  .table-root .table-hud__bar button {
    white-space: nowrap;
  }

  .table-root .table-hud__status {
    gap: 0;
    padding: 0 6px;
    font-size: 0;
  }

  .table-root .table-hud__bar .table-hud__add {
    font-size: 0;
  }

  .table-root .table-hud__bar .table-hud__add::before {
    margin: 0;
    font-size: 18px;
  }

  .table-root .table-hud__settings > span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

@media (min-width: 700px) and (max-width: 1099px) {
  .table-root.has-character-panel .table-hud__bar button {
    white-space: nowrap;
  }

  .table-root.has-character-panel .table-hud__status {
    gap: 0;
    padding: 0 6px;
    font-size: 0;
  }

  .table-root.has-character-panel .table-hud__bar .table-hud__add {
    font-size: 0;
  }

  .table-root.has-character-panel .table-hud__bar .table-hud__add::before {
    margin: 0;
    font-size: 18px;
  }

  .table-root.has-character-panel .table-hud__settings > span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* Even the compact bar (about 410px for the GM) does not fit beside the panel: it wraps into two
   rows, and the dice log and the Inspector keep clear of the higher bar. */
@media (min-width: 761px) and (max-width: 859px) {
  .table-root.has-character-panel {
    --table-hud-clear: 100px;
  }

  .table-root.has-character-panel .table-hud__bar {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}

/* Too narrow for the Inspector beside the panel (it needs 692px): it is gone while the panel is
   open, as on phones, and comes back with the selection when the panel closes. */
@media (min-width: 577px) and (max-width: 691px) {
  .table-root.has-character-panel .table-inspector {
    display: none;
  }
}

/* ---- Dice log placement -------------------------------------------------------------------- */

/* The open log sits at the bottom right of the free table, above the HUD bar. It moves beside the
   character panel as the Inspector does. With the Inspector shown too it goes beside it where
   there is room, else below it in the same column, and the Inspector gets shorter. Where the panel
   takes the whole width (phones, narrow windows) the panel ends above the log. */
.table-root {
  /* How far the log and the Inspector keep above the bottom: clear of the HUD bar. */
  --table-hud-clear: 64px;
  /* The log's height when the Inspector shares its column, and when the panel ends above it. */
  --table-dice-log-stacked: min(35vh, 300px);
  --table-dice-log-docked: min(32dvh, 260px);
}

/* Beside the Inspector: its 240px and a 12px gap further left. */
@media (min-width: 820px) {
  .table-root:not(.has-character-panel):has(> .table-inspector:not([hidden])) > .table-dice-log {
    right: 268px;
  }
}

@media (min-width: 577px) and (max-width: 819px) {
  .table-root:not(.has-character-panel):has(> .table-inspector:not([hidden])) > .table-dice-log {
    max-height: var(--table-dice-log-stacked);
  }

  .table-root:not(.has-character-panel):has(> .table-dice-log:not([hidden])) > .table-inspector {
    max-height: calc(100% - 76px - var(--table-hud-clear) - var(--table-dice-log-stacked));
  }
}

@media (min-width: 761px) {
  .table-root.has-character-panel > .table-dice-log {
    right: calc(var(--table-character-panel-width) + 16px);
  }
}

@media (min-width: 1240px) {
  .table-root.has-character-panel:has(> .table-inspector:not([hidden])) > .table-dice-log {
    right: calc(var(--table-character-panel-width) + 268px);
  }
}

@media (min-width: 761px) and (max-width: 1239px) {
  .table-root.has-character-panel:has(> .table-inspector:not([hidden])) > .table-dice-log {
    max-height: var(--table-dice-log-stacked);
  }

  .table-root.has-character-panel:has(> .table-dice-log:not([hidden])) > .table-inspector {
    max-height: calc(100% - 76px - var(--table-hud-clear) - var(--table-dice-log-stacked));
  }
}

/* No room beside the panel: the log takes the bottom of the panel's column, and the panel ends
   above it, which also uncovers the HUD bar. Stepping aside for a roll works as before. */
@media (max-width: 760px) {
  .table-root.has-character-panel > .table-dice-log {
    height: var(--table-dice-log-docked);
    max-height: none;
  }

  .table-root.has-character-panel:has(> .table-dice-log:not([hidden])) > .table-character-panel {
    bottom: calc(64px + var(--table-dice-log-docked) + 8px);
  }
}

@media (min-width: 577px) and (max-width: 760px) {
  .table-root.has-character-panel > .table-dice-log {
    width: calc(var(--table-character-panel-width) - 32px);
  }
}

/* Phones: both are bottom sheets, so the Inspector's sits on top of the log. */
@media (max-width: 576px) {
  .table-root:not(.has-character-panel):has(> .table-inspector:not([hidden])) > .table-dice-log {
    height: var(--table-dice-log-docked);
  }

  .table-root:not(.has-character-panel):has(> .table-dice-log:not([hidden])) > .table-inspector {
    bottom: calc(64px + var(--table-dice-log-docked) + 8px);
  }

  /* With the map panel at the top too (up to 30% from 64px), the Inspector stops 8px below it. */
  .table-root:not(.has-character-panel):has(> .table-dice-log:not([hidden])):has(> .table-map-panel:not([hidden])) > .table-inspector {
    max-height: min(40dvh, 360px, calc(70% - 144px - var(--table-dice-log-docked)));
  }
}

/* ---- Image showcase --------------------------------------------------------------------- */

.table-showcase {
  position: absolute;
  inset: 0;
  z-index: var(--table-z-showcase);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px 16px;
  background: rgba(var(--table-black-rgb), 0.72);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 600ms ease;
}

.table-showcase.is-open {
  opacity: 1;
}

.table-showcase[hidden] {
  display: none;
}

/* Cards are stacked in one grid cell, so a new one crossfades over the old one. */
.table-showcase__stage {
  display: grid;
  place-items: center;
  max-width: 100%;
  min-height: 0;
}

.table-showcase__card {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 100%;
  margin: 0;
  opacity: 0;
  transform: scale(0.96);
  transition:
    opacity 600ms ease,
    transform 600ms ease;
}

.table-showcase__card.is-visible {
  opacity: 1;
  transform: none;
}

.table-showcase__image {
  display: block;
  max-width: min(100%, 1100px);
  max-height: calc(100vh - 190px);
  max-height: calc(100dvh - 190px);
  object-fit: contain;
  border: 1px solid rgba(var(--table-white-rgb), 0.25);
  border-radius: 8px;
  box-shadow: 0 20px 70px rgba(var(--table-black-rgb), 0.7);
}

/* Without an image: the first letter, like the token picker's portraits. */
.table-showcase__sigil {
  display: grid;
  place-items: center;
  width: min(60vw, 260px);
  aspect-ratio: 1;
  color: var(--table-accent-text);
  font-size: min(30vw, 130px);
  font-weight: 600;
  background: rgba(var(--table-accent-rgb), 0.15);
  border: 3px solid rgba(var(--table-accent-rgb), 0.55);
  border-radius: 50%;
}

.table-showcase__name {
  max-width: 100%;
  padding: 4px 16px;
  overflow: hidden;
  color: var(--table-text);
  font-size: clamp(18px, 3vw, 28px);
  font-weight: 600;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(var(--table-panel-rgb), 0.9);
  border: 1px solid rgba(var(--table-white-rgb), 0.2);
  border-radius: 999px;
}

.table-showcase__controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.table-showcase__button {
  padding: 6px 14px;
  color: var(--table-text);
  font: inherit;
  background: rgba(var(--table-panel-rgb), 0.92);
  border: 1px solid rgba(var(--table-white-rgb), 0.25);
  border-radius: 8px;
  cursor: pointer;
}

.table-showcase__button:hover,
.table-showcase__button:focus-visible {
  background: rgba(var(--table-accent-rgb), 0.25);
  outline: none;
}

.table-showcase__button[hidden] {
  display: none;
}

.table-token-picker__row {
  display: flex;
  align-items: center;
}

.table-token-picker__row > .table-token-picker__item {
  flex: 1;
  min-width: 0;
}

.table-token-picker__showcase {
  display: grid;
  place-items: center;
  flex: none;
  color: var(--table-muted);
}

.table-token-picker__showcase .table-icon {
  width: 18px;
  height: 18px;
}

/* ---- Library picker (LibraryPicker.js) ---------------------------------------------------- */

.table-library-picker {
  position: absolute;
  inset: 0;
  z-index: var(--table-z-dialog);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(var(--table-black-rgb), 0.45);
}

.table-library-picker[hidden] {
  display: none;
}

.table-library-picker__dialog {
  position: static;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(640px, 100%);
  height: min(80vh, 760px);
  height: min(80dvh, 760px);
}

.table-library-picker__dialog.is-busy {
  cursor: progress;
}

.table-library-picker__dialog.is-busy button:disabled {
  cursor: progress;
  opacity: 0.6;
}

.table-library-picker__header {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* "Add hidden", next to the title. */
.table-library-picker__hidden {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  color: var(--table-muted);
  font-size: 13px;
  cursor: pointer;
}

.table-library-picker__close {
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--table-text);
  font: inherit;
  font-size: 18px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.table-library-picker__close:hover,
.table-library-picker__close:focus-visible {
  background: rgba(var(--table-accent-rgb), 0.2);
  outline: none;
}

.table-library-picker__pane {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.table-library-picker__search {
  width: 100%;
  padding: 6px 10px;
  color: var(--table-text);
  font: inherit;
  background: rgba(var(--table-black-rgb), 0.25);
  border: 1px solid rgba(var(--table-white-rgb), 0.16);
  border-radius: 6px;
}

.table-library-picker__search:focus-visible {
  border-color: var(--table-accent);
  outline: none;
}

/* The way back from the open folders. */
.table-library-picker__trail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-width: 0;
  font-size: 13px;
}

.table-library-picker__trail[hidden] {
  display: none;
}

.table-library-picker__crumb {
  padding: 2px 6px;
  color: var(--table-accent-text);
  font: inherit;
  background: transparent;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}

.table-library-picker__crumb:hover,
.table-library-picker__crumb:focus-visible {
  background: rgba(var(--table-accent-rgb), 0.16);
  outline: none;
}

.table-library-picker__separator {
  color: var(--table-muted);
}

.table-library-picker__here {
  padding: 2px 6px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.table-library-picker__list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.table-library-picker__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
  gap: 8px;
}

/* An entry: the whole card adds it (or opens a folder). */
.table-library-picker__item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 4px;
  color: var(--table-text);
  font: inherit;
  font-size: 12px;
  text-align: left;
  background: rgba(var(--table-white-rgb), 0.04);
  border: 1px solid rgba(var(--table-white-rgb), 0.1);
  border-radius: 8px;
  cursor: pointer;
}

.table-library-picker__item:hover,
.table-library-picker__item:focus-visible {
  border-color: rgba(var(--table-accent-rgb), 0.8);
  outline: none;
  box-shadow: 0 0 0 2px rgba(var(--table-accent-rgb), 0.35);
}

.table-library-picker__thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  color: rgba(var(--table-accent-rgb), 0.6);
  background: rgba(var(--table-accent-rgb), 0.12);
  border-radius: 5px;
}

.table-library-picker__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.table-library-picker__thumb.is-empty .table-icon {
  width: 32px;
  height: 32px;
}

.table-library-picker__name {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-library-picker__meta {
  overflow: hidden;
  color: var(--table-muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Touch targets of at least 44 px. */
@media (pointer: coarse) {
  .table-library-picker__close,
  .table-library-picker__crumb {
    min-width: 44px;
    min-height: 44px;
  }
}

/* ---- Foes in the token picker: role and tier (foeBadges.js) -------------------------------- */

/* Read by screen readers only. */
.table-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.table-foe-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}

.table-foe-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 5px;
  color: var(--table-text);
  font-size: 11px;
  line-height: 18px;
  white-space: nowrap;
  background: rgba(var(--table-white-rgb), 0.05);
  border: 1px solid rgba(var(--table-white-rgb), 0.16);
  border-radius: 4px;
}

/* The upper tiers get a firmer frame, as on the site's badges. */
.table-foe-tier.is-tier-3,
.table-foe-tier.is-tier-4 {
  border-color: rgba(var(--table-accent-rgb), 0.55);
}

.table-foe-tier.is-tier-4 {
  background: rgba(var(--table-accent-rgb), 0.14);
}

/* Four rising bars, filled up to the tier. */
.table-foe-tier__meter {
  display: inline-flex;
  align-items: flex-end;
  gap: 1.5px;
  height: 11px;
}

.table-foe-tier__meter > span {
  width: 3px;
  background: rgba(var(--table-white-rgb), 0.22);
  border-radius: 1px;
}

.table-foe-tier__meter > span:nth-child(1) { height: 5px; }
.table-foe-tier__meter > span:nth-child(2) { height: 7px; }
.table-foe-tier__meter > span:nth-child(3) { height: 9px; }
.table-foe-tier__meter > span:nth-child(4) { height: 11px; }

.table-foe-tier__meter > span.is-on {
  background: var(--table-accent-text);
}

/* Token picker: a plot foe's role and tier under its name. */
.table-token-picker__text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.table-token-picker__text .table-token-picker__name {
  flex: none;
}

@media (prefers-reduced-motion: reduce) {
  .table-showcase,
  .table-showcase__card {
    transition: none;
  }
}

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

  .table-character-panel,
  .table-character-panel.is-open {
    transition: none;
  }

  .table-character-panel__frame,
  .table-character-panel__loading::before {
    animation: none;
  }
}

/* Path decorations (objects/pathStyles.js, pathDecor.js) ----------------------------------- */
/* Gentle, CSS-only animations of animatable path styles and motions. A stamp's wrapper carries
   its placement, so transforms here move the stamp around its own centre. */
.table-path-anim {
  transform-box: fill-box;
  transform-origin: center;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}

/* Dashes that move along the stroke (the river's highlight). */
.table-path-anim--flow {
  animation-name: table-path-flow;
  animation-timing-function: linear;
}

@keyframes table-path-flow {
  to {
    stroke-dashoffset: var(--dash-period, -24px);
  }
}

/* Paused while the page is hidden; off when the system asks for less motion. */
.is-page-hidden .table-path-anim {
  animation-play-state: paused;
}

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

/* A path's label: light text with a dark halo, readable on maps and on the bare table. */
.table-path__label {
  fill: var(--table-text, #ece8e1);
  stroke: rgba(var(--table-black-rgb, 0, 0, 0), 0.55);
  stroke-width: 0.14em;
  stroke-linejoin: round;
  paint-order: stroke;
  font-family: var(--bs-body-font-family, system-ui, sans-serif);
  font-weight: 600;
  letter-spacing: 0.05em;
  pointer-events: none;
}

/* ---- Reveal fades: objects the GM shows or hides (TableObject.fadeIn / destroy) ----------- */

/* Players: a revealed object fades in, a hidden or deleted one fades out before it goes. */
.table-object.is-appearing {
  animation: table-object-appear 0.35s ease-out;
}

.table-object.is-vanishing {
  animation: table-object-vanish 0.35s ease-in forwards;
  pointer-events: none;
}

.table-object.is-vanishing * {
  pointer-events: none;
}

@keyframes table-object-appear {
  from {
    opacity: 0;
  }
}

@keyframes table-object-vanish {
  to {
    opacity: 0;
  }
}

/* The GM: the hidden look comes and goes gradually. */
.table-object > .table-object__content,
.table-path__drawing,
.table-prop-light {
  transition: opacity 0.35s ease;
}

@media (prefers-reduced-motion: reduce) {
  .table-object.is-appearing,
  .table-object.is-vanishing {
    animation: none;
  }

  .table-object > .table-object__content,
  .table-path__drawing,
  .table-prop-light {
    transition: none;
  }
}

/* ---- Animated table effect (TableEffects.js) ----------------------------------------------- */

/* One screen-space canvas: before the world (below the objects) or, `is-above`, over everything
   on the table but below the overlay (marquee, pings) and the HUD. Never takes pointer input. */
.table-effects {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.table-effects.is-above {
  z-index: 4;
}

.table-effects[hidden] {
  display: none;
}

/* An image's own effect (ImageEffects.js): inside the image, below its grid. */
.table-image-effect {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  pointer-events: none;
}

/* ---- Image frames: sheets and edge strips (@taflor/api frames.image) ------------------------
   Sheets (.if-sheet) are SVGs in world px over the frame layer (placed by the shared
   `.table-image-frame > *` rule); edge strips (.if-edge) hold one
   side of an outer frame and scale from the image's edge (--x: left and right, --y: top and
   bottom). Each frame sets its palette here. Only whole sheets, strips and plain elements move,
   on transform and opacity; with the animations off they show their resting state. */

/* An inner frame stays inside the image. */
.table-image-frame[data-placement="inner"] .if-sheet {
  overflow: hidden;
}
