:root {
  color-scheme: dark;
  --bg: #14181c;
  --panel: #1c2329;
  --line: #314049;
  --text: #e7e1d6;
  --muted: #a39888;
  --brass: #c6a15b;
  --danger: #e2a39a;
  --ok: #b7c7a3;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 "Segoe UI", system-ui, sans-serif;
}

.wrap {
  width: min(28rem, calc(100% - 2rem));
  margin: 8vh auto 3rem;
}
.wrap.wide { width: min(42rem, calc(100% - 2rem)); }
.wrap.binder { width: min(64rem, calc(100% - 2rem)); }
.wrap.with-tree,
.wrap.with-tree.wide,
.wrap.with-tree.binder {
  width: 100%;
  max-width: none;
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr);
  align-items: start;
}
.wrap.with-tree.tree-closed { grid-template-columns: 2.75rem minmax(0, 1fr); }
.app-column { min-width: 0; padding: 1.25rem 1.5rem 2.5rem; }
.story-tree {
  position: sticky;
  top: 0;
  align-self: start;
  min-width: 0;
  height: 100vh;
  height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  background: #171d22;
  border-right: 1px solid var(--line);
  padding: 0.65rem 0.4rem 1.25rem;
}
.tree-closed .story-tree { padding: 0.55rem 0.3rem; overflow: hidden; }
.story-tree-head { display: flex; align-items: center; justify-content: flex-start; gap: 0.35rem; margin: 0 0 0.35rem; min-width: 0; }
.tree-closed .story-tree-head { justify-content: center; margin: 0; }
.tree-closed .story-tree-label,
.tree-closed #story-tree-body { display: none; }
.story-tree-label {
  margin: 0;
  min-width: 0;
  flex: 1 1 auto;
  text-align: left;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
#story-tree-body,
.story-tree-list,
.story-tree-list > li { min-width: 0; max-width: 100%; }
#story-fold {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  background: #12171b;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
}
#story-fold::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
}
#story-fold[aria-expanded="true"]::before { transform: rotate(135deg); }
#story-fold:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.story-tree-list { list-style: none; margin: 0; padding: 0; display: grid; justify-items: stretch; }
.story-tree-list .story-tree-list { margin: 0; padding: 0 0 0 0.7rem; }
.tree-row {
  display: grid;
  grid-template-columns: 1rem minmax(0, 1fr);
  align-items: center;
  justify-content: start;
  width: 100%;
  min-width: 0;
  gap: 0.1rem;
}
.tree-twist {
  display: grid;
  place-items: center;
  width: 100%;
  height: 1.5rem;
  padding: 0;
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: 3px;
}
.tree-twist::before {
  content: "";
  width: 0.34rem;
  height: 0.34rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
}
.tree-twist[aria-expanded="true"]::before { transform: rotate(45deg); }
.tree-twist.spacer::before { content: none; }
button.tree-link {
  width: 100%;
  min-width: 0;
  display: flex;
  gap: 0.4rem;
  align-items: baseline;
  justify-content: flex-start;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: 0;
  border-radius: 4px;
  padding: 0.2rem 0.25rem;
  margin: 0;
  font-size: 0.92rem;
}
.tree-name {
  flex: 0 1 auto;
  min-width: 0;
  margin-right: auto;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tree-link:hover { background: #243038; }
.tree-link[aria-current="page"] { background: rgba(198, 161, 91, 0.16); color: var(--brass); }
.tree-link .muted { font-size: 0.72rem; flex: 0 0 auto; }

.crumbs { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin: 0 0 0.35rem; color: var(--muted); font-size: 0.92rem; }
button.crumb { padding: 0; background: none; color: var(--brass); border: 0; border-radius: 0; }
button.crumb:hover { color: var(--text); }
.title-line {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  max-width: 100%;
}
.page-head .title-line { margin: 0 0 0.2rem; }
.page-head .title-line h1 { margin: 0; flex: 0 1 auto; min-width: 0; }
.inline-name { cursor: text; border-radius: 4px; }
.inline-name.is-empty::before { content: attr(data-placeholder); color: var(--muted); }
.roll-label { min-height: 1.2em; }
.inline-name:hover,
.inline-name:focus-visible { box-shadow: inset 0 -1px 0 var(--line); }
.inline-name.editing { box-shadow: none; }
input.inline-name-field {
  width: auto;
  max-width: min(28rem, 70vw);
  margin: 0;
  padding: 0 0.1rem 0.05rem;
  border: 0;
  border-bottom: 1px solid var(--brass);
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  line-height: inherit;
}
.more { position: relative; flex: 0 0 auto; }
button.more-btn,
.tools button.more-btn,
.choice-list button.more-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  flex: 0 0 auto;
  font-size: 1.15rem;
  line-height: 1;
}
.more-menu {
  min-width: 11rem;
  padding: 0.3rem 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  z-index: 50;
}
.more-menu button,
.choice-list .more-menu button,
.tools .more-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: 0;
  border-radius: 0;
  padding: 0.5rem 0.8rem;
}
.more-menu button:hover,
.more-menu button:focus-visible { background: #243038; }
.more-menu button.danger { color: var(--danger); }
.board-names { display: grid; gap: 0.35rem; }
.board-names .inline-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.board-names .inline-name.editing { overflow: visible; text-overflow: clip; }
.board-use > button:not(.more-btn) { flex: 1 1 auto; text-align: left; }
.choice-list .title-line > button:not(.more-btn) { flex: 1 1 auto; width: auto; }
.desk {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(16rem, 0.9fr);
  gap: 0 1rem;
  align-items: start;
}
.desk-tools:empty { display: none; }
.desk:has(.desk-tools:empty) { grid-template-columns: minmax(0, 1fr); }
.desk .panel { margin-top: 1rem; }
.desk-tools .panel:first-child { margin-top: 1rem; }

h1 {
  margin: 0 0 0.2rem;
  font-family: Palatino, "Iowan Old Style", Georgia, serif;
  font-weight: 500;
  font-size: 2rem;
  letter-spacing: 0.01em;
}

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

.panel {
  margin-top: 1.5rem;
  padding: 1.1rem 1.1rem 1.25rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

form { display: grid; gap: 0.75rem; }

label { display: grid; gap: 0.3rem; font-size: 0.92rem; }

input, select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #12171b;
  color: var(--text);
  font: inherit;
}

input[type="color"] { padding: 0.2rem; height: 2.4rem; }
.row > input[type="color"] { flex: 0 0 auto; width: 3rem; }
.swatch { width: 1rem; height: 1rem; border-radius: 50%; display: inline-block; border: 1px solid var(--line); }
input[type="range"] { padding: 0; background: transparent; }

button, .linkish {
  font: inherit;
}

button {
  padding: 0.55rem 0.8rem;
  border: 0;
  border-radius: 6px;
  background: var(--brass);
  color: #1a140c;
  cursor: pointer;
}

button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

.row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.row > input, .row > select { width: auto; flex: 1 1 12rem; min-width: 0; }
.row.spread { justify-content: space-between; align-items: flex-start; }

.page-head {
  position: relative;
  z-index: 6;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.15rem;
}
.page-head-copy { min-width: 0; }
.page-head .lede,
.page-head .brand { margin: 0 0 0.15rem; }
.page-head-nav { margin: 0.65rem 0 0; }
.page-head-nav .ghost { font-size: 0.92rem; }
button.brand {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
button.brand:hover { color: var(--text); }
button.brand:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

.account { position: relative; flex: 0 0 auto; }
.account-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--brass);
  background: #2a2418;
  color: var(--brass);
  font: 700 0.95rem/1 "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0;
}
.account-btn[aria-expanded="true"] {
  background: var(--brass);
  color: #1a140c;
}
.account-btn:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}
.account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  min-width: 12.5rem;
  padding: 0.3rem 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  z-index: 40;
}
.account-who {
  padding: 0.45rem 0.85rem 0.55rem;
  border-bottom: 1px solid var(--line);
}
.account-name {
  margin: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-role {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
}
.account-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: 0;
  border-radius: 0;
  padding: 0.55rem 0.85rem;
}
.account-menu button:hover,
.account-menu button:focus-visible {
  background: #243038;
}

.note { min-height: 1.3rem; margin: 0.4rem 0 0; }
#token-note:empty, #add-note:empty, #editor-note:empty { min-height: 0; margin: 0; }
.note.error { color: var(--danger); }
.note.ok { color: var(--ok); }

.badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--brass);
  border-radius: 999px;
  color: var(--brass);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h2 { margin: 0 0 0.8rem; font-size: 1.05rem; font-weight: 600; }

.token-section {
  margin: 0.15rem 0 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.token-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.token-row-line { display: flex; align-items: center; gap: 0.35rem; min-width: 0; }
.token-row-line .swatch { flex: 0 0 auto; width: 0.85rem; height: 0.85rem; }
.token-row-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.token-row-kind {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}
.tools button.token-row-main,
.tools button.token-place,
.palette button.token-row-main,
.palette button.token-place {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.tools button.token-row-main,
.palette button.token-row-main {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  text-align: left;
}
.tools button.token-row-main.on,
.palette button.token-row-main.on { border-color: var(--brass); }
.tools button.token-place,
.palette button.token-place { flex: 0 0 auto; padding: 0.35rem 0.6rem; }
.token-edit { display: grid; gap: 0.4rem; padding: 0.15rem 0 0.1rem; }
.token-edit label.check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
}
.token-row-hidden {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.token-row-main.concealed .token-row-name { font-style: italic; }
.token-add { margin-top: 0.35rem; padding-left: 0.7rem; border-top: 1px solid var(--line); }
.token-add > summary { font-weight: 600; }
.tools .token-add[open] > summary::before,
.palette .token-add[open] > summary::before { transform: translateY(0.06rem) rotate(45deg); }
.token-add form,
.token-add .note { margin-top: 0.45rem; }
#unplaced-block .token-section,
#npc-block .token-section { margin-top: 0.4rem; }
#npc-block .muted { margin: 0.2rem 0 0; }

.choice-list { display: grid; gap: 0.35rem; list-style: none; padding: 0; margin: 0.6rem 0 0; }
.choice-list button {
  display: grid;
  gap: 0.1rem;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.choice-list button.on { border-color: var(--brass); }
.choice-list .muted { font-size: 0.85rem; }

ul.plain { margin: 0.2rem 0 0; padding-left: 1.1rem; }

body.is-map { overflow: hidden; height: 100vh; height: 100dvh; }

.map-app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: 13.25rem minmax(0, 1fr);
  overflow: hidden;
}
.map-app.tree-closed { grid-template-columns: 2.75rem minmax(0, 1fr); }
.map-app .story-tree { position: relative; height: 100%; }
.map-column {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.map-loading { padding: 1.2rem; }

.top {
  position: relative;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.28rem 0.5rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-wrap: wrap;
}
.top button { padding: 0.2rem 0.45rem; font-size: 0.78rem; }
.top .account-btn { width: 1.85rem; height: 1.85rem; font-size: 0.8rem; padding: 0; }
.top .badge { margin-left: 0; font-size: 0.65rem; }
.session-switch { display: flex; align-items: center; gap: 0.35rem; color: var(--muted); font-size: 0.85rem; }
.session-switch select { max-width: 14rem; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 0.2rem 0.35rem; }

.top h1 {
  margin: 0;
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 16rem;
}
.top h1.inline-name.editing { overflow: visible; max-width: min(20rem, 70vw); }
.spacer { flex: 1; }
.error-text { color: var(--danger); }

.map-main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(13.75rem, 16rem);
}
.map-view {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.toolbox {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  padding: 0.22rem 0.45rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.tool-modes { display: flex; gap: 0.25rem; }
.tool-modes button {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.18rem 0.4rem;
  font-size: 0.78rem;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.tool-modes button[aria-pressed="true"] {
  background: var(--brass);
  color: #1a140c;
  border-color: var(--brass);
}
.tool-modes svg { width: 0.95rem; height: 0.95rem; display: block; flex: 0 0 auto; }
.toolbox .brush {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-width: 8rem;
  flex: 1;
  font-size: 0.75rem;
}
.toolbox .brush input[type="range"] { width: auto; flex: 1; min-width: 6rem; }
.toolbox #select-count { min-width: 4.2rem; }
.palette-anchor { position: relative; display: flex; align-items: center; }
.palette-anchor.pin-end { margin-left: auto; }
.palette-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.18rem 0.45rem;
  font-size: 0.78rem;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.palette-btn[aria-expanded="true"] {
  background: var(--brass);
  color: #1a140c;
  border-color: var(--brass);
}
.palette-btn:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.palette-btn .dice-summary { font-size: 0.75rem; }
.palette-btn .dice-summary:empty { display: none; }
.palette-btn .glyph { font-size: 0.9rem; }
/* A palette drops from its toolbar button. Roll is the right-hand one, so its panel aligns to that edge. */
.palette {
  position: absolute;
  top: calc(100% + 0.28rem);
  left: 0;
  z-index: 6;
  width: min(18.5rem, calc(100vw - 2rem));
  max-height: min(70dvh, 34rem);
  overflow: auto;
  padding: 0.55rem 0.65rem 0.7rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  font-size: 0.78rem;
  line-height: 1.3;
}
.palette-anchor.pin-end .palette {
  left: auto;
  right: 0;
  width: min(22rem, calc(100vw - 2rem));
}
.palette form { gap: 0.4rem; }
.palette label { font-size: inherit; gap: 0.15rem; }
.palette p { margin: 0; }
.palette .muted { font-size: 0.7rem; line-height: 1.3; }
.palette .note { min-height: 0; margin: 0.25rem 0 0; font-size: 0.72rem; }
.palette .note:empty { display: none; }
.palette button { padding: 0.22rem 0.45rem; font-size: 0.75rem; }
.palette button.more-btn { width: 1.9rem; height: 1.9rem; padding: 0; font-size: 1.15rem; }
.palette input, .palette select { padding: 0.22rem 0.35rem; font-size: 0.75rem; }
.palette input[type="color"] { height: 1.55rem; padding: 0.1rem; }
.palette input[type="range"] { padding: 0; }
.palette details > summary {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0;
  cursor: pointer;
  list-style: none;
  font-size: 0.75rem;
  color: var(--muted);
}
.palette details > summary::-webkit-details-marker { display: none; }
.palette details > summary::before {
  content: "";
  flex: 0 0 auto;
  width: 0.38rem;
  height: 0.38rem;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-0.05rem) rotate(-45deg);
}
.palette details[open] > summary::before { transform: translateY(0.06rem) rotate(45deg); }
.palette details > summary:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.palette .token-add > summary { color: var(--text); font-weight: 600; }

.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #0c0f12;
  touch-action: none;
  user-select: none;
}
.stage:focus { outline: none; }
.stage:focus-visible { outline: 2px solid var(--brass); outline-offset: -2px; }

.map-layer { position: absolute; top: 0; left: 0; pointer-events: none; }
.map-layer img,
.map-layer canvas,
.map-layer svg,
.map-board {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.map-layer img { display: block; object-fit: fill; }
.map-board,
.navigator-board {
  background:
    linear-gradient(rgba(198, 161, 91, 0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(198, 161, 91, 0.09) 1px, transparent 1px),
    #12171b;
  background-size: 48px 48px, 48px 48px, auto;
}
/* Color and opacity are set from the shared grid. Players see the same overlay. */
.bands { color: #c6a15b; opacity: 0.45; }
.bands line, .bands polygon {
  stroke: currentColor;
  stroke-width: 1;
  fill: none;
}
/* Range rings are the board's Close, Medium, Long, and Extreme sizes, drawn around the selected token. */
.range-rings { pointer-events: none; }
.range-rings circle { fill: none; stroke-width: 2; stroke-dasharray: 6 4; }
.range-rings circle.band-close { stroke: #e7d7b1; }
.range-rings circle.band-medium { stroke: #c6a15b; }
.range-rings circle.band-long { stroke: #6faf9a; }
.range-rings circle.band-extreme { stroke: #8aa4b8; }
.range-rings text {
  font-size: 12px;
  font-family: inherit;
  stroke: #0c0f12;
  stroke-width: 3px;
  paint-order: stroke fill;
}
.range-rings text.band-close { fill: #e7d7b1; }
.range-rings text.band-medium { fill: #c6a15b; }
.range-rings text.band-long { fill: #6faf9a; }
.range-rings text.band-extreme { fill: #8aa4b8; }
.tools .band-each,
.palette .band-each {
  border-top: 1px solid var(--line);
  margin-top: 0.15rem;
  padding-top: 0.1rem;
}
.tools .band-each > summary,
.palette .band-each > summary {
  padding: 0.2rem 0.1rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.tools .band-each[open] > summary::before,
.palette .band-each[open] > summary::before { transform: translateY(0.06rem) rotate(45deg); }
.tools .band-each[open] > summary,
.palette .band-each[open] > summary { margin-bottom: 0.15rem; }
/* The GM sees through the fog. Players keep a solid cover. --gm-fog is this screen only. */
.stage.gm,
.tools.gm { --gm-fog: 0.45; }
.stage.gm #fog,
.tools.gm #navigator-fog { opacity: var(--gm-fog); }

.token {
  position: absolute;
  transform: translate(-50%, -50%);
  display: grid;
  justify-items: center;
  gap: 0.12rem;
  width: max-content;
  max-width: 8rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  pointer-events: none;
}
.stage.gm:not(.reveal) .token { pointer-events: auto; cursor: grab; }
.token-dot {
  position: relative;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  border: 2px solid #f4efe4;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
}
.token.ko .token-dot::after {
  content: "×";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f7f3ea;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 0 2px #0c0f12, 0 1px 0 #0c0f12, 0 -1px 0 #0c0f12;
  pointer-events: none;
}
.token-name {
  max-width: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  background: rgba(12, 16, 20, 0.86);
  font-size: 0.75rem;
  line-height: 1.2;
}
.token.selected .token-dot { outline: 2px solid var(--brass); outline-offset: 2px; }
.token.turn-now .token-dot { box-shadow: 0 0 0 2px #1a140c, 0 0 0 5px var(--brass), 0 1px 4px rgba(0, 0, 0, 0.55); }
.token-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 12rem;
}
/* Current turn reads as one brass plate, the same in every view. NOW sits under the name, clear of the ring. */
.token.turn-now .token-label,
.token.your-turn .token-label {
  margin-top: 0.2rem;
  padding: 0.06rem 0.45rem 0.1rem;
  background: var(--brass);
  color: #1a140c;
  border-radius: 0.55rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}
.token.turn-now .token-name,
.token.your-turn .token-name {
  font-weight: 800;
  background: transparent;
  color: inherit;
  padding: 0;
}
.token-now {
  flex: 0 0 auto;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.1;
  text-transform: uppercase;
  color: inherit;
  background: transparent;
  padding: 0;
}
.turn-banner {
  position: absolute;
  z-index: 4;
  top: 0.55rem;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 1.5rem);
  padding: 0.4rem 0.85rem;
  background: var(--brass);
  color: #1a140c;
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1.2;
  text-align: center;
  border-radius: 999px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
.palette-anchor.wide .palette { width: min(26rem, calc(100vw - 1.5rem)); }
.turn-list { list-style: none; margin: 0.35rem 0 0; padding: 0; display: grid; gap: 0.28rem; }
.turn-row { display: grid; gap: 0.2rem; }
.turn-row.now { background: rgba(198, 161, 91, 0.14); border-radius: 6px; }
.turn-row.you .turn-name { font-weight: 800; }
.turn-row.dragging { opacity: 0.65; }
.turn-row-line { display: flex; align-items: center; gap: 0.28rem; min-width: 0; width: 100%; }
.turn-actions { margin-left: auto; display: inline-flex; align-items: center; gap: 0.28rem; flex: 0 0 auto; }
.turn-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  text-align: left;
  background: transparent;
  color: inherit;
  border: 0;
  padding: 0.12rem 0.2rem;
}
.turn-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.turn-row-line > .turn-name { flex: 0 1 auto; }
.turn-now {
  flex: 0 0 auto;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #1a140c;
  background: var(--brass);
  border-radius: 999px;
  padding: 0 0.3rem;
}
.turn-swatch {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  border: 1px solid #f4efe4;
  flex: 0 0 auto;
}
.turn-grip, .turn-remove { flex: 0 0 auto; }
.turn-grip { cursor: grab; touch-action: none; padding: 0.12rem 0.28rem; letter-spacing: -0.12em; }
.turn-roll {
  margin: 0.15rem 0 0.2rem;
  padding: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}
.turn-held { display: flex; align-items: center; gap: 0.4rem; padding: 0 0.2rem 0.15rem 1.4rem; font-size: 0.75rem; }
.encounter-board { display: grid; gap: 0.45rem; }
.encounter-board[hidden] { display: none; }
.encounter-picker { display: flex; align-items: center; gap: 0.35rem; min-width: 0; }
.encounter-title {
  display: flex;
  align-items: center;
  gap: 0.05rem;
  flex: 1 1 auto;
  min-width: 0;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.08rem;
}
.encounter-title .inline-name,
.encounter-title .encounter-empty {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  font-size: 1rem;
  box-shadow: none;
  border-radius: 0;
}
.encounter-title .encounter-empty { color: var(--muted); font-weight: 600; }
.encounter-title .inline-name:hover,
.encounter-title .inline-name:focus-visible { box-shadow: none; }
.encounter-title .inline-name.editing { overflow: visible; text-overflow: clip; }
.encounter-title:has(.editing) { border-bottom-color: transparent; }
.palette button.more-btn.encounter-caret,
button.more-btn.encounter-caret {
  width: auto;
  height: auto;
  min-width: 0;
  padding: 0 0.2rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
}
.more-menu button[aria-current="true"] { color: var(--brass); }
.encounter-plus { flex: 0 0 auto; min-width: 2rem; font-weight: 700; }
.encounter-flyout {
  display: grid;
  gap: 0.4rem;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}
.encounter-choices { display: grid; gap: 0.28rem; max-height: 11rem; overflow: auto; }
.encounter-choice { display: flex; align-items: center; gap: 0.35rem; }
.encounter-meta { flex: 0 0 auto; font-size: 0.75rem; }
.encounter-actions { width: 100%; }
.encounter-rounds {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
}
.encounter-round {
  min-width: 4.4rem;
  text-align: center;
  font-weight: 700;
}
.encounter-live { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.encounter-live .turn-name { flex: 1 1 auto; font-weight: 700; }
.encounter-board .row button,
.encounter-live button,
.encounter-flyout button,
.encounter-detail .turn-row button { padding: 0.28rem 0.5rem; font-size: 0.85rem; }
.turn-row.ko .turn-name { text-decoration: line-through; opacity: 0.75; }
/* Concealed is the GM's drawing of a marker players do not receive. */
.token.concealed { opacity: 0.72; }
.token.concealed .token-dot { border-style: dashed; }
.tools input[type="checkbox"],
.palette input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  padding: 0;
  flex: 0 0 auto;
}
.stage.selecting { cursor: crosshair; }

.choice button[aria-pressed="false"] {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.brush-preview {
  flex: 0 0 auto;
  width: 1.55rem;
  height: 1.55rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #0c1014;
}
#brush-dot {
  display: block;
  width: 33%;
  height: 33%;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px #fff, inset 0 0 0 3px rgba(0, 0, 0, 0.85);
}
.stage.reveal.brushing { cursor: none; }
.toolbox input[type="range"] { cursor: ew-resize; padding: 0; }
/* Sized in pixels by paintLasso. Shown by removing the hidden attribute; the SVG hidden property does not do that. */
.lasso {
  position: absolute;
  inset: 0;
  z-index: 6;
  overflow: visible;
  pointer-events: none;
}
/* Beats [hidden] { display: none !important } if the attribute is still present. */
.stage .lasso.on { display: block !important; }
#lasso-halo {
  fill: none;
  stroke: #0c0f12;
  stroke-width: 6;
  stroke-linejoin: round;
  stroke-linecap: round;
}
#lasso-edge {
  fill: rgba(198, 161, 91, 0.22);
  stroke: #f4efe4;
  stroke-width: 2.5;
  stroke-dasharray: 7 5;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.brush-cursor {
  position: absolute;
  z-index: 4;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px #fff, inset 0 0 0 3px rgba(0, 0, 0, 0.85);
  pointer-events: none;
}
.zoom-tools { gap: 0.25rem; }
.zoom-tools button { padding: 0.16rem 0.4rem; font-size: 0.78rem; }
.zoom-label { min-width: 2rem; text-align: center; color: var(--muted); font-size: 0.75rem; }

.fog-hint {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(22rem, calc(100% - 2rem));
  margin: 0;
  padding: 0.8rem 0.9rem;
  background: rgba(20, 24, 28, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
  pointer-events: none;
}
.scale {
  position: absolute;
  z-index: 2;
  left: 0.75rem;
  bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text);
  font-size: 0.85rem;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}
#scale-bar {
  display: block;
  height: 6px;
  background: var(--brass);
  border-radius: 99px;
}

.tools {
  overflow: hidden;
  padding: 0.35rem 0.45rem 0.3rem;
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  font-size: 0.78rem;
  line-height: 1.3;
}
.tools-scroll {
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 0.35rem;
}
.tools h2 { margin: 0; font-size: 0.8rem; font-weight: 600; }
.tools .note { min-height: 0; margin: 0; font-size: 0.72rem; }
.tools .note:empty { display: none; }
.tools .map-live { margin-bottom: 0.2rem; }
.navigator {
  display: grid;
  gap: 0.2rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--line);
}
.navigator .nav-hint { font-size: 0.68rem; line-height: 1.25; }
.navigator-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 1;
  margin-inline: auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0c0f12;
  touch-action: none;
  user-select: none;
}
.navigator-frame.live { cursor: grab; }
.navigator-frame.live.dragging { cursor: grabbing; }
.navigator-frame img,
.navigator-board,
.navigator-frame canvas,
.navigator-view {
  position: absolute;
  display: block;
  pointer-events: none;
}
.navigator-frame img,
.navigator-board,
.navigator-frame canvas {
  inset: 0;
  width: 100%;
  height: 100%;
}
.navigator-frame img { object-fit: fill; }
.navigator-board { background-size: 14px 14px, 14px 14px, auto; }
.navigator-view {
  box-shadow: inset 0 0 0 2px var(--brass), 0 0 0 1px rgba(0, 0, 0, 0.7);
  background: rgba(198, 161, 91, 0.16);
}
.tools form { gap: 0.32rem; }
.tools label { font-size: inherit; gap: 0.12rem; }
.tools button { padding: 0.22rem 0.45rem; font-size: 0.75rem; }
.tools input, .tools select { padding: 0.22rem 0.35rem; font-size: 0.75rem; }
.tools input[type="color"] { height: 1.55rem; padding: 0.1rem; }
.tools input[type="range"] { padding: 0; }
.tools p { margin: 0; }
.tools .fold {
  border-bottom: 1px solid var(--line);
  padding: 0.1rem 0 0.2rem;
}
.tools .fold:last-child { border-bottom: 0; }
.tools summary {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.28rem 0.1rem;
  cursor: pointer;
  list-style: none;
}
.tools summary::-webkit-details-marker { display: none; }
.tools summary::before {
  content: "";
  flex: 0 0 auto;
  width: 0.38rem;
  height: 0.38rem;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-0.05rem) rotate(-45deg);
}
.tools .fold[open] > summary::before {
  transform: translateY(0.06rem) rotate(45deg);
}
.tools summary:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}
.tools .fold-body, .editor { display: grid; gap: 0.32rem; }
.tools .fold-body { padding: 0.05rem 0 0.28rem; }
.tools .muted { font-size: 0.7rem; line-height: 1.3; }

@font-face {
  font-family: "EotE Symbol";
  src: url("/eote-symbol.otf") format("opentype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}
.dice-dock {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 0.2rem 0.45rem 0.4rem;
}
.desk-tools .dice-dock { margin-top: 0.65rem; }
.dice-history {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--line);
}
.dice-history h2 { margin: 0; font-size: 0.8rem; font-weight: 600; flex: 0 0 auto; }
.dice-history .dice-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.dice-dock summary {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.16rem 0.05rem;
  cursor: pointer;
  list-style: none;
  flex: 0 0 auto;
}
.dice-dock summary::-webkit-details-marker { display: none; }
.dice-dock summary::before {
  content: "";
  flex: 0 0 auto;
  width: 0.38rem;
  height: 0.38rem;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-0.05rem) rotate(-45deg);
}
.dice-dock[open] > summary::before { transform: translateY(0.06rem) rotate(45deg); }
.dice-dock summary h2 { margin: 0; font-size: 0.8rem; font-weight: 600; }
.dice-dock summary:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.dice-summary { min-width: 0; display: inline-flex; gap: 0.12rem; align-items: center; font-size: 0.75rem; }
.dice-summary .glyph { font-size: 0.9rem; }
.dice-body { display: flex; flex-direction: column; gap: 0.28rem; padding-top: 0.12rem; min-height: 0; }
.dice-body p { margin: 0; }
.dice-builder { display: grid; gap: 0.2rem; flex: 0 0 auto; }
.dice-fields { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); gap: 0.25rem; }
.dice-field { display: block; min-width: 0; }
.dice-field input { padding: 0.18rem 0.32rem; font-size: 0.72rem; }
.dice-actions { display: flex; align-items: center; gap: 0.28rem; }
.dice-actions button { padding: 0.16rem 0.48rem; font-size: 0.75rem; }
.dice-gm { margin-left: auto; font-size: 0.7rem; gap: 0.22rem; white-space: nowrap; }
.dice-skin .note { min-height: 0; margin: 0; font-size: 0.7rem; }
.dice-skin .note:empty { display: none; }
.dice-saved { font-size: 0.72rem; }
.dice-saved summary {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  color: var(--muted);
  list-style: none;
}
.dice-saved summary::before {
  content: "";
  flex: 0 0 auto;
  width: 0.32rem;
  height: 0.32rem;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-0.04rem) rotate(-45deg);
}
.dice-saved[open] > summary::before { transform: translateY(0.04rem) rotate(45deg); }
.dice-saved summary::-webkit-details-marker { display: none; }
.dice-saved summary:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.dice-saved[open] summary { margin-bottom: 0.2rem; }
.dice-saved .row { gap: 0.25rem; }
.dice-saved .row > input { flex: 1 1 auto; min-width: 0; width: auto; padding: 0.16rem 0.32rem; font-size: 0.72rem; }
.dice-saved .row > button { padding: 0.14rem 0.4rem; font-size: 0.7rem; }
.dice-dice, .dice-symbols, .dice-pool, .dice-faces, .dice-net, .preset-line, .roll-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.12rem;
  align-items: center;
}
.dice-skin button.die-btn,
.dice-skin button.die-chip,
.dice-skin button.symbol-btn,
.dice-skin button.symbol-chip {
  width: auto;
  height: auto;
  min-width: 1.35rem;
  min-height: 1.35rem;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  font-size: 1.15rem;
  font-weight: normal;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.dice-skin button.die-btn:hover,
.dice-skin button.die-chip:hover,
.dice-skin button.symbol-btn:hover,
.dice-skin button.symbol-chip:hover { opacity: 0.75; }
.dice-skin button.die-btn:focus-visible,
.dice-skin button.die-chip:focus-visible,
.dice-skin button.symbol-btn:focus-visible,
.dice-skin button.symbol-chip:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}
.dice-faces { gap: 0.12rem; }
.dice-skin .die-face {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  flex: 0 0 auto;
  background: none;
  padding: 0;
}
.face-extra {
  display: inline-flex;
  align-items: center;
  gap: 0.04rem;
  color: inherit;
}
.face-extra .symbol-run { display: inline-flex; gap: 0.02rem; }
.face-extra .glyph { font-size: 0.9rem; }
.dice-skin .die-body {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.dice-skin .die-pips {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 74%;
  line-height: 1;
  transform: translateY(-0.16em);
}
.net-readout { display: inline-flex; flex-wrap: wrap; gap: 0.55rem; align-items: center; }
.net-bit { display: inline-flex; align-items: center; gap: 0.12rem; }
.net-bit .glyph { font-size: 0.85rem; }
.dice-skin .die-pips .symbol-run { display: inline-flex; }
.dice-skin .die-y { color: #e2c15a; }
.dice-skin .die-g { color: #6fbf78; }
.dice-skin .die-b { color: #6aaed4; }
.dice-skin .die-p { color: #c08adf; }
.dice-skin .die-r { color: #e07068; }
.dice-skin .die-k { color: #d7dee6; }
.dice-skin .die-w { color: #f4efe4; }
.dice-skin .die-face.die-y .die-body { color: #e2c15a; }
.dice-skin .die-face.die-g .die-body { color: #3f8f4e; }
.dice-skin .die-face.die-b .die-body { color: #3d7eae; }
.dice-skin .die-face.die-p .die-body { color: #7a4ea3; }
.dice-skin .die-face.die-r .die-body { color: #b34742; }
.dice-skin .die-face.die-k .die-body { color: #2a3138; }
.dice-skin .die-face.die-k .die-body rect { stroke: #8b97a3; stroke-width: 1.5; }
.dice-skin .die-face.die-w .die-body { color: #f3efe4; }
.dice-skin .die-face.ink-dark .die-pips { color: #1a140c; }
.dice-skin .die-face.ink-light .die-pips { color: #f7f3ea; }
.glyph, .die-shape {
  font-family: "EotE Symbol", sans-serif;
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  color: inherit;
}
.glyph { font-size: 0.95rem; }
.die-shape { font-size: 1.15rem; }
.die-pips.pip-one .glyph { font-size: 0.68rem; }
.die-pips.pip-many .glyph { font-size: 0.48rem; }
.dice-skin button.symbol-btn,
.dice-skin button.symbol-chip {
  color: inherit;
  background: transparent;
}
.dice-skin button.symbol-btn .glyph,
.dice-skin button.symbol-chip .glyph { font-size: 1.05rem; }
.dice-log {
  position: relative;
  z-index: 0;
  display: grid;
  gap: 0.12rem;
  align-content: start;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}
.desk-tools .dice-log { max-height: 14rem; }
.die-roll {
  display: grid;
  gap: 0.08rem;
  padding-top: 0.18rem;
  border-top: 1px solid var(--line);
}
.roll-head { justify-content: flex-start; gap: 0.28rem; }
.roll-who { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roll-when { margin-left: auto; font-size: 0.68rem; flex: 0 0 auto; }
.roll-label { font-size: 0.72rem; }
.roll-d100 { font-size: 0.85rem; }
.die-roll .row button { padding: 0.08rem 0.35rem; font-size: 0.68rem; }
.dice-hidden {
  border: 1px solid var(--brass);
  color: var(--brass);
  border-radius: 999px;
  padding: 0 0.35rem;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.preset-line { justify-content: space-between; gap: 0.2rem; }
.preset-line > div:first-child { min-width: 0; }
.preset-name { font-weight: 600; font-size: 0.72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preset-line .muted { font-size: 0.66rem; }
.preset-line button { padding: 0.08rem 0.32rem; font-size: 0.68rem; }
.dice-skin .check { display: flex; align-items: center; gap: 0.25rem; }

@media (max-width: 800px) {
  .desk { grid-template-columns: minmax(0, 1fr); }
  .navigator-frame { width: min(100%, 16rem); }
  .map-main {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(12rem, 1fr) minmax(8rem, 38dvh);
  }
  .tools { border-left: 0; border-top: 1px solid var(--line); }
  .top h1 { max-width: 9rem; font-size: 1.05rem; }
  .top h1.inline-name.editing { max-width: 70vw; }
}

[hidden] { display: none !important; }
