:root {
  color-scheme: dark;
  --ink: #f4ead4;
  --muted: #b8aa91;
  --night: #0d1112;
  --panel: #171c1c;
  --panel-raised: #202626;
  --line: #3b403b;
  --gold: #d3a94b;
  --gold-light: #f1d28b;
  --red: #a83f3f;
  --green: #65a876;
  --blue: #6b9fc5;
  --teal: #4a9b94;
  --burgundy: #713b49;
  --shadow: 0 22px 55px rgb(0 0 0 / 30%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--night);
  color: var(--ink);
}

* { box-sizing: border-box; }

body {
  min-width: 300px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 20% -5%, rgb(211 169 75 / 12%), transparent 31rem),
    radial-gradient(circle at 100% 40%, rgb(111 54 46 / 11%), transparent 38rem),
    linear-gradient(180deg, #111616, var(--night));
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: repeating-linear-gradient(102deg, transparent 0 27px, rgb(255 255 255 / 1.5%) 28px);
  content: "";
  pointer-events: none;
}

a { color: var(--gold-light); text-decoration: none; }
a:hover { color: #fff1ca; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(14rem, 1fr) auto minmax(14rem, 1fr);
  align-items: center;
  gap: 1rem;
  min-height: 4.6rem;
  padding: .65rem clamp(1rem, 3vw, 3rem);
  border-bottom: 1px solid rgb(211 169 75 / 25%);
  background: rgb(13 17 18 / 91%);
  backdrop-filter: blur(18px);
}

.brand { display: inline-flex; align-items: center; gap: .75rem; color: var(--ink); }
.brand:hover { color: var(--ink); }
.brand > span:last-child { display: grid; }
.brand strong { font-family: Georgia, serif; font-size: 1.08rem; letter-spacing: .04em; }
.brand small { color: var(--muted); font-size: .7rem; letter-spacing: .13em; text-transform: uppercase; }
.brand-mark {
  display: grid;
  width: 2.8rem;
  height: 2.8rem;
  place-items: center;
  clip-path: polygon(50% 0, 93% 25%, 82% 78%, 50% 100%, 18% 78%, 7% 25%);
  background: linear-gradient(145deg, var(--gold-light), #85601d);
  color: #17120a;
  font-size: .67rem;
  font-weight: 900;
}

nav { display: flex; align-items: center; gap: 1.25rem; }
nav a { color: var(--muted); font-size: .9rem; font-weight: 650; }
.identity-controls { display: flex; justify-content: flex-end; gap: .55rem; min-width: 0; }
.identity-controls select { max-width: 11rem; }

.page {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 5.5rem) 0 5rem;
}

.page.narrow { width: min(760px, calc(100% - 2rem)); }
.hero { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(18rem, .8fr); align-items: end; gap: 2rem; margin-bottom: 2.6rem; }
.eyebrow { margin: 0 0 .65rem; color: var(--gold); font-size: .75rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, h3 { margin: 0; font-family: Georgia, Cambria, serif; font-weight: 600; line-height: 1.08; }
h1 { max-width: 16ch; font-size: clamp(2.35rem, 6vw, 5rem); letter-spacing: -.035em; }
h2 { font-size: clamp(1.35rem, 3vw, 2rem); }
h3 { font-size: 1.08rem; }
.lede { max-width: 65ch; margin: 1.1rem 0 0; color: var(--muted); font-size: clamp(1rem, 1.8vw, 1.18rem); line-height: 1.7; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; }
.hero .actions { justify-content: flex-end; }

.button {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .68rem 1rem;
  border: 1px solid #bf9438;
  border-radius: .35rem;
  background: linear-gradient(180deg, #d8ad4e, #a57b27);
  box-shadow: 0 5px 18px rgb(0 0 0 / 18%);
  color: #171208;
  cursor: pointer;
  font-weight: 800;
  line-height: 1;
}

.button:hover { border-color: var(--gold-light); color: #080807; filter: brightness(1.08); }
.button.secondary { border-color: var(--line); background: #252b2a; color: var(--ink); box-shadow: none; }
.button.secondary:hover { border-color: #77735f; color: #fff; }
.button.danger { border-color: #8c3939; background: #662b2b; color: #fff0ec; }
.button.small { min-height: 2.2rem; padding: .48rem .72rem; font-size: .82rem; }
.button:disabled { cursor: wait; filter: grayscale(.5); opacity: .55; }

.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1rem; }
.span-12 { grid-column: span 12; }
.span-8 { grid-column: span 8; }
.span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; }
.card {
  position: relative;
  padding: clamp(1.1rem, 2.4vw, 1.65rem);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: .55rem;
  background: linear-gradient(145deg, rgb(34 40 39 / 96%), rgb(22 27 27 / 96%));
  box-shadow: var(--shadow);
}
.card.subtle { box-shadow: none; }
.card.gold { border-color: rgb(211 169 75 / 48%); }
.card > h2 + *, .card > h3 + * { margin-top: .85rem; }
.card p { color: var(--muted); line-height: 1.6; }
.card p:last-child { margin-bottom: 0; }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; }
.card-header p { margin: .35rem 0 0; }
.stack { display: grid; gap: 1rem; }
.stack.tight { gap: .55rem; }
.section { margin-top: 1.2rem; }

.meta { display: flex; flex-wrap: wrap; gap: .55rem 1.1rem; margin: .9rem 0 0; color: var(--muted); font-size: .82rem; }
.pill { display: inline-flex; align-items: center; gap: .35rem; padding: .27rem .5rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .72rem; font-weight: 750; text-transform: uppercase; }
.pill.good { border-color: rgb(101 168 118 / 55%); color: #a9d5b3; }
.pill.warn { border-color: rgb(211 169 75 / 55%); color: var(--gold-light); }
.pill.bad { border-color: rgb(168 63 63 / 70%); color: #e9a2a2; }

.list { display: grid; gap: .7rem; margin: 0; padding: 0; list-style: none; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem .9rem; border: 1px solid var(--line); border-radius: .4rem; background: rgb(9 13 13 / 30%); }
.list-item-main { min-width: 0; }
.list-item-main strong, .identity { overflow-wrap: anywhere; }
.list-item-main small { display: block; margin-top: .25rem; color: var(--muted); }

form { display: grid; gap: 1rem; }
.field { display: grid; gap: .42rem; }
.field label, .field > span:first-child { color: var(--ink); font-size: .84rem; font-weight: 750; }
.hint { margin: 0; color: var(--muted); font-size: .78rem; line-height: 1.45; }
input, textarea, select {
  width: 100%;
  border: 1px solid #484d48;
  border-radius: .35rem;
  outline: none;
  background: #0d1212;
  color: var(--ink);
}
input, select { min-height: 2.8rem; padding: .58rem .7rem; }
textarea { min-height: 8rem; padding: .75rem; resize: vertical; line-height: 1.5; }
textarea.code, pre, code { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
input:focus, textarea:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgb(211 169 75 / 11%); }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.check-row { display: flex; align-items: flex-start; gap: .7rem; padding: .7rem; border: 1px solid var(--line); border-radius: .35rem; }
.check-row input { width: 1rem; min-height: 1rem; margin-top: .15rem; accent-color: var(--gold); }
.check-row span { min-width: 0; overflow-wrap: anywhere; }

.status { padding: .8rem 1rem; border: 1px solid var(--blue); border-radius: .4rem; background: rgb(70 115 145 / 12%); color: #b8d8ec; line-height: 1.45; }
.status.success { border-color: var(--green); background: rgb(68 130 82 / 13%); color: #b9dec0; }
.status.error { border-color: var(--red); background: rgb(145 55 55 / 13%); color: #f0b2b2; }
.global-status { position: fixed; right: 1rem; bottom: 1rem; z-index: 50; max-width: min(30rem, calc(100% - 2rem)); padding: .9rem 1rem; border: 1px solid var(--red); border-radius: .4rem; background: #411e1e; box-shadow: var(--shadow); color: #ffe1da; }
.empty { padding: 2rem; border: 1px dashed var(--line); border-radius: .45rem; color: var(--muted); text-align: center; }
.loading { min-height: 45vh; display: grid; place-items: center; color: var(--muted); }
.loading::before { width: 2rem; height: 2rem; border: 2px solid var(--line); border-top-color: var(--gold); border-radius: 50%; content: ""; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.state-view { display: grid; gap: .7rem; }
.state-entry { padding: .9rem; border-left: 3px solid var(--gold); background: rgb(7 10 10 / 35%); }
.state-entry pre { margin: .6rem 0 0; overflow: auto; color: #d8d0bf; white-space: pre-wrap; }
.reply { padding: 1rem; border: 1px solid var(--line); border-radius: .4rem; }
.reply.eligible-action { border-left: 3px solid var(--green); }
.reply.unaccepted-reply, .reply.nested-reply { opacity: .7; }
.reply p { margin: .55rem 0 0; color: var(--ink); white-space: pre-wrap; }
.audit { font-size: .8rem; }
.audit.good { color: #9bd1a8; }
.audit.bad { color: #e79d9d; }
.divider { height: 1px; margin: .4rem 0; background: var(--line); }
.copy-id { overflow-wrap: anywhere; color: var(--muted); font-family: monospace; font-size: .76rem; }
.campaign-feature {
  min-height: 25rem;
  display: flex;
  align-items: flex-end;
  background:
    linear-gradient(90deg, rgb(12 16 16 / 98%) 0%, rgb(12 16 16 / 87%) 42%, rgb(12 16 16 / 18%) 76%),
    linear-gradient(0deg, rgb(12 16 16 / 82%), transparent 55%),
    url("../campaigns/bell-below-bramblewick/maps/01-bramblewick-village.png") center 46% / cover;
  border-color: rgb(74 155 148 / 55%);
}
.campaign-feature-copy { max-width: 37rem; padding: clamp(.5rem, 3vw, 2rem); }
.campaign-feature-copy h2 { font-size: clamp(2rem, 4vw, 3.6rem); }
.campaign-feature-copy p:not(.eyebrow) { color: #ddd1bb; font-size: 1.02rem; }
.template-bindings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.template-binding { display: grid; grid-template-columns: 4rem minmax(0, 1fr); gap: .75rem; align-items: center; padding: .75rem; border: 1px solid var(--line); border-radius: .4rem; background: rgb(8 12 12 / 42%); }
.template-binding img { grid-row: span 2; width: 4rem; aspect-ratio: 1; object-fit: contain; border-radius: 50%; }
.template-binding span { min-width: 0; }
.template-binding small { display: block; margin-top: .2rem; color: var(--muted); }
.template-binding select { grid-column: 1 / -1; }

.map-preview, .map-source-preview {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: .4rem;
  background: #080b0b;
}
.map-preview { aspect-ratio: 16 / 10; margin: -1.65rem -1.65rem 1rem; }
.map-preview img, .map-source-preview img { display: block; width: 100%; height: 100%; object-fit: cover; }
.map-source-preview { min-height: 10rem; }
.map-source-preview img { max-height: 34rem; object-fit: contain; }
.map-workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(18rem, 24rem); align-items: start; gap: 1rem; }
.map-board-card { min-width: 0; padding: .8rem; }
.map-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .35rem .35rem 1rem; }
.map-toolbar .meta { margin: 0; }
.map-inspector { position: sticky; top: 6rem; max-height: calc(100vh - 7rem); overflow: auto; }
.map-stage { position: relative; width: 100%; overflow: hidden; border: 1px solid #5b594b; border-radius: .38rem; background: #070909; line-height: 0; touch-action: none; }
.map-image { display: block; width: 100%; height: auto; user-select: none; }
.map-token-layer { position: absolute; inset: 0; }
.map-token {
  position: absolute;
  left: var(--x);
  top: var(--y);
  z-index: var(--layer);
  width: var(--size);
  min-height: 0;
  height: auto;
  aspect-ratio: 1;
  padding: 0;
  transform: translate(-50%, -50%) rotate(var(--rotation));
  border: 3px solid var(--token-color);
  border-radius: 50%;
  background: #111;
  box-shadow: 0 3px 0 rgb(0 0 0 / 55%), 0 0 0 1px rgb(236 215 167 / 75%), 0 0 16px color-mix(in srgb, var(--token-color), transparent 45%), 0 7px 22px rgb(0 0 0 / 55%);
  color: #fff;
  cursor: pointer;
  opacity: var(--piece-opacity, 1);
  touch-action: none;
}
.editing .map-token { cursor: grab; }
.map-token.dragging { cursor: grabbing; scale: 1.08; }
.map-token.is-hidden { opacity: calc(var(--piece-opacity, 1) * .45); filter: grayscale(.7); }
.map-token-face, .map-token-face img { display: grid; width: 100%; height: 100%; place-items: center; border-radius: 50%; }
.map-token-face { overflow: hidden; background: color-mix(in srgb, var(--token-color), #111 58%); font-size: .72rem; font-weight: 900; line-height: 1; }
.map-token-face img { object-fit: cover; }
.map-token.is-effect {
  height: auto;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  mix-blend-mode: var(--piece-blend, normal);
}
.map-token.is-effect .map-token-face,
.map-token.is-effect .map-token-face img {
  display: block;
  height: auto;
  overflow: visible;
  border-radius: 0;
  background: transparent;
  object-fit: contain;
}
.map-token.is-effect .map-token-face img { filter: drop-shadow(0 .25rem .6rem rgb(0 0 0 / 48%)); }
.map-token.is-effect [data-token-initials] { display: none; }
.map-token-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + .65rem);
  z-index: 1500;
  display: none;
  min-width: max-content;
  max-width: 15rem;
  padding: .45rem .6rem;
  transform: translateX(-50%) rotate(calc(var(--rotation) * -1));
  border: 1px solid var(--gold);
  border-radius: .3rem;
  background: rgb(10 13 13 / 96%);
  box-shadow: var(--shadow);
  color: var(--ink);
  line-height: 1.25;
  pointer-events: none;
}
.map-token-tooltip small { display: block; margin-top: .18rem; color: var(--muted); text-transform: capitalize; }
.map-token:hover .map-token-tooltip, .map-token:focus-visible .map-token-tooltip { display: block; }
.map-detail-swatch { width: 1.5rem; height: 1.5rem; flex: 0 0 auto; border: 3px solid #fff; border-radius: 50%; background: var(--token-color); }
.token-state { margin-top: 1rem; }
.token-state pre { max-height: 16rem; margin: .65rem 0 0; padding: .75rem; overflow: auto; border: 1px solid var(--line); border-radius: .3rem; background: #0b0f0f; color: #d8d0bf; white-space: pre-wrap; }

/* The campaign page is the live table. The map stays primary; role-specific
   controls and technical history are arranged around it. */
.game-mode .site-header { grid-template-columns: minmax(14rem, 1fr) auto; }
.game-mode .site-header nav { display: none; }
.page.game-page { width: min(1600px, calc(100% - 2rem)); padding-top: 1rem; }
.game-campaign-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1rem;
}
.game-campaign-header h1 { max-width: none; font-size: clamp(1.85rem, 3.5vw, 3rem); }
.game-campaign-header .meta { margin-top: .45rem; }
.game-workspace-nav {
  display: flex;
  align-items: center;
  gap: .25rem;
  margin: -.2rem 0 1rem;
  padding: .35rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: rgb(9 13 13 / 76%);
  scrollbar-width: thin;
}
.game-workspace-nav a {
  flex: 0 0 auto;
  padding: .55rem .75rem;
  border-radius: .35rem;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 750;
  text-decoration: none;
}
.game-workspace-nav a:hover, .game-workspace-nav a:focus-visible { background: rgb(211 169 75 / 8%); color: var(--ink); }
.game-workspace-nav a.active { background: rgb(211 169 75 / 14%); color: var(--gold-light); box-shadow: inset 0 0 0 1px rgb(211 169 75 / 28%); }
.game-left-rail { position: sticky; top: 5.85rem; display: grid; gap: 1rem; min-width: 0; }
.game-rail-card { padding: .8rem; }
.game-rail-card .card-header { margin-bottom: .55rem; }
.game-rail-card h2 { font-size: 1rem; }
.game-rail-list { display: grid; gap: .35rem; }
.game-rail-list.tight { gap: .25rem; }
.game-rail-person, .game-rail-scene {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: .55rem;
  width: 100%;
  padding: .58rem .55rem;
  border: 1px solid transparent;
  border-radius: .4rem;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.game-rail-person:hover, .game-rail-person:focus-visible, .game-rail-scene:hover, .game-rail-scene:focus-visible {
  border-color: rgb(211 169 75 / 40%);
  background: rgb(211 169 75 / 8%);
}
.game-rail-copy, .game-rail-scene > span:nth-child(2) { min-width: 0; }
.game-rail-copy strong, .game-rail-scene strong { display: block; overflow: hidden; font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.game-rail-state { display: block; margin-top: .18rem; overflow: hidden; color: var(--muted); font-size: .68rem; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.game-rail-state b { color: #c8bfad; font-weight: 750; }
.game-rail-chevron { color: var(--muted); font-size: 1.2rem; }
.game-rail-scene .map-detail-swatch { width: .8rem; height: .8rem; border-width: 2px; }
.game-rail-scene small { display: block; margin-top: .1rem; color: var(--muted); font-size: .66rem; text-transform: capitalize; }
.game-scene-groups { display: grid; gap: .35rem; }
.game-scene-group { border-top: 1px solid var(--line); }
.game-scene-group > summary { display: flex; justify-content: space-between; gap: .5rem; padding: .55rem .2rem; color: var(--gold-light); cursor: pointer; font-size: .76rem; font-weight: 750; }
.game-scene-group > summary span { color: var(--muted); }
.game-scene-group[open] > summary { margin-bottom: .2rem; }
.game-table { display: grid; align-items: start; gap: 1rem; }
.game-table-player { grid-template-columns: minmax(0, 1fr) minmax(20rem, 23.5rem); }
.game-table-dm { grid-template-columns: minmax(13.5rem, 16rem) minmax(32rem, 1fr) minmax(20rem, 23.5rem); }
.game-map-panel { min-width: 0; padding: .75rem; overflow: visible; border-color: rgb(211 169 75 / 38%); }
.game-map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .2rem .25rem .8rem;
}
.game-map-toolbar .eyebrow { margin-bottom: .28rem; }
.game-map-toolbar h2 { font-size: clamp(1.15rem, 2vw, 1.6rem); }
.game-map-stage { border-color: rgb(211 169 75 / 52%); box-shadow: 0 18px 45px rgb(0 0 0 / 34%); }
.game-signing .game-map-stage { pointer-events: none; filter: saturate(.75); opacity: .82; }
.game-map-footer { display: flex; justify-content: space-between; gap: 1rem; padding: .75rem .25rem .05rem; color: var(--muted); font-size: .78rem; line-height: 1.4; }
.game-map-empty {
  display: grid;
  min-height: 34rem;
  place-items: center;
  padding: 2rem;
  border: 1px dashed rgb(211 169 75 / 48%);
  border-radius: .55rem;
  background: rgb(11 15 15 / 65%);
  text-align: center;
}
.game-map-empty p:not(.eyebrow) { max-width: 36rem; margin: .7rem auto 1.2rem; color: var(--muted); }
.game-side-panel { position: sticky; top: 5.85rem; display: grid; gap: 1rem; min-width: 0; }
.game-focus-card { border-top: 3px solid var(--gold); }
.game-focus-card > p:not(.eyebrow), .game-prompt-copy { color: var(--ink); font-size: .98rem; line-height: 1.65; white-space: pre-wrap; }
.game-focus-card > .button, .game-primary-action { width: 100%; margin-top: 1rem; }
.game-panel-actions { display: grid; gap: .65rem; margin-top: 1rem; }
.game-panel-actions .button { width: 100%; }
.game-response-list { display: grid; max-height: 44vh; margin-top: 1rem; overflow: auto; border-top: 1px solid var(--line); }
.game-response-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: .6rem; padding: .72rem 0; border-bottom: 1px solid var(--line); }
.game-response-row div { min-width: 0; }
.game-response-row strong, .game-response-row span { display: block; }
.game-response-row div span { margin-top: .18rem; overflow: hidden; color: var(--muted); font-size: .78rem; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.game-response-row b { color: var(--muted); }
.game-response-row.has-replied b { color: var(--green); }
.game-response-detail { margin-top: .18rem; }
.game-response-detail > summary { overflow: hidden; color: var(--muted); font-size: .78rem; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; list-style-position: inside; }
.game-response-detail[open] > summary { color: var(--gold-light); white-space: normal; }
.game-response-detail p { margin: .45rem 0 0; padding: .5rem .6rem; border-left: 2px solid var(--gold); background: rgb(211 169 75 / 6%); color: var(--ink); font-size: .78rem; line-height: 1.45; white-space: pre-wrap; }
.game-person-mark {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border: 1px solid rgb(211 169 75 / 48%);
  border-radius: 50%;
  background: rgb(211 169 75 / 10%);
  color: var(--gold-light);
  font-weight: 800;
}
.game-action-form { margin-top: 1rem; }
.game-action-form textarea { min-height: 7.5rem; }
.game-action-form .game-primary-action { margin-top: 0; }
.game-action-form .hint { overflow-wrap: anywhere; }
.game-panel-details { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.game-panel-details > summary, .game-character-state > summary { padding: .75rem 0; color: var(--gold-light); cursor: pointer; font-size: .82rem; font-weight: 750; }
.game-panel-details[open] { padding-bottom: .8rem; }
.game-panel-details .check-row { padding: .55rem; }
.game-advance-dice { display: grid; grid-template-columns: 5rem minmax(0, 1fr) auto; gap: .5rem; }
.game-advance-dice select, .game-advance-dice input { min-height: 2.2rem; padding-block: .4rem; }
.game-character-state { border-bottom: 1px solid var(--line); }
.game-character-state textarea { min-height: 7rem; margin-bottom: .75rem; }
.game-character-stats { border-bottom: 1px solid var(--line); }
.game-character-stats > summary { display: flex; align-items: center; justify-content: space-between; gap: .7rem; padding: .8rem 0; color: var(--ink); cursor: pointer; font-weight: 750; }
.game-character-stats > summary span { color: var(--muted); font-size: .72rem; font-weight: 600; }
.game-stat-editor { display: grid; gap: .55rem; margin-top: .4rem; }
.game-stat-row { display: grid; grid-template-columns: minmax(6rem, .8fr) minmax(7rem, 1fr) auto; gap: .45rem; align-items: center; }
.game-stat-row input { min-height: 2.3rem; padding-block: .4rem; }
.game-stat-view { display: grid; gap: .45rem; margin-inline: 0; }
.game-stat-view > div { display: grid; grid-template-columns: minmax(7rem, .7fr) minmax(0, 1fr); gap: .75rem; align-items: start; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: .35rem; background: rgb(8 12 12 / 35%); }
.game-stat-view dt { color: var(--muted); font-size: .78rem; font-weight: 750; }
.game-stat-view dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.game-stat-view dd.is-complex { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: .78rem; white-space: pre-wrap; }
.game-player-piece { display: grid; gap: .7rem; }
.game-player-piece .card-header { margin-bottom: .05rem; }
.game-player-piece h2 { margin: 0; }
.game-piece-identity { margin: .2rem 0 0; font-size: .82rem; }
.game-piece-description { margin: .2rem 0 .35rem; color: var(--ink) !important; white-space: pre-wrap; }
.game-piece-data { display: grid; gap: .45rem; margin: 0; }
.game-piece-data > div { display: grid; grid-template-columns: minmax(7rem, .7fr) minmax(0, 1fr); gap: .75rem; align-items: start; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: .35rem; background: rgb(8 12 12 / 35%); }
.game-piece-data dt, .game-piece-nested dt { color: var(--muted); font-size: .78rem; font-weight: 750; }
.game-piece-data dd, .game-piece-nested dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.game-piece-muted { color: var(--muted); }
.game-piece-boolean.is-true { color: var(--green); font-weight: 750; }
.game-piece-boolean.is-false { color: var(--muted); }
.game-piece-nested { display: grid; gap: .3rem; margin: 0; }
.game-piece-nested > div { display: grid; grid-template-columns: minmax(5rem, .55fr) minmax(0, 1fr); gap: .5rem; }
.game-piece-sublist { display: grid; gap: .25rem; margin: 0; padding-left: 1.1rem; }
.game-piece-tags { display: flex; flex-wrap: wrap; gap: .4rem; }
.game-piece-tag { padding: .35rem .55rem; border: 1px solid rgb(211 169 75 / 52%); border-radius: 999px; background: rgb(211 169 75 / 10%); color: var(--gold-light); font-size: .78rem; font-weight: 750; }
.game-piece-note { margin-top: .15rem; padding: .7rem .75rem; border-left: 2px solid var(--gold); background: rgb(211 169 75 / 7%); }
.game-piece-note strong { display: block; color: var(--gold-light); font-size: .75rem; letter-spacing: .05em; text-transform: uppercase; }
.game-piece-note p { margin: .25rem 0 0; color: var(--ink) !important; white-space: pre-wrap; }
.game-encrypted-action { display: grid; gap: .6rem; margin-top: 1rem; }
.game-encrypted-action .game-primary-action { margin-top: 0; }
.game-encrypted-chat-links { display: flex; flex-wrap: wrap; gap: .45rem; }
.game-encrypted-ref-row {
  display: grid;
  grid-template-columns: minmax(8rem, .75fr) minmax(12rem, 1.3fr) minmax(9rem, 1fr) auto;
  gap: .5rem;
  align-items: end;
  padding: .65rem;
  border: 1px solid var(--line);
  border-radius: .4rem;
  background: rgb(8 12 12 / 35%);
}
.game-encrypted-ref-row label { display: grid; gap: .3rem; min-width: 0; color: var(--muted); font-size: .72rem; }
.game-encrypted-ref-row input, .game-encrypted-ref-row select { min-width: 0; min-height: 2.3rem; padding-block: .4rem; }
.game-encrypted-ref-row .button { min-height: 2.3rem; }
.game-record-link { display: inline-block; margin-top: 1rem; font-size: .82rem; }
.game-quick-tools { padding-block: 1rem; }
.game-quick-tools .card-header { margin-bottom: .75rem; }
.game-quick-tools h3 { font-family: inherit; font-size: .92rem; font-weight: 750; }
.game-quick-tools p { font-size: .76rem; }
.game-dice-row { display: grid; grid-template-columns: 1fr 4.5rem; gap: .65rem; }
.game-dice-row input { min-height: 2.2rem; padding: .4rem; text-align: center; }
.game-archive { margin-top: 1rem; border-top: 1px solid var(--line); }
.game-archive > summary, .game-event-details > summary, .game-token-data > summary {
  padding: 1rem .25rem;
  color: var(--gold-light);
  cursor: pointer;
  font-weight: 750;
}
.game-archive > summary:hover, .game-event-details > summary:hover, .game-token-data > summary:hover { color: #fff1ca; }
.game-event-details { overflow: visible; }
.game-event-details > summary { padding: 0; }
.game-token-dialog { width: min(34rem, calc(100% - 2rem)); max-height: calc(100vh - 2rem); padding: 1.35rem; overflow: auto; }
.game-token-dialog::backdrop { background: rgb(0 0 0 / 62%); backdrop-filter: blur(3px); }
.game-token-dialog p { color: var(--muted); line-height: 1.55; }
.game-dialog-close { width: 100%; margin-top: 1rem; }
.game-overlap-picker { margin: -.25rem 0 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.game-overlap-picker > p { margin-bottom: .5rem; color: var(--gold-light); font-size: .75rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.game-overlap-picker > div { display: grid; gap: .4rem; }
.game-overlap-picker button { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .1rem .55rem; align-items: center; width: 100%; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: .35rem; background: rgb(8 12 12 / 45%); color: var(--ink); text-align: left; cursor: pointer; }
.game-overlap-picker button:hover, .game-overlap-picker button:focus-visible, .game-overlap-picker button.selected { border-color: var(--gold); background: rgb(211 169 75 / 10%); }
.game-overlap-picker button > span { grid-row: 1 / span 2; width: .75rem; height: .75rem; border: 2px solid #fff; border-radius: 50%; background: var(--token-color); }
.game-overlap-picker b { overflow: hidden; font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.game-overlap-picker small { color: var(--muted); font-size: .68rem; text-transform: capitalize; }
.game-effect-dialog { width: min(40rem, calc(100% - 2rem)); max-height: calc(100vh - 2rem); padding: 1.35rem; overflow: auto; }
.game-effect-dialog::backdrop { background: rgb(0 0 0 / 68%); backdrop-filter: blur(3px); }
.game-effect-dialog .card-header p { margin-top: .25rem; color: var(--muted); }
.game-effect-library > div { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr)); gap: .55rem; }
.game-effect-library button { display: grid; gap: .35rem; min-width: 0; padding: .45rem; border: 1px solid var(--line); border-radius: .4rem; background: rgb(8 12 12 / 55%); color: var(--ink); cursor: pointer; }
.game-effect-library button:hover, .game-effect-library button:focus-visible { border-color: var(--gold); }
.game-effect-library img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.game-effect-library span { overflow: hidden; font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.game-effect-preview { display: grid; min-height: 8rem; place-items: center; overflow: hidden; border: 1px dashed var(--line); border-radius: .4rem; background-color: #111; background-image: linear-gradient(45deg, #1b2020 25%, transparent 25%), linear-gradient(-45deg, #1b2020 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #1b2020 75%), linear-gradient(-45deg, transparent 75%, #1b2020 75%); background-position: 0 0, 0 .6rem, .6rem -.6rem, -.6rem 0; background-size: 1.2rem 1.2rem; }
.game-effect-preview img { display: block; width: 100%; max-height: 15rem; object-fit: contain; }
.game-effect-preview .empty { background: rgb(8 12 12 / 82%); }
.game-effect-form h3 { margin-bottom: .75rem; }
.game-bundle-loader { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .65rem; align-items: stretch; }
.game-bundle-loader .button { white-space: nowrap; }

.game-map-commandbar { display: grid; gap: .4rem; padding-top: .65rem; }
.game-map-tools { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }
.game-map-tools .button.active { border-color: var(--gold); color: var(--gold-light); }
.game-map-commandbar .game-map-footer { padding-top: .25rem; }
.game-turn-command .game-prompt-copy { max-height: 12rem; overflow: auto; padding-right: .2rem; }
.game-response-state { display: grid; justify-items: end; gap: .05rem; }
.game-response-state b { font-size: 1rem; }
.game-response-state small { color: var(--muted); font-size: .62rem; white-space: nowrap; }
.game-message-shortcut {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: .35rem;
  color: var(--gold-light);
  font-size: .68rem;
  font-weight: 800;
  text-decoration: none;
}
.game-message-shortcut:hover, .game-message-shortcut:focus-visible { border-color: var(--gold); background: rgb(211 169 75 / 9%); }
.game-review-button { min-height: 3rem; font-size: .92rem; }
.game-panel-actions.compact { grid-template-columns: 1fr; }
.game-advance-dialog { width: min(76rem, calc(100% - 2rem)); max-height: calc(100vh - 2rem); padding: 0; overflow: hidden; }
.game-advance-dialog::backdrop { background: rgb(0 0 0 / 76%); backdrop-filter: blur(4px); }
.game-advance-review { display: grid; max-height: calc(100vh - 2rem); overflow: auto; }
.game-review-header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgb(17 24 23 / 96%);
}
.game-review-header h2 { margin-top: .15rem; font-size: 1.55rem; }
.game-review-header p:last-child { margin: .35rem 0 0; color: var(--muted); }
.game-advance-review > .status { margin: 1rem 1.25rem 0; }
.game-review-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; padding: 1.1rem 1.25rem; }
.game-review-section { min-width: 0; padding: 1rem; border: 1px solid var(--line); border-radius: .5rem; background: rgb(8 12 12 / 34%); }
.game-review-section .card-header { margin-bottom: .6rem; }
.game-review-section h3 { font-size: 1rem; }
.game-review-state { grid-column: 1 / -1; }
.game-review-action { align-items: flex-start; }
.game-review-action span { line-height: 1.45; }
.game-review-footer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: flex;
  justify-content: flex-end;
  gap: .65rem;
  padding: .9rem 1.25rem;
  border-top: 1px solid var(--line);
  background: rgb(17 24 23 / 96%);
}
.game-review-footer .game-primary-action { width: auto; min-width: 12rem; margin-top: 0; }
.game-review-signing-note { margin: -.3rem 1.25rem 1rem; text-align: right; }

dialog { width: min(34rem, calc(100% - 2rem)); border: 1px solid var(--line); border-radius: .5rem; background: var(--panel); color: var(--ink); }

@media (max-width: 1180px) and (min-width: 851px) {
  .page.game-page { width: min(100% - 1.25rem, 1120px); }
  .game-table-dm { grid-template-columns: minmax(0, 1fr) minmax(20rem, 23rem); }
  .game-left-rail { position: static; grid-column: 1 / -1; grid-template-columns: 1fr 1fr; }
}

@media (max-width: 850px) {
  .site-header { grid-template-columns: 1fr auto; }
  .site-header nav { grid-row: 2; grid-column: 1 / -1; justify-content: center; padding-top: .4rem; border-top: 1px solid var(--line); }
  .hero { grid-template-columns: 1fr; align-items: start; }
  .hero .actions { justify-content: flex-start; }
  .span-8, .span-7, .span-6, .span-5, .span-4 { grid-column: span 12; }
  .map-workspace { grid-template-columns: 1fr; }
  .map-inspector { position: static; max-height: none; }
  .template-bindings { grid-template-columns: 1fr; }
  .page.game-page { width: min(100% - 1rem, 52rem); padding-top: .8rem; }
  .game-campaign-header { align-items: flex-start; }
  .game-table-player, .game-table-dm { grid-template-columns: 1fr; }
  .game-left-rail { position: static; grid-template-columns: 1fr 1fr; }
  .game-map-panel { position: sticky; top: 7.8rem; z-index: 1; }
  .game-side-panel { position: relative; top: auto; z-index: 2; }
  .game-focus-card { box-shadow: 0 -16px 35px rgb(0 0 0 / 48%); }
  .game-encrypted-ref-row { grid-template-columns: 1fr 1fr; }
}


@media (max-width: 560px) {
  .site-header { padding-inline: .75rem; }
  .brand strong { font-size: .92rem; }
  .brand-mark { width: 2.25rem; height: 2.25rem; }
  .identity-controls select { max-width: 7.5rem; }
  .field-row { grid-template-columns: 1fr; }
  .list-item, .card-header { align-items: stretch; flex-direction: column; }
  .list-item .button { width: 100%; }
  .game-mode .site-header { grid-template-columns: minmax(0, 1fr) auto; }
  .game-campaign-header { display: grid; gap: .75rem; }
  .game-campaign-header .actions, .game-campaign-header .button { width: 100%; }
  .game-map-panel { top: 5rem; padding: .4rem; }
  .game-map-toolbar { align-items: flex-start; }
  .game-map-toolbar .actions { justify-content: flex-end; }
  .game-map-toolbar .pill { display: none; }
  .game-map-footer { display: none; }
  .game-focus-card { border-radius: .55rem .55rem 0 0; }
  .game-stat-row { grid-template-columns: 1fr auto; }
  .game-stat-row [data-stat-name] { grid-column: 1 / -1; }
  .game-stat-view > div { grid-template-columns: 1fr; gap: .2rem; }
  .game-bundle-loader { grid-template-columns: 1fr; }
  .game-encrypted-ref-row { grid-template-columns: 1fr; }
  .game-encrypted-ref-row .button, .game-encrypted-chat-links .button { width: 100%; }
  .game-left-rail { grid-template-columns: 1fr; }
  .game-workspace-nav { margin-inline: -.1rem; }
  .game-map-tools .button, .game-map-tools .button.secondary { flex: 1 1 auto; }
  .game-response-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .game-message-shortcut { grid-column: 2 / -1; width: 100%; height: 1.8rem; }
  .game-review-grid { grid-template-columns: 1fr; padding-inline: .75rem; }
  .game-review-state { grid-column: auto; }
  .game-review-header, .game-review-footer { padding-inline: .75rem; }
  .game-review-footer { display: grid; grid-template-columns: 1fr; }
  .game-review-footer .button, .game-review-footer .game-primary-action { width: 100%; }
  .game-review-signing-note { margin-inline: .75rem; text-align: left; }
}


/* Dungeons-native messaging UX backed exclusively by the UBNet messaging SDK. */
.dnd-message-sdk-surface.full {
  display: grid;
  grid-template-columns: minmax(13.5rem, 17rem) minmax(28rem, 1fr) minmax(15rem, 19rem);
  min-height: min(46rem, calc(100vh - 13rem));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: .7rem;
  background: rgb(8 12 12 / 54%);
  box-shadow: 0 1.25rem 3.5rem rgb(0 0 0 / 20%);
}
.dnd-message-sdk-surface.compact {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.dnd-message-room-list, .dnd-message-info { min-width: 0; padding: 1rem; background: rgb(8 12 12 / 42%); }
.dnd-message-sdk-surface.full .dnd-message-room-list { border-right: 1px solid var(--line); }
.dnd-message-sdk-surface.full .dnd-message-info { border-left: 1px solid var(--line); }
.dnd-message-section-head { margin-bottom: .65rem; }
.dnd-message-section-head h2, .dnd-message-conversation-head h2, .game-chat-drawer-head h2 { margin: .1rem 0 0; }
.dnd-message-rooms { display: grid; gap: .35rem; }
.dnd-message-room {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: .6rem;
  align-items: center;
  width: 100%;
  padding: .65rem .7rem;
  border: 1px solid transparent;
  border-radius: .45rem;
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}
.dnd-message-room:hover:not(:disabled), .dnd-message-room:focus-visible:not(:disabled) { border-color: rgb(211 169 75 / 26%); background: rgb(211 169 75 / 7%); color: var(--ink); }
.dnd-message-room.active { border-color: rgb(211 169 75 / 28%); background: rgb(211 169 75 / 13%); color: var(--ink); }
.dnd-message-room:disabled { cursor: not-allowed; opacity: .62; }
.dnd-message-room strong, .dnd-message-room small { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dnd-message-room strong { color: inherit; }
.dnd-message-room small { margin-top: .08rem; color: var(--muted); font-size: .69rem; }
.dnd-room-dot { width: .62rem; height: .62rem; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 3px rgb(255 255 255 / 3%); }
.dnd-room-dot.party { background: var(--gold); }
.dnd-room-dot.direct { background: var(--green); }
.dnd-unread-count, .dnd-chat-unread { display: inline-flex; align-items: center; justify-content: center; min-width: 1.25rem; height: 1.25rem; padding: 0 .3rem; border-radius: 999px; background: var(--gold); color: #17120a; font-size: .65rem; font-weight: 850; }
.dnd-chat-unread[hidden] { display: none; }
.dnd-message-room-divider { margin: .7rem 0 .3rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .63rem; text-transform: uppercase; letter-spacing: .08em; }
.dnd-message-room-divider span { display: inline-block; transform: translateY(-.55em); padding-right: .5rem; background: #0d1412; }
.dnd-party-setup { margin-top: 1rem; padding-top: .85rem; border-top: 1px solid var(--line); }
.dnd-party-setup > strong { color: var(--gold-light); font-size: .78rem; }
.dnd-party-setup p { color: var(--muted); font-size: .72rem; line-height: 1.45; }
.dnd-message-security-card { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.dnd-message-security-card > strong { color: var(--gold-light); }
.dnd-message-security-card > p { margin: .25rem 0 .65rem; color: var(--muted); font-size: .72rem; line-height: 1.45; }
.dnd-message-tools { display: flex; flex-wrap: wrap; gap: .4rem; }
.dnd-message-conversation { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto auto; min-width: 0; min-height: 0; background: #0b100f; }
.dnd-message-conversation-head { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: .85rem 1rem; border-bottom: 1px solid var(--line); }
.dnd-message-security-state { padding: .8rem 1rem; border-bottom: 1px solid var(--line); background: rgb(211 169 75 / 5%); }
.dnd-message-lock-card { display: grid; gap: .5rem; }
.dnd-message-lock-card strong { color: var(--gold-light); }
.dnd-message-lock-card p { margin: 0; color: var(--muted); font-size: .76rem; line-height: 1.5; }
.dnd-message-lock-card.error strong { color: #efaaaa; }
.dnd-message-thread { min-height: 0; overflow: auto; padding: 1rem; background: linear-gradient(180deg, rgb(18 26 24 / 38%), rgb(7 10 9 / 22%)); scrollbar-width: thin; }
.dnd-chat-message { display: grid; gap: .28rem; max-width: min(85%, 42rem); margin: 0 0 .85rem; }
.dnd-chat-message.mine { margin-left: auto; justify-items: end; }
.dnd-chat-message.theirs { margin-right: auto; }
.dnd-chat-message-meta { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; color: var(--muted); font-size: .64rem; }
.dnd-chat-message-meta strong { color: var(--gold-light); }
.dnd-chat-message.mine .dnd-chat-message-meta { justify-content: flex-end; }
.dnd-chat-bubble { padding: .68rem .78rem; border: 1px solid var(--line); border-radius: .65rem .65rem .65rem .18rem; background: rgb(26 36 33 / 84%); color: var(--ink); font-size: .82rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.dnd-chat-message.mine .dnd-chat-bubble { border-color: rgb(211 169 75 / 22%); border-radius: .65rem .65rem .18rem .65rem; background: rgb(211 169 75 / 11%); }
.dnd-chat-message-actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.dnd-chat-message.mine .dnd-chat-message-actions { justify-content: flex-end; }
.dnd-message-composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .55rem; align-items: end; padding: .7rem .8rem; border-top: 1px solid var(--line); background: #0d1412; }
.dnd-message-composer textarea { min-height: 2.6rem; max-height: 10rem; resize: vertical; }
.dnd-message-status { min-height: 1.4rem; padding: .2rem .8rem .5rem; color: var(--muted); font-size: .67rem; background: #0d1412; }
.dnd-message-status[data-tone="success"] { color: var(--green); }
.dnd-message-status[data-tone="warn"] { color: var(--gold-light); }
.dnd-message-status[data-tone="error"] { color: #efaaaa; }
.dnd-message-info h3 { margin-top: 0; }
.dnd-message-info > p { color: var(--muted); font-size: .76rem; line-height: 1.5; }
.dnd-message-channel-note { display: grid; gap: .2rem; margin-top: .75rem; padding: .7rem; border: 1px solid var(--line); border-radius: .45rem; background: rgb(8 12 12 / 45%); }
.dnd-message-channel-note strong { color: var(--gold-light); font-size: .75rem; }
.dnd-message-channel-note span { color: var(--muted); font-size: .69rem; line-height: 1.45; overflow-wrap: anywhere; }
.dnd-message-settings-dialog { width: min(44rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 0; border: 1px solid rgb(211 169 75 / 32%); border-radius: .7rem; background: #0d1412; color: var(--ink); box-shadow: 0 1.5rem 4rem rgb(0 0 0 / 48%); }
.dnd-message-settings-dialog::backdrop { background: rgb(0 0 0 / 58%); backdrop-filter: blur(2px); }
.dnd-message-settings-shell { display: grid; gap: 1rem; padding: 1rem; }
.dnd-message-settings-shell > header { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.dnd-message-settings-shell h2 { margin: .1rem 0 0; }
.dnd-message-settings-shell textarea { width: 100%; }
.dnd-message-diagnostics { max-height: 16rem; overflow: auto; padding: .7rem; border: 1px solid var(--line); border-radius: .4rem; background: #080d0c; white-space: pre-wrap; }

.dnd-message-sdk-surface.compact .dnd-message-room-list { padding: .55rem .65rem; border-bottom: 1px solid var(--line); background: #0d1412; }
.dnd-message-sdk-surface.compact .dnd-message-section-head { display: none; }
.dnd-message-sdk-surface.compact .dnd-message-rooms { display: flex; gap: .35rem; padding-bottom: .35rem; overflow-x: auto; scrollbar-width: thin; }
.dnd-message-sdk-surface.compact .dnd-message-room { flex: 0 0 auto; width: auto; min-width: 8.5rem; padding: .48rem .58rem; }
.dnd-message-sdk-surface.compact .dnd-message-security-card { display: flex; gap: .6rem; align-items: center; margin: .4rem 0 0; padding: .45rem 0 0; }
.dnd-message-sdk-surface.compact .dnd-message-security-card > strong, .dnd-message-sdk-surface.compact .dnd-message-security-card > p { display: none; }
.dnd-message-sdk-surface.compact .dnd-party-setup { margin: .4rem 0 0; padding: .5rem 0 0; }
.dnd-message-sdk-surface.compact .dnd-message-info { display: none; }
.dnd-message-sdk-surface.compact .dnd-message-conversation { border: 0; }
.dnd-message-sdk-surface.compact .dnd-message-thread { padding: .75rem; }

.game-chat-backdrop { position: fixed; z-index: 80; inset: 0; background: rgb(0 0 0 / 36%); backdrop-filter: blur(1px); }
.game-chat-drawer {
  position: fixed;
  z-index: 81;
  top: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(42rem, 100vw);
  padding: 0;
  overflow: hidden;
  border-left: 1px solid rgb(211 169 75 / 30%);
  background: #0d1412;
  box-shadow: -1.25rem 0 3rem rgb(0 0 0 / 34%);
}
.game-chat-drawer[hidden], .game-chat-backdrop[hidden] { display: none !important; }
.game-chat-drawer-head { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: .9rem 1rem; border-bottom: 1px solid var(--line); }
.game-chat-drawer-foot { display: flex; justify-content: space-between; gap: .75rem; align-items: center; padding: .6rem .8rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .68rem; }
.game-chat-drawer-foot a { color: var(--gold-light); white-space: nowrap; }
body.game-chat-open { overflow: hidden; }

@media (max-width: 1100px) {
  .dnd-message-sdk-surface.full { grid-template-columns: minmax(12rem, 15rem) minmax(0, 1fr); }
  .dnd-message-sdk-surface.full .dnd-message-info { display: none; }
}
@media (max-width: 760px) {
  .dnd-message-sdk-surface.full { display: block; min-height: 0; overflow: visible; border: 0; background: transparent; box-shadow: none; }
  .dnd-message-sdk-surface.full .dnd-message-room-list { padding: .65rem 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; }
  .dnd-message-sdk-surface.full .dnd-message-section-head { padding-inline: .25rem; }
  .dnd-message-sdk-surface.full .dnd-message-rooms { display: flex; gap: .35rem; padding-bottom: .35rem; overflow-x: auto; }
  .dnd-message-sdk-surface.full .dnd-message-room { flex: 0 0 auto; width: auto; min-width: 9.5rem; }
  .dnd-message-sdk-surface.full .dnd-message-security-card, .dnd-message-sdk-surface.full .dnd-party-setup { margin-inline: .25rem; }
  .dnd-message-sdk-surface.full .dnd-message-conversation { margin-top: .75rem; min-height: 34rem; border: 1px solid var(--line); border-radius: .55rem; overflow: hidden; }
  .dnd-message-conversation-head { padding: .7rem .75rem; }
  .dnd-message-composer { grid-template-columns: 1fr; }
  .dnd-message-composer .button { width: 100%; }
  .game-chat-drawer { width: 100vw; }
  .game-chat-drawer-foot { align-items: flex-start; flex-direction: column; }
  .game-chat-drawer-foot a { white-space: normal; }
  .dnd-chat-message { max-width: 94%; }
}

.dnd-message-section-head { display: flex; justify-content: space-between; gap: .65rem; align-items: flex-start; }
.dnd-message-new-dialog { width: min(38rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 0; border: 1px solid rgb(211 169 75 / 32%); border-radius: .7rem; background: #0d1412; color: var(--ink); box-shadow: 0 1.5rem 4rem rgb(0 0 0 / 48%); }
.dnd-message-new-dialog::backdrop { background: rgb(0 0 0 / 58%); backdrop-filter: blur(2px); }
.dnd-copy-event { border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.dnd-copy-event:hover, .dnd-copy-event:focus-visible { color: var(--gold-light); }

/* Role-first Dungeons UX */
.role-home .page-header { max-width: 52rem; }
.role-choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.role-choice-card { display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: start; min-height: 14rem; padding: 1.4rem; border: 1px solid var(--line); border-radius: .75rem; background: linear-gradient(180deg, rgb(255 255 255 / 2%), transparent), var(--panel); color: var(--ink); text-decoration: none; box-shadow: var(--shadow); }
.role-choice-card:hover, .role-choice-card:focus-visible { border-color: rgb(211 169 75 / 52%); transform: translateY(-1px); }
.role-choice-icon { display: grid; place-items: center; width: 3.4rem; height: 3.4rem; border: 1px solid rgb(211 169 75 / 35%); border-radius: .7rem; background: rgb(211 169 75 / 10%); color: var(--gold-light); font: 800 1.15rem/1 var(--font-display); }
.role-choice-card h2 { margin: .2rem 0 .55rem; font-size: clamp(1.45rem, 3vw, 2rem); }
.role-choice-card p { max-width: 38rem; color: var(--muted); }
.role-choice-action { display: inline-block; margin-top: 1rem; color: var(--gold-light); font-weight: 700; }
.home-secondary { margin-top: 1rem; }
.dashboard-page .page-header { align-items: end; }
.dashboard-section { margin-top: 1rem; }
.dashboard-section-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-end; margin-bottom: .65rem; }
.dashboard-campaign-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }
.dashboard-campaign-card { display: flex; flex-direction: column; justify-content: space-between; gap: .7rem; min-width: 0; padding: .9rem; border: 1px solid var(--line); border-radius: .6rem; background: var(--panel); color: var(--ink); text-decoration: none; }
.dashboard-campaign-card:hover, .dashboard-campaign-card:focus-visible { border-color: rgb(211 169 75 / 40%); }
.dashboard-campaign-card.rich { min-height: 13rem; }
.dashboard-campaign-card h3 { margin: .45rem 0 .35rem; }
.dashboard-campaign-card p { color: var(--muted); }
.dashboard-card-footer { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; margin-top: auto; padding-top: .7rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .76rem; }
.dashboard-card-footer > span { margin-right: auto; }
.dashboard-template { display: flex; justify-content: space-between; gap: 1.25rem; align-items: center; }
.player-open-campaign { display: grid; grid-template-columns: minmax(0, 1fr) minmax(18rem, 27rem); gap: 1rem; align-items: end; }
.player-open-campaign form { display: flex; gap: .55rem; align-items: end; }
.player-open-campaign .field { flex: 1; margin: 0; }

.campaign-create-steps { display: grid; gap: .8rem; }
.campaign-create-step { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .85rem 1rem; }
.campaign-create-step > .section, .campaign-create-step > form { grid-column: 2; }
.campaign-step-number { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 50%; background: rgb(211 169 75 / 14%); color: var(--gold-light); font-weight: 800; }
.campaign-template-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.campaign-template-choice { padding: 1rem; border: 1px solid var(--line); border-radius: .55rem; background: var(--panel-soft); color: var(--ink); text-align: left; cursor: pointer; }
.campaign-template-choice strong, .campaign-template-choice span { display: block; }
.campaign-template-choice span { margin-top: .35rem; color: var(--muted); }
.campaign-template-choice.selected { border-color: var(--gold); box-shadow: inset 0 0 0 1px rgb(211 169 75 / 35%); }
.campaign-create-footer { display: flex; justify-content: space-between; gap: 1rem; align-items: center; }

.campaign-setup-nav { position: sticky; z-index: 9; top: .5rem; display: flex; gap: .25rem; margin: .6rem 0 1rem; padding: .3rem; overflow-x: auto; border: 1px solid var(--line); border-radius: .55rem; background: rgb(13 20 18 / 94%); backdrop-filter: blur(8px); }
.campaign-setup-nav a { flex: 0 0 auto; padding: .52rem .75rem; border-radius: .4rem; color: var(--muted); text-decoration: none; font-weight: 700; font-size: .78rem; }
.campaign-setup-nav a:hover, .campaign-setup-nav a:focus-visible { background: rgb(255 255 255 / 4%); color: var(--ink); }
.campaign-setup-grid > [id] { scroll-margin-top: 5rem; }
.campaign-overview-stats { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: .85rem; }
.campaign-overview-stats span { padding: .42rem .6rem; border: 1px solid var(--line); border-radius: .45rem; color: var(--muted); }
.campaign-overview-stats b { color: var(--ink); }
.campaign-section-heading { margin: .5rem 0 .75rem; }
.campaign-advanced-card > summary { cursor: pointer; font-weight: 750; }

.campaign-properties-editor { min-width: 0; }
.campaign-entity-list { display: grid; gap: .65rem; margin-top: .75rem; }
.campaign-entity-definition { padding: .8rem; }
.campaign-entity-head, .campaign-entity-title { display: flex; justify-content: space-between; gap: .6rem; align-items: center; }
.campaign-entity-title { justify-content: flex-start; margin-top: .2rem; }
.campaign-entity-title input { width: min(22rem, 60vw); font-size: 1.05rem; font-weight: 750; }
.campaign-property-table-head, .campaign-property-row { display: grid; grid-template-columns: minmax(6rem, .8fr) minmax(7rem, 1fr) 7.5rem minmax(6rem, .8fr) 4.4rem 4.4rem 4rem auto; gap: .35rem; align-items: center; }
.campaign-property-table-head { margin-top: .75rem; padding: 0 .25rem; color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; }
.campaign-property-list { display: grid; gap: .35rem; margin: .35rem 0 .55rem; }
.campaign-property-row { padding: .35rem; border: 1px solid var(--line); border-radius: .4rem; background: rgb(255 255 255 / 1.5%); }
.campaign-property-row input, .campaign-property-row select { min-width: 0; }
.campaign-property-actions { display: flex; gap: .25rem; justify-content: flex-end; }
.campaign-property-actions .button { min-width: 2rem; padding-inline: .45rem; }
.campaign-property-flag { display: flex; gap: .25rem; align-items: center; font-size: .68rem; color: var(--muted); }
.campaign-property-flag input { width: auto; }
.campaign-add-type-dialog, .dm-guide-dialog { width: min(52rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 0; border: 1px solid rgb(211 169 75 / 32%); border-radius: .7rem; background: #0d1412; color: var(--ink); box-shadow: 0 1.5rem 4rem rgb(0 0 0 / 48%); }
.campaign-add-type-dialog::backdrop, .dm-guide-dialog::backdrop { background: rgb(0 0 0 / 58%); backdrop-filter: blur(2px); }
.campaign-add-type-form, .dm-guide-shell { padding: 1rem; }

.dm-guide-shell { display: grid; gap: .85rem; }
.dm-guide-shell > header { display: flex; justify-content: space-between; gap: 1rem; align-items: start; padding-bottom: .75rem; border-bottom: 1px solid var(--line); }
.dm-guide-reference { padding: .8rem; border: 1px solid rgb(211 169 75 / 22%); border-radius: .5rem; background: rgb(211 169 75 / 5%); }
.dm-guide-reference ul { margin: .45rem 0 0; padding-left: 1.2rem; color: var(--muted); }
.dm-guide-privacy { display: flex; gap: .55rem; align-items: baseline; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: .45rem; color: var(--muted); font-size: .76rem; }
.dm-guide-privacy strong { color: var(--ink); }

.game-configured-entity-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
.game-configured-entity .field { margin: 0; }
.player-self-card .game-stat-view { margin-bottom: .6rem; }
.game-record-link { color: var(--gold-light); font-size: .78rem; }
.game-table-player { grid-template-columns: minmax(14rem, 18rem) minmax(0, 1fr) minmax(18rem, 23rem); }

@media (max-width: 1100px) {
  .dashboard-campaign-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .campaign-property-table-head { display: none; }
  .campaign-property-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .campaign-property-row .campaign-property-flag { min-height: 2.2rem; }
  .game-table-player { grid-template-columns: minmax(14rem, 17rem) minmax(0, 1fr); }
  .game-table-player > :last-child { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .role-choice-grid, .dashboard-campaign-grid, .campaign-template-grid { grid-template-columns: 1fr; }
  .role-choice-card { min-height: 0; }
  .dashboard-template, .campaign-create-footer, .player-open-campaign { display: block; }
  .dashboard-template .actions, .campaign-create-footer .button, .player-open-campaign form { margin-top: .75rem; }
  .player-open-campaign form { display: block; }
  .player-open-campaign .button { width: 100%; margin-top: .45rem; }
  .campaign-create-step { grid-template-columns: auto minmax(0, 1fr); }
  .campaign-create-step > .section, .campaign-create-step > form { grid-column: 1 / -1; }
  .campaign-entity-head { align-items: flex-start; flex-direction: column; }
  .campaign-property-row { grid-template-columns: 1fr; }
  .campaign-property-flag { min-height: auto; }
  .game-configured-entity-fields { grid-template-columns: 1fr; }
  .game-table-player { grid-template-columns: 1fr; }
  .game-table-player > :last-child { grid-column: auto; }
  .dm-guide-privacy { align-items: flex-start; flex-direction: column; }
}
