@charset "UTF-8";
:root {
  color-scheme: dark;
  --ink: #e9e4d5;
  --muted: #9eaaa4;
  --gold: #d8b477;
  --gold-bright: #f4d49a;
  --green: #7bad9a;
  --red: #e29682;
  --surface: #20342f;
  --base: #10231f;
  --line: #3b5046;
  --paper: #e8ddc4;
  --paper-ink: #332e25;
  --shadow: 0 16px 42px #05100da6;
  --serif: Georgia, "Noto Serif CJK SC", "Songti SC", SimSun, serif;
  --sans: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  font: 14px/1.55 var(--sans);
  background: var(--base);
  color: var(--ink);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
textarea,
select {
  font: inherit;
}
button,
a,
input,
textarea,
select {
  touch-action: manipulation;
}
button {
  color: inherit;
  background: #2a4038;
  border: 1px solid #5a6d5c;
  border-radius: 5px;
  padding: 7px 12px;
  cursor: pointer;
  line-height: 1.35;
}
button:hover {
  background: #3b5245;
  border-color: var(--gold);
}
button:active {
  transform: translateY(1px);
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
button.primary {
  color: #242c22;
  background: var(--gold);
  border-color: var(--gold-bright);
  font-weight: 650;
}
button.primary:hover {
  background: var(--gold-bright);
}
button.danger {
  color: #ffd4c4;
  border-color: #ab6757;
}
button.ghost {
  background: transparent;
  border-color: var(--line);
}
button[aria-pressed="true"],
button.active {
  color: var(--gold-bright);
  border-color: var(--gold);
  background: #45513b;
}
a {
  color: var(--gold);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
input,
textarea,
select {
  background: #10221e;
  border: 1px solid #5b6c5d;
  border-radius: 4px;
  color: var(--ink);
  padding: 8px 10px;
  min-width: 0;
}
textarea {
  resize: vertical;
  line-height: 1.6;
}
label {
  display: grid;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1,
h2,
h3 {
  font-family: var(--serif);
}
h2 {
  font-size: 25px;
}
h3 {
  font-size: 18px;
}
small,
.muted {
  color: var(--muted);
}
.row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.spaced {
  justify-content: space-between;
}
.stack {
  display: grid;
  gap: 12px;
}
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.grid3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.full {
  grid-column: 1/-1;
}
.rule {
  height: 1px;
  background: var(--line);
  margin: 18px 0;
}
.pill {
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 3px;
}
.empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--muted);
}
.warning {
  padding: 12px;
  border: 1px solid #997c45;
  background: #594a2629;
  color: #e2c798;
}
.error {
  color: var(--red);
}
.scroll {
  overflow: auto;
  min-height: 0;
  scrollbar-color: #687866 #172923;
  scrollbar-width: thin;
}
.icon-button {
  padding: 3px 9px;
  font-size: 24px;
  line-height: 1;
  border: 0;
  background: none;
}
.small {
  font-size: 12px;
}
.nowrap {
  white-space: nowrap;
}
.initial-loading {
  padding: 80px;
  text-align: center;
}
.masthead {
  height: 64px;
  border-bottom: 1px solid var(--line);
  background: #142721;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font: 600 18px var(--serif);
}
.brand:hover {
  text-decoration: none;
}
.brand small {
  display: block;
  font: 9px var(--sans);
  letter-spacing: 1.8px;
  margin-top: 4px;
}
.brand-mark {
  display: grid;
  place-items: center;
  color: var(--gold);
  font-size: 35px;
  border: 1px solid #7f815a;
  width: 40px;
  height: 40px;
  transform: rotate(5deg);
}
.masthead nav {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
}
.masthead nav button {
  background: none;
  border: 0;
  padding: 5px;
}
.connection {
  font-size: 11px;
  color: var(--muted);
}
.connection.live:before {
  content: "●";
  color: #a9c59b;
  margin-right: 6px;
}
.connection.offline {
  color: var(--red);
}
.lobby {
  max-width: 1260px;
  margin: auto;
  padding: 36px 30px 60px;
}
.hero {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  min-height: 350px;
  background: #1d352d;
  border: 1px solid #53614b;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}
.hero-copy {
  padding: 44px 42px;
  z-index: 1;
}
.eyebrow {
  font-size: 10px;
  letter-spacing: 2.6px;
  color: var(--gold);
  text-transform: uppercase;
}
.hero h1 {
  font-size: 46px;
  line-height: 1.25;
  margin: 16px 0;
  color: #efe5c9;
  letter-spacing: 0.03em;
}
.hero p {
  color: #b8c3b5;
  max-width: 420px;
  line-height: 1.9;
}
.hero .row {
  margin-top: 26px;
}
.hero-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  min-height: 350px;
}
.lobby-section {
  margin-top: 32px;
}
.lobby-section h2 {
  font-size: 23px;
  margin-bottom: 15px;
}
.campaign-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.campaign-card {
  background: #21372d;
  border: 1px solid var(--line);
  padding: 22px;
  display: grid;
  gap: 12px;
  position: relative;
}
.campaign-card:before {
  content: "◇";
  position: absolute;
  right: 20px;
  top: 12px;
  font-size: 40px;
  color: #72886659;
}
.campaign-card h3 {
  padding-right: 38px;
}
.campaign-card button {
  justify-self: start;
}
.book-strip {
  margin-top: 24px;
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}
.table {
  height: calc(100dvh - 64px);
  min-height: 500px;
  display: grid;
  grid-template-columns: 226px minmax(340px, 1fr) 350px;
  grid-template-rows: 48px minmax(0, 1fr) 66px;
}
.table-head {
  grid-column: 1/-1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 18px;
  background: #20352d;
  border-bottom: 1px solid var(--line);
  gap: 10px;
}
.table-head h1 {
  font: 600 17px var(--serif);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.table-head .sub {
  font: 10px var(--sans);
  color: var(--gold);
  margin-right: 10px;
  letter-spacing: 1px;
}
.table-head button {
  font-size: 12px;
  padding: 5px 9px;
}
.party-panel {
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  background: #172c25;
  overflow: auto;
}
.panel-title {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--gold);
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
}
.party-card {
  padding: 12px 8px;
  display: grid;
  grid-template-columns: 43px 1fr;
  gap: 9px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.party-card.selected {
  background: #344a36;
  border-left: 2px solid var(--gold);
  padding-left: 6px;
}
.portrait {
  width: 42px;
  height: 48px;
  border: 1px solid #6f7c5f;
  border-radius: 17px 17px 4px 4px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at 30% 20%, #a9bb9477, transparent), #344c40;
  color: var(--gold);
  font: 30px var(--serif);
}
.portrait.fighter,
.portrait.paladin {
  background-color: #3d5869;
}
.portrait.rogue,
.portrait.warlock {
  background-color: #58435f;
}
.portrait.cleric,
.portrait.druid {
  background-color: #647148;
}
.portrait.wizard,
.portrait.sorcerer {
  background-color: #5b4b76;
}
.party-name {
  font-size: 13px;
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.party-meta {
  font-size: 10px;
  color: var(--muted);
}
.hp-track {
  height: 4px;
  background: #08150f;
  border-radius: 2px;
  margin: 7px 0 3px;
  overflow: hidden;
}
.hp-track i {
  display: block;
  height: 100%;
  width: var(--hp);
  background: #88b78c;
}
.hp-track.low i {
  background: #c37b65;
}
.hp-caption {
  font-size: 10px;
  display: flex;
  justify-content: space-between;
}
.party-actions {
  display: grid;
  gap: 6px;
  margin-top: 18px;
}
.party-actions button {
  text-align: left;
  font-size: 12px;
}
.source-note {
  font-size: 10px;
  color: #8d9c8d;
  margin-top: 20px;
  line-height: 1.7;
}
.combat-order {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 10px 0;
}
.combat-order span {
  border: 1px solid var(--line);
  padding: 3px 6px;
  font-size: 11px;
}
.combat-order .current {
  border-color: var(--gold);
  color: var(--gold-bright);
}
.map-panel {
  position: relative;
  overflow: hidden;
  background: #0e211b;
}
.map-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
}
.map-caption {
  position: absolute;
  top: 16px;
  left: 16px;
  max-width: calc(100% - 100px);
  pointer-events: none;
  text-shadow: 0 1px 4px #000;
}
.map-caption h2 {
  font-size: 21px;
  color: #eee5cd;
}
.map-caption small {
  font-size: 10px;
  color: #bcc5ae;
}
.map-controls {
  position: absolute;
  right: 13px;
  top: 14px;
  display: grid;
  gap: 5px;
}
.map-controls button {
  background: #1b302be8;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 17px;
  box-shadow: 0 2px 4px #0005;
}
.map-tools {
  position: absolute;
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  background: #14271fea;
  border: 1px solid #63735b;
  border-radius: 7px;
  padding: 4px;
  gap: 4px;
  box-shadow: 0 6px 20px #0007;
  white-space: nowrap;
}
.map-tools button {
  font-size: 11px;
  padding: 6px 10px;
  background: transparent;
  border-color: transparent;
}
.map-tools button.active {
  background: #566144;
  border-color: #a38e59;
}
.map-hint {
  position: absolute;
  bottom: 65px;
  left: 12px;
  font-size: 10px;
  color: #d8dfc4;
  pointer-events: none;
  text-shadow: 0 1px 3px #000;
}
.map-error {
  position: absolute;
  inset: 40% 15%;
  background: #182c26;
  padding: 20px;
  border: 1px solid var(--gold);
  z-index: 2;
}
.right-panel {
  border-left: 1px solid var(--line);
  display: grid;
  grid-template-rows: 42px minmax(0, 1fr) auto;
  background: #1c3029;
  min-height: 0;
}
.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  padding: 0 12px;
  gap: 16px;
}
.panel-tabs button {
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 12px;
  padding: 8px 2px;
}
.panel-tabs button.active {
  border-bottom: 2px solid var(--gold);
  color: var(--gold);
}
.journal-log {
  overflow: auto;
  padding: 18px 18px 5px;
  scrollbar-width: thin;
  scrollbar-color: #687866 #172923;
}
.log-entry {
  margin-bottom: 17px;
  animation: line-enter 0.18s ease-out;
}
.log-entry .speaker {
  font-size: 10px;
  letter-spacing: 0.5px;
  color: var(--gold);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}
.log-entry.narration p {
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.9;
  color: #e0dfce;
  white-space: pre-wrap;
}
.log-entry.speech,
.log-entry.intent,
.log-entry.companion {
  border-left: 2px solid #6f8e70;
  padding-left: 11px;
}
.log-entry p {
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.7;
}
.log-entry.ooc {
  color: var(--muted);
  font-style: italic;
}
.log-entry.roll,
.log-entry.attack,
.log-entry.ruling {
  background: #14271f;
  padding: 10px;
  border: 1px solid #3e5845;
  font-size: 12px;
}
.log-entry.system,
.log-entry.move,
.log-entry.turn,
.log-entry.map {
  color: #9cae9b;
  font-size: 11px;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 8px;
  margin-bottom: 10px;
}
.roll-number {
  color: var(--gold-bright);
  font-size: 23px;
  font-family: var(--serif);
}
.log-entry.guide {
  border: 1px dashed #80794f;
  color: #c0c8ac;
  padding: 10px;
  font-size: 12px;
}
.pending-list {
  display: grid;
  gap: 7px;
}
.pending-card {
  padding: 10px;
  background: #17291f;
  border: 1px solid #8e8452;
  font-size: 12px;
}
.pending-card .row {
  margin-top: 8px;
}
.composer {
  border-top: 1px solid var(--line);
  padding: 10px 12px 12px;
  background: #1b3027;
}
.composer .row {
  margin-bottom: 6px;
}
.composer .opening-actions:empty { display: none; }
.composer .opening-actions { flex-wrap: wrap; gap: 4px; }
.crew-choice:not([hidden]) { display: flex; align-items: center; gap: 8px; }
.crew-choice[hidden] { display: none; }
.crew-choice input { width: auto; }
.composer select {
  padding: 4px 6px;
  font-size: 11px;
  max-width: 125px;
}
.composer textarea {
  width: 100%;
  min-height: 66px;
  height: 66px;
  font-size: 13px;
  resize: none;
  background: #0f221c;
  border-color: #49614a;
}
.composer .send-row {
  display: flex;
  gap: 7px;
  align-items: center;
  margin-top: 7px;
}
.composer .send-row button {
  font-size: 12px;
  padding: 6px 10px;
}
.composer .send-row .primary {
  margin-left: auto;
}
.ai-status {
  font-size: 10px;
  color: var(--muted);
  flex: 1;
}
.ai-status.thinking {
  color: var(--gold);
  animation: breathe 1.5s ease-in-out infinite;
}
.actionbar {
  grid-column: 1/-1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border-top: 1px solid #6c7353;
  background: #263c2e;
}
.action-identity {
  min-width: 145px;
  line-height: 1.3;
}
.action-identity strong {
  font: 600 15px var(--serif);
  display: block;
}
.action-identity small {
  font-size: 10px;
}
.action-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.action-buttons button {
  padding: 6px 10px;
  font-size: 12px;
}
.turn-end {
  margin-left: auto;
}
.mobile-tabs {
  display: none;
}
.lobby-table {
  max-width: 1000px;
  margin: auto;
  padding: 32px 24px;
}
.ready-cast {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin: 22px 0;
}
.ready-person {
  background: #20392c;
  border: 1px solid #617358;
  padding: 20px;
  display: grid;
  gap: 10px;
}
.ready-person .portrait {
  width: 58px;
  height: 68px;
  font-size: 40px;
}
.ready-person h3 {
  font-size: 22px;
}
.ready-person p {
  font-size: 12px;
  color: var(--muted);
}
dialog {
  border: 1px solid #8d8a60;
  border-radius: 8px;
  background: #1e342b;
  color: var(--ink);
  width: min(790px, calc(100vw - 24px));
  max-height: calc(100dvh - 40px);
  padding: 0;
  box-shadow: 0 25px 100px #0009;
  overflow: hidden;
}
dialog[open] {
  display: flex;
  flex-direction: column;
  animation: dialog-in 0.18s ease-out;
}
dialog::backdrop {
  background: #05140fba;
  backdrop-filter: blur(2px);
}
dialog > header {
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
dialog > header small {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--gold);
}
dialog h2 {
  font-size: 24px;
  margin-top: 3px;
}
#dialog-body {
  padding: 22px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}
.form-error {
  color: var(--red);
  font-size: 12px;
  min-height: 18px;
}
.ability-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.ability-box {
  text-align: center;
  border: 1px solid var(--line);
  padding: 10px 5px;
  background: #172b22;
}
.ability-box b {
  font-size: 24px;
  font-family: var(--serif);
  display: block;
  color: var(--gold-bright);
}
.ability-box small {
  font-size: 10px;
}
.ability-box select {
  width: 100%;
  padding: 6px 2px;
  text-align: center;
}
.sheet-header {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
}
.sheet-header .portrait {
  height: 80px;
  width: 65px;
  font-size: 48px;
}
.sheet-header h3 {
  font-size: 30px;
}
.sheet-stats {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  margin: 18px 0;
}
.sheet-stats b {
  font: 26px var(--serif);
  color: var(--gold);
  display: block;
}
.sheet-stats span {
  font-size: 10px;
  color: var(--muted);
}
.sheet-tabs {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}
.skill-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 22px;
  margin: 16px 0;
}
.skill-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  border-bottom: 1px dotted #3a5341;
  padding: 4px 0;
}
.skill-row.proficient {
  color: var(--gold);
}
.spell-row,
.book-result {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.spell-row h3 {
  font: 600 16px var(--serif);
  margin-bottom: 5px;
}
.spell-row p {
  font-size: 12px;
  color: var(--muted);
}
.spell-row details {
  font-size: 13px;
  white-space: pre-wrap;
  margin-top: 6px;
  line-height: 1.85;
}
.book-page {
  font: 16px/1.95 var(--serif);
  white-space: pre-wrap;
  max-width: 65ch;
  margin: auto;
  background: var(--paper);
  color: var(--paper-ink);
  padding: 22px;
}
.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.chips label {
  display: flex;
  gap: 4px;
  border: 1px solid var(--line);
  padding: 4px 7px;
  font-size: 12px;
  align-items: center;
}
.chips input {
  margin: 0;
}
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  max-width: min(90vw, 600px);
  background: #443f28;
  border: 1px solid var(--gold);
  color: #ffebc0;
  padding: 10px 18px;
  border-radius: 5px;
  box-shadow: var(--shadow);
  display: none;
  font-size: 13px;
}
.toast.visible {
  display: block;
}
.room-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  font-size: 12px;
}
.secret-box {
  font: 12px/1.7 monospace;
  overflow-wrap: anywhere;
  background: #0c2118;
  border: 1px solid var(--line);
  padding: 10px;
  user-select: all;
}
.dm-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}
.dm-block {
  padding: 15px;
  background: #152c21;
  border: 1px solid var(--line);
}
.dm-block h3 {
  font-size: 16px;
  margin-bottom: 10px;
}
.dm-block input,
.dm-block select,
.dm-block textarea {
  width: 100%;
  margin-top: 5px;
  font-size: 12px;
}
.dm-block button {
  font-size: 12px;
  margin-top: 8px;
}
.dm-map-toolbar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.notice-inline {
  font-size: 11px;
  color: #d3bf8d;
}
.amount {
  font-variant-numeric: tabular-nums;
}
@keyframes dialog-in {
  from {
    transform: translateY(12px);
    opacity: 0.3;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
@keyframes line-enter {
  from {
    transform: translateY(5px);
    opacity: 0.4;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
@keyframes breathe {
  50% {
    opacity: 0.55;
  }
}
@media (min-width: 1600px) {
  .table {
    grid-template-columns: 250px minmax(340px, 1fr) 390px;
  }
  .journal-log {
    padding: 24px;
  }
  .log-entry.narration p {
    font-size: 16px;
  }
}
@media (max-width: 1100px) {
  .table {
    grid-template-columns: 175px minmax(300px, 1fr) 310px;
  }
  .party-panel {
    padding: 12px 7px;
  }
  .action-identity {
    min-width: 110px;
  }
  .actionbar {
    gap: 6px;
  }
  .action-buttons button {
    font-size: 11px;
    padding: 6px;
  }
  .masthead {
    padding: 0 16px;
  }
  .hero h1 {
    font-size: 37px;
  }
  .hero-copy {
    padding: 35px 28px;
  }
}
@media (max-width: 820px) {
  .masthead {
    height: 52px;
    padding: 0 12px;
    gap: 8px;
  }
  .brand {
    font-size: 15px;
    gap: 7px;
  }
  .brand small {
    font-size: 7px;
    letter-spacing: 1px;
  }
  .brand-mark {
    width: 31px;
    height: 33px;
    font-size: 27px;
  }
  .masthead nav {
    gap: 6px;
  }
  .masthead .games-back {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    white-space: nowrap;
  }
  .connection {
    font-size: 9px;
    max-width: 90px;
    text-align: right;
  }
  .lobby {
    padding: 16px 12px 35px;
  }
  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .hero-copy {
    padding: 30px 24px 23px;
  }
  .hero h1 {
    font-size: 36px;
  }
  .hero-art {
    height: 215px;
    min-height: 0;
    grid-row: 1;
  }
  .hero p {
    font-size: 13px;
    line-height: 1.8;
  }
  .hero .row {
    margin-top: 20px;
  }
  .lobby-section {
    margin-top: 24px;
  }
  .book-strip {
    gap: 10px;
  }
  .table {
    height: calc(100dvh - 52px);
    min-height: 380px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 42px 39px minmax(0, 1fr) 67px;
  }
  .table-head {
    padding: 0 10px;
    grid-row: 1;
  }
  .table-head h1 {
    font-size: 15px;
  }
  .table-head .sub {
    display: none;
  }
  .table-head button {
    font-size: 11px;
    padding: 5px 7px;
  }
  .mobile-tabs {
    display: flex;
    grid-column: 1;
    grid-row: 2;
    align-items: stretch;
    gap: 0;
    border-bottom: 1px solid var(--line);
    background: #1b3329;
  }
  .mobile-tabs button {
    flex: 1;
    border: 0;
    border-radius: 0;
    font-size: 12px;
    background: transparent;
    padding: 7px 2px;
  }
  .mobile-tabs button.active {
    color: var(--gold-bright);
    border-bottom: 2px solid var(--gold);
    background: #344a35;
  }
  .party-panel,
  .right-panel,
  .map-panel {
    grid-column: 1;
    grid-row: 3;
    display: none;
    border: 0;
  }
  .table[data-mobile="map"] .map-panel {
    display: block;
  }
  .table[data-mobile="chat"] .right-panel {
    display: grid;
  }
  .table[data-mobile="party"] .party-panel {
    display: block;
  }
  .party-panel {
    padding: 12px 18px;
  }
  .party-card {
    grid-template-columns: 45px 1fr;
    max-width: 600px;
  }
  .party-card .hp-caption {
    font-size: 11px;
  }
  .party-actions {
    grid-template-columns: 1fr 1fr;
  }
  .actionbar {
    grid-row: 4;
    padding: 7px 10px;
    gap: 6px;
    align-items: center;
    overflow-x: auto;
    flex-wrap: nowrap;
  }
  .action-identity {
    min-width: 75px;
    max-width: 90px;
  }
  .action-identity strong {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .action-identity small {
    font-size: 9px;
  }
  .action-buttons {
    flex-wrap: nowrap;
  }
  .action-buttons button {
    font-size: 11px;
    white-space: nowrap;
    padding: 8px 9px;
  }
  .turn-end {
    font-size: 11px;
    white-space: nowrap;
    padding: 8px 9px;
  }
  .map-caption {
    top: 12px;
    left: 12px;
  }
  .map-caption h2 {
    font-size: 19px;
  }
  .map-tools {
    bottom: 12px;
  }
  .map-hint {
    bottom: 57px;
  }
  .map-controls button {
    width: 33px;
    height: 33px;
  }
  .right-panel {
    grid-template-rows: 36px minmax(0, 1fr) auto;
  }
  .journal-log {
    padding: 12px 16px;
  }
  .composer textarea {
    height: 54px;
    min-height: 54px;
    font-size: 14px;
  }
  .composer {
    padding: 8px 12px;
  }
  .log-entry.narration p {
    font-size: 15px;
    line-height: 1.85;
  }
  .panel-tabs {
    justify-content: center;
  }
  .ready-cast {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .ready-person {
    padding: 13px;
  }
  .ready-person h3 {
    font-size: 20px;
  }
  .lobby-table {
    padding: 22px 14px;
  }
  .lobby-table h2 {
    font-size: 25px;
  }
  .grid3 {
    grid-template-columns: 1fr 1fr;
  }
  .ability-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .ability-box {
    padding: 7px 5px;
  }
  .ability-box b {
    font-size: 22px;
  }
  dialog {
    max-height: calc(100dvh - 20px);
    width: calc(100vw - 16px);
    border-radius: 6px;
  }
  dialog > header {
    padding: 12px 15px;
  }
  dialog h2 {
    font-size: 21px;
  }
  #dialog-body {
    padding: 15px;
  }
  .dm-grid {
    grid-template-columns: 1fr;
  }
  .sheet-header {
    gap: 12px;
    margin-bottom: 14px;
  }
  .sheet-header h3 {
    font-size: 25px;
  }
  .sheet-stats {
    gap: 17px;
  }
  .sheet-stats b {
    font-size: 23px;
  }
  .book-page {
    padding: 13px;
    font-size: 15px;
  }
  .skill-grid {
    gap: 2px 12px;
  }
  .toast {
    bottom: 78px;
    font-size: 12px;
    padding: 8px 12px;
  }
  .form-stack .grid2 {
    gap: 9px;
  }
}
@media (max-width: 540px) {
  .masthead {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand actions" "status actions";
    height: auto;
    min-height: 52px;
    gap: 0 6px;
    padding: 4px 10px;
  }
  .masthead .brand { grid-area: brand; }
  .brand-mark { width: 22px; height: 22px; font-size: 20px; }
  .brand small { display: none; }
  .masthead nav { grid-area: actions; white-space: nowrap; }
  .masthead nav button { min-height: 32px; }
  .masthead .connection { grid-area: status; max-width: none; text-align: start; font-size: 11px; }
}
@media (max-width: 360px) {
  .brand {
    font-size: 14px;
  }
  .masthead nav {
    gap: 0;
  }
  .table-head .row {
    gap: 4px;
  }
  .hero h1 {
    font-size: 30px;
  }
  .hero-copy {
    padding: 22px 19px;
  }
  .action-identity {
    min-width: 60px;
    max-width: 70px;
  }
  .action-buttons button {
    padding: 8px 7px;
  }
  .table-head h1 {
    max-width: 155px;
  }
  .grid2 {
    grid-template-columns: 1fr;
  }
  .ready-cast {
    grid-template-columns: 1fr 1fr;
  }
  .sheet-stats {
    gap: 12px;
  }
}
@media (max-height: 520px) and (orientation: landscape) {
  .masthead {
    height: 40px;
  }
  .table {
    height: calc(100dvh - 40px);
    min-height: 260px;
    grid-template-rows: 34px 31px minmax(0, 1fr) 48px;
  }
  .actionbar {
    padding: 4px 8px;
  }
  .composer textarea {
    height: 40px;
    min-height: 40px;
  }
  .map-tools {
    bottom: 7px;
  }
  .map-caption {
    top: 7px;
  }
  .map-caption h2 {
    font-size: 15px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Errors must not squeeze mobile action buttons into one-character columns. */
.ai-status, .form-error, .attack-readiness { min-width: 0; overflow-wrap: anywhere; }
.composer .send-row > button { flex-shrink: 0; }
[data-shield-status] .row { flex-wrap: wrap; }
.adventure-shelf {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 245px), 1fr));
  gap: 12px;
  margin-top: 16px;
}
.adventure-book {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--border, #42564b);
  border-top: 3px solid var(--gold, #cfb16e);
  background: var(--panel, #1c322a);
}
.adventure-book h3 { margin: 0; }
.adventure-book p { line-height: 1.65; }
.adventure-book button { align-self: flex-start; margin-top: auto; }
.source-map-options { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
#advancement-options:empty { display: none; }
@media (max-width: 600px) {
  .adventure-book { padding: 12px; gap: 8px; }
  .adventure-book .eyebrow { letter-spacing: .06em; }
}
