:root {
  --bg: #100d0a;
  --panel: rgba(22, 16, 12, 0.88);
  --line: rgba(226, 193, 122, 0.22);
  --gold: #e2c17a;
  --gold-deep: #a8843f;
  --parchment: #f4e7cf;
  --parchment-deep: #ead7b4;
  --ink: #2c241c;
  --ink-soft: #5c4e3e;
  --text: #f3eadb;
  --muted: #b5a48e;
  --ember: #d4654a;
  --moss: #7ea184;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: Manrope, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
* { scrollbar-width: thin; scrollbar-color: #6a5438 transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  /* Cormorant рисует «старые» цифры: 1 и 0 похожи на буквы (d1oo). Нужны лайнинговые. */
  font-feature-settings: "lnum" 1;
  background:
    radial-gradient(ellipse at top, rgba(90, 58, 28, 0.35), transparent 46%),
    radial-gradient(ellipse at bottom, rgba(0, 0, 0, 0.45), transparent 40%),
    var(--bg);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.65; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
::selection { background: var(--gold); color: var(--ink); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; }

button, .join-card button {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  background: var(--gold);
  color: var(--ink);
}
button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.sheet button.ghost { color: var(--ink); border-color: rgba(44, 36, 28, 0.28); }

.join {
  position: fixed;
  inset: 0;
  z-index: 5;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 16px 10px 32px;
}
.join-card {
  width: min(560px, 100%);
  max-width: 100%;
  min-width: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 252, 245, 0.4), transparent 30%),
    linear-gradient(180deg, var(--parchment), var(--parchment-deep));
  border-radius: 18px;
  padding: 22px 16px 18px;
  box-shadow: var(--shadow);
}
.join-brand { display: flex; align-items: center; gap: 14px; }
.join-brand > div { min-width: 0; }
.join-brand h1 { margin: 0; }
.mark { width: 54px; height: 54px; color: var(--gold-deep); display: block; }
.mark text { font-family: var(--serif); font-size: 16px; fill: currentColor; }
.join-card .portrait-button {
  position: relative;
  width: 84px;
  height: 84px;
  flex: 0 0 84px;
  display: grid;
  place-items: center;
  padding: 0;
  overflow: hidden;
  border-radius: 50%;
  border: 2px solid rgba(168, 132, 63, 0.75);
  background: rgba(255, 255, 255, 0.55);
  color: var(--gold-deep);
}
.portrait-button .mark { width: 46px; height: 46px; }
.portrait-button img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.portrait-button.has-icon .mark { visibility: hidden; }
.lobby-face {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.55);
}
.eyebrow {
  margin: 8px 0 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--gold-deep);
}
.join-card h1 {
  margin: 0;
  font-size: clamp(40px, 14vw, 78px);
  font-style: italic;
  line-height: 0.92;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.lead, .points { color: var(--ink-soft); }
.points { padding-left: 18px; }
.lobby-seats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0;
  margin: 0 0 16px;
  list-style: none;
}
.lobby-seats li {
  min-height: 64px;
  border: 1px dashed rgba(44, 36, 28, 0.35);
  border-radius: 12px;
  padding: 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.lobby-seats li.is-on { border-style: solid; background: rgba(255, 255, 255, 0.28); }
.lobby-seats li.is-away { border-style: solid; opacity: 0.7; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.join-card input, .join-card select, .sheet input, .sheet select, .sheet textarea {
  width: 100%;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid rgba(44, 36, 28, 0.2);
  border-radius: 10px;
  padding: 10px 12px;
}
.join-card button[type="submit"] { width: 100%; padding: 12px 16px; font-weight: 700; }
.card-import { margin-bottom: 14px; }
.join-card .card-file {
  width: 100%;
  padding: 11px 16px;
  border-radius: 12px;
  background: transparent;
  border: 1px dashed rgba(44, 36, 28, 0.45);
  font-weight: 700;
}
.join-card .card-file:disabled { cursor: wait; }
.join-card .card-file.is-busy { opacity: 0.65; }
.status { min-height: 1.2em; }
.status.is-error { color: #8d2f24; }
.hint { color: var(--ink-soft); font-size: 13px; }
.invite-block { margin-top: 8px; font-size: 14px; min-width: 0; }
.invite-block ul, .invite ul { padding-left: 18px; margin: 0; }
.invite-block a, .invite a { color: inherit; overflow-wrap: anywhere; }

.app {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { margin: 0; font-size: 26px; font-weight: 600; white-space: nowrap; }
.topbar .turnbar {
  flex: 1 1 320px;
  flex-direction: row;
  justify-content: center;
  gap: 14px;
  padding: 0;
  border: 0;
  background: none;
}
.topbar .turn-order { width: auto; padding: 0; }
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #6a5a48;
}
.dot.is-on { background: var(--moss); box-shadow: 0 0 8px var(--moss); }
.pill {
  margin: 0;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
}
.pill.is-mine {
  color: var(--ink);
  background: var(--gold);
  border-color: var(--gold);
  font-weight: 700;
  box-shadow: 0 0 16px rgba(226, 193, 122, 0.38);
}
.app.is-clean .is-system { display: none !important; }
.app.is-clean .table-rest { margin-top: 10px; border-top: 0; padding-top: 0; }
.gold { display: flex; align-items: center; gap: 6px; }
.gold strong { min-width: 4.5rem; text-align: center; font-variant-numeric: tabular-nums; }
.gold button { padding: 6px 10px; }

.turnbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 16px 6px;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(ellipse at center top, rgba(226, 193, 122, 0.14), transparent 62%),
    rgba(16, 13, 10, 0.35);
}
.turn-round {
  margin: 0;
  color: var(--gold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 12px;
  line-height: 1.1;
}
.turn-order {
  display: flex;
  justify-content: center;
  align-items: end;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 4px 4px 0;
  list-style: none;
  overflow: auto;
}
.turn-order li, .turn-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 56px;
  color: var(--muted);
}
.turn-face {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #1a120c;
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.28);
}
.turn-face.has-icon { color: transparent; }
.turn-face img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
.turn-ring {
  --lost: 0deg;
  --hp-color: #7ea184;
  display: grid;
  padding: 2px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #4a1410 0deg var(--lost), var(--hp-color) var(--lost) 360deg);
}
.turn-ring.is-mid { --hp-color: #d4b15a; }
.turn-ring.is-low { --hp-color: #d4654a; }
.turn-ring.is-down { background: #4a1410; }
.turn-name {
  max-width: 104px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
.turn-order li.is-active { color: var(--text); }
.turn-order li.is-enemy .turn-name { color: #e7b2a4; }
.turn-order li.is-active .turn-face {
  width: 48px;
  height: 48px;
  font-size: 23px;
}
.turn-order li.is-active > .turn-face {
  box-shadow: 0 0 0 3px var(--gold), 0 10px 24px rgba(226, 193, 122, 0.28);
}
.turn-order li.is-active .turn-ring {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  box-shadow: 0 10px 24px rgba(226, 193, 122, 0.28);
}
.turn-order li.is-enemy:not(.is-active) .turn-face {
  box-shadow: inset 0 0 0 2px rgba(80, 24, 14, 0.45);
}
.combat-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px 14px;
  margin-bottom: 14px;
}
.skill-combat { flex: 1 1 280px; min-width: 0; }
.skill-combat .hotbar-group h3 { margin-bottom: 6px; }
.turn-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 0 1 210px;
  padding-top: 22px;
}
.turn-actions button { width: 100%; }
.turn-resource {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.turn-resource.is-ready {
  color: var(--ink);
  background: var(--gold);
  border-color: var(--gold);
}
.turn-resource.is-spent {
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
  text-decoration: line-through;
}
.turn-resource:disabled {
  cursor: default;
  opacity: 1;
}
#endTurn { font-weight: 700; }
.turn-hint {
  flex: 1 1 220px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.initiative {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  padding: 4px 16px;
  border-bottom: 1px solid var(--line);
}
.initiative-head, .init-form, #initForm { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.initiative h2 { margin: 0; font-size: 20px; cursor: help; }
.init-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-left: auto; }
.initiative button, .initiative input { padding-top: 4px; padding-bottom: 4px; font-size: 13px; }
.init-tools .gold button { padding: 4px 8px; }
#roundLabel { color: var(--muted); }
#initValue { width: 88px; }
.init-list {
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: auto;
}
.init-list li, .init-empty {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  white-space: nowrap;
}
.init-roll { font-variant-numeric: tabular-nums; color: var(--gold); }
.init-list li.is-active { background: var(--gold); color: var(--ink); }
.init-list li.is-active .init-roll { color: var(--ink); }

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 330px;
  gap: 14px;
  padding: 14px;
}
.col {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  padding: 12px 14px;
}
.col h2 { margin: 0 0 10px; font-size: 28px; }
.party, .chat { display: flex; flex-direction: column; }
.party-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.party-head h2 { margin: 0; }
.party-head .ghost { padding: 4px 10px; font-size: 12px; flex: 0 0 auto; }
.app.is-party-min .layout { grid-template-columns: 92px minmax(0, 1fr) 330px; }
.party.is-min { padding: 8px 6px; }
.party.is-min .party-head { position: relative; justify-content: center; margin-bottom: 8px; }
.party.is-min .party-head h2 {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.party.is-min .party-head .ghost { width: 100%; padding: 2px 0; line-height: 1; text-align: center; }
.party.is-min .seats { align-items: stretch; gap: 8px; }
.party.is-min .seat.is-empty { display: none; }
.party.is-min .seat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 4px 6px;
  border-left-width: 1px;
  border-top-width: 3px;
}
.party.is-min .seat.tone-0 { border-top-color: #e2c17a; }
.party.is-min .seat.tone-1 { border-top-color: #8fbfa0; }
.party.is-min .seat.tone-2 { border-top-color: #e09a78; }
.party.is-min .seat > :not(.seat-title):not(.hp-row) { display: none; }
.party.is-min .seat h3 { display: none; }
.party.is-min .seat-title { justify-content: center; }
.party.is-min .hp-row { flex-direction: column; width: 100%; gap: 3px; }
.party.is-min .hp { width: 100%; flex: none; }
.party.is-min .hp-num { min-width: 0; text-align: center; font-size: 11px; line-height: 1.1; }
.seats { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.table {
  overflow: auto;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 50% 18%, rgba(116, 74, 38, 0.38), rgba(18, 13, 10, 0.92) 58%),
    var(--panel);
}
.map-board { flex: 0 0 auto; }
.skill-tray {
  flex: none;
  max-height: 34vh;
  overflow: auto;
  margin: 0 14px 14px;
  padding: 10px 10px 12px;
  border: 1px solid rgba(226, 193, 122, 0.38);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(226, 193, 122, 0.16), transparent 22px),
    linear-gradient(180deg, #2a2118, #120e0b 46%);
  box-shadow: inset 0 1px 0 rgba(243, 212, 138, 0.35), 0 10px 28px rgba(0, 0, 0, 0.28);
}
.hotbar-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 10px;
}
.hotbar-title { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.hotbar-title .ghost { padding: 4px 10px; font-size: 12px; }
.skill-tray.is-skills-hidden .hotbar-group.is-skills,
.skill-tray.is-skills-hidden .hotbar-notes { display: none; }
.skill-tray.is-min .combat-row,
.skill-tray.is-min .hotbar-body,
.skill-tray.is-min .hotbar-hint { display: none; }
.skill-tray.is-min { padding-bottom: 10px; }
.skill-tray.is-min .hotbar-head { margin-bottom: 0; }
.hotbar-head .dock-toggle {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  min-height: 0;
  padding: 0;
  margin-left: auto;
  border-radius: 50%;
}
.dock-toggle svg { transition: transform 160ms ease; }
.skill-tray.is-min .dock-toggle svg { transform: rotate(180deg); }
.hotbar-who {
  margin: 0;
  font-family: var(--serif);
  font-size: 28px;
  font-style: italic;
  line-height: 1;
}
.hotbar-hint {
  display: flex;
  flex: 1 1 220px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}
button.hotbar-clear { padding: 4px 10px; font-size: 12px; }

.action-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border: 1px solid rgba(226, 193, 122, 0.4);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(48, 38, 28, 0.92), rgba(18, 14, 11, 0.92));
  box-shadow: inset 0 1px 0 rgba(243, 212, 138, 0.25), 0 2px 8px rgba(0, 0, 0, 0.35);
}
.action-bar:empty { display: none; }
.ar-chip,
.ar-slot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 2px 10px 2px 7px;
  border: 1px solid rgba(226, 193, 122, 0.3);
  border-radius: 999px;
  background: rgba(8, 6, 4, 0.6);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 1;
  transition: filter 160ms ease, opacity 160ms ease, border-color 160ms ease;
}
.ar-icon { position: relative; flex: none; width: 14px; height: 14px; }
.ar-icon::before { content: ""; position: absolute; inset: 0; }
.ar-action .ar-icon { filter: drop-shadow(0 0 4px rgba(79, 211, 106, 0.8)); }
.ar-action .ar-icon::before { border-radius: 50%; background: #4fd36a; }
.ar-bonus .ar-icon { filter: drop-shadow(0 0 4px rgba(255, 154, 60, 0.8)); }
.ar-bonus .ar-icon::before { background: #ff9a3c; clip-path: polygon(50% 6%, 100% 92%, 0 92%); }
.ar-move .ar-icon { filter: drop-shadow(0 0 4px rgba(243, 198, 74, 0.8)); }
.ar-move .ar-icon::before { background: #f3c64a; clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); }
.ar-chip.is-ready { border-color: rgba(226, 193, 122, 0.7); }
.ar-chip.is-partial { border-color: rgba(226, 193, 122, 0.7); }
.ar-chip.is-idle { opacity: 0.6; }
.ar-chip.is-spent,
.ar-chip.is-blocked { color: var(--muted); border-color: rgba(226, 193, 122, 0.14); }
.ar-chip.is-spent .ar-icon,
.ar-chip.is-blocked .ar-icon { filter: none; }
.ar-chip.is-spent .ar-icon::before,
.ar-chip.is-blocked .ar-icon::before { background: #6d6a66; }
.ar-chip.is-spent .ar-count { text-decoration: line-through; }
.ar-chip.is-blocked .ar-icon::after {
  content: "";
  position: absolute;
  left: -3px;
  right: -3px;
  top: 50%;
  height: 2px;
  background: #e0503c;
  transform: rotate(-40deg);
}
.ar-chip.is-blocked { border-color: rgba(224, 80, 60, 0.55); }
.ar-slots { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.ar-slot { padding: 2px 9px; gap: 7px; border-color: rgba(96, 170, 220, 0.4); }
.ar-slot b { font-size: 11px; letter-spacing: 0.04em; color: #b9dcf3; }
.ar-slot.is-pact { border-color: rgba(176, 140, 235, 0.5); }
.ar-slot.is-pact b { color: #d5c1f5; }
.ar-pips { display: inline-flex; gap: 3px; }
.ar-pips i { display: block; width: 7px; height: 14px; border-radius: 2px; background: #39b6f0; box-shadow: 0 0 5px rgba(57, 182, 240, 0.7); }
.ar-slot.is-pact .ar-pips i.is-full { background: #a77ef0; box-shadow: 0 0 5px rgba(167, 126, 240, 0.7); }
.ar-pips i.is-empty { background: #34383c; box-shadow: none; }
.ar-slot.is-empty { opacity: 0.6; }
.hotbar-body { display: grid; gap: 14px; }
.hotbar-group h3 {
  margin: 0 0 6px;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}
.hotbar-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fill, 112px);
  gap: 6px;
  justify-content: start;
  padding: 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  box-shadow: inset 0 0 0 1px rgba(226, 193, 122, 0.12);
}
button.hotbar-cell {
  position: relative;
  display: grid;
  grid-template-rows: 14px minmax(26px, 1fr) 2.45em;
  align-items: center;
  justify-items: center;
  width: 112px;
  height: 94px;
  padding: 6px 2px 6px;
  border-radius: 8px;
  border: 1px solid rgba(226, 193, 122, 0.28);
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.08), transparent 58%),
    #1c1612;
  color: var(--text);
  text-align: center;
  line-height: 1.05;
  overflow: hidden;
}
button.hotbar-cell[data-kind="melee"] {
  background:
    radial-gradient(circle at 50% 18%, rgba(224, 154, 120, 0.4), transparent 60%),
    #2a1814;
}
button.hotbar-cell[data-kind="ranged"] {
  background:
    radial-gradient(circle at 50% 18%, rgba(143, 191, 160, 0.38), transparent 60%),
    #142018;
}
button.hotbar-cell[data-kind="power"] {
  background:
    radial-gradient(circle at 50% 18%, rgba(226, 193, 122, 0.28), transparent 62%),
    #221c14;
}
button.hotbar-cell[data-kind="spell"] {
  background:
    radial-gradient(circle at 50% 18%, rgba(142, 170, 230, 0.42), transparent 60%),
    #161824;
}
button.hotbar-cell[data-kind="dash"] {
  background:
    radial-gradient(circle at 50% 18%, rgba(226, 193, 122, 0.34), transparent 60%),
    #241c12;
}
button.hotbar-cell[data-ability="str"] {
  background:
    radial-gradient(circle at 50% 16%, rgba(212, 101, 74, 0.5), transparent 62%),
    #2a1614;
}
button.hotbar-cell[data-ability="dex"] {
  background:
    radial-gradient(circle at 50% 16%, rgba(126, 191, 122, 0.42), transparent 62%),
    #142216;
}
button.hotbar-cell[data-ability="con"] {
  background:
    radial-gradient(circle at 50% 16%, rgba(214, 154, 74, 0.42), transparent 62%),
    #261c10;
}
button.hotbar-cell[data-ability="int"] {
  background:
    radial-gradient(circle at 50% 16%, rgba(120, 156, 214, 0.48), transparent 62%),
    #141824;
}
button.hotbar-cell[data-ability="wis"] {
  background:
    radial-gradient(circle at 50% 16%, rgba(120, 196, 186, 0.4), transparent 62%),
    #12201e;
}
button.hotbar-cell[data-ability="cha"] {
  background:
    radial-gradient(circle at 50% 16%, rgba(214, 140, 176, 0.42), transparent 62%),
    #24141c;
}
button.hotbar-cell[data-cost]::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 6px;
  width: 8px;
  height: 8px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55);
}
button.hotbar-cell[data-cost="action"]::before {
  border-radius: 50%;
  background: #8fbfa0;
}
button.hotbar-cell[data-cost="slot"]::before {
  border-radius: 2px;
  background: #8eaae6;
}
button.hotbar-cell[data-cost="bonus"]::before {
  width: 0;
  height: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  border-style: solid;
  border-width: 0 5px 8px 5px;
  border-color: transparent transparent #e09a4a transparent;
}
.hotbar-mod {
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1;
  color: var(--gold);
}
.hotbar-name {
  width: 100%;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.15;
  overflow-wrap: normal;
  word-break: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hotbar-meta {
  max-width: 100%;
  padding: 0 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}
button.hotbar-cell.is-trained { border-color: rgba(226, 193, 122, 0.9); }
button.hotbar-cell.is-expert {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(226, 193, 122, 0.65), 0 0 12px rgba(226, 193, 122, 0.18);
}
button.hotbar-cell.is-half { border-style: dashed; border-color: rgba(226, 193, 122, 0.7); }
button.hotbar-cell.is-untrained { opacity: 0.78; }
button.hotbar-cell.is-untrained .hotbar-mod { color: var(--parchment); }
button.hotbar-cell.is-on {
  border-color: #f6e2aa;
  color: var(--parchment);
  box-shadow: 0 0 0 1px #f6e2aa, 0 0 18px rgba(226, 193, 122, 0.45);
  background:
    radial-gradient(circle at 50% 20%, rgba(243, 212, 138, 0.4), transparent 62%),
    #3a2e1c;
}
button.hotbar-cell:hover:not(:disabled) { border-color: #f6e2aa; }
button.hotbar-cell:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  filter: grayscale(0.35);
}
.hotbar-caption { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.hotbar-notes { display: grid; gap: 6px; }
.hotbar-note { border-top: 1px solid var(--line); padding-top: 6px; }
.hotbar-note summary { cursor: pointer; color: var(--gold); font-size: 13px; }
.hotbar-note p { margin: 6px 0 0; white-space: pre-wrap; font-size: 13px; }
button.turn-resource:disabled.is-ready {
  color: var(--ink);
  background: var(--gold);
  border-color: var(--gold);
}
button.turn-resource:disabled.is-spent {
  color: var(--muted);
  background: transparent;
}
.map-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 8px;
}
.map-head h2 { margin: 0; }
.map-move, .map-mover { margin: 0; }
.map-move { color: var(--gold); font-variant-numeric: tabular-nums; }
.map-move.has-scale { display: inline-flex; align-items: center; gap: 8px; }
.move-scale {
  position: relative;
  width: 148px;
  height: 10px;
  flex: 0 0 148px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.35);
  box-shadow: inset 0 0 0 1px rgba(226, 193, 122, 0.5);
}
.move-scale-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(90deg, #8d6a32, #f6e2aa);
  transition: width 180ms ease;
}
.move-scale::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent calc(100% / var(--notches, 6) - 1px),
    rgba(16, 13, 10, 0.55) calc(100% / var(--notches, 6) - 1px),
    rgba(16, 13, 10, 0.55) calc(100% / var(--notches, 6))
  );
}
.move-scale-label { white-space: nowrap; }
.map-mover { flex: 1 1 200px; color: var(--muted); font-size: 13px; }
.map-frame {
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(244, 231, 207, 0.08), transparent 42%),
    #1a1410;
}
.map-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 18), minmax(0, 1fr));
  gap: 3px;
  width: min(100%, 920px, max(360px, calc((100vh - 520px) * var(--cols, 4) / var(--rows, 3))));
  margin: 0 auto;
  user-select: none;
  touch-action: none;
}
.map-grid.is-empty { display: block; aspect-ratio: auto; }
.map-grid button.map-cell {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: #6d6458;
  color: inherit;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.map-grid button.map-cell[data-terrain="meadow"] { background: #8fbf4a; }
.map-grid button.map-cell[data-terrain="road"] { background: #e0b15a; }
.map-grid button.map-cell[data-terrain="forest"] { background: #1f8a45; }
.map-grid button.map-cell[data-terrain="thicket"] { background: #0d5a38; }
.map-grid button.map-cell[data-terrain="hill"] { background: #d2a24a; }
.map-grid button.map-cell[data-terrain="rock"] { background: #c3bbb2; }
.map-grid button.map-cell[data-terrain="swamp"] { background: #6f8f32; }
.map-grid button.map-cell[data-terrain="water"] { background: #3aa0d8; }
.map-grid button.map-cell[data-terrain="ice"] { background: #e7f4fb; }
.map-grid button.map-cell[data-terrain="ruins"] { background: #c56a3a; }
.map-grid button.map-cell[data-terrain="sand"] { background: #e6c98a; }
.map-grid button.map-cell[data-terrain="wall"] { background: #2a241e; }
.map-grid button.map-cell[data-terrain="greens"] { background: #7eaa4a; }
.map-grid button.map-cell[data-terrain="heights"] { background: #6f9a38; }
.map-grid button.map-cell[data-terrain="pier"] { background: #9a958c; }
.map-grid button.map-cell[data-terrain="deep"] { background: #1a6d82; }
.map-grid button.map-cell[data-terrain="cargo"] { background: #c4894a; }
.map-grid button.map-cell[data-terrain="scatter"] { background: #8d6e45; }
.map-grid button.map-cell[data-terrain="boat"] { background: #a86b38; }
.map-grid button.map-cell[data-terrain="boulder"] { background: #7e7872; }
.map-grid.has-art {
  gap: 0;
  width: min(100%, 980px, max(360px, calc((100vh - 520px) * var(--cols, 4) / var(--rows, 3))));
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
}
.app.is-clean .map-grid,
.app.is-clean .map-grid.has-art {
  width: min(100%, 980px, max(360px, calc((100vh - 470px) * var(--cols, 4) / var(--rows, 3))));
}
.app.is-dock-min .map-grid,
.app.is-dock-min .map-grid.has-art {
  width: min(100%, 980px, max(360px, calc((100vh - 350px) * var(--cols, 4) / var(--rows, 3))));
}
.app.is-clean.is-dock-min .map-grid,
.app.is-clean.is-dock-min .map-grid.has-art {
  width: min(100%, 980px, max(360px, calc((100vh - 300px) * var(--cols, 4) / var(--rows, 3))));
}
.map-grid.has-art button.map-cell,
.map-grid.has-art button.map-cell[data-terrain] {
  border-radius: 0;
  background: transparent;
  box-shadow: inset 0 0 0 1px rgba(12, 10, 8, 0.24);
}
.map-grid.has-art button.map-cell[data-terrain="wall"] { background: rgba(10, 8, 6, 0.34); }
.map-grid.has-art button.map-cell[data-terrain="deep"] { background: rgba(10, 58, 82, 0.22); }
.map-grid.has-art .map-cell.is-difficult::after {
  background: repeating-linear-gradient(-45deg, transparent, transparent 4px, rgba(20, 14, 8, 0.16) 4px, rgba(20, 14, 8, 0.16) 5px);
}
.map-cell.is-difficult::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 3px;
  border-radius: 2px;
  background: repeating-linear-gradient(-45deg, transparent, transparent 3px, rgba(0, 0, 0, 0.14) 3px, rgba(0, 0, 0, 0.14) 4px);
  pointer-events: none;
}
.map-cell.is-reachable { cursor: pointer; }
.reach-ink {
  position: absolute;
  z-index: 0;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: rgba(var(--reach-rgb, 243, 196, 74), var(--reach-alpha, 0.35));
  box-shadow: inset 0 0 0 2px rgba(var(--reach-edge, 255, 244, 190), 0.7);
  animation: reach-draw 280ms cubic-bezier(.2, .7, .2, 1) both;
  animation-delay: var(--reach-delay, 0ms);
}
.map-cell.is-difficult .reach-ink { --reach-rgb: 245, 130, 32; --reach-edge: 255, 205, 150; }
.map-cell.is-hazard .reach-ink { --reach-rgb: 226, 48, 40; --reach-edge: 255, 170, 160; }
.map-grid button.map-cell[data-terrain="fire"] { background: #c8431e; }
@keyframes reach-draw {
  from { clip-path: inset(var(--from-t) var(--from-r) var(--from-b) var(--from-l)); }
  to { clip-path: inset(0 0 0 0); }
}
.map-cell.is-target {
  outline: 2px solid #d4654a;
  outline-offset: -2px;
  z-index: 2;
  cursor: crosshair;
}
.map-cell.is-look { outline: 2px solid var(--parchment); outline-offset: -2px; z-index: 1; }
.map-cell.is-mover { outline: 2px solid #fff; outline-offset: -2px; z-index: 2; }
.map-cell.is-movable { cursor: grab; }
.map-cell.is-origin { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.8); }
.map-cell.is-drop {
  outline: 3px solid #fff8df;
  outline-offset: -3px;
  z-index: 3;
  box-shadow: inset 0 0 0 999px rgba(255, 248, 223, 0.28);
}
.map-token {
  position: absolute;
  z-index: 1;
  inset: 14%;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #1a120c;
  font-family: var(--serif);
  font-size: clamp(11px, 1.5vw, 18px);
  line-height: 1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
.map-token.is-held { visibility: hidden; }
.map-token.has-icon { overflow: hidden; color: transparent; }
.map-token img,
.map-piece img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  pointer-events: none;
}
.map-token.is-creature img,
.map-piece.is-creature img { object-position: center 16%; }
.map-token.is-carried {
  z-index: 4;
  animation: piece-carry 340ms cubic-bezier(.18, .8, .22, 1);
}
.map-piece {
  position: fixed;
  z-index: 40;
  display: grid;
  place-items: center;
  border-radius: 50%;
  overflow: hidden;
  color: #1a120c;
  font-family: var(--serif);
  font-size: clamp(14px, 2vw, 22px);
  line-height: 1;
  pointer-events: none;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.35);
  transform: translate(-50%, -50%);
  transition: transform 80ms linear, box-shadow 120ms ease;
}
.map-piece.is-lifted { box-shadow: 0 18px 16px rgba(0, 0, 0, 0.42); }
.map-piece.is-settling {
  transition:
    left 240ms cubic-bezier(.2, .75, .2, 1),
    top 240ms cubic-bezier(.2, .75, .2, 1),
    transform 240ms cubic-bezier(.2, .75, .2, 1),
    box-shadow 240ms ease;
}
html.is-dragging-piece,
html.is-dragging-piece * { cursor: grabbing !important; }
.seat-title { display: flex; align-items: center; gap: 8px; }
.seat-face {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 50%;
  object-fit: cover;
  background: #1a120c;
}
.seat-face.is-letter {
  display: grid;
  place-items: center;
  color: #1a120c;
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1;
}
.seat.tone-0 .seat-face.is-letter { background: #e2c17a; }
.seat.tone-1 .seat-face.is-letter { background: #8fbfa0; }
.seat.tone-2 .seat-face.is-letter { background: #e09a78; }
@keyframes piece-carry {
  0% {
    transform: translate(var(--from-x), var(--from-y)) scale(1);
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
  }
  42% {
    transform: translate(calc(var(--from-x) * 0.42), calc(var(--from-y) * 0.42 - 16px)) scale(1.18) rotate(-8deg);
    filter: drop-shadow(0 14px 6px rgba(0, 0, 0, 0.35));
  }
  100% {
    transform: translate(0, 0) scale(1) rotate(0deg);
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
  }
}
@media (prefers-reduced-motion: reduce) {
  .map-token.is-carried,
  .reach-ink { animation: none; }
  .reach-ink { clip-path: none; }
  .map-piece,
  .map-piece.is-settling,
  .move-scale-fill { transition: none; }
}
.map-hover, .map-stance p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.map-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 8px; }
.map-key { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.map-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.map-swatch[data-terrain="meadow"] { background: #8fbf4a; }
.map-swatch[data-terrain="road"] { background: #e0b15a; }
.map-swatch[data-terrain="forest"] { background: #1f8a45; }
.map-swatch[data-terrain="thicket"] { background: #0d5a38; }
.map-swatch[data-terrain="hill"] { background: #d2a24a; }
.map-swatch[data-terrain="rock"] { background: #c3bbb2; }
.map-swatch[data-terrain="swamp"] { background: #6f8f32; }
.map-swatch[data-terrain="water"] { background: #3aa0d8; }
.map-swatch[data-terrain="ice"] { background: #e7f4fb; }
.map-swatch[data-terrain="ruins"] { background: #c56a3a; }
.map-swatch[data-terrain="sand"] { background: #e6c98a; }
.map-swatch[data-terrain="wall"] { background: #2a241e; }
.map-swatch[data-terrain="greens"] { background: #7eaa4a; }
.map-swatch[data-terrain="heights"] { background: #6f9a38; }
.map-swatch[data-terrain="pier"] { background: #9a958c; }
.map-swatch[data-terrain="deep"] { background: #1a6d82; }
.map-swatch[data-terrain="cargo"] { background: #c4894a; }
.map-swatch[data-terrain="scatter"] { background: #8d6e45; }
.map-swatch[data-terrain="boat"] { background: #a86b38; }
.map-swatch[data-terrain="boulder"] { background: #7e7872; }
.map-stance { max-height: 9.5rem; overflow: auto; }
.table-rest { margin-top: 14px; padding-top: 4px; border-top: 1px solid var(--line); }
.table input, .table textarea, .chat input, .initiative input {
  width: 100%;
  color: var(--text);
  background: #140f0c;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}
.table textarea { resize: vertical; min-height: 96px; }
.chat form, #initForm { width: auto; }
#initForm input { width: 88px; }

.seat {
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.18);
}
.seat.tone-0 { border-left-color: #e2c17a; }
.seat.tone-1 { border-left-color: #8fbfa0; }
.seat.tone-2 { border-left-color: #e09a78; }
.seat.is-self { box-shadow: inset 0 0 0 1px rgba(226, 193, 122, 0.45); }
.seat.is-turn { box-shadow: inset 0 0 0 1px var(--gold), 0 0 22px rgba(226, 193, 122, 0.16); }
.seat.is-down { filter: saturate(0.7); }
.seat.is-empty {
  border-style: dashed;
  color: var(--muted);
  min-height: 92px;
}
.seat-top, .hp-row, .meta, .hp-actions, .enemy header, .enemies-head, .roller-head, .sheet-head, .sheet-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
.kicker { margin: 0; color: var(--gold); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; }
.seat h3 { margin: 2px 0; font-size: 28px; line-height: 1; font-weight: 600; }
.class-line, .who, .meta, .notes { margin: 2px 0; color: var(--muted); font-size: 13px; }
.notes { color: var(--text); }
.seat-kit { display: grid; gap: 6px; margin-top: 8px; }
.seat-kit details { border-top: 1px solid var(--line); padding-top: 6px; }
.seat-kit summary { cursor: pointer; color: var(--gold); font-size: 13px; }
.seat-kit p, .sheet-kit { margin: 6px 0 0; white-space: pre-wrap; font-size: 13px; }
.seat-kit .chip-row { margin-top: 6px; }
.seat-kit .chip-row button { padding: 4px 10px; font-size: 12px; }
.hp { flex: 1; height: 8px; border-radius: 99px; background: #3a2a2a; overflow: hidden; }
.hp > span { display: block; height: 100%; }
.hp-num { font-variant-numeric: tabular-nums; min-width: 4.2rem; text-align: right; }
.hp-actions { margin-top: 8px; flex-wrap: wrap; }
.hp-actions button, .enemy-controls button { padding: 4px 8px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag, .pip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  color: var(--parchment);
}
.death { margin-top: 8px; }
.death-roll { margin-top: 8px; }
.pips { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.pip {
  width: 16px;
  height: 16px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
}
button.pip.is-on { background: var(--moss); }
button.pip.is-fail.is-on, span.pip.is-fail.is-on { background: var(--ember); }
.inspire.is-on { background: transparent; color: var(--gold); border-color: var(--gold); }

.banner { text-align: center; padding: 8px 8px 0; }
.banner-kicker, .banner-detail { margin: 0; color: var(--muted); }
.banner-total {
  margin: 0;
  font-family: var(--serif);
  font-size: 92px;
  line-height: 0.85;
  font-variant-numeric: tabular-nums;
}
.banner.is-crit .banner-total { color: #f0d78c; }
.banner.is-fail .banner-total { color: #e07a6a; }
.banner-total.is-fresh { animation: pop 0.35s ease; }
@keyframes pop { from { transform: scale(0.86); opacity: 0.45; } to { transform: none; opacity: 1; } }

.roller, .enemies { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.roller h2, .enemies h2 { margin-bottom: 0; }
.roller h3 { margin: 14px 0 8px; font-size: 22px; }
.roller-head p { margin: 0; color: var(--muted); }
.dice-row, .chip-row, .modes, .roll-controls, .enemies-head, .sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.die {
  min-width: 52px;
  height: 52px;
  padding: 0 10px;
  border-radius: 12px;
  background: #241910;
  color: var(--gold);
  border: 1px solid var(--line);
  font-family: var(--serif);
  font-size: 20px;
}
.die.is-on, .modes .is-on { background: var(--gold); color: var(--ink); }
.roll-controls { align-items: end; margin-top: 10px; }
.roll-controls label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.roll-controls input { width: 88px; }
.notation { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.notation input { flex: 1; min-width: 0; }
.chip-row button, .modes button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.chip-row button.is-on { background: var(--gold); color: var(--ink); border-color: transparent; }
.chip-row button.is-trained { border-color: var(--gold); color: var(--gold); }
.chip-row button.is-expert { background: rgba(226, 193, 122, 0.16); }
.skills-line { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.skill-fields button {
  background: transparent;
  color: var(--ink);
  border: 1px solid rgba(44, 36, 28, 0.28);
  padding: 4px 10px;
  font-size: 13px;
}
.skill-fields button.is-trained { background: var(--gold); border-color: transparent; }
.skill-fields button.is-expert { background: #2c241c; color: var(--parchment); border-color: transparent; }
.modes .is-on { color: var(--ink); }
#rollButton { background: var(--gold); color: var(--ink); border: 0; }

.enemies-head { align-items: end; margin-bottom: 8px; }
.enemies-head form, .enemy-controls { display: flex; flex-wrap: wrap; gap: 6px; }
.enemies-head input[type="number"] { width: 76px; }
.enemies-head #enemyName { width: 160px; }
.enemy {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  margin-top: 8px;
}
.enemy.is-down { opacity: 0.62; }
.enemy.is-target { box-shadow: inset 0 0 0 1px #d4654a; }
.enemy header { margin-bottom: 6px; }
.enemy header strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.enemy header span { flex: none; color: var(--muted); }
.enemy .hp-row { margin-bottom: 8px; }
.enemy .hp-num { min-width: 3rem; }
.enemy { overflow: hidden; }
.enemy-face {
  float: right;
  width: 72px;
  height: 92px;
  margin: 0 0 8px 8px;
  object-fit: cover;
  object-position: center 12%;
  border-radius: 10px;
}
.bestiary-row { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
button.bestiary-card {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  text-align: left;
}
button.bestiary-card img {
  width: 72px;
  height: 92px;
  object-fit: cover;
  object-position: center 12%;
  border-radius: 8px;
  flex: none;
}
.bestiary-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bestiary-copy span { color: var(--muted); font-size: 12px; }
.enemy-target {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 8px 0;
  color: var(--muted);
  font-size: 13px;
}
.enemy-target select {
  width: 100%;
  color: var(--text);
  background: #140f0c;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}
.enemy-legend { margin-top: 6px; clear: both; }
.enemy-legend .meta { margin: 0 0 4px; color: var(--gold); }
.enemy-controls .legend-btn { border-color: var(--gold); }
.ailment-grid { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.ailment-grid button { padding: 2px 6px; font-size: 12px; }
.ailment-grid button.is-on { background: var(--gold); color: #2a2118; border-color: var(--gold); }
.ailment-sources { display: grid; gap: 6px; margin-top: 8px; }
.ailment-sources select, .enemy-ailments select, .enemy-ailments input[type="number"] { width: 100%; }
.enemy-sheet { margin-top: 8px; clear: both; }
.enemy-sheet summary { cursor: pointer; color: var(--gold); }
.enemy-sheet p { margin: 4px 0; font-size: 13px; color: var(--text); }
.enemy-links { color: var(--muted); }
.enemy-sheet a { color: var(--gold); }
.empty { color: var(--muted); }

.log { flex: 1; overflow: auto; padding-right: 4px; }
.chat form { display: flex; align-items: center; gap: 8px; padding-top: 10px; }
.chat form input { flex: 1; min-width: 0; }
.chat form button.chat-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  min-height: 0;
  padding: 0;
  border-radius: 50%;
}
.chat form button.chat-send { padding-right: 2px; }
.chat form button.chat-voice {
  background: transparent;
  border: 1px solid rgba(226, 193, 122, 0.4);
  color: var(--gold);
}
.chat form button.chat-voice:disabled { opacity: 0.55; cursor: not-allowed; }
.msg { padding: 8px 0; border-bottom: 1px solid rgba(226, 193, 122, 0.12); }
.msg header { display: flex; justify-content: space-between; gap: 8px; }
.msg p { margin: 2px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg time { color: var(--muted); font-size: 12px; }
.msg-system { color: var(--muted); font-size: 13px; }
.msg-purpose { color: var(--gold); }
.msg b { display: block; font-family: var(--serif); font-size: 32px; line-height: 1; font-weight: 600; }
.msg b.is-crit { color: #f0d78c; }
.msg b.is-fail { color: #e07a6a; }
.tone-0 strong { color: #e2c17a; }
.tone-1 strong { color: #8fbfa0; }
.tone-2 strong { color: #e09a78; }
.msg-detail { color: var(--muted); font-size: 13px; }

#diceModal { border: 0; padding: 0; background: transparent; color: var(--text); }
#diceModal::backdrop { background: rgba(8, 6, 4, 0.74); }
.dice-modal {
  width: min(520px, 94vw);
  max-height: min(92vh, 820px);
  overflow: auto;
  background:
    radial-gradient(ellipse at top, rgba(226, 193, 122, 0.18), transparent 42%),
    #1a140f;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
}
.dice-head, .dice-actions { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.dice-head h2 { margin: 0; font-size: 34px; line-height: 1; }
.dice-modal .kicker { margin-bottom: 2px; }
.dice-stage {
  height: 228px;
  margin: 12px 0 4px;
  border-radius: 16px;
  background:
    radial-gradient(ellipse at center, rgba(120, 52, 28, 0.35), transparent 68%),
    #120e0b;
  border: 1px solid rgba(226, 193, 122, 0.16);
  overflow: hidden;
}
#diceCanvas { width: 100%; height: 100%; display: block; }
.dice-formula, .dice-detail { margin: 8px 0 0; text-align: center; color: var(--muted); }
.dice-formula { color: var(--gold); min-height: 1.4em; }
.dice-detail { white-space: pre-line; }
.dice-verdict {
  margin: 2px 0 0;
  text-align: center;
  font-family: var(--serif);
  font-size: clamp(28px, 7vw, 42px);
  line-height: 1.05;
}
.verdict.is-crit, .msg-verdict.is-crit, .dice-verdict.is-crit { color: #f0d78c; }
.verdict.is-hit, .verdict.is-success, .msg-verdict.is-hit, .msg-verdict.is-success, .dice-verdict.is-hit, .dice-verdict.is-success { color: #b7d7c4; }
.verdict.is-miss, .verdict.is-fail, .msg-verdict.is-miss, .msg-verdict.is-fail, .dice-verdict.is-miss, .dice-verdict.is-fail { color: #e07a6a; }
.msg-verdict { margin: 0; font-family: var(--serif); font-size: 26px; line-height: 1.05; }
.dice-columns { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 12px; }
.dice-columns h3 { margin: 0 0 6px; font-size: 22px; }
.dice-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.dice-list li { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.dice-list b { font-variant-numeric: tabular-nums; color: var(--gold); }
.dice-list .is-adv,
.dice-list .is-dis,
.dice-list .is-cancel,
.dice-list .is-muted { display: block; }
.dice-list .is-adv { color: #c5e0cf; }
.dice-list .is-dis { color: #f0c2b6; }
.dice-list .is-cancel, .dice-list .is-sum { color: var(--gold); }
.dice-list .is-muted { color: var(--muted); }
.dice-total {
  margin: 8px 0 0;
  text-align: center;
  font-family: var(--serif);
  font-size: 84px;
  line-height: 0.85;
  font-variant-numeric: tabular-nums;
}
.dice-total.is-crit { color: #f0d78c; }
.dice-total.is-fail { color: #e07a6a; }
.dice-actions {
  flex-direction: column;
  align-items: stretch;
  margin-top: 14px;
}
.dice-actions .modes { flex: none; }
#diceInspire, #diceRoll { width: 100%; }
#diceInspire.is-on { color: var(--gold); border-color: var(--gold); }
#diceRoll { background: var(--gold); color: var(--ink); border: 0; }

#sheet { border: 0; padding: 0; background: transparent; color-scheme: light; }
#sheet::backdrop { background: rgba(8, 6, 4, 0.74); }
.sheet {
  width: min(680px, 92vw);
  max-height: min(86vh, 900px);
  overflow: auto;
  color: var(--ink);
  background: linear-gradient(180deg, #f7edd9, #ead7b4);
  border-radius: 16px;
  padding: 20px;
}
.sheet h2, .sheet h3 { margin: 8px 0; }
.sheet .hint { margin-top: 0; }
.split { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.split .field { margin-bottom: 0; }
.abilities { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ability { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center; }
.ability span { grid-column: 1 / -1; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label, .checkline {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid rgba(44, 36, 28, 0.2);
  border-radius: 999px;
  font-size: 13px;
}
.checkline { width: fit-content; margin: 8px 0; }
.chips label, .checkline { white-space: nowrap; }
.sheet .chips input, .sheet .checkline input {
  flex: none;
  width: auto;
  margin: 0;
  padding: 0;
}
.sheet-actions { margin-top: 8px; }
.invite { margin-top: 16px; color: var(--muted); }

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 20;
}
.toast {
  background: var(--parchment);
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  html, body { height: auto; }
  .app { display: block; height: auto; }
  .layout { display: flex; flex-direction: column; }
  .log { max-height: 420px; }
  .split, .abilities { grid-template-columns: 1fr 1fr; }
  .banner-total { font-size: 72px; }
  .brand h1 { font-size: 26px; }
  .col, .topbar, .initiative, .layout { min-width: 0; }
  .app.is-party-min .party .seats { flex-direction: row; overflow-x: auto; }
  .app.is-party-min .party .seat { width: 84px; flex: 0 0 84px; }
  .app.is-party-min .party-head { justify-content: flex-start; }
  .app.is-party-min .party-head .ghost { width: auto; padding: 4px 10px; }
}

@media (max-width: 520px) {
  .dice-columns { grid-template-columns: 1fr; }
  .dice-head h2 { font-size: 28px; }
  .dice-total { font-size: 64px; }
  .dice-stage { height: 196px; }
  .lobby-seats { grid-template-columns: 1fr; }
  .die { width: 44px; height: 44px; font-size: 18px; }
  .banner-total { font-size: 64px; }
  .seat h3 { font-size: 24px; }
  .gold strong { min-width: 3.4rem; }
  .turn-actions { flex: 1 1 100%; flex-direction: row; flex-wrap: wrap; padding-top: 0; }
  .turn-actions button { width: auto; flex: 1 1 140px; }
  .hotbar-who { font-size: 24px; }
  .hotbar-hint { justify-content: flex-start; text-align: left; }
  .hotbar-matrix { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  button.hotbar-cell {
    width: 100%;
    height: auto;
    aspect-ratio: 0.92;
  }
  .hotbar-mod { font-size: 22px; }
  .hotbar-name { overflow-wrap: anywhere; font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .banner-total.is-fresh { animation: none; }
}
